use of mekanism.additions.common.block.plastic.BlockPlasticStairs in project Mekanism by mekanism.
the class AdditionsBlockStateProvider method coloredStairs.
private void coloredStairs(Map<?, ? extends BlockRegistryObject<? extends BlockPlasticStairs, ?>> stairs, String existingPrefix) {
ModelFile stairsModel = models().getExistingFile(modLoc("block/plastic/" + existingPrefix + "stairs"));
ModelFile stairsInner = models().getExistingFile(modLoc("block/plastic/" + existingPrefix + "stairs_inner"));
ModelFile stairsOuter = models().getExistingFile(modLoc("block/plastic/" + existingPrefix + "stairs_outer"));
for (BlockRegistryObject<? extends BlockPlasticStairs, ?> stair : stairs.values()) {
BlockPlasticStairs block = stair.getBlock();
// Copy of BlockStateProvider#stairsBlock, except also ignores our fluid logging extension
getVariantBuilder(block).forAllStatesExcept(state -> {
Direction facing = state.getValue(StairsBlock.FACING);
Half half = state.getValue(StairsBlock.HALF);
StairsShape shape = state.getValue(StairsBlock.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 ? stairsModel : shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT ? stairsInner : stairsOuter).rotationX(half == Half.BOTTOM ? 0 : 180).rotationY(yRot).uvLock(uvlock).build();
}, StairsBlock.WATERLOGGED, block.getFluidLoggedProperty());
}
}
Aggregations