Java Code Examples for net.minecraftforge.common.util.ForgeDirection#EAST
The following examples show how to use
net.minecraftforge.common.util.ForgeDirection#EAST .
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: 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 2
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 3
Source File: ModelUniversalSensor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public void renderModel(float size, float dishRotation, boolean[] sidesConnected){ Base1.render(size); Base2.render(size); GL11.glPushMatrix(); GL11.glRotatef(dishRotation, 0, 1, 0); Dish1.render(size); Dish2.render(size); Dish3.render(size); Dish4.render(size); Dish5.render(size); Dish6.render(size); GL11.glPopMatrix(); ForgeDirection d = ForgeDirection.EAST; for(int i = 0; i < 4; i++) { d = d.getRotation(ForgeDirection.UP); if(sidesConnected[d.ordinal()]) { TubeConnection.rotateAngleY = (float)(i * Math.PI / 2); TubeConnection.render(size); } } }
Example 4
Source File: BlockPresent.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
public AxisAlignedBB getBoundingBox(TileEntityPresent me) { if (me == null) { return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); } int x = me.xCoord, y = me.yCoord, z = me.zCoord; if (me.isConnected()) { ForgeDirection dir = me.getConnectionDir(); // warning: magic below! Do not change this conditional if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) { return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ); } else { return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ); } } return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); }
Example 5
Source File: StaticUtils.java From BigReactors with MIT License | 5 votes |
/** * @param entity The entity whose facing you wish to query. * @return The ForgeDirection which entity is facing (north/south/east/west) */ protected ForgeDirection getFacingDirection(Entity entity) { int facingAngle = (MathHelper.floor_double((entity.rotationYaw * 4F) / 360F + 0.5D) & 3); switch(facingAngle) { case 1: return ForgeDirection.EAST; case 2: return ForgeDirection.SOUTH; case 3: return ForgeDirection.WEST; default: return ForgeDirection.NORTH; } }
Example 6
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 7
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 8
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 9
Source File: TileEntityPressureChamberValve.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean isConnectedTo(ForgeDirection side){ switch(ForgeDirection.getOrientation(getBlockMetadata())){ case UP: case DOWN: return side == ForgeDirection.UP || side == ForgeDirection.DOWN; 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 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: Sponge.java From Et-Futurum with The Unlicense | 5 votes |
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random rand) { if (world.getBlockMetadata(x, y, z) == 1) { ForgeDirection dir = getRandomDirection(rand); if (dir != ForgeDirection.UP && !World.doesBlockHaveSolidTopSurface(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) { double d0 = x; double d1 = y; double d2 = z; if (dir == ForgeDirection.DOWN) { d1 -= 0.05D; d0 += rand.nextDouble(); d2 += rand.nextDouble(); } else { d1 += rand.nextDouble() * 0.8D; if (dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) { d2 += rand.nextDouble(); if (dir == ForgeDirection.EAST) d0++; else d0 += 0.05D; } else { d0 += rand.nextDouble(); if (dir == ForgeDirection.SOUTH) d2++; else d2 += 0.05D; } } world.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D); } } }
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: 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 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: 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 18
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 19
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 20
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; } }