mojira.dev
MC-119932

Light-emitting solid blocks (lit furnaces, magma blocks, glowstone, lit redstone ore) let light (sunlight, block light) through

The bug

Light-emitting full solid blocks let light through.

Affected blocks:

  • lit furnace

  • magma block

  • lit redstone ore

  • glowstone

  • lit redstone lamp

  • jack o'lantern

Code analysis and suggested fix

Code analysis and suggested fix by @unknown can be found in this comment.

Forge pull request

A pull request on MinecraftForge can be found here: https://github.com/MinecraftForge/MinecraftForge/pull/4642

Related issues

Comments

migrated

Confirmed for 1.12.1

tryashtar

What do you mean by "let light through"?

I constructed a solid wall at night and placed glowstone on one side, keeping the other side dark. Adding a magma block adjacent to the glowstone did light up the other side brighter than it should have, and it did appear to be "letting light through."

However, this behavior is simply MC-102162. If you mean something else, let me know. Otherwise, this is a duplicate.

migrated

The code-accurate description of the issue is that light-emitting blocks let light through, even if they're solid and their light level is much less than the light they're letting through.

MC-102162 is just a side-effect of the lighting update code not handling light-emitting blocks which emit less light than their in-world value. In other words, MC-102162 is caused by this issue.

Fixing MC-102162 doesn't fix this issue. On the other hand, fixing this issue would hide (but not technically fix) MC-102162.

The same applies to sunlight, as both sunlight and block light share most of the update code (NB: sunlight code also includes direct downwards propagation, which is the part that does not suffer from this issue - the solid blocks listed in this issue stop downwards propagation - however see MC-3961). The part that is shared uses a simple value to control which lightmap to access.

tryashtar

That's perfect, thank you!

PhiPro

The relevant code lines that cause the issue are

IBlockState iblockstate1 = this.getBlockState(pos);
int blockLight = iblockstate1.getBlock().getLightValue(iblockstate1, this, pos);
int j2 = lightType == EnumSkyBlock.SKY ? 0 : blockLight;
int k2 = iblockstate1.getBlock().getLightOpacity(iblockstate1, this, pos);

 if (k2 >= 15 && blockLight > 0)
{
    k2 = 1;
}

inside World.getRawLight(...). The opacity for solid light sources is set to 1 (for whatever reason...).

However, MC-3961 is mainly caused by an unrelated issue. See MC-117067 for a detailed description and solution.

migrated

As stated previously, the problematic code code here is inside World.getRawLight.

The current code:

IBlockState iblockstate1 = this.getBlockState(pos);
int j2 = lightType == EnumSkyBlock.SKY ? 0 : iblockstate1.getLightValue();
int k2 = iblockstate1.getLightOpacity();

if (k2 >= 15 && iblockstate1.getLightValue() > 0)
{
	k2 = 1;
}

if (k2 < 1)
{
	k2 = 1;
}

if (k2 >= 15)
{
	return 0;
}
else if (j2 >= 14)
{
	return j2;
}
else
{
	// check light values at adjacent positions
}

Suggested fix:

IBlockState iblockstate1 = this.getBlockState(pos);
int j2 = lightType == EnumSkyBlock.SKY ? 0 : iblockstate1.getLightValue();
int k2 = iblockstate1.getLightOpacity();

if (k2 < 1)
{
	k2 = 1;
}

if (k2 >= 15 || j2 >= 14)
{
	return j2;
}
else
{
	// check light values at adjacent positions
}

Rather than setting light-emitting opaque blocks to have an effective opacity of 1, the new code just returns the source light for the block, instead of 0.
This is the value that would be returned if the full logic ran - the reason for the early return is just to save running the extra code if it is known not to affect the result.
Given a maximum light value of 15, and a minimum reduction of 1 (due to distance), this is the case if:

  • The block has an opacity of at least 15, and so will nullify any contribution from adjacent blocks.

  • The block has a source light level of at least 14, which is the maximum it can receive from adjacent blocks.

migrated

Fry

Confirmed

Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2

Minecraft 18w43a

Retrieved