The change of light from the value of the logical blockstate

Started by Kostya_Swiftkey on

Topic category: Help with modding (Java Edition)

Last seen on 08:33, 25. Feb 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The change of light from the value of the logical blockstate

I want to make a block that works like a redstone lamp:

when the logical blockstate LIT = true, return the light 15

else the logical blockstate LIT = false, return the light 0

public class LargeKeroseneLanternBlock extends Block {

public static final IntegerProperty POWER = IntegerProperty.create("power", 0, 15);
public static final ToIntFunction<BlockState> LIGHT = $$0 -> $$0.getValue(POWER);
public LargeKeroseneLanternBlock() {
super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(3f).lightLevel(LIGHT).requiresCorrectToolForDrops());
this.registerDefaultState(this.stateDefinition.any().setValue(POWER, 0));
}

I use the ToIntFunction to set the light level to the block, but how can I do this in the case of a logical blockstate LIT (like a redstone lamp).

Can anyone help me with this?