Fix PlaceItemUtils and SmartPlaceListener
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
c0b40d00a5
Commit
925ba19ff3
@ -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());
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren