Java Code Examples for net.minecraftforge.common.util.ForgeDirection#WEST
The following examples show how to use
net.minecraftforge.common.util.ForgeDirection#WEST .
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: RotorSimpleRenderer.java From BigReactors with MIT License | 6 votes |
/** * @param world * @param x * @param y * @param z * @param block * @return The major axis of the rotor. This is always one of the positive directions. */ private static ForgeDirection findRotorMajorAxis(IBlockAccess world, int x, int y, int z, Block block) { ForgeDirection retDir = ForgeDirection.UP; for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == block && BlockTurbineRotorPart.isRotorShaft(world.getBlockMetadata(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))) { retDir = dir; break; } } if(retDir == ForgeDirection.DOWN || retDir == ForgeDirection.NORTH || retDir == ForgeDirection.WEST) { retDir = retDir.getOpposite(); } return retDir; // Defaults to up if there's no neighbors of the same type }
Example 2
Source File: TileEntityVortexTube.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public ForgeDirection getTubeDirection(){ ForgeDirection d; switch(getRotation()){ case DOWN: case NORTH: case UP: d = ForgeDirection.WEST; break; case SOUTH: d = ForgeDirection.EAST; break; case WEST: d = ForgeDirection.SOUTH; break; case EAST: d = ForgeDirection.NORTH; break; default: d = ForgeDirection.SOUTH; } for(int i = 0; i < roll; i++) { d = d.getRotation(getRotation()); } return d; }
Example 3
Source File: PneumaticCraftUtils.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
/** * Returns the ForgeDirection of the facing of the entity given. * @param entity * @param includeUpAndDown false when UP/DOWN should not be included. * @return */ public static ForgeDirection getDirectionFacing(EntityLivingBase entity, boolean includeUpAndDown){ double yaw = entity.rotationYaw; while(yaw < 0) yaw += 360; yaw = yaw % 360; if(includeUpAndDown) { if(entity.rotationPitch > 45) return ForgeDirection.DOWN; else if(entity.rotationPitch < -45) return ForgeDirection.UP; } if(yaw < 45) return ForgeDirection.SOUTH; else if(yaw < 135) return ForgeDirection.WEST; else if(yaw < 225) return ForgeDirection.NORTH; else if(yaw < 315) return ForgeDirection.EAST; else return ForgeDirection.SOUTH; }
Example 4
Source File: RenderTileArcaneDropper.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y - 0.5, z + 0.5); int metadata = tile.getBlockMetadata(); ForgeDirection side = ForgeDirection.getOrientation(metadata & 7); if(side == ForgeDirection.UP) { GL11.glRotatef(180, 1, 0, 0); GL11.glTranslatef(0, -2, 0); } else if(side != ForgeDirection.DOWN) { GL11.glRotatef(-90, side.offsetZ, 0, -1*side.offsetX); GL11.glTranslatef(side.offsetX, -1, side.offsetZ); } boolean flipped = (metadata & 8) == 8; if(side == ForgeDirection.WEST || side == ForgeDirection.EAST) { flipped = !flipped; } if(flipped) { GL11.glRotatef(90, 0, 1, 0); } bindTexture(RESOURCE); MODEL.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); renderBellow(); GL11.glRotatef(180, 0, 1, 0); renderBellow(); GL11.glPopMatrix(); }
Example 5
Source File: RectangularMultiblockTileEntityBase.java From BeefCore with MIT License | 5 votes |
public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) { outwards = ForgeDirection.UNKNOWN; position = PartPosition.Unknown; int facesMatching = 0; if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; } if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; } if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; } if(facesMatching <= 0) { position = PartPosition.Interior; } else if(facesMatching >= 3) { position = PartPosition.FrameCorner; } else if(facesMatching == 2) { position = PartPosition.Frame; } else { // 1 face matches if(maxCoord.x == this.xCoord) { position = PartPosition.EastFace; outwards = ForgeDirection.EAST; } else if(minCoord.x == this.xCoord) { position = PartPosition.WestFace; outwards = ForgeDirection.WEST; } else if(maxCoord.z == this.zCoord) { position = PartPosition.SouthFace; outwards = ForgeDirection.SOUTH; } else if(minCoord.z == this.zCoord) { position = PartPosition.NorthFace; outwards = ForgeDirection.NORTH; } else if(maxCoord.y == this.yCoord) { position = PartPosition.TopFace; outwards = ForgeDirection.UP; } else { position = PartPosition.BottomFace; outwards = ForgeDirection.DOWN; } } }
Example 6
Source File: TileEntityVacuumPump.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean isConnectedTo(ForgeDirection side){ int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); switch(ForgeDirection.getOrientation(meta)){ case NORTH: case SOUTH: return side == ForgeDirection.NORTH || side == ForgeDirection.SOUTH; case EAST: case WEST: return side == ForgeDirection.EAST || side == ForgeDirection.WEST; } return false; }
Example 7
Source File: TileEntityAssemblyRobot.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public ForgeDirection[] getPlatformDirection(){ for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) { if(worldObj.getTileEntity(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{dir, ForgeDirection.UNKNOWN}; } } if(canMoveToDiagonalNeighbours()) { if(worldObj.getTileEntity(xCoord + ForgeDirection.NORTH.offsetX + ForgeDirection.WEST.offsetX, yCoord, zCoord + ForgeDirection.NORTH.offsetZ + ForgeDirection.WEST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.WEST}; if(worldObj.getTileEntity(xCoord + ForgeDirection.NORTH.offsetX + ForgeDirection.EAST.offsetX, yCoord, zCoord + ForgeDirection.NORTH.offsetZ + ForgeDirection.EAST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.EAST}; if(worldObj.getTileEntity(xCoord + ForgeDirection.SOUTH.offsetX + ForgeDirection.WEST.offsetX, yCoord, zCoord + ForgeDirection.SOUTH.offsetZ + ForgeDirection.WEST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.SOUTH, ForgeDirection.WEST}; if(worldObj.getTileEntity(xCoord + ForgeDirection.SOUTH.offsetX + ForgeDirection.EAST.offsetX, yCoord, zCoord + ForgeDirection.SOUTH.offsetZ + ForgeDirection.EAST.offsetZ) instanceof TileEntityAssemblyPlatform) return new ForgeDirection[]{ForgeDirection.SOUTH, ForgeDirection.EAST}; } return null; }
Example 8
Source File: CoordTriplet.java From BeefCore with MIT License | 5 votes |
public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z) { if(this.x < x) { return ForgeDirection.WEST; } else if(this.x > x) { return ForgeDirection.EAST; } else if(this.y < y) { return ForgeDirection.DOWN; } else if(this.y > y) { return ForgeDirection.UP; } else if(this.z < z) { return ForgeDirection.SOUTH; } else if(this.z > z) { return ForgeDirection.NORTH; } else { return ForgeDirection.UNKNOWN; } }
Example 9
Source File: AchievementHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static void checkFor9x9(EntityPlayer player, int x, int y, int z){ ChunkCache cache = new ChunkCache(player.worldObj, x - 8, y, z - 8, x + 8, y, z + 8, 0); ForgeDirection[] dirs = {ForgeDirection.NORTH, ForgeDirection.WEST}; for(ForgeDirection dir : dirs) { int wallLength = 1; int minX = x; int minZ = z; int maxX = x; int maxZ = z; int newX = x + dir.offsetX; int newZ = z + dir.offsetZ; while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) { wallLength++; minX = Math.min(minX, newX); minZ = Math.min(minZ, newZ); maxX = Math.max(maxX, newX); maxZ = Math.max(maxZ, newZ); newX += dir.offsetX; newZ += dir.offsetZ; } newX = x - dir.offsetX; newZ = z - dir.offsetZ; while(wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) { wallLength++; minX = Math.min(minX, newX); minZ = Math.min(minZ, newZ); maxX = Math.max(maxX, newX); maxZ = Math.max(maxZ, newZ); newX -= dir.offsetX; newZ -= dir.offsetZ; } if(wallLength == 9) { if(checkFor9x9(cache, x, y, z, minX, minZ, maxX, maxZ)) { giveAchievement(player, "dw9x9"); return; } } } }
Example 10
Source File: WorldCoord.java From Framez with GNU General Public License v3.0 | 5 votes |
/** * Will Return NULL if it's at some diagonal! */ public ForgeDirection directionTo(WorldCoord loc) { int ox = x - loc.x; int oy = y - loc.y; int oz = z - loc.z; int xlen = Math.abs( ox ); int ylen = Math.abs( oy ); int zlen = Math.abs( oz ); if ( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) ) return ForgeDirection.EAST; if ( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) ) return ForgeDirection.WEST; if ( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) ) return ForgeDirection.NORTH; if ( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) ) return ForgeDirection.SOUTH; if ( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) ) return ForgeDirection.UP; if ( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) ) return ForgeDirection.DOWN; return null; }
Example 11
Source File: EndRod.java From Et-Futurum with The Unlicense | 5 votes |
@Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); if (dir == ForgeDirection.DOWN || dir == ForgeDirection.UP) setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); else if (dir == ForgeDirection.WEST || dir == ForgeDirection.EAST) setBlockBounds(0.0F, 0.375F, 0.375F, 1.0F, 0.625F, 0.625F); else if (dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) setBlockBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F); }
Example 12
Source File: CoordTriplet.java From BeefCore with MIT License | 5 votes |
public ForgeDirection getOppositeDirectionFromSourceCoords(int x, int y, int z) { if(this.x < x) { return ForgeDirection.EAST; } else if(this.x > x) { return ForgeDirection.WEST; } else if(this.y < y) { return ForgeDirection.UP; } else if(this.y > y) { return ForgeDirection.DOWN; } else if(this.z < z) { return ForgeDirection.NORTH; } else if(this.z > z) { return ForgeDirection.SOUTH; } else { return ForgeDirection.UNKNOWN; } }
Example 13
Source File: EtFuturumWorldGenerator.java From Et-Futurum with The Unlicense | 5 votes |
public static void generateChorusPlant(World world, int x, int y, int z, int pass) { int height; for (height = 0; height < 4; height++) { if (!ChorusFlower.canPlantStay(world, x, y + height, z)) { world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2); break; } world.setBlock(x, y + height, z, ModBlocks.chorus_plant); } if (height > 1) { world.setBlock(x, y + height, z, ModBlocks.chorus_plant); boolean grew = false; if (pass < 5) { ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH }; for (int j = 0; j < world.rand.nextInt(4); j++) { ForgeDirection dir = dirs[world.rand.nextInt(dirs.length)]; int xx = x + dir.offsetX; int yy = y + height + dir.offsetY; int zz = z + dir.offsetZ; if (world.isAirBlock(xx, yy, zz) && ChorusFlower.isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) { generateChorusPlant(world, xx, yy, zz, pass + 1); grew = true; } } } if (!grew) world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2); } }
Example 14
Source File: TileEssentiaCompressor.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canOutputTo(ForgeDirection direction) { if(isMultiblockFormed() && multiblockYIndex == 1) { //The middle one return direction == ForgeDirection.SOUTH || direction == ForgeDirection.NORTH || direction == ForgeDirection.EAST || direction == ForgeDirection.WEST; } return false; }
Example 15
Source File: TileEssentiaCompressor.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canInputFrom(ForgeDirection direction) { if(isMultiblockFormed() && multiblockYIndex == 1) { //The middle one return direction == ForgeDirection.SOUTH || direction == ForgeDirection.NORTH || direction == ForgeDirection.EAST || direction == ForgeDirection.WEST; } return false; }
Example 16
Source File: TileStickyJar.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public ForgeDirection changeDirection(ForgeDirection face) { if(placedOn == ForgeDirection.UP) { if(face == ForgeDirection.UP || face == ForgeDirection.DOWN) { return face.getOpposite(); } return face; } if(placedOn == ForgeDirection.DOWN) { return face; } if(face == ForgeDirection.UP) { return ForgeDirection.NORTH; } if(face == ForgeDirection.DOWN) { return ForgeDirection.SOUTH; } if(face == placedOn) { return ForgeDirection.DOWN; } if(face == placedOn.getOpposite()) { return ForgeDirection.UP; } switch (placedOn) { case EAST: return face == ForgeDirection.NORTH ? ForgeDirection.WEST : ForgeDirection.EAST; case SOUTH: return face.getOpposite(); case WEST: return face == ForgeDirection.SOUTH ? ForgeDirection.WEST : ForgeDirection.EAST; } return face; }
Example 17
Source File: WorldCoord.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
/** * Will Return NULL if it's at some diagonal! */ public ForgeDirection directionTo( WorldCoord loc ) { int ox = this.x - loc.x; int oy = this.y - loc.y; int oz = this.z - loc.z; int xlen = Math.abs( ox ); int ylen = Math.abs( oy ); int zlen = Math.abs( oz ); if( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) ) { return ForgeDirection.EAST; } if( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) ) { return ForgeDirection.WEST; } if( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) ) { return ForgeDirection.NORTH; } if( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) ) { return ForgeDirection.SOUTH; } if( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) ) { return ForgeDirection.UP; } if( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) ) { return ForgeDirection.DOWN; } return null; }
Example 18
Source File: TileEntityAssemblyRobot.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
/** * Goes to the neighbour, and returns true if the neighbour was diagonal to this arm. * @param primaryDir * @param secondaryDir * @return */ @SuppressWarnings("incomplete-switch") public boolean gotoNeighbour(ForgeDirection primaryDir, ForgeDirection secondaryDir){ targetDirection = new ForgeDirection[]{primaryDir, secondaryDir}; boolean diagonal = true; boolean diagonalAllowed = canMoveToDiagonalNeighbours(); switch(primaryDir){ case SOUTH: if(secondaryDir == ForgeDirection.EAST && diagonalAllowed) { targetAngles[EnumAngles.TURN.ordinal()] = -45F; targetAngles[EnumAngles.HEAD.ordinal()] = 40F; } else if(secondaryDir == ForgeDirection.WEST && diagonalAllowed) { targetAngles[EnumAngles.TURN.ordinal()] = 45F; targetAngles[EnumAngles.HEAD.ordinal()] = -40F; } else { targetAngles[EnumAngles.TURN.ordinal()] = 0F; targetAngles[EnumAngles.HEAD.ordinal()] = 90F; diagonal = false; } break; case EAST: targetAngles[EnumAngles.TURN.ordinal()] = -90F; targetAngles[EnumAngles.HEAD.ordinal()] = 0F; diagonal = false; break; case NORTH: if(secondaryDir == ForgeDirection.EAST && diagonalAllowed) { targetAngles[EnumAngles.TURN.ordinal()] = -135F; targetAngles[EnumAngles.HEAD.ordinal()] = -40F; } else if(secondaryDir == ForgeDirection.WEST && diagonalAllowed) { targetAngles[EnumAngles.TURN.ordinal()] = 135F; targetAngles[EnumAngles.HEAD.ordinal()] = 40F; } else { targetAngles[EnumAngles.TURN.ordinal()] = 180F; targetAngles[EnumAngles.HEAD.ordinal()] = 90F; diagonal = false; } break; case WEST: targetAngles[EnumAngles.TURN.ordinal()] = 90F; targetAngles[EnumAngles.HEAD.ordinal()] = 0F; diagonal = false; break; } if(diagonal) { targetAngles[EnumAngles.BASE.ordinal()] = 160F; targetAngles[EnumAngles.MIDDLE.ordinal()] = -85F; targetAngles[EnumAngles.TAIL.ordinal()] = -20F; } else { targetAngles[EnumAngles.BASE.ordinal()] = 100F; targetAngles[EnumAngles.MIDDLE.ordinal()] = -10F; targetAngles[EnumAngles.TAIL.ordinal()] = 0F; } return diagonal; }
Example 19
Source File: BlockStickyJar.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
private void flipBlockBounds(TileStickyJar stickyJar) { ForgeDirection placedOn = stickyJar.placedOn; if (placedOn != ForgeDirection.DOWN) { float minX = (float) getBlockBoundsMinX(); float minY = (float) getBlockBoundsMinY(); float minZ = (float) getBlockBoundsMinZ(); float maxX = (float) getBlockBoundsMaxX(); float maxY = (float) getBlockBoundsMaxY(); float maxZ = (float) getBlockBoundsMaxZ(); float temp; if (placedOn == ForgeDirection.NORTH || placedOn == ForgeDirection.SOUTH) { temp = minZ; minZ = minY; minY = temp; temp = maxZ; maxZ = maxY; maxY = temp; } else if (placedOn == ForgeDirection.WEST || placedOn == ForgeDirection.EAST) { temp = minX; minX = minY; minY = temp; temp = maxX; maxX = maxY; maxY = temp; } if (placedOn == ForgeDirection.UP || placedOn == ForgeDirection.SOUTH || placedOn == ForgeDirection.EAST) { minX = 1 - minX; minY = 1 - minY; minZ = 1 - minZ; maxX = 1 - maxX; maxY = 1 - maxY; maxZ = 1 - maxZ; temp = minX; minX = maxX; maxX = temp; temp = minY; minY = maxY; maxY = temp; temp = minZ; minZ = maxZ; maxZ = temp; } this.minX = minX; this.minY = minY; this.minZ = minZ; this.maxX = maxX; this.maxY = maxY; this.maxZ = maxZ; } }
Example 20
Source File: RenderBabyChest.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
@Override public void renderTileEntityAt(TileEntity pTileEntity, double pX, double pY, double pZ, float pTick) { if (pTileEntity instanceof TileEntityBabyChest) { TileEntityBabyChest tTileEntityBabyChest = (TileEntityBabyChest) pTileEntity; ForgeDirection tDirection = null; if (tTileEntityBabyChest.getWorldObj() != null) { tDirection = tTileEntityBabyChest.getOrientation(); } World tWorld = tTileEntityBabyChest.getWorldObj(); Block tBlock = tWorld.getBlock(tTileEntityBabyChest.xCoord, tTileEntityBabyChest.yCoord, tTileEntityBabyChest.zCoord); if (tBlock instanceof BlockBabyChest) { BlockBabyChest blockBabyChest = (BlockBabyChest) tBlock; bindTexture(new ResourceLocation("minecraft:textures/entity/chest/normal.png")); } GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) pX, (float) pY + 1.0F, (float) pZ + 1.0F); GL11.glScalef(0.5F, -0.5F, -0.5F); GL11.glTranslatef(0.5F, 1F, 0.5F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short tAngle = 0; if (tDirection != null) { if (tDirection == ForgeDirection.NORTH) { tAngle = 180; } else if (tDirection == ForgeDirection.SOUTH) { tAngle = 0; } else if (tDirection == ForgeDirection.WEST) { tAngle = 90; } else if (tDirection == ForgeDirection.EAST) { tAngle = -90; } } GL11.glRotatef(tAngle, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float adjustedLidAngle = tTileEntityBabyChest._mPrevLidAngle + (tTileEntityBabyChest._mLidAngle - tTileEntityBabyChest._mPrevLidAngle) * pTick; adjustedLidAngle = 1.0F - adjustedLidAngle; adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle; _mModelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F); _mModelChest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }