Jump to content

[SOLVED]Why isn't my "Laser" working?


memcallen

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

...*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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.