Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private HashMap<Material, Block> build = new HashMap<Material, Block>();
- private BlockFace[] around = {BlockFace.NORTH,BlockFace.SOUTH,BlockFace.EAST,BlockFace.WEST,BlockFace.SELF};
- public void setNear(Block b){
- build.clear();
- for(BlockFace f : around){
- build.put(b.getRelative(f).getType(), b.getRelative(f));
- }
- b = b.getRelative(BlockFace.UP);
- for(BlockFace f : around){
- build.put(b.getRelative(f).getType(), b.getRelative(f));
- }
- b = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
- for(BlockFace f : around){
- build.put(b.getRelative(f).getType(), b.getRelative(f));
- }
- }
- public void onBlockRedstoneChange (BlockRedstoneEvent e){
- setNear(e.getBlock());
- if(build.containsKey(Material.TRAP_DOOR)){
- if(!isTrapDoorOpen(build.get(Material.TRAP_DOOR))){
- if(e.getOldCurrent() < 1 && e.getNewCurrent() > 0)
- openTrapDoor(build.get(Material.TRAP_DOOR));
- }else{
- if(e.getOldCurrent() > 0 && e.getNewCurrent() < 1)
- closeTrapDoor(build.get(Material.TRAP_DOOR));
- }
- }
Add Comment
Please, Sign In to add comment