Skip to content

Commit

Permalink
Merge pull request #115 from ST-DDT/master
Browse files Browse the repository at this point in the history
Changed Gate to work with Nether_Brick_Fence - Thanks ST-DDT!
  • Loading branch information
TexasGamer committed Apr 1, 2012
2 parents 11e580a + fc96b77 commit 7a899d1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mechanisms/src/main/java/com/sk89q/craftbook/mech/Gate.java
Expand Up @@ -202,7 +202,8 @@ private boolean recurseColumn(WorldVector pt,
World world = ((BukkitWorld)pt.getWorld()).getWorld(); World world = ((BukkitWorld)pt.getWorld()).getWorld();
if (visitedColumns.size() > 14) { return false; } if (visitedColumns.size() > 14) { return false; }
if (visitedColumns.contains(pt.setY(0).toBlockVector())) { return false; } if (visitedColumns.contains(pt.setY(0).toBlockVector())) { return false; }
if (world.getBlockTypeIdAt(BukkitUtil.toLocation(pt)) != BlockID.FENCE) { if (world.getBlockTypeIdAt(BukkitUtil.toLocation(pt)) != BlockID.FENCE
&& world.getBlockTypeIdAt(BukkitUtil.toLocation(pt)) != BlockID.NETHER_BRICK_FENCE) {
return false; return false;
} }


Expand All @@ -214,7 +215,8 @@ private boolean recurseColumn(WorldVector pt,


// Find the top most fence // Find the top most fence
for (int y1 = y + 1; y1 <= y + 12; y1++) { for (int y1 = y + 1; y1 <= y + 12; y1++) {
if (world.getBlockTypeIdAt(x, y1, z) == BlockID.FENCE) { if (world.getBlockTypeIdAt(x, y1, z) == BlockID.FENCE
|| world.getBlockTypeIdAt(x, y1, z) == BlockID.NETHER_BRICK_FENCE) {
y = y1; y = y1;
} else { } else {
break; break;
Expand All @@ -230,7 +232,9 @@ private boolean recurseColumn(WorldVector pt,
if (close == null) { if (close == null) {
// Close the gate if the block below does not exist as a fence // Close the gate if the block below does not exist as a fence
// block, otherwise open the gate // block, otherwise open the gate
close = world.getBlockTypeIdAt(x, y - 1, z) != BlockID.FENCE;
close = world.getBlockTypeIdAt(x, y - 1, z) != BlockID.FENCE
&& world.getBlockTypeIdAt(x, y - 1, z) != BlockID.NETHER_BRICK_FENCE;
} }


// Recursively go to connected fence blocks of the same level // Recursively go to connected fence blocks of the same level
Expand Down Expand Up @@ -259,6 +263,9 @@ private void toggleColumn(WorldVector topPoint, boolean close,
// below with fence blocks; otherwise, we want to replace fence // below with fence blocks; otherwise, we want to replace fence
// blocks below with air // blocks below with air
int minY = Math.max(0, y - 12); int minY = Math.max(0, y - 12);
int ID = 0;
if (close)
ID = world.getBlockAt(x, y, z).getTypeId();
for (int y1 = y - 1; y1 >= minY; y1--) { for (int y1 = y - 1; y1 >= minY; y1--) {
int cur = world.getBlockTypeIdAt(x, y1, z); int cur = world.getBlockTypeIdAt(x, y1, z);


Expand All @@ -268,13 +275,14 @@ private void toggleColumn(WorldVector topPoint, boolean close,
&& cur != BlockID.LAVA && cur != BlockID.LAVA
&& cur != BlockID.STATIONARY_LAVA && cur != BlockID.STATIONARY_LAVA
&& cur != BlockID.FENCE && cur != BlockID.FENCE
&& cur != BlockID.NETHER_BRICK_FENCE
&& cur != BlockID.SNOW && cur != BlockID.SNOW
&& cur != 0) { && cur != 0) {
break; break;
} }


//bag.setBlockID(w, x, y1, z, close ? BlockID.FENCE : 0); //bag.setBlockID(w, x, y1, z, ID);
world.getBlockAt(x, y1, z).setTypeId(close ? BlockID.FENCE : 0); world.getBlockAt(x, y1, z).setTypeId(ID);


WorldVector pt = new BlockWorldVector(topPoint, x, y1, z); WorldVector pt = new BlockWorldVector(topPoint, x, y1, z);
recurseColumn(new BlockWorldVector(topPoint, pt.add(1, 0, 0)), visitedColumns, close); recurseColumn(new BlockWorldVector(topPoint, pt.add(1, 0, 0)), visitedColumns, close);
Expand Down

0 comments on commit 7a899d1

Please sign in to comment.