From d4535ff36dae0b1aab6be5c4b5cf4460027ad603 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 01:15:19 +0200 Subject: [PATCH 1/7] Fix Loader Redstone --- .../bausystem/world/AutoLoader_15.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index 846dd40..720a857 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -30,10 +30,28 @@ class AutoLoader_15 { Powerable powerable = (Powerable) data; powerable.setPowered(active); block.setBlockData(powerable); - block.getState().update(true); + updateBlock(block.getLocation()); return true; } + static void updateBlock(Location location) { + Location[] locations = new Location[] { + location.clone(), + location.clone().add(1, 0,0), + location.clone().add(-1, 0,0), + location.clone().add(0, 1,0), + location.clone().add(0, -1,0), + location.clone().add(0, 0,1), + location.clone().add(0, 0,-1) + }; + for (Location value : locations) { + if (value.getBlock().getType().toString().contains("SIGN")) continue; + BlockData data = value.getBlock().getBlockData(); + value.getBlock().setType(Material.BARRIER, true); + value.getBlock().setBlockData(data, true); + } + } + static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) return; -- 2.39.5 From 6afaeebfae21a1b3833c6d1b643f0f519de307fe Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 09:12:09 +0200 Subject: [PATCH 2/7] Fixed Autoloader 15 Redstone under Block --- .../src/de/steamwar/bausystem/world/AutoLoader_15.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index 720a857..2dbcbba 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -36,7 +36,6 @@ class AutoLoader_15 { static void updateBlock(Location location) { Location[] locations = new Location[] { - location.clone(), location.clone().add(1, 0,0), location.clone().add(-1, 0,0), location.clone().add(0, 1,0), @@ -45,7 +44,7 @@ class AutoLoader_15 { location.clone().add(0, 0,-1) }; for (Location value : locations) { - if (value.getBlock().getType().toString().contains("SIGN")) continue; + if (!value.getBlock().getType().isSolid()) continue; BlockData data = value.getBlock().getBlockData(); value.getBlock().setType(Material.BARRIER, true); value.getBlock().setBlockData(data, true); -- 2.39.5 From 88a495f4aea9b46a43835ade87fd75e260c04bf8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 09:30:29 +0200 Subject: [PATCH 3/7] Fixed Sign Text Disappearing if Next to a Button pressed by Auto Loader --- BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index 2dbcbba..dbbb48e 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -44,7 +44,7 @@ class AutoLoader_15 { location.clone().add(0, 0,-1) }; for (Location value : locations) { - if (!value.getBlock().getType().isSolid()) continue; + if (!value.getBlock().getType().isOccluding()) continue; BlockData data = value.getBlock().getBlockData(); value.getBlock().setType(Material.BARRIER, true); value.getBlock().setBlockData(data, true); -- 2.39.5 From bb814a210373b6c201185b4f5aef040949e5fbe5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 10:27:32 +0200 Subject: [PATCH 4/7] Improved Location Selection --- .../bausystem/world/AutoLoader_15.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index dbbb48e..daa04b0 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -9,6 +9,9 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; class AutoLoader_15 { + + private static int[][] offsets = new int[][]{{1, 0, 0}, {-2, 0, 0}, {1, 1, 0}, {0, -2, 0}, {0, 1, 1}, {0, 0, -2}, {0, 0, 1}}; + private AutoLoader_15() { } @@ -35,19 +38,12 @@ class AutoLoader_15 { } static void updateBlock(Location location) { - Location[] locations = new Location[] { - location.clone().add(1, 0,0), - location.clone().add(-1, 0,0), - location.clone().add(0, 1,0), - location.clone().add(0, -1,0), - location.clone().add(0, 0,1), - location.clone().add(0, 0,-1) - }; - for (Location value : locations) { - if (!value.getBlock().getType().isOccluding()) continue; - BlockData data = value.getBlock().getBlockData(); - value.getBlock().setType(Material.BARRIER, true); - value.getBlock().setBlockData(data, true); + for (int[] offset : offsets) { + location.add(offset[0], offset[1], offset[2]); + if (!location.getBlock().getType().isOccluding()) continue; + BlockData data = location.getBlock().getBlockData(); + location.getBlock().setType(Material.BARRIER, true); + location.getBlock().setBlockData(data, true); } } -- 2.39.5 From a933da7c301b5e86b2cd2481529fe84d0fa9e73f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 29 Aug 2020 11:02:01 +0200 Subject: [PATCH 5/7] Getting next block --- .../bausystem/world/AutoLoader_15.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index daa04b0..0ffa968 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -3,8 +3,10 @@ package de.steamwar.bausystem.world; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Powerable; +import org.bukkit.block.data.type.Switch; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; @@ -33,7 +35,24 @@ class AutoLoader_15 { Powerable powerable = (Powerable) data; powerable.setPowered(active); block.setBlockData(powerable); - updateBlock(block.getLocation()); + + if (data instanceof Switch){ + Switch swtch = (Switch) data; + Block relative; + switch(swtch.getFace()){ + case FLOOR: + relative = block.getRelative(BlockFace.DOWN); + break; + case CEILING: + relative = block.getRelative(BlockFace.UP); + break; + default: + relative = block.getRelative(swtch.getFacing()); + break; + } + relative.getState().update(true); + updateBlock(relative.getLocation()); + } return true; } -- 2.39.5 From 4a5e8c3d66a3fc431297be57d5cab468c1b52a50 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 11:18:49 +0200 Subject: [PATCH 6/7] Reduced Number of Updated Blocks --- .../steamwar/bausystem/world/AutoLoader_15.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index 0ffa968..af0148b 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -50,20 +50,15 @@ class AutoLoader_15 { relative = block.getRelative(swtch.getFacing()); break; } - relative.getState().update(true); - updateBlock(relative.getLocation()); + updateBlock(relative); } return true; } - static void updateBlock(Location location) { - for (int[] offset : offsets) { - location.add(offset[0], offset[1], offset[2]); - if (!location.getBlock().getType().isOccluding()) continue; - BlockData data = location.getBlock().getBlockData(); - location.getBlock().setType(Material.BARRIER, true); - location.getBlock().setBlockData(data, true); - } + static void updateBlock(Block block) { + BlockData data = block.getBlockData(); + block.setType(Material.BARRIER, true); + block.setBlockData(data, true); } static void onPlayerInteract(IAutoLoader loader, PlayerInteractEvent event) { -- 2.39.5 From 7b3fcf90b10ee27a8386bb8efb2338cc157a6983 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 11:19:42 +0200 Subject: [PATCH 7/7] Removed Offset Array --- BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index af0148b..e0b478e 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -12,8 +12,6 @@ import org.bukkit.event.player.PlayerInteractEvent; class AutoLoader_15 { - private static int[][] offsets = new int[][]{{1, 0, 0}, {-2, 0, 0}, {1, 1, 0}, {0, -2, 0}, {0, 1, 1}, {0, 0, -2}, {0, 0, 1}}; - private AutoLoader_15() { } -- 2.39.5