I'm attempting to make a plug-in for a pvp/survival map called TheWalls, and I need a plugin to change blocks at certain locations to air, or zero, or something. I tried to do it, but failed miserably, if anyone can help, I would extremely appreciate it.
If I remember correctly... Code: loc.getBlock().setType(Material.AIR); EDIT: I suppose that you also need a way to get all blocks in a certain area... Given that loc0 represents the corner with the largest X,Y,Z coordinates, loc1 represents the corner with the smallest X,Y,Z coordinates: Code: for(int x = loc1.getBlockX(); x < loc0.getBlockX; x++) { for(int z = loc1.getBlockZ(); z < loc0.getBlockZ; z++) { for(int y = loc1.getBlockY(); y < loc0.getBlockY; y++) { // do stuff here } } } That's pretty basic stuff here
Is there a way to set the world in the location? I keep using player.getWorld, and it's not going to work for this.
Depends on what you are doing and when. Can you post a snipit of your code where player.getWorld(); wouldnt work?
Code: while (xx<=409 && zz<=-731) { //TODO Location delPlanksXLocation = new Location(onlinePlayer.getWorld(), xx, 112, -409); Location delPlanksXLocation = new Location(onlinePlayer.getWorld(), 347, 112, zz); delPlanksXLocation.getBlock().setType(Material.AIR); delPlanksZLocation.getBlock().setType(Material.AIR); xx--; zz--; } (ignore the //TODO)
You can create a new location by passing a different world, but the same coordinates of another location. Here is one constructor for Location: Code: public Location(World world, double x, double y, double z)
Thank you, dark navi, but when I posted that into my code I got a lot of errors, and I wasn't sure how to use it, is there another way, or could someone explain how to do it, or give me a link explaining it?