Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • 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

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.

  • 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

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.

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.

  • 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

'Seen' and 'read carefully and then applied' are not equivalent :P

 

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.

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.

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

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.