Java Code Examples for net.minecraftforge.common.util.ForgeDirection#getOrientation()
The following examples show how to use
net.minecraftforge.common.util.ForgeDirection#getOrientation() .
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: GT_TileEntity_ElectricImplosionCompressor.java From bartworks with MIT License | 6 votes |
private void resetPiston() { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; if (!this.piston) { int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; int aX = this.getBaseMetaTileEntity().getXCoord(), aY = this.getBaseMetaTileEntity().getYCoord(), aZ = this.getBaseMetaTileEntity().getZCoord(); for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) this.getBaseMetaTileEntity().getWorld().setBlock(xDir + aX + x, aY + 2, zDir + aZ + z, GregTech_API.sBlockMetal5, 2, 3); } } GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); this.piston = !this.piston; } }
Example 2
Source File: TileEntityOmnidirectionalHopper.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); inputDir = ForgeDirection.getOrientation(tag.getInteger("inputDir")); redstoneMode = tag.getInteger("redstoneMode"); leaveMaterial = tag.getBoolean("leaveMaterial"); NBTTagList tagList = tag.getTagList("Inventory", 10); inventory = new ItemStack[inventory.length]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } }
Example 3
Source File: TileEntityEndRodRenderer.java From Et-Futurum with The Unlicense | 5 votes |
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialTicks) { OpenGLHelper.pushMatrix(); OpenGLHelper.translate(x, y, z); OpenGLHelper.colour(0xFFFFFF); bindTexture(TextureMap.locationBlocksTexture); ForgeDirection dir = ForgeDirection.getOrientation(tile.getBlockMetadata()); switch (dir) { case DOWN: OpenGLHelper.rotate(180, 1, 0, 0); OpenGLHelper.translate(0, -1, -1); break; case EAST: OpenGLHelper.rotate(270, 0, 0, 1); OpenGLHelper.translate(-1, 0, 0); break; case NORTH: OpenGLHelper.rotate(270, 1, 0, 0); OpenGLHelper.translate(0, -1, 0); break; case SOUTH: OpenGLHelper.rotate(90, 1, 0, 0); OpenGLHelper.translate(0, 0, -1); break; case WEST: OpenGLHelper.rotate(90, 0, 0, 1); OpenGLHelper.translate(0, -1, 0); break; default: break; } renderRod(renderer, tile.getBlockType(), tile.getBlockMetadata()); OpenGLHelper.popMatrix(); }
Example 4
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 5 votes |
@Override public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int meta) { ForgeDirection dir = ForgeDirection.getOrientation(meta); return (dir == NORTH && world.getBlock(x, y, z + 1).isSideSolid(world, x, y, z + 1, NORTH)) || (dir == SOUTH && world.getBlock(x, y, z - 1).isSideSolid(world, x, y, z - 1, SOUTH)) || (dir == WEST && world.getBlock(x + 1, y, z).isSideSolid(world, x + 1, y, z, WEST )) || (dir == EAST && world.getBlock(x - 1, y, z).isSideSolid(world, x - 1, y, z, EAST )); }
Example 5
Source File: TileEntityProgrammableController.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int[] getAccessibleSlotsFromSide(int var1){ if(ForgeDirection.getOrientation(var1) == ForgeDirection.UP) { return new int[]{0}; } else { if(worldObj.isRemote) return new int[0]; int[] mainInv = new int[getSizeInventory()]; for(int i = 0; i < getSizeInventory(); i++) { mainInv[i] = i + 5; } return mainInv; } }
Example 6
Source File: GT_TileEntity_BioVat.java From bartworks with MIT License | 5 votes |
@Override public void onRemoval() { int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX * 2; int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ * 2; for (int x = -1; x < 2; x++) { for (int y = 1; y < 3; y++) { for (int z = -1; z < 2; z++) { if (this.getBaseMetaTileEntity().getWorld().getBlock(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()).equals(FluidLoader.bioFluidBlock)) this.getBaseMetaTileEntity().getWorld().setBlockToAir(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()); GT_TileEntity_BioVat.staticColorMap.remove(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()), this.getBaseMetaTileEntity().getWorld().provider.dimensionId); if (SideReference.Side.Server) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( this.getBaseMetaTileEntity().getWorld(), new RendererPacket( new Coords( xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId ), this.mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : this.mCulture.getColorRGB(), true ), this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord() ); } } } super.onRemoval(); }
Example 7
Source File: TileEntityAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private void spawnBurningParticle(){ Random rand = new Random(); if(rand.nextInt(3) != 0) return; float f = xCoord + 0.5F; float f1 = yCoord + 0.0F + rand.nextFloat() * 6.0F / 16.0F; float f2 = zCoord + 0.5F; float f3 = 0.5F; float f4 = rand.nextFloat() * 0.4F - 0.2F; switch(ForgeDirection.getOrientation(getBlockMetadata())){ case EAST: worldObj.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); break; case WEST: worldObj.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); break; case SOUTH: worldObj.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); break; case NORTH: worldObj.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); worldObj.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); break; } }
Example 8
Source File: RenderTileInfusionClaw.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private void createSideZap(TileInfusionClaw tile) { for(int i = 2; i < 6; i++) { ForgeDirection dir = ForgeDirection.getOrientation(i); createZap(tile, 0.5f + 0.5f*(float)dir.offsetX, 0.6f, 0.5f + 0.5f*(float)dir.offsetZ, 0.5f + dir.offsetX*0.2f, 0.2f, 0.5f + dir.offsetZ*0.2f); playZapSound(tile.xCoord, tile.yCoord, tile.zCoord); } }
Example 9
Source File: GT_TileEntity_THTR.java From bartworks with MIT License | 4 votes |
@Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { byte xz = 5; int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * xz; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * xz; for (int x = -xz; x <= xz; x++) { for (int z = -xz; z <= xz; z++) { for (int y = 0; y < 12; y++) { if (y == 0 || y == 11) { if ( !((Math.abs(z) == xz-1 && Math.abs(x) == xz)) && !((Math.abs(z) == xz && Math.abs(x) == xz-1)) && !((Math.abs(x) == Math.abs(z) && Math.abs(x) == xz)) ) { if (x + xDir == 0 && y == 0 && z + zDir == 0) continue; if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { if ( ( !(this.addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) && y == 11) && !(this.addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) && y == 0)) && !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) ) { return false; } } } } // else if (!((Math.abs(x) == 4 && Math.abs(z) == 4) || (Math.abs(x) == 3 && Math.abs(z) == 3)) && !(Math.abs(x) < 3 || Math.abs(z) < 3) && !((Math.abs(x) == Math.abs(z) && Math.abs(x) == 3) || Math.abs(x) == 4 || Math.abs(z) == 4)) { else if (!((Math.abs(z) == xz-1 && Math.abs(x) == xz))) if (!((Math.abs(z) == xz && Math.abs(x) == xz-1))) if (!((Math.abs(x) == Math.abs(z) && Math.abs(x) == xz))) if (!(Math.abs(x) < xz && Math.abs(z) != xz)) { if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { if ( !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX)) { return false; } } } } } } return this.mMaintenanceHatches.size() == 1; }
Example 10
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 11
Source File: GT_TileEntity_MegaBlastFurnace.java From bartworks with MIT License | 4 votes |
private boolean getCoilHeat(IGregTechTileEntity iGregTechTileEntity, int y) { int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 7; int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 7; int internalH = 0; for (int x = -6; x <= 6; x++) { for (int z = -6; z <= 6; z++) { if (Math.abs(x) < 6 && Math.abs(z) != 6) continue; byte tUsedMeta = iGregTechTileEntity.getMetaIDOffset(xDir + x, y, zDir + z); switch (tUsedMeta) { case 0: internalH = 1801; break; case 1: internalH = 2701; break; case 2: internalH = 3601; break; case 3: internalH = 4501; break; case 4: internalH = 5401; break; case 5: internalH = 7201; break; case 6: internalH = 9001; break; case 7: internalH = 9901; break; case 8: internalH = 10801; break; case 9: internalH = 21601; break; default: break; } if (this.mHeatingCapacity > 0 && internalH != this.mHeatingCapacity) return false; else if (this.mHeatingCapacity == 0) this.mHeatingCapacity = internalH; } } return true; }
Example 12
Source File: GuiProgWidgetPlace.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed(IGuiWidget guiWidget){ if(guiWidget.getID() >= 10 && guiWidget.getID() < 16) widget.placeDir = ForgeDirection.getOrientation(guiWidget.getID() - 10); super.actionPerformed(guiWidget); }
Example 13
Source File: ProgWidgetInventoryBase.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public String getExtraStringInfo(){ boolean allSides = true; boolean noSides = true; for(boolean bool : accessingSides) { if(bool) { noSides = false; } else { allSides = false; } } if(allSides) { return "All sides"; } else if(noSides) { return "No Sides"; } else { String tip = ""; for(int i = 0; i < 6; i++) { if(accessingSides[i]) { switch(ForgeDirection.getOrientation(i)){ case UP: tip += "top, "; break; case DOWN: tip += "bottom, "; break; case NORTH: tip += "north, "; break; case SOUTH: tip += "south, "; break; case EAST: tip += "east, "; break; case WEST: tip += "west, "; break; } } } return tip.substring(0, tip.length() - 2); } }
Example 14
Source File: TileEntityPneumaticGenerator.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isConnectedTo(ForgeDirection side){ return ForgeDirection.getOrientation(getBlockMetadata()) == side; }
Example 15
Source File: TileEntityLiquidHopper.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override protected boolean exportItem(int maxItems){ ForgeDirection dir = ForgeDirection.getOrientation(getBlockMetadata()); if(tank.getFluid() != null) { TileEntity neighbor = IOHelper.getNeighbor(this, dir); if(neighbor instanceof IFluidHandler) { IFluidHandler fluidHandler = (IFluidHandler)neighbor; if(fluidHandler.canFill(dir.getOpposite(), tank.getFluid().getFluid())) { FluidStack fluid = tank.getFluid().copy(); fluid.amount = Math.min(maxItems * 100, tank.getFluid().amount - (leaveMaterial ? 1000 : 0)); if(fluid.amount > 0) { tank.getFluid().amount -= fluidHandler.fill(dir.getOpposite(), fluid, true); if(tank.getFluidAmount() <= 0) tank.setFluid(null); return true; } } } } if(worldObj.isAirBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)) { for(EntityItem entity : getNeighborItems(this, dir)) { if(!entity.isDead) { List<ItemStack> returnedItems = new ArrayList<ItemStack>(); if(FluidUtils.tryExtractingLiquid(this, entity.getEntityItem(), returnedItems)) { if(entity.getEntityItem().stackSize <= 0) entity.setDead(); for(ItemStack stack : returnedItems) { EntityItem item = new EntityItem(worldObj, entity.posX, entity.posY, entity.posZ, stack); item.motionX = entity.motionX; item.motionY = entity.motionY; item.motionZ = entity.motionZ; worldObj.spawnEntityInWorld(item); } return true; } } } } if(getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) { if(worldObj.isAirBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)) { FluidStack extractedFluid = drain(ForgeDirection.UNKNOWN, 1000, false); if(extractedFluid != null && extractedFluid.amount == 1000) { Block fluidBlock = extractedFluid.getFluid().getBlock(); if(fluidBlock != null) { drain(ForgeDirection.UNKNOWN, 1000, true); worldObj.setBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, fluidBlock); } } } } return false; }
Example 16
Source File: TileEntityAirCannon.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); redstonePowered = tag.getBoolean("redstonePowered"); targetRotationAngle = tag.getFloat("targetRotationAngle"); targetHeightAngle = tag.getFloat("targetHeightAngle"); rotationAngle = tag.getFloat("rotationAngle"); heightAngle = tag.getFloat("heightAngle"); gpsX = tag.getInteger("gpsX"); gpsY = tag.getInteger("gpsY"); gpsZ = tag.getInteger("gpsZ"); if(tag.hasKey("fireOnRightAngle")) { redstoneMode = tag.getBoolean("fireOnRightAngle") ? 0 : 1; //TODO remove legacy } else { redstoneMode = tag.getByte("redstoneMode"); } coordWithinReach = tag.getBoolean("targetWithinReach"); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } trackedItemIds = new HashSet<UUID>(); tagList = tag.getTagList("trackedItems", 10); for(int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound t = tagList.getCompoundTagAt(i); trackedItemIds.add(new UUID(t.getLong("UUIDMost"), t.getLong("UUIDLeast"))); } if(tag.hasKey("inventoryX")) { lastInsertingInventory = new ChunkPosition(tag.getInteger("inventoryX"), tag.getInteger("inventoryY"), tag.getInteger("inventoryZ")); lastInsertingInventorySide = ForgeDirection.getOrientation(tag.getByte("inventorySide")); } else { lastInsertingInventory = null; lastInsertingInventorySide = null; } }
Example 17
Source File: BlockHeatSink.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int par2, int par3, int par4){ ForgeDirection dir = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(par2, par3, par4)); setBlockBounds(dir.offsetX <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetY <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetX >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetY >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS); }
Example 18
Source File: TileEntityBabyChest.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
public void setOrientation(int pOrientationInt) { _mOrientation = ForgeDirection.getOrientation(pOrientationInt); }
Example 19
Source File: PacketUpdateTubeModule.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void fromBytes(ByteBuf buffer){ super.fromBytes(buffer); moduleSide = ForgeDirection.getOrientation(buffer.readByte()); }
Example 20
Source File: AIBreakBlock.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean continueExecuting() { if(hasValidTool) { if(!hasBlock(currentMarker)) { return false; } if(distanceSquaredToGolem(currentMarker) < 1) { if(golem.getCarried() == null) { golem.startActionTimer(); } else { golem.startRightArmTimer(); } if(clickCount % (7 - Math.min(6, golem.getGolemStrength())) == 0) { doLeftClick(); } clickCount++; golem.getLookHelper().setLookPosition(currentMarker.x + 0.5D, currentMarker.y + 0.5D, currentMarker.z + 0.5D, 30.0F, 30.0F); count = 0; } else { if(count == 20) { count = 0; ForgeDirection dir = ForgeDirection.getOrientation(currentMarker.side); boolean path = golem.getNavigator().tryMoveToXYZ(currentMarker.x + 0.5D + dir.offsetX, currentMarker.y + 0.5D + dir.offsetY, currentMarker.z + 0.5D + dir.offsetZ, golem.getAIMoveSpeed()); if(!path) { if (blacklistCount > 10) { blacklist.put(currentMarker, golem.ticksExisted); return false; } blacklistCount++; } } count++; clickCount = 0; } } else { if(golem.ticksExisted % Config.golemDelay > 0) { if(isInHomeRange()) { IInventory homeChest = getHomeChest(); if(homeChest != null) { trySwitchTool(homeChest); } } else { return false; } } } return true; }