[WorldEdit] replacing all blocks inside a region

Discussion in 'Plugin Development' started by MarioNoobProgrammer, Apr 13, 2017.

Thread Status:
Not open for further replies.
  1. Hello, I'm making a plugin and I am wondering if I am able to set all blocks inside a custom region I've made into a specific block. I've been googling all day and could not find the awnser. I want all blocks inside my regions to be set to Stone every x amount of time.

    Regards
     
  2. Offline

    Caderape2

    @MarioNoobProgrammer
    you have a Selection with worldedit ?
    - You can loops from the minimum poiint to the max.
    - get the location and set the block
     
  3. @Caderape2
    Code:
    public static Location getLocation(String regions, String corner) {
            World world = Bukkit.getWorld((String) main.getConfig().get("regions."+regions+".world"));
            double x = main.getConfig().getDouble("regions."+regions+"."+corner+".x");
            double y = main.getConfig().getDouble("regions."+regions+"."+corner+".y");
            double z = main.getConfig().getDouble("regions."+regions+"."+corner+".z");
            return new Location(world, x, y, z);
        }
    Would that work? as I already made a method for it? or do I need to do it the same way I did when I created the region?
    Code:
    main.getConfig().set("regions."+regions+".world", sel.getMaximumPoint().getWorld().getName());
                           
                            main.getConfig().set("regions."+regions+".cornerA.x", sel.getMaximumPoint().getX());
                            main.getConfig().set("regions."+regions+".cornerA.y", sel.getMaximumPoint().getY());
                            main.getConfig().set("regions."+regions+".cornerA.z", sel.getMaximumPoint().getZ());
            
                            main.getConfig().set("regions."+regions+".cornerB.x", sel.getMinimumPoint().getX());
                            main.getConfig().set("regions."+regions+".cornerB.y", sel.getMinimumPoint().getY());
                            main.getConfig().set("regions."+regions+".cornerB.z", sel.getMinimumPoint().getZ());
                            main.saveConfig();
            
                            p.sendMessage(ChatColor.GREEN+"Successfully created a new town: "+ChatColor.translateAlternateColorCodes('&', regions));
                            
     
  4. Offline

    Caderape2

    @MarioNoobProgrammer
    Yea, if you stored both corner in a f ile, retrieve the two location from it.
    Then now you have to change each block between thoses two location with a loops
     
  5. @Caderape2

    Im trying to find out how to change all blocks between there :p

    I cant find out how though.
     
  6. Offline

    Caderape2

  7. You will have to loop trough all coordinates. So it will be something like:
    Code:
    for (int i = xMin; i <= xMax; i++){
      for (int j = yMin; i <= yMax; j++){
        for (int k = zMin; z<= zMax; z++{
    //      Handle the block at coordinates i,j,k
        }
      }
    }
    @MarioNoobProgrammer
     
    ipodtouch0218 likes this.
Thread Status:
Not open for further replies.

Share This Page