Fabric API

Fabric API

106M Downloads

Set block luminance based on lambda funcion

IbraheemR opened this issue ยท 4 comments

commented

As of the 1.16 snapshots (at least since 20w13b) Block#getLuminance no longer excists.
Looking at the vanilla code, luminance is now set with a lambda, that takes a block state and returns a light level. For most lit blocks this returns a constant, but for blocks like redstone lamp this returns a value based on its "lit" property.

This should probably be added to the FabricBlockSettings API, as without it there seems to be no way to create blocks with 'dynamic' light levels (without entering mixin hell).
@modmuss50 tells me this is already planned for an upcoming revamp, but that it could trivially be added sooner

commented

We can't realistically patch all of these call sites:
image

A workaround for dynamic blocks is to store the luminance as a block state property.

commented

Light lamda functions can be used without mixins, like here

commented

So vanilla currently restricts the context of luminance (server side lighting) but allows you to return custom emissive light levels ( i.e. client only light level). Weird indeed, hope they can move the luminance to one of the lambdas in settings.

commented

As of object builders v1, there is a ToIntFunction<BlockState> inside of FabricBlockSettings to calculate the value. However whether this provides enough context for this use case is a different question.