Jump to content

[1.6.4]Strange lighting problem


Recommended Posts

Hi all,


Im having issues with my blocks and lighting, the problem being that I have a block that as it grows using updateTick() it goes up through its meta blocks, so starts at meta 0 and goes up to 5. When its meta 0-4 the light value is 1 when it is meta 5 its light value is 2, ive done this via:


public int getLightValue(IBlockAccess world, int x, int y, int z) 
    	this.setLightValue(world.getBlockMetadata(x, y, z) == 4 ? 2 : 1);
        return lightValue[blockID];


but when the block hits meta 5 I get a nasty shadow appear under the block and another side effect being that the light source for this block seems to move on me relogging.... and by that I mean I can break the block in the night and it still be lit up, I then need to place blocks around to find the source and kill it. (leftover TE?) what am I missing? Ill grab a pic if people need it.

Link to comment
Share on other sites



Some background information on lighting here



Your world.getBlockMetadata(x, y, z) == 4 ? 2 : 1 doesn't appear to match your description.. >= 5 ? 2 : 1 perhaps?


I think you don't need to use setLightValue at all.  Vanilla only uses it to tell whether a block is glowing (>=1) or not (==0).  getLightValue is called whenever vanilla needs to know the strength of the blocklight.


Instead, just return world.getBLockMetadata(x,y,z) >= 5 ? 2 : 1



Link to comment
Share on other sites

yeah i got my numbers wrong, the post is correct. Straight returning the check as per above does not work i end up with no light emitted.


So has anyone got meta block based lighting working when the block updates itself, i.e im not placing separate meta ID blocks, block 0 updates itself to block 1 updates to 2, 3 and finally4 where i want the light to be a different strength.

Link to comment
Share on other sites



Straight returning the check as per above does not work i end up with no light emitted.


Perhaps I should have been more explicit - you will need to

Block.setLightValue(1.0F) at least once when you construct the block instance, for example like BlockGlowstone. 


public static final Block glowStone = (new BlockGlowStone(89, Material.glass)).setHardness(0.3F).setStepSound(soundGlassFootstep).setLightValue(1.0F).setUnlocalizedName("lightgem").setTextureName("glowstone");


There is no need to set it every time in your getLightValue method.


Try changing the block metadata using


World.setBlock(int x, int y, int z, int newBlockID, int newMetadata, int flags)


where flags is 2 + 1




Link to comment
Share on other sites

Edit - ignore im being an idiot. The help text on this method is really wrong...


ok so, is there an issue with really low level light, like using 10+ in setLightLevel when i place 4 blocks next to each other in a 2x2 the middle goes dark...


edit - ok now its not....what the hell is going on with my lighting...

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.

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.

  • Create New...

Important Information

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