Search in sources :

Example 1 with StairsShape

use of net.minecraft.world.level.block.state.properties.StairsShape in project MinecraftForge by MinecraftForge.

the class BlockStateProvider method stairsBlock.

public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
    getVariantBuilder(block).forAllStatesExcept(state -> {
        Direction facing = state.getValue(StairBlock.FACING);
        Half half = state.getValue(StairBlock.HALF);
        StairsShape shape = state.getValue(StairBlock.SHAPE);
        // Stairs model is rotated 90 degrees clockwise for some reason
        int yRot = (int) facing.getClockWise().toYRot();
        if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
            // Left facing stairs are rotated 90 degrees clockwise
            yRot += 270;
        }
        if (shape != StairsShape.STRAIGHT && half == Half.TOP) {
            // Top stairs are rotated 90 degrees clockwise
            yRot += 90;
        }
        yRot %= 360;
        // Don't set uvlock for states that have no rotation
        boolean uvlock = yRot != 0 || half == Half.TOP;
        return ConfiguredModel.builder().modelFile(shape == StairsShape.STRAIGHT ? stairs : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter).rotationX(half == Half.BOTTOM ? 0 : 180).rotationY(yRot).uvLock(uvlock).build();
    }, StairBlock.WATERLOGGED);
}
Also used : DoubleBlockHalf(net.minecraft.world.level.block.state.properties.DoubleBlockHalf) Half(net.minecraft.world.level.block.state.properties.Half) StairsShape(net.minecraft.world.level.block.state.properties.StairsShape) Direction(net.minecraft.core.Direction)

Aggregations

Direction (net.minecraft.core.Direction)1 DoubleBlockHalf (net.minecraft.world.level.block.state.properties.DoubleBlockHalf)1 Half (net.minecraft.world.level.block.state.properties.Half)1 StairsShape (net.minecraft.world.level.block.state.properties.StairsShape)1