Area regeneration

Discussion in 'Plugin Development' started by franga2000, Mar 17, 2014.

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

    franga2000

    Hi, I'm making a minigame for our server and I'd like to regenerate the arena after the round ends. The arena is defined by a radius so I'd like to regen everything inside the area. Or at least the cake blocks. I'm kinda new to bukkit plugins so I have no idea how to do this.

    How would I go about doing this?
     
  2. Offline

    ShadowLAX

    franga2000 You can either loop through a predefined cuboid and see if the block is cake (CPU demanding if the cuboid is large), or get the cake's exact location and make a new Location() out of it and regenerate that. There are other ways, but these are just some suggestions.
     
  3. Offline

    NathanWolf

    My plugin can do that for you if you want, it's a bit tricky to set up, but you can see it in action on play.distinctcraft.com. I helped the owner of that server build a regenerating arena (that also has a few other tricks - mob spawners, lighting storms, cluster bombs, a floor that turns to lava, etc)

    You could theoretically disable everything in Magic (wands, spells, etc) and just use it for an auto-regenerating arena.

    I'd say you could also just "look at my code" (since I understand the desire to want to code this yourself), but the way I do all of this is really complex and involves a lot of different moving parts for schematic loading (relying on WorldEdit), building large structures without lag, allowing safe undo, etc.
     
  4. Offline

    franga2000

    ShadowLAX I tried a similar approach:
    Area save:
    Code:java
    1.  
    2. cakes.clear();
    3. double pX = this.spawnPoint.getX();
    4. double pY = this.spawnPoint.getY();
    5. double pZ = this.spawnPoint.getZ();
    6. for (int x = -(radius); x <= radius; x ++) {
    7. for (int y = -(radius); y <= radius; y ++) {
    8. for (int z = -(radius); z <= radius; z ++) {
    9. Block b = spawnPoint.getWorld().getBlockAt((int)pX+x, (int)pY+y, (int)pZ+z);
    10. if (b.getType() == Material.CAKE_BLOCK) {
    11. cakes.add(b);
    12. }
    13. }
    14. }
    15. }
    16.  


    Area regen:
    Code:java
    1.  
    2. for (Block b : cakes) {
    3. b.setType(Material.CAKE_BLOCK);
    4. }
    5.  


    It didn't work at first but I figured out what was wrong. I accidentally used Material.CAKE instead of Material.CAKE_BLOCK :p
    My only other question is: How heavy will this be on my CPU? Is there a way to optimize it without using WE?
     
Thread Status:
Not open for further replies.

Share This Page