Permalink
Browse files

Merge pull request #115 from ST-DDT/master

Changed Gate to work with Nether_Brick_Fence - Thanks ST-DDT!
  • Loading branch information...
ThomasGaubert committed Apr 1, 2012
2 parents 11e580a + fc96b77 commit 7a899d1da7049fd1d8c2ca795c3730ae554dd282
Showing with 13 additions and 5 deletions.
  1. +13 −5 mechanisms/src/main/java/com/sk89q/craftbook/mech/Gate.java
@@ -202,7 +202,8 @@ private boolean recurseColumn(WorldVector pt,
World world = ((BukkitWorld)pt.getWorld()).getWorld();
if (visitedColumns.size() > 14) { 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;
}
@@ -214,7 +215,8 @@ private boolean recurseColumn(WorldVector pt,
// Find the top most fence
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;
} else {
break;
@@ -230,7 +232,9 @@ private boolean recurseColumn(WorldVector pt,
if (close == null) {
// Close the gate if the block below does not exist as a fence
// 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
@@ -259,6 +263,9 @@ private void toggleColumn(WorldVector topPoint, boolean close,
// below with fence blocks; otherwise, we want to replace fence
// blocks below with air
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--) {
int cur = world.getBlockTypeIdAt(x, y1, z);
@@ -268,13 +275,14 @@ private void toggleColumn(WorldVector topPoint, boolean close,
&& cur != BlockID.LAVA
&& cur != BlockID.STATIONARY_LAVA
&& cur != BlockID.FENCE
+ && cur != BlockID.NETHER_BRICK_FENCE
&& cur != BlockID.SNOW
&& cur != 0) {
break;
}
- //bag.setBlockID(w, x, y1, z, close ? BlockID.FENCE : 0);
- world.getBlockAt(x, y1, z).setTypeId(close ? BlockID.FENCE : 0);
+ //bag.setBlockID(w, x, y1, z, ID);
+ world.getBlockAt(x, y1, z).setTypeId(ID);
WorldVector pt = new BlockWorldVector(topPoint, x, y1, z);
recurseColumn(new BlockWorldVector(topPoint, pt.add(1, 0, 0)), visitedColumns, close);

0 comments on commit 7a899d1

Please sign in to comment.