Posted December 31, 201410 yr I've made this laser block, it creates a laser beam when powered by redstone. The beam is supposed to be 100 blocks long, when I power it the beam doesn't even show up. heres the onNeighborBlockChange function: public void onNeighborBlockChange(World world, int x, int y, int z, Block block){ System.out.println("X:"+x+" Y:"+y+" Z:"+z); if(world.isBlockIndirectlyGettingPowered(x, y, z)){ System.out.println(true); int meta = world.getBlockMetadata(x, y, z); ForgeDirection dir = ForgeDirection.getOrientation(meta); BlockLaserTileEntity te = (BlockLaserTileEntity)world.getTileEntity(x, y, z); for(int i = 0; i==100;i++){ int tx = (dir.offsetX*i)+x,ty = (dir.offsetY*i)+y,tz = (dir.offsetZ*i)+z; System.out.println("X:"+tx+" Y:"+ty+" Z:"+tz); world.setBlock(tx, ty, tz, gammacraft.LaserBeam); world.scheduleBlockUpdate(tx, ty, tz, (Block)this, 10); } } } it prints the x/y/z and when there is a redstone signal, it prints true. It doesn't print tx/ty/tz because it would spam the console with 100 lines but it doesn't. I have no idea why this isn't working. -sidenote this is just a prototype, I will add extra bits to it like it stops when it hits a block. The proud(ish) developer of Ancients
December 31, 201410 yr i == 100, eh? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 31, 201410 yr Author yeah, it loops for 100 blocks in a direction and sets the block every loop fyi, the block update is for my block class, in the updateTick it sets itself to air The proud(ish) developer of Ancients
December 31, 201410 yr I would look at that loop definition again. You have a mistake, evidenced by the fact that it is not spamming the console. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 31, 201410 yr Author I don't see a problem with the loop, and as you know I can't do for loops. The proud(ish) developer of Ancients
December 31, 201410 yr And....read signature. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 31, 201410 yr Author I changed it to work with a do/while loop, now it works. The proud(ish) developer of Ancients
January 1, 201510 yr Since you did not read his signature, I'll repost it here. "If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked." Maker of the Craft++ mod.
January 1, 201510 yr I don't see a problem with the loop, and as you know I can't do for loops. For loop documentation. Now you CAN do for loops. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author 1.I did read his signature 2. for whatever reason, For loops haven't "clicked" with me yet, I've already seen that website, and multiple others yet I still have no idea why my for loops don't work. (I can do the var:array ones though) The proud(ish) developer of Ancients
January 1, 201510 yr 'Seen' and 'read carefully and then applied' are not equivalent The for loop in your code above doesn't work because the condition is 'i == 100', but when you start the loop i is 0, so your condition immediately fails and the loop exits. Try 'i < 100' as the condition. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author ...*facepalms* I thought it was when it was supposed to stop The proud(ish) developer of Ancients
January 1, 201510 yr And it didn't run, ergo something was wrong with it. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 1, 201510 yr ...*facepalms* I thought it was when it was supposed to stop Lol, well it is, kind of. The condition is checked every single iteration, so think of it more like 'run as long as this condition is true' - once 'i' reaches 100, it WILL stop. You can have all sorts of conditions, initial states, etc., though a single incrementing integer is by far the most common. I highly recommend you find do some further reading / practice with for loops - they are very useful and one of the most basic features of probably every programming language. http://i.imgur.com/NdrFdld.png[/img]
January 1, 201510 yr Author Yeah, they were the most basic thing I couldn't figure out. No idea why I didn't figure it out earlier. The proud(ish) developer of Ancients
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.