File tree 6 files changed +34
-32
lines changed
worldedit-bukkit/adapters
adapter-1.21.3/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_3
adapter-1.21.4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_4
adapter-1.21.5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_21_5
worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal
worldedit-neoforge/src/main/java/com/sk89q/worldedit/neoforge/internal
worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge
6 files changed +34
-32
lines changed Original file line number Diff line number Diff line change @@ -290,8 +290,8 @@ private static String getEntityId(Entity entity) {
290
290
* @param entity the entity
291
291
* @param tag the tag
292
292
*/
293
- private static void readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
- entity .save (tag );
293
+ private static boolean readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
+ return entity .save (tag );
295
295
}
296
296
297
297
private static Block getBlockFromType (BlockType blockType ) {
@@ -471,15 +471,12 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
471
471
CraftEntity craftEntity = ((CraftEntity ) entity );
472
472
Entity mcEntity = craftEntity .getHandle ();
473
473
474
- // Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
475
- if (mcEntity .isPassenger ()) {
476
- return null ;
477
- }
478
-
479
474
String id = getEntityId (mcEntity );
480
475
481
476
net .minecraft .nbt .CompoundTag tag = new net .minecraft .nbt .CompoundTag ();
482
- readEntityIntoTag (mcEntity , tag );
477
+ if (!readEntityIntoTag (mcEntity , tag )) {
478
+ return null ;
479
+ }
483
480
return new BaseEntity (
484
481
EntityTypes .get (id ),
485
482
LazyReference .from (() -> (LinCompoundTag ) toNative (tag ))
Original file line number Diff line number Diff line change @@ -290,8 +290,8 @@ private static String getEntityId(Entity entity) {
290
290
* @param entity the entity
291
291
* @param tag the tag
292
292
*/
293
- private static void readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
- entity .save (tag );
293
+ private static boolean readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
+ return entity .save (tag );
295
295
}
296
296
297
297
private static Block getBlockFromType (BlockType blockType ) {
@@ -471,15 +471,12 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
471
471
CraftEntity craftEntity = ((CraftEntity ) entity );
472
472
Entity mcEntity = craftEntity .getHandle ();
473
473
474
- // Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
475
- if (mcEntity .isPassenger ()) {
476
- return null ;
477
- }
478
-
479
474
String id = getEntityId (mcEntity );
480
475
481
476
net .minecraft .nbt .CompoundTag tag = new net .minecraft .nbt .CompoundTag ();
482
- readEntityIntoTag (mcEntity , tag );
477
+ if (!readEntityIntoTag (mcEntity , tag )) {
478
+ return null ;
479
+ }
483
480
return new BaseEntity (
484
481
EntityTypes .get (id ),
485
482
LazyReference .from (() -> (LinCompoundTag ) toNative (tag ))
Original file line number Diff line number Diff line change @@ -290,8 +290,8 @@ private static String getEntityId(Entity entity) {
290
290
* @param entity the entity
291
291
* @param tag the tag
292
292
*/
293
- private static void readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
- entity .save (tag );
293
+ private static boolean readEntityIntoTag (Entity entity , net .minecraft .nbt .CompoundTag tag ) {
294
+ return entity .save (tag );
295
295
}
296
296
297
297
private static Block getBlockFromType (BlockType blockType ) {
@@ -471,15 +471,12 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
471
471
CraftEntity craftEntity = ((CraftEntity ) entity );
472
472
Entity mcEntity = craftEntity .getHandle ();
473
473
474
- // Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
475
- if (mcEntity .isPassenger ()) {
476
- return null ;
477
- }
478
-
479
474
String id = getEntityId (mcEntity );
480
475
481
476
net .minecraft .nbt .CompoundTag tag = new net .minecraft .nbt .CompoundTag ();
482
- readEntityIntoTag (mcEntity , tag );
477
+ if (!readEntityIntoTag (mcEntity , tag )) {
478
+ return null ;
479
+ }
483
480
return new BaseEntity (
484
481
EntityTypes .get (id ),
485
482
LazyReference .from (() -> (LinCompoundTag ) toNative (tag ))
Original file line number Diff line number Diff line change @@ -52,12 +52,14 @@ public FabricEntity(net.minecraft.world.entity.Entity entity) {
52
52
@ Override
53
53
public BaseEntity getState () {
54
54
net .minecraft .world .entity .Entity entity = entityRef .get ();
55
- if (entity == null || entity . isPassenger () ) {
55
+ if (entity == null ) {
56
56
return null ;
57
57
}
58
- ResourceLocation id = FabricWorldEdit .getRegistry (Registries .ENTITY_TYPE ).getKey (entity .getType ());
59
58
CompoundTag tag = new CompoundTag ();
60
- entity .saveWithoutId (tag );
59
+ if (!entity .save (tag )) {
60
+ return null ;
61
+ }
62
+ ResourceLocation id = FabricWorldEdit .getRegistry (Registries .ENTITY_TYPE ).getKey (entity .getType ());
61
63
return new BaseEntity (
62
64
EntityTypes .get (id .toString ()),
63
65
LazyReference .from (() -> NBTConverter .fromNative (tag ))
Original file line number Diff line number Diff line change @@ -52,13 +52,18 @@ public NeoForgeEntity(net.minecraft.world.entity.Entity entity) {
52
52
@ Override
53
53
public BaseEntity getState () {
54
54
net .minecraft .world .entity .Entity entity = entityRef .get ();
55
- if (entity == null || entity . isPassenger () ) {
55
+ if (entity == null ) {
56
56
return null ;
57
57
}
58
- ResourceLocation id = BuiltInRegistries .ENTITY_TYPE .getKey (entity .getType ());
59
58
CompoundTag tag = new CompoundTag ();
60
- entity .saveWithoutId (tag );
61
- return new BaseEntity (EntityTypes .get (id .toString ()), LazyReference .from (() -> NBTConverter .fromNative (tag )));
59
+ if (!entity .save (tag )) {
60
+ return null ;
61
+ }
62
+ ResourceLocation id = BuiltInRegistries .ENTITY_TYPE .getKey (entity .getType ());
63
+ return new BaseEntity (
64
+ EntityTypes .get (id .toString ()),
65
+ LazyReference .from (() -> NBTConverter .fromNative (tag ))
66
+ );
62
67
}
63
68
64
69
@ Override
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ public BaseEntity getState() {
53
53
if (entity == null || entity .vehicle ().isPresent ()) {
54
54
return null ;
55
55
}
56
- EntityType entityType = EntityType .REGISTRY .get (entity .type ().key (RegistryTypes .ENTITY_TYPE ).asString ());
56
+ org .spongepowered .api .entity .EntityType <?> spongeEntityType = entity .type ();
57
+ if (spongeEntityType .isTransient ()) {
58
+ return null ;
59
+ }
60
+ EntityType entityType = EntityType .REGISTRY .get (spongeEntityType .key (RegistryTypes .ENTITY_TYPE ).asString ());
57
61
if (entityType == null ) {
58
62
return null ;
59
63
}
You can’t perform that action at this time.
0 commit comments