Someone knows why my code does that: Not that: Its very interesting... Code:java public void set(Player p, double y, double z) { Location l = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() + y, p.getLocation().getZ() + z); l.getBlock().setType(Material.GLASS); } for (int i = 0; i < 10; i++) { set(p, i, i); }
DevManABCD Your loop only sets ten block, and every time it increases it's Y & Z coordinate, causing the blocks to be placed diagonal.
DevManABCD Actually use 2 seperate loops? Not sure how do you expect a single variable to hold 2 different values.
DevManABCD You need to select a cuboid of blocks, and then set them all to glass. Use this resource to make this possible: http://forums.bukkit.org/threads/protection-region-cuboid-creation.164161/ Code:java Location loc1 = new Location(p.getLocation().getWorld(), p.getX(), p.getLocation().getY() + 1, p.getLocation().getZ());Location loc2 = new Location(p.getLocation().getWorld(), p.getX() + 10, p.getLocation().getY(), p.getLocation().getZ() + 10);Cuboid cuboid = new Cuboid(loc1, loc2);for (Block block : cuboid) { lock.setType(Material.GLASS);}
Code:java //...for(int i=0; i<100; i++){ set(p, i%10, i/10);} Edit: DevManABCD , please don't use this in your plugin; just go with 2 loops.
DevManABCD That would be 2 loops for the left and forward stuff. And a loop for the height. Or a timelapse
For me fresh java/bukkit codder its too dificult and i need some tips for that. I dont expect ready code.
I have a tip: Don't start in bukkit at the same moment that you start with java. Get to know the java basics first. Then come back to bukkit. It will help you a lot.
Then: Multiple people told you that already. And don't try to do things when you don't know how. Take small steps
DevManABCD But yet you expect a variable to hold 2 different values. I dont see why you dont use a nested loop to do a 2D rectangle.