Java Code Examples for net.minecraft.util.EnumFacing#rotateAround()
The following examples show how to use
net.minecraft.util.EnumFacing#rotateAround() .
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: RotationTest.java From AdvancedRocketry with MIT License | 5 votes |
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(); } } }
Example 2
Source File: PositionUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
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 3
Source File: BlockPosEU.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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 4
Source File: PortalFormer.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
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; }