Creating hollow cube with 2 locations?

Discussion in 'Plugin Development' started by IconByte, Apr 22, 2015.

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

    IconByte

    Hello. I am having problems with making hollow cube with 2 locations, also I am not that good on for looping maths.. :/

    This is what I have got at the moment:
    Code:
                    String arenaName = plugin.getConfig().getString("arena-name");
                    int startX = Math.min(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.X1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.X2"));
                    int endX = Math.max(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.X1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.X2"));
                    int startY = Math.min(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Y1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Y2"));
                    int endY = Math.max(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Y1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Y2"));
                    int startZ = Math.min(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Z1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Z2"));
                    int endZ = Math.max(mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Z1"), mapsConfig.getInt("arena." + arenaName + ".Arena-Positions.Z2"));
    
                    for (int x = startX; x < endX; x++) {
                        for (int z = startZ; z < endZ; z++) {
                            for (int y = startY; y <= endY; y++) {
                                Location loc = new Location(Bukkit.getWorld(arenaName), startX + x, startY + y, startZ + z);
                                if ((x >= 0 && z == 0) || (x >= 0 && z == 2) ||( x == 0 && z >= 0) || (x == 2 && z >= 0)) {
                                    loc.getBlock().setType(Material.GLOWSTONE);
                                }
                            }
                        }
                    }
     
  2. Offline

    ItsMattHogan

    What problems are you having?
     
  3. Offline

    Msrules123

    What if the x and z values are negative? You aren't performing checks on any of the values, I would recommend doing so.
     
  4. Offline

    mythbusterma

    @Msrules123

    It doesn't matter, you can still iterate from a lower negative number to a higher one?
     
  5. Offline

    Msrules123

    @mythbusterma

    I wasn't talking about the for loops, I was talking about the 14th line. Although now that I look at the 14th line, I don't know what I thought to made me post something about checking for negatives.
     
    mythbusterma likes this.
  6. @IconByte You could use the WorldEdit API (found here). It's a lot easier.
     
Thread Status:
Not open for further replies.

Share This Page