diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index 6fd41b70..3879b175 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -69,7 +69,7 @@ public class SmartPlaceListener implements Listener { shouldRotate = false; } - PlaceItemUtils.PlaceItemResult result = PlaceItemUtils.placeItem(event.getPlayer(), event.getItem(), event.getClickedBlock(), event.getBlockFace(), event.getHand(), true, false, shouldRotate, false); + PlaceItemUtils.PlaceItemResult result = PlaceItemUtils.placeItem(event.getPlayer(), event.getItem(), event.getClickedBlock(), event.getBlockFace(), event.getHand(), true, true, shouldRotate, false); if (result.isSuccess()) { event.setCancelled(true); Block block = event.getClickedBlock().getRelative(event.getBlockFace()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java index 0635b01a..5631a373 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java @@ -183,22 +183,37 @@ public class PlaceItemUtils { // Lightning Rod is always rotated against the block you place against ((Directional) blockData).setFacing(againstSide); } - if (force && blockData instanceof Switch) { - // Forcing to Place a switch against the Block you specified. Needs the force flag to be set - Switch switchType = (Switch) blockData; - if (againstSide == BlockFace.DOWN) { - switchType.setAttachedFace(FaceAttachable.AttachedFace.CEILING); + if (force && blockData instanceof FaceAttachable) { + // Forcing to Place a FaceAttachable against the Block you specified. Needs the force flag to be set + FaceAttachable faceAttachable = (FaceAttachable) blockData; + if (blockData instanceof Switch && againstSide == BlockFace.DOWN) { + faceAttachable.setAttachedFace(FaceAttachable.AttachedFace.CEILING); } else if (againstSide == BlockFace.UP) { - switchType.setAttachedFace(FaceAttachable.AttachedFace.FLOOR); - } else { - switchType.setFacing(againstSide); + faceAttachable.setAttachedFace(FaceAttachable.AttachedFace.FLOOR); + } else if (blockData instanceof Directional) { + ((Directional) blockData).setFacing(againstSide); } - // Levers and Buttons are always Rotated the other way - switch (switchType.getAttachedFace()) { - case FLOOR: - case CEILING: - switchType.setFacing(switchType.getFacing().getOppositeFace()); - break; + if (blockData instanceof Switch) { + // Levers and Buttons are always Rotated the other way + Switch switchType = (Switch) blockData; + switch (switchType.getAttachedFace()) { + case FLOOR: + case CEILING: + switchType.setFacing(switchType.getFacing().getOppositeFace()); + break; + } + } + } + if (force && blockData instanceof Directional && !(blockData instanceof FaceAttachable) && BLOCK_MATERIAL_TO_WALL_BLOCK_MATERIAL.containsValue(blockData.getMaterial())) { + Directional directional = (Directional) blockData; + if (directional.getFaces().contains(againstSide)) { + directional.setFacing(againstSide); + } + } + if (force && blockData instanceof Rotatable && !(blockData instanceof FaceAttachable)) { + Rotatable rotatable = (Rotatable) blockData; + if (againstSide != BlockFace.UP && againstSide != BlockFace.DOWN) { + rotatable.setRotation(againstSide); } } @@ -211,6 +226,10 @@ public class PlaceItemUtils { redstoneWire.setFace(BlockFace.WEST, RedstoneWire.Connection.SIDE); } + if (force) { + + } + if (rotateAway) { // Rotate the other way if rotateAway is set to true BlockFace blockFace = getRotation(blockData); @@ -255,9 +274,9 @@ public class PlaceItemUtils { Location blockmin = block.getLocation(); Location blockmax = block.getLocation().add(1.0, 1.0, 1.0); if ( - max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() || + !(max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() || max.getY() <= blockmin.getY() || min.getY() >= blockmax.getY() || - max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ() + max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ()) ) { return PlaceItemResult.NO_PLACE_INSIDE_PLAYER; }