Solved [WorldEdit]totally lost need a path!

Discussion in 'Plugin Development' started by sockmonkey1, Feb 11, 2014.

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

    sockmonkey1

    I have been developing a plugin (shocker on a bukkit forum int he development...) I want to have this area above an arena be reset everytime a player joins. I have everything around this working and set-up. I just need the blocks to reset, the blocks will be 5%gold blocks 1% diamond blocks and the rest air.

    I want to use WorldEdit because its really great at doing this in commands. I recently talked to a nice person on the IRC for WorldEdit and he showed me this. And I attempted to make something work off it it. Since I want the plugin to reset these blocks and not a player it was a little challenging. so far I have this;

    Code:java
    1. Vector minV = arena.getMinVector();
    2. Vector maxV = arena.getMaxVector();
    3.  
    4. CuboidRegion region = new CuboidRegion(minV, maxV);
    5.  
    6. World world = Bukkit.getWorld("world");
    7. BukkitWorld bworld = new BukkitWorld(world);
    8. EditSession editSession = new EditSession(bworld, -1);
    9.  
    10. List<BlockChance> blockChances = new ArrayList<BlockChance>();
    11. BaseBlock goldBlock = new BaseBlock(41);
    12. BaseBlock diamondBlock = new BaseBlock(57);
    13. BaseBlock air = new BaseBlock(0);
    14. blockChances.add(new BlockChance(goldBlock, .05));
    15. blockChances.add(new BlockChance(diamondBlock, .01));
    16. blockChances.add(new BlockChance(air, .94));
    17. RandomFillPattern rfp = new RandomFillPattern(blockChances);
    18.  
    19. try {
    20. editSession.setBlocks(region, rfp);
    21. } catch (MaxChangedBlocksException e) {
    22. e.printStackTrace();
    23. }

    I do not get errors, It just doesn't work... Honestly I wish I had errors, then I might know that there is something wrong!

    I have been all over looking for this. This really is a last resort. I have been to almost every class in the wordedit plugin on github. I went thru a little bit of the WorldGuard plugin on git hub because I know the two tie into eachother!

    So I don't know if you guys can help me. I'm not really hoping for too much. I'm sure you guys will just link me pages from github that I have already seen.

    TL;DR: I can't get the region above the area to set the randomblocks. I have seached thru WorldEdit on github. Please no github page links. I have already been there, and actually have it bookmarked so I do know how to get there.

    Maybe instead of making WorldEdit do the editing make I can just use this snip of code from WorldEdit to make my plugin change the area.
    Code:java
    1. Vector min = region.getMinimumPoint();
    2. Vector max = region.getMaximumPoint();
    3.  
    4. int minX = min.getBlockX();
    5. int minY = min.getBlockY();
    6. int minZ = min.getBlockZ();
    7. int maxX = max.getBlockX();
    8. int maxY = max.getBlockY();
    9. int maxZ = max.getBlockZ();
    10.  
    11. for (int x = minX; x <= maxX; ++x) {
    12. for (int y = minY; y <= maxY; ++y) {
    13. for (int z = minZ; z <= maxZ; ++z) {
    14. Vector pt = new Vector(x, y, z);
    15.  
    16. if (setBlock(pt, pattern.next(pt))) {
    17. ++affected;
    18. }
    19. }
    20. }
    21. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    Minecrell

    sockmonkey1
    Your code is working perfectly for me, maybe the world or the locations are wrong? Make some debug output to check if they're really correct.
     
    sockmonkey1 likes this.
  3. Offline

    sockmonkey1

    :O oh that means I'm close! yay thanks!

    Checked for nulls as it turns out I wasn't adding my vectors! oops! Well I at least hope this helps someone who needs it in the future as there is like NO documentation on how WorldEdit works!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page