use of net.minecraft.state.properties.StairsShape 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());
}
}
use of net.minecraft.state.properties.StairsShape in project Structurize by ldtteam.
the class ModBlockStateProvider method stairsBlockUnlockUV.
public void stairsBlockUnlockUV(StairsBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
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;
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(false).build();
}, StairsBlock.WATERLOGGED);
}
use of net.minecraft.state.properties.StairsShape in project MCMOD-Industria by M-Marvin.
the class BlockCornerBlockBase method mirror.
/**
* Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
* blockstate.
* @deprecated call via {@link IBlockState#withMirror(Mirror)} whenever possible. Implementing/overriding is fine.
*/
@SuppressWarnings("incomplete-switch")
public BlockState mirror(BlockState state, Mirror mirrorIn) {
Direction direction = state.getValue(FACING);
StairsShape stairsshape = state.getValue(SHAPE);
switch(mirrorIn) {
case LEFT_RIGHT:
if (direction.getAxis() == Direction.Axis.Z) {
switch(stairsshape) {
case INNER_LEFT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_RIGHT);
case INNER_RIGHT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_LEFT);
case OUTER_LEFT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_RIGHT);
case OUTER_RIGHT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_LEFT);
default:
return state.rotate(Rotation.CLOCKWISE_180);
}
}
break;
case FRONT_BACK:
if (direction.getAxis() == Direction.Axis.X) {
switch(stairsshape) {
case INNER_LEFT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_LEFT);
case INNER_RIGHT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.INNER_RIGHT);
case OUTER_LEFT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_RIGHT);
case OUTER_RIGHT:
return state.rotate(Rotation.CLOCKWISE_180).setValue(SHAPE, StairsShape.OUTER_LEFT);
case STRAIGHT:
return state.rotate(Rotation.CLOCKWISE_180);
}
}
}
return super.mirror(state, mirrorIn);
}
Aggregations