SteamWar/BauSystem2.0
Archiviert
12
0

QOL #203

Zusammengeführt
YoyoNow hat 44 Commits von QOL nach master 2023-10-06 14:59:48 +02:00 zusammengeführt
2 geänderte Dateien mit 36 neuen und 17 gelöschten Zeilen
Nur Änderungen aus Commit 925ba19ff3 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -69,7 +69,7 @@ public class SmartPlaceListener implements Listener {
shouldRotate = false; 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()) { if (result.isSuccess()) {
event.setCancelled(true); event.setCancelled(true);
Block block = event.getClickedBlock().getRelative(event.getBlockFace()); Block block = event.getClickedBlock().getRelative(event.getBlockFace());

Datei anzeigen

@ -183,22 +183,37 @@ public class PlaceItemUtils {
// Lightning Rod is always rotated against the block you place against // Lightning Rod is always rotated against the block you place against
((Directional) blockData).setFacing(againstSide); ((Directional) blockData).setFacing(againstSide);
} }
if (force && blockData instanceof Switch) { if (force && blockData instanceof FaceAttachable) {
// Forcing to Place a switch against the Block you specified. Needs the force flag to be set // Forcing to Place a FaceAttachable against the Block you specified. Needs the force flag to be set
Switch switchType = (Switch) blockData; FaceAttachable faceAttachable = (FaceAttachable) blockData;
if (againstSide == BlockFace.DOWN) { if (blockData instanceof Switch && againstSide == BlockFace.DOWN) {
switchType.setAttachedFace(FaceAttachable.AttachedFace.CEILING); faceAttachable.setAttachedFace(FaceAttachable.AttachedFace.CEILING);
} else if (againstSide == BlockFace.UP) { } else if (againstSide == BlockFace.UP) {
switchType.setAttachedFace(FaceAttachable.AttachedFace.FLOOR); faceAttachable.setAttachedFace(FaceAttachable.AttachedFace.FLOOR);
} else { } else if (blockData instanceof Directional) {
switchType.setFacing(againstSide); ((Directional) blockData).setFacing(againstSide);
} }
// Levers and Buttons are always Rotated the other way if (blockData instanceof Switch) {
switch (switchType.getAttachedFace()) { // Levers and Buttons are always Rotated the other way
case FLOOR: Switch switchType = (Switch) blockData;
case CEILING: switch (switchType.getAttachedFace()) {
switchType.setFacing(switchType.getFacing().getOppositeFace()); case FLOOR:
break; 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); redstoneWire.setFace(BlockFace.WEST, RedstoneWire.Connection.SIDE);
} }
if (force) {
}
if (rotateAway) { if (rotateAway) {
// Rotate the other way if rotateAway is set to true // Rotate the other way if rotateAway is set to true
BlockFace blockFace = getRotation(blockData); BlockFace blockFace = getRotation(blockData);
@ -255,9 +274,9 @@ public class PlaceItemUtils {
Location blockmin = block.getLocation(); Location blockmin = block.getLocation();
Location blockmax = block.getLocation().add(1.0, 1.0, 1.0); Location blockmax = block.getLocation().add(1.0, 1.0, 1.0);
if ( 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.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; return PlaceItemResult.NO_PLACE_INSIDE_PLAYER;
} }