Guest User

Untitled

a guest
Dec 10th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. private HashMap<Material, Block> build = new HashMap<Material, Block>();
  2. private BlockFace[] around = {BlockFace.NORTH,BlockFace.SOUTH,BlockFace.EAST,BlockFace.WEST,BlockFace.SELF};
  3. public void setNear(Block b){
  4. build.clear();
  5. for(BlockFace f : around){
  6. build.put(b.getRelative(f).getType(), b.getRelative(f));
  7. }
  8. b = b.getRelative(BlockFace.UP);
  9. for(BlockFace f : around){
  10. build.put(b.getRelative(f).getType(), b.getRelative(f));
  11. }
  12. b = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
  13. for(BlockFace f : around){
  14. build.put(b.getRelative(f).getType(), b.getRelative(f));
  15. }
  16. }
  17.  
  18. public void onBlockRedstoneChange (BlockRedstoneEvent e){
  19. setNear(e.getBlock());
  20. if(build.containsKey(Material.TRAP_DOOR)){
  21. if(!isTrapDoorOpen(build.get(Material.TRAP_DOOR))){
  22. if(e.getOldCurrent() < 1 && e.getNewCurrent() > 0)
  23. openTrapDoor(build.get(Material.TRAP_DOOR));
  24. }else{
  25. if(e.getOldCurrent() > 0 && e.getNewCurrent() < 1)
  26. closeTrapDoor(build.get(Material.TRAP_DOOR));
  27. }
  28. }
Add Comment
Please, Sign In to add comment