Advertisement
Guest User

Untitled

a guest
May 1st, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. private boolean isObsidianDoor(Block b)
  2. {
  3. Block up = b.getRelative(BlockFace.UP);
  4. Block down = b.getRelative(BlockFace.DOWN);
  5. Block east = b.getRelative(BlockFace.EAST);
  6. Block west = b.getRelative(BlockFace.WEST);
  7. Block north = b.getRelative(BlockFace.NORTH);
  8. Block south = b.getRelative(BlockFace.SOUTH);
  9. if (up.getType() == Material.IRON_DOOR_BLOCK)
  10. {
  11. Block otherWest = up.getRelative(BlockFace.WEST);
  12. Block otherEast = up.getRelative(BlockFace.EAST);
  13. Block otherNorth = up.getRelative(BlockFace.NORTH);
  14. Block otherSouth = up.getRelative(BlockFace.SOUTH);
  15. up = up.getRelative(BlockFace.UP);
  16. }
  17. else if (down.getType() == Material.IRON_DOOR_BLOCK)
  18. {
  19. Block otherWest = down.getRelative(BlockFace.WEST);
  20. Block otherEast = down.getRelative(BlockFace.EAST);
  21. Block otherNorth = down.getRelative(BlockFace.NORTH);
  22. Block otherSouth = down.getRelative(BlockFace.SOUTH);
  23. down = down.getRelative(BlockFace.DOWN);
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29. Block otherSouth;
  30. Block otherNorth;
  31. Block otherEast;
  32. Block otherWest;
  33. if ((up.getTypeId() == 49) && (down.getTypeId() == 49) &&
  34. (east.getTypeId() == 49) && (west.getTypeId() == 49) &&
  35. (otherWest.getTypeId() == 49) && (otherEast.getTypeId() == 49)) {
  36. return true;
  37. }
  38. if ((up.getTypeId() == 49) && (down.getTypeId() == 49) &&
  39. (north.getTypeId() == 49) && (south.getTypeId() == 49) &&
  40. (otherNorth.getTypeId() == 49) && (otherSouth.getTypeId() == 49)) {
  41. return true;
  42. }
  43. return false;
  44. }
  45.  
  46. @EventHandler
  47. public void onEntityExplode(EntityExplodeEvent event)
  48. {
  49. List<Block> destroy = event.blockList();
  50. Iterator<Block> it = destroy.iterator();
  51. while (it.hasNext())
  52. {
  53. Block b = (Block)it.next();
  54. if ((b.getType() == Material.IRON_DOOR_BLOCK) &&
  55. (isObsidianDoor(b))) {
  56. it.remove();
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement