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

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.

Screenshots?

 

Also, you can't use this.setLightValue unless you want all your blocks, regardless of metadata to have that light value.

Hi

 

Some background information on lighting here

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

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

 

-TGG

  • Author

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.

Hi

 

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

 

-TGG

 

  • Author

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

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.