Advertisement
Guest User

GoldMineStructureGenerator

a guest
Feb 21st, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1.     @EventHandler
  2.     public void onBlockPlaceEvent(PlayerInteractEvent event) {
  3.         if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
  4.             return;
  5.         } else if (event.getItem().getType() != Material.GOLD_ORE) {
  6.             event.getClickedBlock().setType(Material.SIGN_POST);
  7.             return;
  8.         }
  9.         Block block = event.getClickedBlock();
  10.         Player player = event.getPlayer();
  11.         Location loc = block.getLocation();
  12.         World world = loc.getWorld();
  13.         int x = loc.getBlockX() - 1;
  14.         int z = loc.getBlockZ();
  15.         int y = loc.getBlockY();
  16.         int x2 = x + 2;
  17.         int y2 = y + 4;
  18.         int z2 = z + 3;
  19.         for (int xPoint = x; xPoint <= x2; xPoint++) {
  20.             for (int yPoint = y; yPoint <= y2; yPoint++) {
  21.                 for (int zPoint = z; zPoint <= z2; zPoint++) {
  22.                     Block curBlock = world.getBlockAt(xPoint, yPoint, zPoint);
  23.                     if (yPoint == y && xPoint == x + 1
  24.                             && (zPoint == z + 1 || zPoint == z + 2)) {
  25.                         curBlock.setType(Material.GOLD_ORE);
  26.                     } else if (yPoint == y + 1 && xPoint == x + 1
  27.                             && zPoint == z) {
  28.                         curBlock.setType(Material.GOLD_ORE);
  29.                     } else if (yPoint == y + 1 && xPoint == x + 1
  30.                             && zPoint == z + 1) {
  31.                         curBlock.setType(Material.AIR);
  32.                     } else if (yPoint == y + 1 && xPoint != x + 1 && zPoint > z) {
  33.                         curBlock.setType(Material.WOOD);
  34.                     } else if (yPoint == y + 1 && xPoint == x + 1
  35.                             && zPoint == z + 3) {
  36.                         curBlock.setType(Material.WOOD);
  37.                     } else if ((yPoint > y && yPoint < y + 4)
  38.                             && xPoint == x + 1 && zPoint != z + 3) {
  39.                         curBlock.setType(Material.AIR);
  40.                     } else if (yPoint < y + 4 && zPoint > z) {
  41.                         curBlock.setType(Material.WOOD);
  42.                     } else if (yPoint == y + 2 && xPoint != x + 1
  43.                             && zPoint == z) {
  44.                         curBlock.setType(Material.LOG);
  45.                     } else if (yPoint == y + 3 && xPoint != x + 1
  46.                             && zPoint == z) {
  47.                         curBlock.setType(Material.FENCE);
  48.                     } else if (yPoint == y + 4 && xPoint != x + 1
  49.                             && zPoint == z) {
  50.                         curBlock.setType(Material.AIR);
  51.                     } else if (yPoint == y + 4 && xPoint == x + 1
  52.                             && zPoint == z) {
  53.                         curBlock.setType(Material.WOOD_STEP);
  54.                     } else if (yPoint == y + 4 && xPoint != x + 1) {
  55.                         curBlock.setType(Material.WOOD_STAIRS);
  56.                     } else if (yPoint == y + 4 && xPoint == x + 1
  57.                             && zPoint == z2) {
  58.                         curBlock.setType(Material.WOOD_STAIRS);
  59.                     } else if (yPoint == y2 && xPoint == x + 1) {
  60.                         curBlock.setType(Material.WOOD_STEP);
  61.                     }
  62.  
  63.                     else {
  64.                         curBlock.setType(Material.DIRT);
  65.                     }
  66.                 }
  67.             }
  68.         }
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement