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

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

源代码1 项目: AdvancedRocketry   文件: RotationTest.java
public static void main(String str[]) {
	
	for(EnumFacing stationFacing : EnumFacing.values()) {
		for(EnumFacing dirFacing : EnumFacing.values() ) {
			EnumFacing cross = dirFacing.rotateAround(stationFacing.getAxis());
			System.out.println();
		}
	}
}
 
源代码2 项目: 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;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: enderutilities   文件: PortalFormer.java
private boolean walkFrameLoop(BlockPos pos, EnumFacing.Axis axis, EnumFacing frameSide, int distanceLimit)
{
    int counter = 0;
    int turns = 0;
    int tries = 0;
    IBlockState state;
    Block block;
    BlockPos startPos = pos;
    BlockPos posLast = startPos;
    EnumFacing firstTrySide = frameSide;
    EnumFacing moveDirection = frameSide;

    while (counter < distanceLimit)
    {
        moveDirection = firstTrySide;

        for (tries = 0; tries < 4; tries++)
        {
            pos = posLast.offset(moveDirection);
            state = this.world.getBlockState(pos);
            block = state.getBlock();

            if (block.isAir(state, this.world, pos))
            {
                posLast = pos;

                // The firstTrySide is facing into the adjacent portal frame when traveling
                // along a straight frame. Thus we need to rotate it once to keep going straight.
                // If we need to rotate it more than once, then we have hit a "right hand corner".
                if (tries > 1)
                {
                    turns++;
                }
                // If we didn't have to rotate the firstTrySide at all, then we hit a "left hand turn"
                // ie. traveled through an outer bend.
                else if (tries == 0)
                {
                    turns--;
                }

                // Set the firstTrySide one rotation back from the side that we successfully moved to
                // so that we can go around possible outer bends.
                firstTrySide = moveDirection.rotateAround(axis).getOpposite();

                break;
            }
            // Found a portal frame block, try the next adjacent side...
            else if (block == this.blockFrame)
            {
                moveDirection = moveDirection.rotateAround(axis);
            }
            // Found a non-air, non-portal-frame block -> invalid area.
            else
            {
                return false;
            }
        }

        // If we can return to the starting position hugging the portal frame,
        // then this is a valid portal frame loop.
        // Note that it is only valid if it forms an inside area, thus the turns check.
        // the tries == 4 && counter == 0 check is for a 1x1 area special case
        if ((tries == 4 && counter == 0) || pos.equals(startPos))
        {
            return turns >= 0;
        }

        counter++;
    }

    return false;
}