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

Hey,

I was wondering if there is a way to force a light update on a certain block. I've tried forced block updates, forced render updates, changing the metadata of the block and even calling world.updateAllLightTypes without success.

This is my code right now http://pste.me/IvXo8

Btw it does update the lighting when the block is activated a second time.

  • Author

I've changed the code a bit. http://pste.me/1LCqv/

According to the console output the light level on the server is correct, however the client always has value 15. It even prints out 15 when the client world is dark at that position.

2013-12-23 20:23:20 [information] [sTDOUT] Client: 15
2013-12-23 20:23:20 [information] [sTDOUT] Server: 7

Try This

 

    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (player.isSneaking())
    return false;

ItemStack test = player.getCurrentEquippedItem();
if (test != null && test.getItem() instanceof ItemBlock) {
    Block b = Block.blocksList[test.itemID];
    if ((b.getRenderType() == 0 || b.getRenderType() == 16 || b.getRenderType() == 31 || b.getRenderType() == 39) && b.getBlockBoundsMinX() == 0F && b.getBlockBoundsMinY() == 0F && b.getBlockBoundsMinZ() == 0F && b.getBlockBoundsMaxX() == 1F && b.getBlockBoundsMaxY() == 1F && b.getBlockBoundsMaxZ() == 1F) {
	TileEntityMiniatureBlock tile = (TileEntityMiniatureBlock) world.getBlockTileEntity(x, y, z);

	    tile.blockID = test.itemID;
	    tile.damage = test.getItemDamage();

	world.markBlockForUpdate(x, y, z);

	world.notifyBlocksOfNeighborChange(x, y, z, blockID);

	world.notifyBlocksOfNeighborChange(x + 1, y, z, blockID);
	world.notifyBlocksOfNeighborChange(x - 1, y, z, blockID);
	world.notifyBlocksOfNeighborChange(x, y + 1, z, blockID);
	world.notifyBlocksOfNeighborChange(x, y - 1, z, blockID);
	world.notifyBlocksOfNeighborChange(x, y, z + 1, blockID);
	world.notifyBlocksOfNeighborChange(x, y, z - 1, blockID);

	world.markBlockForRenderUpdate(x, y, z);

	System.out.println(world.isRemote ? "Client: " : "Server: " + world.getBlockLightValue(x, y, z));
    }
}

return true;
    }

 

Not entirely sure why you are changing the block ID and damage only on one side. I rearranged your code so it notifies blocks of an update first, then marks it for a lighting update.

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.