Skip to content

Commit f524cf0

Browse files
dordsor21octylFractalssquadteamme4502brickmonster
authored
chore: upstream merges (#3184)
* Merge pull request EngineHub/WorldEdit#2740 from ssquadteam/version/7.3.x Add ability to copy state string from info tool Co-authored-by: ssquadteam <[email protected]> * Update enum-like classes with 1.21.5-rc1 data from MCUtils * Do not paste unsaveable entities in their default state (#2721) Remove a redundant passenger check, as entity.save() returns false in that case. This also causes leash knots to not be copied. I don't think this is a problem because: - They would not be saved to disk, it's misleading for users that they appear. - Pasted leashed mobs still think they're leashed to the original position and get unleashed* - no change in behaviour. \* Unless they're pasted close enough to the original position, in which case this has better behaviour because they create their own leash_knot entity. * Update click and hover text component serialization for 1.21.5. (#2757) Hacky workaround by overwriting the text3 StyleSerializer class with our own modified copy. Note that the hover events "show_entity" and "show_item" aren't supported as they no longer take a rendered component, but just the NBT structure. Behavior remains unchanged if 1.21.4- is detected. Fixes #2756. * Add text3 bukkit adapter override for Spigot gson change. (#2759) * Make SpigotAdapter compatible with pre 1.21.5 api --------- Co-authored-by: Octavia Togami <[email protected]> Co-authored-by: ssquadteam <[email protected]> Co-authored-by: Maddy Miller <[email protected]> Co-authored-by: brickmonster <[email protected]> Co-authored-by: wizjany <[email protected]> Co-authored-by: SirYwell <[email protected]>
1 parent 3c2b643 commit f524cf0

File tree

24 files changed

+541
-57
lines changed

24 files changed

+541
-57
lines changed

worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity
286286
* @param entity the entity
287287
* @param tag the tag
288288
*/
289-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
290-
entity.save(tag);
289+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
290+
return entity.save(tag);
291291
}
292292

293293
private static Block getBlockFromType(BlockType blockType) {
@@ -482,7 +482,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
482482
String id = getEntityId(mcEntity);
483483

484484
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
485-
readEntityIntoTag(mcEntity, tag);
485+
if (!readEntityIntoTag(mcEntity, tag)) {
486+
return null;
487+
}
486488
return new BaseEntity(
487489
com.sk89q.worldedit.world.entity.EntityTypes.get(id),
488490
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag))

worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ private static String getEntityId(Entity entity) {
139139
return resourceLocation == null ? null : resourceLocation.toString();
140140
}
141141

142-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
143-
entity.save(compoundTag);
142+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
143+
return entity.save(compoundTag);
144144
}
145145

146146
@Override
@@ -334,7 +334,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
334334
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
335335
Supplier<LinCompoundTag> saveTag = () -> {
336336
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
337-
readEntityIntoTag(mcEntity, minecraftTag);
337+
if (!readEntityIntoTag(mcEntity, minecraftTag)) {
338+
return null;
339+
}
338340
//add Id for AbstractChangeSet to work
339341
final LinCompoundTag tag = (LinCompoundTag) toNativeLin(minecraftTag);
340342
final Map<String, LinTag<?>> tags = NbtUtils.getLinCompoundTagValues(tag);

worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R3/PaperweightAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity
286286
* @param entity the entity
287287
* @param tag the tag
288288
*/
289-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
290-
entity.save(tag);
289+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
290+
return entity.save(tag);
291291
}
292292

293293
private static Block getBlockFromType(BlockType blockType) {
@@ -481,7 +481,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
481481
String id = getEntityId(mcEntity);
482482

483483
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
484-
readEntityIntoTag(mcEntity, tag);
484+
if (!readEntityIntoTag(mcEntity, tag)) {
485+
return null;
486+
}
485487
return new BaseEntity(
486488
com.sk89q.worldedit.world.entity.EntityTypes.get(id),
487489
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag))

worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightFaweAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ private static String getEntityId(Entity entity) {
138138
return resourceLocation == null ? null : resourceLocation.toString();
139139
}
140140

141-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
142-
entity.save(compoundTag);
141+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
142+
return entity.save(compoundTag);
143143
}
144144

145145
@Override
@@ -333,7 +333,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
333333
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
334334
Supplier<LinCompoundTag> saveTag = () -> {
335335
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
336-
readEntityIntoTag(mcEntity, minecraftTag);
336+
if (!readEntityIntoTag(mcEntity, minecraftTag)) {
337+
return null;
338+
}
337339
//add Id for AbstractChangeSet to work
338340
final LinCompoundTag tag = (LinCompoundTag) toNativeLin(minecraftTag);
339341
final Map<String, LinTag<?>> tags = NbtUtils.getLinCompoundTagValues(tag);

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity
294294
* @param entity the entity
295295
* @param tag the tag
296296
*/
297-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
298-
entity.save(tag);
297+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
298+
return entity.save(tag);
299299
}
300300

301301
private static Block getBlockFromType(BlockType blockType) {
@@ -489,7 +489,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
489489
String id = getEntityId(mcEntity);
490490

491491
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
492-
readEntityIntoTag(mcEntity, tag);
492+
if (!readEntityIntoTag(mcEntity, tag)) {
493+
return null;
494+
}
493495
return new BaseEntity(
494496
com.sk89q.worldedit.world.entity.EntityTypes.get(id),
495497
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag))

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ private static String getEntityId(Entity entity) {
148148
return resourceLocation == null ? null : resourceLocation.toString();
149149
}
150150

151-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
152-
entity.save(compoundTag);
151+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
152+
return entity.save(compoundTag);
153153
}
154154

155155
@Override
@@ -343,7 +343,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
343343
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
344344
Supplier<LinCompoundTag> saveTag = () -> {
345345
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
346-
readEntityIntoTag(mcEntity, minecraftTag);
346+
if (!readEntityIntoTag(mcEntity, minecraftTag)) {
347+
return null;
348+
}
347349
//add Id for AbstractChangeSet to work
348350
final LinCompoundTag tag = (LinCompoundTag) toNativeLin(minecraftTag);
349351
final Map<String, LinTag<?>> tags = NbtUtils.getLinCompoundTagValues(tag);

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity
289289
* @param entity the entity
290290
* @param tag the tag
291291
*/
292-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
293-
entity.save(tag);
292+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
293+
return entity.save(tag);
294294
}
295295

296296
private static Block getBlockFromType(BlockType blockType) {
@@ -476,15 +476,12 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
476476
CraftEntity craftEntity = ((CraftEntity) entity);
477477
Entity mcEntity = craftEntity.getHandle();
478478

479-
// Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
480-
if (mcEntity.isPassenger()) {
481-
return null;
482-
}
483-
484479
String id = getEntityId(mcEntity);
485480

486481
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
487-
readEntityIntoTag(mcEntity, tag);
482+
if (!readEntityIntoTag(mcEntity, tag)) {
483+
return null;
484+
}
488485
return new BaseEntity(
489486
EntityTypes.get(id),
490487
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag))

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ private static String getEntityId(Entity entity) {
148148
return resourceLocation == null ? null : resourceLocation.toString();
149149
}
150150

151-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
152-
entity.save(compoundTag);
151+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
152+
return entity.save(compoundTag);
153153
}
154154

155155
@Override
@@ -343,7 +343,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
343343
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
344344
Supplier<LinCompoundTag> saveTag = () -> {
345345
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
346-
readEntityIntoTag(mcEntity, minecraftTag);
346+
if (!readEntityIntoTag(mcEntity, minecraftTag)) {
347+
return null;
348+
}
347349
//add Id for AbstractChangeSet to work
348350
final LinCompoundTag tag = (LinCompoundTag) toNativeLin(minecraftTag);
349351
final Map<String, LinTag<?>> tags = NbtUtils.getLinCompoundTagValues(tag);

worldedit-bukkit/adapters/adapter-1_21_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_4/PaperweightAdapter.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ private static void readTagIntoEntity(net.minecraft.nbt.CompoundTag tag, Entity
281281
* @param entity the entity
282282
* @param tag the tag
283283
*/
284-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
285-
entity.save(tag);
284+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag tag) {
285+
return entity.save(tag);
286286
}
287287

288288
private static Block getBlockFromType(BlockType blockType) {
@@ -465,15 +465,12 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
465465
CraftEntity craftEntity = ((CraftEntity) entity);
466466
Entity mcEntity = craftEntity.getHandle();
467467

468-
// Do not allow creating of passenger entity snapshots, passengers are included in the vehicle entity
469-
if (mcEntity.isPassenger()) {
470-
return null;
471-
}
472-
473468
String id = getEntityId(mcEntity);
474469

475470
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
476-
readEntityIntoTag(mcEntity, tag);
471+
if (!readEntityIntoTag(mcEntity, tag)) {
472+
return null;
473+
}
477474
return new BaseEntity(
478475
EntityTypes.get(id),
479476
LazyReference.from(() -> (LinCompoundTag) toNativeLin(tag))

worldedit-bukkit/adapters/adapter-1_21_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_4/PaperweightFaweAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ private static String getEntityId(Entity entity) {
167167
return net.minecraft.world.entity.EntityType.getKey(entity.getType()).toString();
168168
}
169169

170-
private static void readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
171-
entity.save(compoundTag);
170+
private static boolean readEntityIntoTag(Entity entity, net.minecraft.nbt.CompoundTag compoundTag) {
171+
return entity.save(compoundTag);
172172
}
173173

174174
@Override
@@ -327,7 +327,9 @@ public BaseEntity getEntity(org.bukkit.entity.Entity entity) {
327327
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
328328
Supplier<LinCompoundTag> saveTag = () -> {
329329
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
330-
readEntityIntoTag(mcEntity, minecraftTag);
330+
if (!readEntityIntoTag(mcEntity, minecraftTag)) {
331+
return null;
332+
}
331333
//add Id for AbstractChangeSet to work
332334
final LinCompoundTag tag = (LinCompoundTag) toNativeLin(minecraftTag);
333335
final Map<String, LinTag<?>> tags = NbtUtils.getLinCompoundTagValues(tag);

0 commit comments

Comments
 (0)