Permalink
Browse files

Add checks to ensure that bridges and doors are atleast 3 blocks long.

  • Loading branch information...
me4502 committed Apr 8, 2017
1 parent 76d74fa commit f3da9d5627697b711f6e0b00241aa36e24154994
@@ -211,7 +211,10 @@ public Block getFarSign(Block trigger) {
@Override
public CuboidRegion getCuboidArea(Block trigger, Block proximalBaseCenter, Block distalBaseCenter) throws InvalidMechanismException {
-
+ double distance = proximalBaseCenter.getLocation().distanceSquared(distalBaseCenter.getLocation());
+ if (distance <= 2*2) {
+ throw new InvalidMechanismException("Bridge too short!");
+ }
CuboidRegion toggle = new CuboidRegion(BukkitUtil.toVector(proximalBaseCenter), BukkitUtil.toVector(distalBaseCenter));
ChangedSign sign = BukkitUtil.toChangedSign(trigger);
int left, right;
@@ -275,6 +275,10 @@ public Block getBlockBase(Block trigger) throws InvalidMechanismException {
@Override
public CuboidRegion getCuboidArea(Block trigger, Block proximalBaseCenter, Block distalBaseCenter) throws InvalidMechanismException {
+ double distance = proximalBaseCenter.getLocation().distanceSquared(distalBaseCenter.getLocation());
+ if (distance <= 2*2) {
+ throw new InvalidMechanismException("Door too short!");
+ }
// Select the togglable region
CuboidRegion toggle = new CuboidRegion(BukkitUtil.toVector(proximalBaseCenter), BukkitUtil.toVector(distalBaseCenter));
ChangedSign sign = BukkitUtil.toChangedSign(trigger);

0 comments on commit f3da9d5

Please sign in to comment.