Java Code Examples for net.minecraftforge.common.util.ForgeDirection#getOpposite()
The following examples show how to use
net.minecraftforge.common.util.ForgeDirection#getOpposite() .
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: BlockArcaneDropper.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { int metadata = world.getBlockMetadata(x, y, z); ForgeDirection direction = ForgeDirection.getOrientation(metadata & 7); boolean flipped = (metadata & 8) == 8; if(direction == ForgeDirection.SOUTH || direction == ForgeDirection.NORTH) { flipped = !flipped; } ForgeDirection rotated = direction.getRotation(flipped ? ForgeDirection.getOrientation((direction.ordinal() + 4) % 6) : ForgeDirection.getOrientation((direction.ordinal() + 2) % 6)); return direction != side && rotated != side && rotated.getOpposite() != side; }
Example 2
Source File: EnvironmentMotor.java From Framez with GNU General Public License v3.0 | 6 votes |
@Callback(doc = "function(face, direction):boolean -- Sets the motor's face and direction. Returns true if it succeeded, false if it didn't.") public Object[] set(Context context, Arguments args) { if (args.count() < 2) throw new RuntimeException("At least 2 arguments are required (face, direction)"); ForgeDirection face = toFD(args.checkAny(0)); ForgeDirection direction = toFD(args.checkAny(1)); if (face == null || direction == null) throw new RuntimeException("Invalid directions!"); if (face == direction || face == direction.getOpposite()) throw new RuntimeException("Motors cannot push or pull blocks!"); // te.setFace(face, true); // te.setDirection(direction, true); return new Object[] { true }; }
Example 3
Source File: MovementSlide.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public boolean rotate(IMotor mover, ForgeDirection axis) { TileMotor te = (TileMotor) mover; ForgeDirection face = te.getFace().getRotation(axis); ForgeDirection direction = getDirection().getRotation(axis); System.out.println(face + " " + direction); if (face == direction || face == direction.getOpposite() || face.getOpposite() == direction) return false; this.direction = direction; te.setFace(face); return true; }
Example 4
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 5
Source File: BlockArcaneDropper.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { int metadata = world.getBlockMetadata(x, y, z); ForgeDirection side = ForgeDirection.getOrientation(metadata); float yaw = MathHelper.wrapAngleTo180_float(entity.rotationYaw); float pitch = entity.rotationPitch; boolean flipped; if(side == ForgeDirection.UP || side == ForgeDirection.DOWN) { yaw += 180; flipped = yaw > 315 || yaw < 45 || (yaw < 225 && yaw > 135); } else { switch (side.getOpposite()) { case WEST: yaw -= 90; break; case NORTH: yaw = (180 - Math.abs(yaw)) * (yaw < 0 ? 1 : -1); break; case EAST: yaw += 90; break; } flipped = Math.abs(yaw) < Math.abs(pitch); } metadata |= flipped ? 8 : 0; world.setBlockMetadataWithNotify(x, y, z, metadata, 2); }
Example 6
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 7
Source File: EndRod.java From Et-Futurum with The Unlicense | 5 votes |
@Override public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) { ForgeDirection dir = ForgeDirection.getOrientation(side).getOpposite(); if (world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) != this) dir = dir.getOpposite(); return dir.ordinal(); }
Example 8
Source File: TileEntityPresent.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) { if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected() && (present.cachedDir == null || present.cachedDir == dir.getOpposite()) && Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) { connection = present; connection.connection = this; connection.cachedDir = dir.getOpposite(); connection.markDirty(); cachedDir = dir; isParent = !present.isParent; markDirty(); PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId); return true; } return false; }
Example 9
Source File: ModelKeroseneLamp.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void renderStatic(float size, TileEntity te){ ForgeDirection sideConnected = ForgeDirection.DOWN; if(te != null) { sideConnected = ((TileEntityKeroseneLamp)te).getSideConnected(); } Tank.render(size); Holder1.render(size); Holder2.render(size); Base.render(size); Top.render(size); if(sideConnected != ForgeDirection.DOWN) { Support1.render(size); if(sideConnected != ForgeDirection.UP) { SupportSide.rotateAngleY = 0; ForgeDirection rotation = ((TileEntityKeroseneLamp)te).getRotation(); if(rotation != ForgeDirection.UP && rotation != ForgeDirection.DOWN) { while(sideConnected != rotation.getOpposite()) { sideConnected = sideConnected.getRotation(ForgeDirection.DOWN); SupportSide.rotateAngleY += Math.toRadians(90); } } SupportSide2.rotateAngleY = SupportSide.rotateAngleY; SupportSide.render(size); SupportSide2.render(size); } } if(te != null) { FluidTankInfo info = ((TileEntityKeroseneLamp)te).getTankInfo(null)[0]; if(info.fluid != null && info.fluid.amount > 10) { float percentageFull = (float)info.fluid.amount / info.capacity; RenderInfo renderInfo = new RenderInfo(-3 / 16F + 0.01F, 23 / 16F - percentageFull * 2.999F / 16F, -3 / 16F + 0.01F, 3 / 16F - 0.01F, 22.99F / 16F, 3 / 16F - 0.01F); RenderUtils.INSTANCE.renderLiquid(info, renderInfo, te.getWorldObj()); } } }
Example 10
Source File: TileEntityPressureChamberInterface.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private void exportToInventory(){ ForgeDirection facing = ForgeDirection.getOrientation(getBlockMetadata()); TileEntity te = worldObj.getTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ); if(te != null) { ForgeDirection side = facing.getOpposite(); ItemStack leftoverStack = PneumaticCraftUtils.exportStackToInventory(te, inventory[0], side); if(leftoverStack == null || leftoverStack.stackSize == 0) { inventory[0] = null; } } }
Example 11
Source File: TileEntityElectricCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isConnectedTo(ForgeDirection side){ ForgeDirection orientation = ForgeDirection.getOrientation(getBlockMetadata()); return orientation == side || orientation == side.getOpposite(); }
Example 12
Source File: TileEntityLiquidCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isConnectedTo(ForgeDirection dir){ ForgeDirection orientation = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); return orientation == dir || orientation == dir.getOpposite() || dir == ForgeDirection.UP; }
Example 13
Source File: TileEntityPeripheralProxy.java From OpenPeripheral-Addons with MIT License | 4 votes |
private void handlePeripheralUpdate(ForgeDirection targetDir) { boolean isConnected = isProxyActive(targetDir); ForgeDirection modemDir = targetDir.getOpposite(); updateModem(modemDir, isConnected); }