Jump to content

Forced light update?


domi1819

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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.