Java Code Examples for net.minecraft.util.EnumFacing#getAxisDirection()

The following examples show how to use net.minecraft.util.EnumFacing#getAxisDirection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TankRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Cuboid6 createFullOffsetCuboid(int connectionMask) {
    Cuboid6 cuboid6 = new Cuboid6();
    for (EnumFacing side : EnumFacing.VALUES) {
        double offset = offset(side, connectionMask);
        double value = side.getAxisDirection() == AxisDirection.POSITIVE ? 1.0 - offset : offset;
        cuboid6.setSide(side, value);
    }
    return cuboid6;
}
 
Example 2
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Area3D adjustArea(EnumFacing facing, int amount)
{
    if (facing.getAxisDirection() == AxisDirection.POSITIVE)
    {
        this.pos.move(facing, amount);
        this.clampBounds(this.pos);
    }
    else
    {
        this.neg.move(facing, -amount);
        this.clampBounds(this.neg);
    }

    return this;
}
 
Example 3
Source File: PositionUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static EnumFacing rotateAround(EnumFacing facing, EnumFacing rotationAxis)
{
    EnumFacing newFacing = facing.rotateAround(rotationAxis.getAxis());

    if (rotationAxis.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE)
    {
        return newFacing;
    }

    // Negative axis direction, if the facing was actually rotated then get the opposite
    return newFacing != facing ? newFacing.getOpposite() : facing;
}
 
Example 4
Source File: BlockPosEU.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Helper method to add back a way to do left hand rotations, like ForgeDirection had.
 */
public static EnumFacing getRotation(EnumFacing facing, EnumFacing axis)
{
    EnumFacing newFacing = facing.rotateAround(axis.getAxis());

    if (axis.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE)
    {
        return newFacing;
    }

    // Negative axis direction, if the facing was actually rotated then get the opposite
    return newFacing != facing ? newFacing.getOpposite() : facing;
}
 
Example 5
Source File: PositionUtils.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Box expandOrShrinkBox(Box box, int amount, EnumFacing side)
{
    BlockPos pos1 = box.getPos1();
    BlockPos pos2 = box.getPos2();

    EnumFacing.Axis axis = side.getAxis();
    boolean positiveSide = side.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE;
    ICoordinateAccessor accessor = axis == EnumFacing.Axis.X ? BLOCKPOS_X_ACCESSOR : (axis == EnumFacing.Axis.Y ? BLOCKPOS_Y_ACCESSOR : BLOCKPOS_Z_ACCESSOR);
    int modifyAmount = positiveSide ? amount : -amount; // the amount is inversed when adjusting the negative axis sides

    // The corners are at the same position on the targeted axis
    if (accessor.getValue(pos1) == accessor.getValue(pos2))
    {
        // Only allow the box to grow from the one thick state
        if (amount > 0)
        {
            // corner 2 should be on the to-be-modified side of the box
            if (positiveSide)
            {
                pos2 = accessor.setValue(pos2, accessor.getValue(pos2) + modifyAmount);
            }
            // corner 1 should be on the to-be-modified side of the box
            else
            {
                pos1 = accessor.setValue(pos1, accessor.getValue(pos1) + modifyAmount);
            }
        }
        else
        {
            return box;
        }
    }
    else
    {
        // corner 1 is on the to-be-modified side of the box
        if (accessor.getValue(pos1) > accessor.getValue(pos2) == positiveSide)
        {
            pos1 = accessor.setValue(pos1, accessor.getValue(pos1) + modifyAmount);
        }
        // corner 2 is on the to-be-modified side of the box
        else
        {
            pos2 = accessor.setValue(pos2, accessor.getValue(pos2) + modifyAmount);
        }
    }

    Box boxNew = box.copy();
    boxNew.setPos1(pos1);
    boxNew.setPos2(pos2);

    return boxNew;
}
 
Example 6
Source File: PositionUtils.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Vec3d rotatePointCWAroundAxis(double x, double y, double z, Vec3d reference, EnumFacing facing)
{
    //System.out.printf("rotatePointCWAroundAxis - axis: %s, ref: %s, x: %.4f, y: %.4f, z: %.4f -> ", facing, reference, x, y, z);
    //System.out.printf("rotatePointCWAroundAxis - axis: %s, ref: %s, vec: %s -> ", facing, reference, new Vec3d(x, y, z));
    //System.out.printf("rotatePointCWAroundAxis - axis: %s\n", facing);
    double rx = reference.x;
    double ry = reference.y;
    double rz = reference.z;
    double newX = x;
    double newY = y;
    double newZ = z;

    if (facing.getAxis() == EnumFacing.Axis.Y)
    {
        if (facing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE)
        {
            newX = rx - (z - rz);
            newZ = rz + (x - rx);
        }
        else
        {
            newX = rx + (z - rz);
            newZ = rz - (x - rx);
        }
    }
    else if (facing.getAxis() == EnumFacing.Axis.Z)
    {
        if (facing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE)
        {
            newX = rx + (y - ry);
            newY = ry - (x - rx);
        }
        else
        {
            newX = rx - (y - ry);
            newY = ry + (x - rx);
        }
    }
    else if (facing.getAxis() == EnumFacing.Axis.X)
    {
        if (facing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE)
        {
            newZ = rz - (y - ry);
            newY = ry + (z - rz);
        }
        else
        {
            newZ = rz + (y - ry);
            newY = ry - (z - rz);
        }
    }

    //System.out.printf("x: %.4f, y: %.4f, z: %.4f\n", newX, newY, newZ);
    //System.out.printf("vec: %s\n", new Vec3d(newX, newY, newZ));
    return new Vec3d(newX, newY, newZ);
}
 
Example 7
Source File: BlockTofuPortal.java    From TofuCraftReload with MIT License 2 votes vote down vote up
public BlockPattern.PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_) {

        EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z;

        Size blockportal$size = new Size(worldIn, p_181089_2_, EnumFacing.Axis.X);

        LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.createLoadingCache(worldIn, true);


        if (!blockportal$size.isValid()) {

            enumfacing$axis = EnumFacing.Axis.X;

            blockportal$size = new Size(worldIn, p_181089_2_, EnumFacing.Axis.Z);

        }

        if (!blockportal$size.isValid()) {

            return new BlockPattern.PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);

        }

        int[] aint = new int[EnumFacing.AxisDirection.values().length];

        EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW();

        BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1);


        for (EnumFacing.AxisDirection enumfacing$axisdirection : EnumFacing.AxisDirection.values()) {

            BlockPattern.PatternHelper blockpattern$patternhelper = new BlockPattern.PatternHelper(

                    enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos :

                            blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1),

                    EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP,

                    loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);


            for (int i = 0; i < blockportal$size.getWidth(); ++i) {

                for (int j = 0; j < blockportal$size.getHeight(); ++j) {

                    BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);


                    if (blockworldstate.getBlockState() != null &&

                            blockworldstate.getBlockState().getMaterial() != Material.AIR) {

                        ++aint[enumfacing$axisdirection.ordinal()];

                    }

                }

            }

        }


        EnumFacing.AxisDirection enumfacing$axisdirection1 = EnumFacing.AxisDirection.POSITIVE;


        for (EnumFacing.AxisDirection enumfacing$axisdirection2 : EnumFacing.AxisDirection.values()) {

            if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) {

                enumfacing$axisdirection1 = enumfacing$axisdirection2;

            }

        }


        return new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos :

                blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1),

                EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache,

                blockportal$size.getWidth(), blockportal$size.getHeight(), 1);

    }