Skip to content

Commit 9ec03da

Browse files
committed
Refactor leash entity handling in clipboard copy
1 parent 3a188d0 commit 9ec03da

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

  • worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard

worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -435,29 +435,11 @@ default void paste(Extent extent, BlockVector3 to, boolean pasteAir, boolean pas
435435
continue;
436436
}
437437
Location pos = entity.getLocation();
438-
if (entity.getType().equals(EntityTypes.LEASH_KNOT)) {
439-
var state = entity.getState();
440-
var nbtData = new HashMap<>(state.getNbtData().getValue());
441-
var posAsMap = new HashMap<String, Tag<?, ?>>();
442-
posAsMap.put("X", new IntTag(pos.getBlockX()));
443-
posAsMap.put("Y", new IntTag(pos.getBlockY()));
444-
posAsMap.put("Z", new IntTag(pos.getBlockZ()));
445-
nbtData.put("OldPos", new CompoundTag(posAsMap));
446-
state.setNbtData(new CompoundTag(nbtData));
447-
Location newPos = new Location(pos.getExtent(), pos.x() + entityOffsetX,
448-
pos.y() + entityOffsetY, pos.z() + entityOffsetZ, pos.getYaw(),
449-
pos.getPitch()
450-
);
451-
452-
extent.createEntity(newPos, state);
453-
} else {
454-
Location newPos = new Location(pos.getExtent(), pos.x() + entityOffsetX,
455-
pos.y() + entityOffsetY, pos.z() + entityOffsetZ, pos.getYaw(),
456-
pos.getPitch()
457-
);
458-
459-
extent.createEntity(newPos, entity.getState());
460-
}
438+
Location newPos = new Location(pos.getExtent(), pos.x() + entityOffsetX,
439+
pos.y() + entityOffsetY, pos.z() + entityOffsetZ, pos.getYaw(),
440+
pos.getPitch()
441+
);
442+
extent.createEntity(newPos, entity.getState());
461443
}
462444
}
463445
if (close) {

0 commit comments

Comments
 (0)