2023-05-10 21:21:16 +02:00
|
|
|
package com.hypherionmc.craterlib.util;
|
2022-05-12 00:20:18 +02:00
|
|
|
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
|
|
|
|
|
|
import java.util.function.ToIntFunction;
|
|
|
|
|
2023-05-10 21:21:16 +02:00
|
|
|
/**
|
|
|
|
* @author HypherionSA
|
|
|
|
* Helper class to create light levels from BlockState values
|
|
|
|
*/
|
2022-05-12 00:20:18 +02:00
|
|
|
public class BlockStateUtils {
|
|
|
|
|
2023-05-10 21:21:16 +02:00
|
|
|
public static ToIntFunction<BlockState> lightLevelFromLitBlockState(int litLevel) {
|
2022-05-12 00:20:18 +02:00
|
|
|
return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0;
|
|
|
|
}
|
|
|
|
|
2023-05-10 21:21:16 +02:00
|
|
|
public static ToIntFunction<BlockState> lightLevelFromPoweredBlockState(int litLevel) {
|
2022-05-12 00:20:18 +02:00
|
|
|
return state -> state.getValue(BlockStateProperties.POWERED) ? litLevel : 0;
|
|
|
|
}
|
|
|
|
|
2022-05-12 00:18:53 +02:00
|
|
|
}
|