SteamWar/BauSystem2.0
Archiviert
12
0

Fix PlaceItemUtils and SmartPlaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-09-27 11:41:44 +02:00
Ursprung c0b40d00a5
Commit 925ba19ff3
2 geänderte Dateien mit 36 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -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());

Datei anzeigen

@ -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;
}