I have tried that before but my problem is that because my class constructor will always be called first i don't know how would i be returning different values with the blockstate from use(). I have tried the following, but obviously it would never work
public static final BooleanProperty LIT = BlockStateProperties.LIT;
private static int LightUp = 15;
public AerialLight(Properties properties){
super(properties.sound(SoundType.WOOL).noCollission().lightLevel((p_60954_) -> {
return LightUp;
}));
this.registerDefaultState(this.stateDefinition.any().setValue(LIT, Boolean.valueOf(true)));
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit){
if(state.getValue(LIT)){
level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(false)), 3);
LightUp = 0;
return InteractionResult.SUCCESS;
}else{
LightUp = 15;
level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(true)), 3);
return InteractionResult.SUCCESS;
}
}
I even tried with a verification inside lightLevel as it is a function