net.minecraft.util.EnumFacing#getAxisDirection ( )源码实例Demo

下面列出了net.minecraft.util.EnumFacing#getAxisDirection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GregTech   文件: TankRenderer.java
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;
}
 
源代码2 项目: enderutilities   文件: ItemBuildersWand.java
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;
}
 
源代码3 项目: enderutilities   文件: PositionUtils.java
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;
}
 
源代码4 项目: enderutilities   文件: BlockPosEU.java
/**
 * 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;
}
 
源代码5 项目: litematica   文件: PositionUtils.java
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;
}
 
源代码6 项目: enderutilities   文件: PositionUtils.java
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);
}
 
源代码7 项目: TofuCraftReload   文件: BlockTofuPortal.java
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);

    }