Fix CableBus Occlusion
shartte opened this issue ยท 0 comments
The cable bus block currently doesn't occlude light as I'd expect it to.
For example, looking up to a cable that should fully occlude the sun will instead look like the same light level as if it was not present:
This means that cable facades can not effectively block light, making cables a liability in mob spawners and such
Some pointers:
Our block properties for CableBusBlock specify noOcclusion()
which is obviously wrong if we want to occlude ๐
We override propagatesSkylightDown
:
Which is also likely broken since it overrides the default method from Block which actually takes the shape into account.
@Override public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { return true; }
We might need to updateLight if a part or facade is changed since it would affect the light-level computation and we do not change the block state in such cases.
This is what Vanilla Levels do when a block state changes:
if ((flags & 128) == 0
&& blockState2 != blockState
&& (
blockState2.getLightBlock(this, pos) != blockState.getLightBlock(this, pos)
|| blockState2.getLightEmission() != blockState.getLightEmission()
|| blockState2.useShapeForLightOcclusion()
|| blockState.useShapeForLightOcclusion()
)) {
this.getProfiler().push("queueCheckLight");
this.getChunkSource().getLightEngine().checkBlock(pos);
this.getProfiler().pop();
}
So we'd likely to have to call this.getChunkSource().getLightEngine().checkBlock(pos);
.
A related issue is culling faces of neighboring blocks. The logic in net.minecraft.world.level.block.Block#shouldRenderFace
completely skips detecting if a side of any block is occluded by the neighbor (the cable bus), if the neighbor has set noOcclusion()
(like we do). That will propagate further into getFaceOcclusionShape()
, which will delegate to getShape()
normally. We could optimize this though by detecting if a facade is present and just returning a full block for that side.