case BlockID.REDSTONE_WIRE:
if (CraftBookPlugin.inst().getConfiguration().indirectRedstone) {
// power all blocks around the redstone wire on the same y level
// north/south
handleDirectWireInput(new WorldVector(w, x - 1, y, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + 1, y, z), block, oldLevel, newLevel);
// east/west
handleDirectWireInput(new WorldVector(w, x, y, z - 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y, z + 1), block, oldLevel, newLevel);
// Can be triggered from below
handleDirectWireInput(new WorldVector(w, x, y + 1, z), block, oldLevel, newLevel);
// Can be triggered from above (Eg, glass->glowstone like redstone lamps)
handleDirectWireInput(new WorldVector(w, x, y - 1, z), block, oldLevel, newLevel);
} else {
int above = world.getBlockTypeIdAt(x, y + 1, z);
int westSide = world.getBlockTypeIdAt(x, y, z + 1);
int westSideAbove = world.getBlockTypeIdAt(x, y + 1, z + 1);
int westSideBelow = world.getBlockTypeIdAt(x, y - 1, z + 1);
int eastSide = world.getBlockTypeIdAt(x, y, z - 1);
int eastSideAbove = world.getBlockTypeIdAt(x, y + 1, z - 1);
int eastSideBelow = world.getBlockTypeIdAt(x, y - 1, z - 1);
int northSide = world.getBlockTypeIdAt(x - 1, y, z);
int northSideAbove = world.getBlockTypeIdAt(x - 1, y + 1, z);
int northSideBelow = world.getBlockTypeIdAt(x - 1, y - 1, z);
int southSide = world.getBlockTypeIdAt(x + 1, y, z);
int southSideAbove = world.getBlockTypeIdAt(x + 1, y + 1, z);
int southSideBelow = world.getBlockTypeIdAt(x + 1, y - 1, z);
// Make sure that the wire points to only this block
if (!BlockType.isRedstoneBlock(westSide) && !BlockType.isRedstoneBlock(eastSide)
&& (!BlockType.isRedstoneBlock(westSideAbove) || westSide == 0 || above != 0)
&& (!BlockType.isRedstoneBlock(eastSideAbove) || eastSide == 0 || above != 0)
&& (!BlockType.isRedstoneBlock(westSideBelow) || westSide != 0)
&& (!BlockType.isRedstoneBlock(eastSideBelow) || eastSide != 0)) {
// Possible blocks north / south
handleDirectWireInput(new WorldVector(w, x - 1, y, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + 1, y, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x - 1, y - 1, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + 1, y - 1, z), block, oldLevel, newLevel);
}
if (!BlockType.isRedstoneBlock(northSide) && !BlockType.isRedstoneBlock(southSide)
&& (!BlockType.isRedstoneBlock(northSideAbove) || northSide == 0 || above != 0)
&& (!BlockType.isRedstoneBlock(southSideAbove) || southSide == 0 || above != 0)
&& (!BlockType.isRedstoneBlock(northSideBelow) || northSide != 0)
&& (!BlockType.isRedstoneBlock(southSideBelow) || southSide != 0)) {
// Possible blocks west / east
handleDirectWireInput(new WorldVector(w, x, y, z - 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y, z + 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y - 1, z - 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y - 1, z + 1), block, oldLevel, newLevel);
}
// Can be triggered from below
handleDirectWireInput(new WorldVector(w, x, y + 1, z), block, oldLevel, newLevel);
// Can be triggered from above
handleDirectWireInput(new WorldVector(w, x, y - 1, z), block, oldLevel, newLevel);
}
return;
case BlockID.REDSTONE_REPEATER_OFF:
case BlockID.REDSTONE_REPEATER_ON:
case BlockID.COMPARATOR_OFF:
case BlockID.COMPARATOR_ON:
Directional diode = (Directional) block.getState().getData();
BlockFace f = diode.getFacing();
handleDirectWireInput(new WorldVector(w, x + f.getModX(), y, z + f.getModZ()), block, oldLevel, newLevel);
if(block.getRelative(f).getTypeId() != 0) {
handleDirectWireInput(new WorldVector(w, x + f.getModX(), y - 1, z + f.getModZ()), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + f.getModX(), y + 1, z + f.getModZ()), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + f.getModX() + 1, y - 1, z + f.getModZ()), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + f.getModX() - 1, y - 1, z + f.getModZ()), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + f.getModX() + 1, y - 1, z + f.getModZ() + 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + f.getModX() - 1, y - 1, z + f.getModZ() - 1), block, oldLevel, newLevel);
}
return;
case BlockID.STONE_BUTTON:
case BlockID.WOODEN_BUTTON:
case BlockID.LEVER:
Attachable button = (Attachable) block.getState().getData();
if(button != null) {
BlockFace face = button.getAttachedFace();
if(face != null)
handleDirectWireInput(new WorldVector(w, x + face.getModX()*2, y, z + face.getModZ()*2), block, oldLevel, newLevel);
}
}
// For redstone wires and repeaters, the code already exited this method
// Non-wire blocks proceed
handleDirectWireInput(new WorldVector(w, x - 1, y, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + 1, y, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x - 1, y - 1, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x + 1, y - 1, z), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y, z - 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y, z + 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y - 1, z - 1), block, oldLevel, newLevel);
handleDirectWireInput(new WorldVector(w, x, y - 1, z + 1), block, oldLevel, newLevel);
// Can be triggered from below
handleDirectWireInput(new WorldVector(w, x, y + 1, z), block, oldLevel, newLevel);
// Can be triggered from above
handleDirectWireInput(new WorldVector(w, x, y - 1, z), block, oldLevel, newLevel);
}