SteamWar/BauSystem2.0
Archiviert
12
0

Fix SmartPlace
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-05-19 16:38:10 +02:00
Ursprung 3d27af7196
Commit 0e9d0d36c9
3 geänderte Dateien mit 18 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -46,24 +46,23 @@ public class SmartPlaceListener implements Listener {
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getPlayer().isSneaking() && Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) {
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
SmartPlaceBehaviour.SmartPlaceResult smartPlaceResult = SmartPlaceBehaviour.SmartPlaceResult.IGNORED;
for (SmartPlaceBehaviour smartPlaceBehaviour : smartPlaceBehaviours) {
if (smartPlaceBehaviour.getType() == SmartPlaceBehaviour.SmartPlaceType.PLACE) {
smartPlaceBehaviour.place(event);
smartPlaceResult = smartPlaceBehaviour.place(event);
}
if (smartPlaceResult == SmartPlaceBehaviour.SmartPlaceResult.APPLIED) {
break;
}
}
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
for (SmartPlaceBehaviour smartPlaceBehaviour : smartPlaceBehaviours) {
SmartPlaceBehaviour.SmartPlaceResult smartPlaceResult = SmartPlaceBehaviour.SmartPlaceResult.IGNORED;

Datei anzeigen

@ -39,7 +39,7 @@ public class BlockPlaceBehaviour implements SmartPlaceBehaviour {
@Override
public SmartPlaceResult place(BlockPlaceEvent event) {
if (event.getBlockAgainst().getType().isInteractable()) {
if (!event.getPlayer().isSneaking()) {
return SmartPlaceResult.IGNORED;
}

Datei anzeigen

@ -43,26 +43,20 @@ public class BlockRotatingBehaviour implements SmartPlaceBehaviour {
@Override
public SmartPlaceResult interact(PlayerInteractEvent event) {
if (event.getClickedBlock().getType() == event.getMaterial() || event.getMaterial() == Material.HOPPER) {
if (!(event.getClickedBlock().getState() instanceof InventoryHolder)) {
return SmartPlaceResult.IGNORED;
}
} else {
BlockData blockData = event.getMaterial().createBlockData();
if (blockData instanceof Directional) {
if (!(blockData instanceof Directional) && !(blockData instanceof Rotatable)) {
return SmartPlaceResult.IGNORED;
}
if (blockData instanceof Rotatable) {
return SmartPlaceResult.IGNORED;
}
}
// TODO: Fix block setting
event.setUseInteractedBlock(Event.Result.DENY);
World world = event.getPlayer().getWorld();
Block block = world.getBlockAt(event.getClickedBlock().getX() + event.getBlockFace().getModX(), event.getClickedBlock().getY() + event.getBlockFace().getModY(), event.getClickedBlock().getZ() + event.getBlockFace().getModZ());
block.setType(event.getMaterial());
BlockData blockData = event.getItem().getType().createBlockData();
blockData = event.getItem().getType().createBlockData();
BlockFace blockFace = event.getBlockFace();
if (block.getType() == Material.HOPPER || block.getType() == Material.OBSERVER) {
blockFace = blockFace.getOppositeFace();