9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 18:09:17 +00:00

Cache block state tags (#451)

* Cache block state tags

* [ci/skip] Fix comment
This commit is contained in:
hayanesuru
2025-08-09 05:37:39 +09:00
committed by GitHub
parent 1ea7c5fe56
commit c92396f324
2 changed files with 61 additions and 25 deletions

View File

@@ -0,0 +1,33 @@
package org.dreeam.leaf.util;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.PowderSnowBlock;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.state.BlockState;
public final class BlockMasks {
public static final int WALL_TAG = 0x01;
public static final int FENCE_TAG = 0x02;
public static final int CLIMBABLE_TAG = 0x04;
public static final int POWDER_SNOW_CL = 0x08;
public static final int FENCE_GATE_CL = 0x10;
public static final int TRAP_DOOR_CL = 0x20;
public static final int WATER = 0x40;
public static final int LAVA = 0x80;
public static final int FLUID = (WATER | LAVA);
public static int init(final BlockState state) {
int i = 0;
i |= state.is(BlockTags.WALLS) ? WALL_TAG : 0;
i |= state.is(BlockTags.FENCES) ? FENCE_TAG : 0;
i |= state.is(BlockTags.CLIMBABLE) ? CLIMBABLE_TAG : 0;
i |= state.getBlock() instanceof PowderSnowBlock ? POWDER_SNOW_CL : 0;
i |= state.getBlock() instanceof FenceGateBlock ? FENCE_GATE_CL : 0;
i |= state.getBlock() instanceof TrapDoorBlock ? TRAP_DOOR_CL : 0;
i |= state.getFluidState().is(FluidTags.WATER) ? WATER : 0;
i |= state.getFluidState().is(FluidTags.LAVA) ? LAVA : 0;
return i;
}
}