Posted March 12, 201510 yr Hi everyone, First of all thanks to anyone that takes time to help me out I've been trying to create a tinted glass block, and a controller and node blocks alongside this so that when you hit the controller block, all the tinted glass blocks change their tint either lighter or darker. The node blocks get placed around the controller (directly above, below, and in each x z direction) which determines the volume of blocks to be checked. I've nearly got to the end of the process, sooooo close now, but I've found out through some debugging that I am having an issue with 3 nested for loops (getting x, y, and z values which were determined from another method). The variables I need are also stored in the constructor which I assume may be causing the issues. Here is my code - I've commented where the issues are near the bottom http://pastebin.com/XYP1D5Wn NB: There's an @Override on one of my methods in this class because it extends that from my other block class so I don't think this is causing any issues? My first loop (for a = lowX; a <= highX; a++) works fine but the b (and c) loops are not getting initialised. Some things I tried were setting variable names outside the loop like this: public boolean changeBlocksInArea(EntityPlayer player, World world, int lowX, int highX, int lowY, int highY, int lowZ, int highZ, String blockName, int flag){ System.out.println("Loop a started"); int lx = lowX; int hx = highX; for(a = lx; a <= hx; a++){ System.out.println("Loop b started"); int ly = lowY; int hy = highY; for(b = ly; b<= hy; b++){ System.out.println("Loop c started"); int lz = lowZ; int hz = highZ; for(c = lz; c<= hz; c++){ //Do stuff } } } } However this also gave the same result... Any ideas?
March 13, 201510 yr The code looks correct to me. So if it is only executing the outer loop that means the condition for the b<=highY must be false right away. Are you sure lowY is less than highY? Is it possible that your highY has a negative value? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
March 13, 201510 yr The variables a, b, and c need to have types, for example "int a = 123;" not "a = 123". Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
March 13, 201510 yr Author The code looks correct to me. So if it is only executing the outer loop that means the condition for the b<=highY must be false right away. Are you sure lowY is less than highY? Is it possible that your highY has a negative value? Derp! For some reason my highY was less than the lowY so they must be getting swapped around in the previous function... More devugging! Thanks for the help
March 13, 201510 yr Author The variables a, b, and c need to have types, for example "int a = 123;" not "a = 123". Another derp! Corrected this in my updated code, thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.