Search in sources :

Example 1 with BlockBone

use of net.minecraft.block.BlockBone in project MC-Prefab by Brian-Wuest.

the class BuildBlock method setComparable.

private static Comparable setComparable(Comparable<?> comparable, Block foundBlock, IProperty<?> property, StructureConfiguration configuration, BuildBlock block, EnumFacing assumedNorth, Optional<?> propertyValue, EnumFacing vineFacing, EnumAxis logFacing, Axis boneFacing, BlockQuartz.EnumType quartzFacing, EnumOrientation leverOrientation, Structure structure) {
    if (property.getName().equals("facing") && !(foundBlock instanceof BlockLever)) {
        // Facing properties should be relative to the configuration facing.
        EnumFacing facing = EnumFacing.byName(propertyValue.get().toString());
        // Cannot rotate verticals.
        if (facing != null && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
            if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
                facing = facing.rotateY();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
                facing = facing.getOpposite();
            } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
                facing = facing.rotateYCCW();
            }
        }
        comparable = facing;
        block.setHasFacing(true);
    } else if (property.getName().equals("facing") && foundBlock instanceof BlockLever) {
        comparable = leverOrientation;
        block.setHasFacing(true);
    } else if (property.getName().equals("rotation")) {
        // 0 = South
        // 4 = West
        // 8 = North
        // 12 = East
        int rotation = (Integer) propertyValue.get();
        EnumFacing facing = rotation == 0 ? EnumFacing.SOUTH : rotation == 4 ? EnumFacing.WEST : rotation == 8 ? EnumFacing.NORTH : EnumFacing.EAST;
        if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateY()) {
            facing = facing.rotateY();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().getOpposite()) {
            facing = facing.getOpposite();
        } else if (configuration.houseFacing.getOpposite() == structure.getClearSpace().getShape().getDirection().rotateYCCW()) {
            facing = facing.rotateYCCW();
        }
        rotation = facing == EnumFacing.SOUTH ? 0 : facing == EnumFacing.WEST ? 4 : facing == EnumFacing.NORTH ? 8 : 12;
        comparable = rotation;
        block.setHasFacing(true);
    } else if (foundBlock instanceof BlockVine) {
        // Vines have a special state. There is 1 property for each "facing".
        if (property.getName().equals(vineFacing.getName2())) {
            comparable = true;
            block.setHasFacing(true);
        } else {
            comparable = false;
        }
    } else if (foundBlock instanceof BlockWall) {
        if (!property.getName().equals("variant")) {
            if (property.getName().equals(vineFacing.getName2()) || property.getName().equals(vineFacing.getOpposite().getName2())) {
                comparable = true;
                block.setHasFacing(true);
            } else {
                comparable = false;
            }
        }
    } else if (foundBlock instanceof BlockLog) {
        // logs have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = logFacing;
        }
    } else if (foundBlock instanceof BlockBone) {
        // bones have a special state. There is a property called axis and it only has 3 directions.
        if (property.getName().equals("axis")) {
            comparable = boneFacing;
        }
    } else if (foundBlock instanceof BlockQuartz) {
        if (property.getName().equals("variant") && quartzFacing != BlockQuartz.EnumType.DEFAULT) {
            comparable = quartzFacing;
        }
    }
    return comparable;
}
Also used : BlockLever(net.minecraft.block.BlockLever) BlockVine(net.minecraft.block.BlockVine) BlockWall(net.minecraft.block.BlockWall) EnumFacing(net.minecraft.util.EnumFacing) BlockLog(net.minecraft.block.BlockLog) BlockBone(net.minecraft.block.BlockBone) BlockQuartz(net.minecraft.block.BlockQuartz)

Aggregations

BlockBone (net.minecraft.block.BlockBone)1 BlockLever (net.minecraft.block.BlockLever)1 BlockLog (net.minecraft.block.BlockLog)1 BlockQuartz (net.minecraft.block.BlockQuartz)1 BlockVine (net.minecraft.block.BlockVine)1 BlockWall (net.minecraft.block.BlockWall)1 EnumFacing (net.minecraft.util.EnumFacing)1