Java Code Examples for net.minecraftforge.common.util.ForgeDirection#ordinal()
The following examples show how to use
net.minecraftforge.common.util.ForgeDirection#ordinal() .
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: BlockPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
/** * Determine if this block can make a redstone connection on the side provided, * Useful to control which sides are inputs and outputs for redstone wires. * * Side: * -1: UP * 0: NORTH * 1: EAST * 2: SOUTH * 3: WEST * * @param world The current world * @param x X Position * @param y Y Position * @param z Z Position * @param side The side that is trying to make the connection * @return True to make the connection */ @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side){ if(side < 0 || side > 3) return false; TileEntityPressureTube tube = (TileEntityPressureTube)world.getTileEntity(x, y, z); ForgeDirection d = ForgeDirection.NORTH; for(int i = 0; i < side; i++) { d = d.getRotation(ForgeDirection.UP); } side = d.ordinal(); for(int i = 0; i < 6; i++) { if(tube.modules[i] != null) { if((side ^ 1) == i || i != side && tube.modules[i].isInline()) {//if we are on the same side, or when we have an 'in line' module that is not on the opposite side. if(tube.modules[i] instanceof TubeModuleRedstoneEmitting) return true; } } } return false; }
Example 2
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 3
Source File: TileLiquidTranslocator.java From Translocators with MIT License | 6 votes |
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(from == ForgeDirection.UNKNOWN) { List<FluidTankInfo> list = new LinkedList<FluidTankInfo>(); for(Attachment a : attachments) if(a != null) list.add(new FluidTankInfo(null, 0)); return list.toArray(new FluidTankInfo[0]); } if(attachments[from.ordinal()] != null) return new FluidTankInfo[]{new FluidTankInfo(null, 0)}; return new FluidTankInfo[0]; }
Example 4
Source File: TileEntityInventory.java From BigReactors with MIT License | 6 votes |
public TileEntityInventory() { super(); _inventories = new ItemStack[getSizeInventory()]; invSlotExposures = new int[getSizeInventory()][1]; for(int i = 0; i < invSlotExposures.length; i++) { // Set up a cached array with all possible exposed inventory slots, so we don't have to alloc at runtime invSlotExposures[i][0] = i; } adjacentInvs = new AdjacentInventoryHelper[ForgeDirection.VALID_DIRECTIONS.length]; for(ForgeDirection dir: ForgeDirection.VALID_DIRECTIONS) { adjacentInvs[dir.ordinal()] = new AdjacentInventoryHelper(dir); } resetAdjacentInventories(); }
Example 5
Source File: TileEntityPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void onAirDispersion(int amount, ForgeDirection side){ if(side != ForgeDirection.UNKNOWN) { int intSide = side/*.getOpposite()*/.ordinal(); if(modules[intSide] instanceof IInfluenceDispersing) { ((IInfluenceDispersing)modules[intSide]).onAirDispersion(amount); } } }
Example 6
Source File: PartFrame.java From Framez with GNU General Public License v3.0 | 5 votes |
@Override public boolean isSideHidden(ForgeDirection side) { if (hidden == null) hidden = new boolean[6]; return hidden[side.ordinal()]; }
Example 7
Source File: TileEntityPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public void updateConnections(World world, int x, int y, int z){ sidesConnected = new boolean[6]; boolean hasModule = false; for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { TileEntity te = getTileCache()[direction.ordinal()].getTileEntity(); IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te); if(machine != null) { sidesConnected[direction.ordinal()] = isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite()); } else if(te instanceof ISidedPneumaticMachine) { sidesConnected[direction.ordinal()] = ((ISidedPneumaticMachine)te).getAirHandler(direction.getOpposite()) != null; } if(modules[direction.ordinal()] != null) { hasModule = true; } } int sidesCount = 0; for(boolean bool : sidesConnected) { if(bool) sidesCount++; } if(sidesCount == 1 && !hasModule) { for(int i = 0; i < 6; i++) { if(sidesConnected[i]) { if(isConnectedTo(ForgeDirection.getOrientation(i).getOpposite())) sidesConnected[i ^ 1] = true; break; } } } for(int i = 0; i < 6; i++) { if(modules[i] != null && modules[i].isInline()) sidesConnected[i] = false; } }
Example 8
Source File: PowerHandler.java From Framez with GNU General Public License v3.0 | 5 votes |
private void updateSources(ForgeDirection source) { if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1)) { for (int i = 0; i < 6; ++i) { powerSources[i] -= sourcesTracker.durationOfLastDelay(); if (powerSources[i] < 0) { powerSources[i] = 0; } } } if (source != null) { powerSources[source.ordinal()] = 10; } }
Example 9
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 10
Source File: TileEntityUniversalSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void onNeighborTileUpdate(){ super.onNeighborTileUpdate(); for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { TileEntity te = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ); if(te instanceof IPneumaticMachine) { sidesConnected[direction.ordinal()] = ((IPneumaticMachine)te).isConnectedTo(direction.getOpposite()); } else { sidesConnected[direction.ordinal()] = false; } } }
Example 11
Source File: TileEntityPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void printManometerMessage(EntityPlayer player, List<String> text){ super.printManometerMessage(player, text); MovingObjectPosition mop = PneumaticCraftUtils.getEntityLookedObject(player); if(mop != null && mop.hitInfo instanceof ForgeDirection) { ForgeDirection dir = (ForgeDirection)mop.hitInfo; if(dir != ForgeDirection.UNKNOWN && modules[dir.ordinal()] != null) { modules[dir.ordinal()].addInfo(text); } } }
Example 12
Source File: TileEntityPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected int getMaxDispersion(ForgeDirection side){ if(side != ForgeDirection.UNKNOWN) { int intSide = side/*.getOpposite()*/.ordinal(); if(modules[intSide] instanceof IInfluenceDispersing) { return ((IInfluenceDispersing)modules[intSide]).getMaxDispersion(); } } return Integer.MAX_VALUE; }
Example 13
Source File: DroneInteractRFImport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){ IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone); if(droneEnergy.getEnergyStored() == droneEnergy.getMaxEnergyStored()) { interactHandler.abort(); return false; } else { TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IEnergyProvider) { IEnergyProvider provider = (IEnergyProvider)te; for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { if(interactHandler.getSides()[d.ordinal()]) { int transferedEnergy = droneEnergy.receiveEnergy(provider.extractEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true); if(transferedEnergy > 0) { if(!simulate) { interactHandler.decreaseCount(transferedEnergy); droneEnergy.receiveEnergy(transferedEnergy, false); provider.extractEnergy(d, transferedEnergy, false); } return true; } } } } return false; } }
Example 14
Source File: DroneInteractRFExport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){ IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone); if(droneEnergy.getEnergyStored() == 0) { interactHandler.abort(); return false; } else { TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IEnergyReceiver) { IEnergyReceiver receiver = (IEnergyReceiver)te; for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { if(interactHandler.getSides()[d.ordinal()]) { int transferedEnergy = droneEnergy.extractEnergy(receiver.receiveEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true); if(transferedEnergy > 0) { if(!simulate) { interactHandler.decreaseCount(transferedEnergy); droneEnergy.extractEnergy(transferedEnergy, false); receiver.receiveEnergy(d, transferedEnergy, false); } return true; } } } } return false; } }
Example 15
Source File: WailaTubeModuleHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static void addModuleInfo(List<String> currenttip, TileEntityPressureTube tube, NBTTagCompound tubeTag, ForgeDirection dir){ if(dir != ForgeDirection.UNKNOWN) { NBTTagList moduleList = tubeTag.getTagList("modules", 10); for(int i = 0; i < moduleList.tagCount(); i++) { NBTTagCompound moduleTag = moduleList.getCompoundTagAt(i); if(dir == ForgeDirection.getOrientation(moduleTag.getInteger("side"))) { if(tube != null && tube.modules[dir.ordinal()] != null) { TubeModule module = tube.modules[dir.ordinal()]; module.readFromNBT(moduleTag); module.addInfo(currenttip); } } } } }
Example 16
Source File: RotorSimpleRenderer.java From BigReactors with MIT License | 4 votes |
private static ForgeDirection findNormal(ForgeDirection majorAxis, ForgeDirection minorAxis) { return normals[majorAxis.ordinal()][minorAxis.ordinal()]; }
Example 17
Source File: TileEntitySidedEnvironment.java From Framez with GNU General Public License v3.0 | 4 votes |
@Override public Node sidedNode(final ForgeDirection side) { return side == ForgeDirection.UNKNOWN ? null : nodes[side.ordinal()]; }
Example 18
Source File: ProgWidgetPlace.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
public static boolean[] getSidesFromDir(ForgeDirection dir){ boolean[] dirs = new boolean[6]; dirs[dir.ordinal()] = true; return dirs; }
Example 19
Source File: ModelPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
public void renderModel(float size, boolean[] sidesConnected){ Base1.render(size); Base2.render(size); Base3.render(size); Base4.render(size); Base5.render(size); Base6.render(size); Base7.render(size); Base8.render(size); Base9.render(size); Base10.render(size); Base11.render(size); Base12.render(size); for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { switch(dir){ case UP: setTubeRotation(0, 0, -90); break; case DOWN: setTubeRotation(0, 0, 90); break; case NORTH: setTubeRotation(0, -90, 0); break; case SOUTH: setTubeRotation(0, 90, 0); break; case WEST: setTubeRotation(0, 0, 180); break; case EAST: setTubeRotation(0, 0, 0); break; } if(sidesConnected[dir.ordinal()]) { Left1.render(size); Left2.render(size); Left3.render(size); Left4.render(size); } else { CapLeft.render(size); } } }
Example 20
Source File: TileEntityPressureTube.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isConnectedTo(ForgeDirection side){ return (modules[side.ordinal()] == null || modules[side.ordinal()].isInline()) && (part == null || ModInteractionUtils.getInstance().isMultipartWiseConnected(part, side)); }