From bb814a210373b6c201185b4f5aef040949e5fbe5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 29 Aug 2020 10:27:32 +0200 Subject: [PATCH] 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); } }