diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/PlacementStateProcessor.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/PlacementStateProcessor.java index 95ed8cbff..3175cd656 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/PlacementStateProcessor.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/processor/PlacementStateProcessor.java @@ -346,7 +346,7 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp return BlockTypesCache.states[ordinal].getNbtData(); } - private char getBlockOrdinal(final int blockX, final int blockY, final int blockZ, final BlockState state) { + private char getBlockOrdinal(int blockX, int blockY, int blockZ, BlockState state) { EnumSet dirs = Direction.getDirections(state); Direction clickedFaceDirection = null; // This should be always be set by the below. Set states = state.getStates().keySet().stream().map(Property::getName).collect(Collectors.toSet()); @@ -358,7 +358,12 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp boolean hadNesw = false; for (Direction dir : NESW) { if (dirs.contains(dir)) { - clickedFaceDirection = dir.getLeft().getLeft(); // opposite + clickedFaceDirection = dir.getLeft().getLeft(); + if (state.getBlockType() == BlockTypes.CHEST || state.getBlockType() == BlockTypes.TRAPPED_CHEST) { + Direction tmp = clickedFaceDirection; + clickedFaceDirection = dir; + dir = tmp; + } clickPos.setComponents( (double) blockX + 0.5 * (1 + dir.getBlockX()), (double) blockY + 0.2, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index f6416f5c1..3d21ef587 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -29,12 +29,10 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Optional; import java.util.OptionalInt; -import java.util.Set; /** * A collection of cardinal, ordinal, and secondary-ordinal directions. @@ -366,7 +364,7 @@ public enum Direction { * @since TODO */ public static EnumSet getDirections(BlockState state) { - Set directions = new HashSet<>(); + EnumSet directions = EnumSet.noneOf(Direction.class); for (Property property : state.getBlockType().getProperties()) { if (property instanceof DirectionalProperty dirProp) { directions.add(state.getState(dirProp)); @@ -376,8 +374,7 @@ public enum Direction { if (!(value instanceof String str)) { if (value instanceof Integer i) { fromRotationIndex(i).ifPresent(directions::add); - } - if (value instanceof Boolean) { + } else if (value instanceof Boolean b && b) { try { directions.add(Direction.valueOf(property.getName().toUpperCase(Locale.ROOT))); } catch (IllegalArgumentException ignored) { @@ -397,9 +394,8 @@ public enum Direction { case "shape" -> {} // Do nothing for now } } - return EnumSet.copyOf(directions); + return directions; } //FAWE end } -