Generating A Beacon

Discussion in 'Plugin Development' started by Monkeyboystein, Jul 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Monkeyboystein

    Hey Im not sure how to go about creating a beacon, everytime i try it comes out spazzy.
    Can someone show me how to make the beacon, (a working beacon one that shoots the light) from code?
    PS im trying to make a beacon spawn some where random in the world, :
    Code:java
    1. Random r = new Random();
    2. int High = 21000;
    3. int low = 0;
    4. int xx = r.nextInt(High - low) + low;
    5. Random rr = new Random();
    6. int zz = rr.nextInt(High-low) + low;
    7.  
    8. Location loc = getServer().getWorld("nether").getBlockAt(xx, 70, zz).getLocation();
    9. loc.getWorld().getBlockAt(loc).setType(Material.IRON_BLOCK);
    10. loc.setX(loc.getX() + 1);
    11. loc.getWorld().getBlockAt(loc).setType(Material.IRON_BLOCK);
    12. loc.setX(loc.getX() + 1);
    13. loc.getWorld().getBlockAt(loc).setType(Material.IRON_BLOCK);
    14. loc.setX(loc.getX() + 1);


    thats where i normally mess up. thanks in advanced.
     
  2. Offline

    Croug

    loc.getWorld().getBlockAt(loc).setType(138);
     
  3. Offline

    Monkeyboystein

    thats not what i mean, I mean to get all nineiron blocks and the beacon on top
     
  4. Offline

    Bart

    Assuming 'l' is the location of the beacon block
    Code:
    Location ironBlocks = l.getBlockRelative(-1, -1, -1);
     
    for(int i = 1; i <= 3; i++) {
      for(int y = 1; y <= 3; y++) {
        l.getBlockRelative(i, 0, y).setType(Material.IRON_BLOCK);
      }
    } 
    
    Untested. I'm pretty tired so it might not work.
     
Thread Status:
Not open for further replies.

Share This Page