From 3b879477b68327f76923020a31827a0ef6264b1a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 7 Aug 2019 10:25:57 +1000 Subject: [PATCH] more compiling --- .../main/java/com/sk89q/jnbt/CompoundTag.java | 2 +- .../worldedit/command/SchematicCommands.java | 2 +- .../command/util/DelegateCommandManager.java | 2 +- .../extent/AbstractDelegateExtent.java | 9 ++- .../function/entity/ExtentEntityCopy.java | 61 +++++-------------- 5 files changed, 24 insertions(+), 52 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java index a23bd6521..a12e58d69 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompoundTag.java @@ -52,7 +52,7 @@ public class CompoundTag extends Tag { } @Override - public final Map getValue() { + public Map getValue() { return value; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 3496c042c..5e76e2522 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -338,7 +338,7 @@ public class SchematicCommands { } if (other) { if (!actor.hasPermission("worldedit.schematic.delete.other")) { - BBC.NO_PERM.send(player, "worldedit.schematic.delete.other"); + BBC.NO_PERM.send(actor, "worldedit.schematic.delete.other"); return; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java index 8b284e8d9..6985eba1d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/DelegateCommandManager.java @@ -61,7 +61,7 @@ public class DelegateCommandManager implements CommandManager { } @Override - public int execute(InjectedValueAccess context, List args) { + public Object execute(InjectedValueAccess context, List args) { return parent.execute(context, args); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index aad178ec3..0414112a8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -27,6 +27,7 @@ import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.util.ExtentTraverser; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer; import com.sk89q.worldedit.function.operation.Operation; @@ -165,10 +166,14 @@ public class AbstractDelegateExtent implements Extent, LightingExtent { return extent.setBlock(x, y, z, block); } + @Override + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + return setBlock(x, y, z, getBlock(x, y, z).toBaseBlock(tile)); + } /* - Light - */ + Light + */ public int getSkyLight(int x, int y, int z) { if (extent instanceof LightingExtent) { return ((LightingExtent) extent).getSkyLight(x, y, z); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index b4aa500bc..ae028db56 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; @@ -156,76 +157,42 @@ public class ExtentEntityCopy implements EntityFunction { BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); return new BaseEntity(state.getType(), tag.createBuilder() .put("Leash", leashCompound.createBuilder() - .putInt("X", newLeash.getBlockX()) - .putInt("Y", newLeash.getBlockY()) - .putInt("Z", newLeash.getBlockZ()) - .build() + .putInt("X", newLeash.getBlockX()) + .putInt("Y", newLeash.getBlockY()) + .putInt("Z", newLeash.getBlockZ()) + .build() ).build()); } } - boolean changed = false; // Handle hanging entities (paintings, item frames, etc.) boolean hasTilePosition = tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ"); boolean hasFacing = tag.containsKey("Facing"); - tag = tag.createBuilder().build(); - - Map values = ReflectionUtils.getMap(tag.getValue()); - - boolean hasDirection = tag.containsKey("Direction"); - boolean hasLegacyDirection = tag.containsKey("Dir"); if (hasTilePosition) { - changed = true; Vector3 tilePosition = Vector3.at(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); - values.put("TileX", new IntTag(newTilePosition.getBlockX())); - values.put("TileY", new IntTag(newTilePosition.getBlockY())); - values.put("TileZ", new IntTag(newTilePosition.getBlockZ())); + CompoundTagBuilder builder = tag.createBuilder() + .putInt("TileX", newTilePosition.getBlockX()) + .putInt("TileY", newTilePosition.getBlockY()) + .putInt("TileZ", newTilePosition.getBlockZ()); - if (hasDirection || hasLegacyDirection || hasFacing) { - int d; - if (hasDirection) { - d = tag.asInt("Direction"); - } else if (hasLegacyDirection) { - d = MCDirections.fromLegacyHanging((byte) tag.asInt("Dir")); - } else { - d = tag.asInt("Facing"); - } - - Direction direction = MCDirections.fromHanging(d); + if (hasFacing) { + boolean isPainting = state.getType() == EntityTypes.PAINTING; // Paintings have different facing values + Direction direction = isPainting ? MCDirections.fromHorizontalHanging(tag.asInt("Facing")) : MCDirections.fromHanging(tag.asInt("Facing")); if (direction != null) { Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize(); Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL); if (newDirection != null) { - byte hangingByte = (byte) MCDirections.toHanging(newDirection); - values.put("Direction", new ByteTag(hangingByte)); - values.put("Facing", new ByteTag(hangingByte)); - values.put("Dir", new ByteTag(MCDirections.toLegacyHanging(MCDirections.toHanging(newDirection)))); + builder.putByte("Facing", (byte) (isPainting ? MCDirections.toHorizontalHanging(newDirection) : MCDirections.toHanging(newDirection))); } } } - } - ListTag rotation = tag.getListTag("Rotation"); - if (rotation != null && rotation.getValue().size() >= 2) { - changed = true; - double yaw = Math.toRadians(rotation.getFloat(0)); - double pitch = Math.toRadians(rotation.getFloat(1)); - - double xz = Math.cos(pitch); - Vector3 direction = Vector3.at(-xz * Math.sin(yaw), -Math.sin(pitch), xz * Math.cos(yaw)); - direction = transform.apply(direction); - FloatTag yawTag = new FloatTag((float) direction.toYaw()); - FloatTag pitchTag = new FloatTag((float) direction.toPitch()); - values.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(yawTag, pitchTag))); - } - - if (changed) { - return new BaseEntity(state.getType(), tag); + return new BaseEntity(state.getType(), builder.build()); } }