}
@Override
public CuboidRegion getCuboidArea(Block trigger, Block proximalBaseCenter, Block distalBaseCenter) throws InvalidMechanismException {
CuboidRegion toggle = new CuboidRegion(BukkitUtil.toVector(proximalBaseCenter), BukkitUtil.toVector(distalBaseCenter));
ChangedSign sign = BukkitUtil.toChangedSign(trigger);
int left, right;
try {
left = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(2))));
} catch (Exception e) {
left = 1;
}
try {
right = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(3))));
} catch (Exception e) {
right = 1;
}
// Expand Left
for (int i = 0; i < left; i++) {
if(!BlockUtil.areBlocksIdentical(distalBaseCenter.getRelative(SignUtil.getLeft(trigger), i), proximalBaseCenter.getRelative(SignUtil.getLeft(trigger), i)))
throw new InvalidMechanismException("mech.bridge.material");
toggle.expand(BukkitUtil.toVector(SignUtil.getLeft(trigger)), new Vector(0, 0, 0));
}
// Expand Right
for (int i = 0; i < right; i++) {
if(!BlockUtil.areBlocksIdentical(distalBaseCenter.getRelative(SignUtil.getRight(trigger), i), proximalBaseCenter.getRelative(SignUtil.getRight(trigger), i)))
throw new InvalidMechanismException("mech.bridge.material");
toggle.expand(BukkitUtil.toVector(SignUtil.getRight(trigger)), new Vector(0, 0, 0));
}
// Don't toggle the end points
toggle.contract(BukkitUtil.toVector(SignUtil.getBack(trigger)), BukkitUtil.toVector(SignUtil.getFront(trigger)));
return toggle;
}