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'm trying to make a simple analog lamp, where the light output equals the max redstone input. I thought this would be simple, but it's not working. This is the relevant code, inside the block class:

 

	@Override
	public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
		if (world instanceof World) {
			World theWorld = (World) world;
			return theWorld.isBlockIndirectlyGettingPowered(pos);
		}
		return 0;
	}

	@Override
	public void observedNeighborChange(IBlockState thisState, World world, BlockPos thisPos, Block changedBlock,
			BlockPos changedBlockPos) {
		world.setLightFor(EnumSkyBlock.BLOCK, thisPos, world.isBlockIndirectlyGettingPowered(thisPos));
		world.checkLight(thisPos);
	}

 

Some debug output shows that the observedNeighborChange() method is being called correctly, when there's a block state change next to the lamp, and that isBlockIndirectlyGettingPowered() is returning the appropriate redstone signal strength.

Yet the block never lights up. Why not?

 

*Update* After more testing, it seems like the block light *is* getting set properly, but only after I exit the world and reload it. I thought checkLight() was supposed to update the light levels; if it's not, what do I need to call to update the light levels without relogging?

*UPDATE 2* I fixed it! As it turns out, you need to change the block state for Minecraft to actually update the lighting. Even calling setBlockState with the current state won't work; it needs to be a new block state. So I added a "power" property and set power equal to the redstone input, then I change the blockstate whenever the neighbor changes and it all works fine.

Edited by IceMetalPunk
Solved it myself

Whatever Minecraft needs, it is most likely not yet another tool tier.

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.