Skip to content

Commit

Permalink
DoorOpener should still work if door is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed May 5, 2019
1 parent 77cdcf0 commit 05aea81
Showing 1 changed file with 11 additions and 9 deletions.
Expand Up @@ -30,17 +30,19 @@ public PassableState isPassable(BlockSource source, PathPoint point) {
static class DoorOpener implements PathCallback {
@Override
public void run(NPC npc, Block point, ListIterator<Block> path) {
if (!MinecraftBlockExaminer.isDoor(point.getType()))
return;
if (npc.getStoredLocation().distanceSquared(point.getLocation()) > 4)
return;
BlockState state = point.getState();
Door door = (Door) state.getData();
if (npc.getStoredLocation().distanceSquared(point.getLocation()) < 4) {
boolean bottom = !door.isTopHalf();
Block set = bottom ? point : point.getRelative(BlockFace.DOWN);
state = set.getState();
door = (Door) state.getData();
door.setOpen(true);
state.setData(door);
state.update();
}
boolean bottom = !door.isTopHalf();
Block set = bottom ? point : point.getRelative(BlockFace.DOWN);
state = set.getState();
door = (Door) state.getData();
door.setOpen(true);
state.setData(door);
state.update();
}
}
}

0 comments on commit 05aea81

Please sign in to comment.