public void renderLiquid(FluidTankInfo info, RenderInfo renderInfo, World world) { if (info.fluid.getFluid().getBlock() != null) { renderInfo.baseBlock = info.fluid.getFluid().getBlock(); } else { renderInfo.baseBlock = Blocks.WATER; } renderInfo.texture = info.fluid.getFluid().getStill(info.fluid); //TODO 1.8 still or flowing? FMLClientHandler.instance().getClient().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // Tessellator.instance.setColorOpaque_I(); int color = info.fluid.getFluid().getColor(info.fluid); int red = color >> 16 & 255; int green = color >> 8 & 255; int blue = color & 255; GL11.glColor4ub((byte) red, (byte) green, (byte) blue, (byte) 255); RenderUtils.INSTANCE.renderBlock(renderInfo, world, 0, 0, 0, false, true); }
@Override public void addData(final Object tile, final List<String> data, final ForgeDirection side, final EntityPlayer player) { final FluidTankInfo[] tanks = ((IFluidHandler)tile).getTankInfo(side); if (tanks != null) { if (tanks.length == 1) { if (tanks[0].fluid != null && tanks[0].fluid.amount > 0) { data.add("Fluid Tank: " + tanks[0].fluid.getFluid().getLocalizedName(tanks[0].fluid) + " - " + tanks[0].fluid.amount + " / " + tanks[0].capacity); } else { data.add("Fluid Tank: Empty - 0 / " + tanks[0].capacity); } } else { for (int i = 0; i < tanks.length; ++i) { if (tanks[i].fluid != null && tanks[i].fluid.amount > 0) { data.add("Fluid Tank " + i + ": " + tanks[i].fluid.getFluid().getLocalizedName(tanks[i].fluid) + " - " + tanks[i].fluid.amount + " / " + tanks[i].capacity); } else { data.add("Fluid Tank " + i + ": Empty - 0 / " + tanks[i].capacity); } } } } }
public int getComparatorInputOverride(final World world, final int x, final int y, final int z, final int side) { if (!(world.getTileEntity(x, y, z) instanceof TileEntityDrum)) { return 0; } final TileEntityDrum drum = (TileEntityDrum)world.getTileEntity(x, y, z); final FluidTankInfo tank = drum.getTankInfo(ForgeDirection.UP)[0]; if (tank == null || tank.fluid == null || tank.fluid.amount == 0) { return 0; } double t = tank.fluid.amount * 14.0 / tank.capacity; if (t < 0.0) { t = 0.0; } if (t > 15.0) { t = 14.0; } return (int)Math.floor(t) + 1; }
public static boolean isValidTileEntity(final TileEntity inv, final int side) { if (inv == null) { return false; } final ForgeDirection forgeSide = ForgeDirection.getOrientation(side); final String classname = inv.getClass().toString(); if (classname.contains("thermalexpansion") && classname.contains("conduit")) { return false; } if (inv instanceof IFluidHandler) { final FluidTankInfo[] t = ((IFluidHandler)inv).getTankInfo(forgeSide); if (t != null && t.length != 0) { return true; } } if (inv instanceof IInventory && ((IInventory)inv).getSizeInventory() > 0) { if (!(inv instanceof ISidedInventory)) { return true; } final int[] t2 = ((ISidedInventory)inv).getAccessibleSlotsFromSide(side); if (t2 != null && t2.length != 0) { return true; } } return isRFEnergy(inv, forgeSide); }
public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side) { if(tile instanceof ITransmitterTile || !(tile instanceof IFluidHandler)) return false; IFluidHandler container = (IFluidHandler)tile; FluidTankInfo[] infoArray = container.getTankInfo(side.getOpposite()); if(container.canDrain(side.getOpposite(), FluidRegistry.WATER) || container.canFill(side.getOpposite(), FluidRegistry.WATER)) //I hesitate to pass null to these. { return true; } else if(infoArray != null && infoArray.length > 0) { for(FluidTankInfo info : infoArray) { if(info != null) { return true; } } } return false; }
@EventHandler public void init(FMLInitializationEvent event) { PacketHandler.init(); Recipes.init(); proxy.registerTileEntities(); proxy.registerRenderers(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); FMLCommonHandler.instance().bus().register(new TickHandler()); LuaType.registerTypeConverter(new ConverterFluidTankInfo()); LuaType.registerTypeConverter(new ConverterForgeDirection()); LuaType.registerTypeConverter(new ConverterAdvancedItemStack()); LuaType.registerClassToNameMapping(FluidTankInfo.class, "fluid_tank"); LuaType.registerClassToNameMapping(ForgeDirection.class, "direction"); LuaType.registerClassToNameMapping(AdvancedItemStack.class, "item_with_nbt"); }
public CardState updateLiquid(World world, ICardWrapper card, int range) { ChunkCoordinates target = card.getTarget(); if(target == null) return CardState.NO_TARGET; FluidTankInfo storage = LiquidStorageHelper.getStorageAt(world, target.posX, target.posY, target.posZ); if (storage != null) { int capacity = storage.capacity; int amount = 0; int liquidId = 0; NBTTagCompound liquidTag = null; if (storage.fluid != null) { amount = storage.fluid.amount; if (storage.fluid.getFluidID() != 0 && amount > 0) { liquidId = storage.fluid.getFluidID(); liquidTag = storage.fluid.tag; } } card.setInt("capacity", capacity); card.setInt("amount", amount); card.setInt("liquidId", liquidId); card.setTag("liquidTag", liquidTag); card.setDouble("range_trigger_amount", (double)amount); return CardState.OK; } else { return CardState.NO_TARGET; } }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if (!this.isInProgress() || copyStack == null) return null; FluidTankInfo[] ret = new FluidTankInfo[1]; for (Type t : Type.values()) { int num = copyStack.stackTagCompound.getInteger(t.name()); if (num > 0) { ArrayUtils.add(ret, new FluidTankInfo(new FluidStack(MCFluids.fluidsEnumList.get(t), 0), num)); } } return ret; }
@Override public void renderStatic(float size, TileEntity te){ Shape2.render(size); Shape3b.render(size); Shape1.render(size); Shape3.render(size); Shape4b.render(size); Shape4.render(size); if(te != null) { TileEntityPlasticMixer mixer = (TileEntityPlasticMixer)te; FluidTankInfo info = mixer.getTankInfo(null)[0]; if(info.fluid != null && info.fluid.amount > 10) { float percentageFull = (float)info.fluid.amount / info.capacity; RenderInfo renderInfo = new RenderInfo(-6 / 16F + 0.01F, 22 / 16F - percentageFull * 13.999F / 16F, -6 / 16F + 0.01F, 6 / 16F - 0.01F, 22 / 16F, 6 / 16F - 0.01F); RenderUtils.INSTANCE.renderLiquid(info, renderInfo, mixer.getWorldObj()); } } }
public void renderLiquid(FluidTankInfo info, RenderInfo renderInfo, World worldObj){ if(info.fluid.getFluid().getBlock() != null) { renderInfo.baseBlock = info.fluid.getFluid().getBlock(); } else { renderInfo.baseBlock = Blocks.water; } renderInfo.texture = info.fluid.getFluid().getIcon(info.fluid); FMLClientHandler.instance().getClient().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); // Tessellator.instance.setColorOpaque_I(); int color = info.fluid.getFluid().getColor(info.fluid); int red = color >> 16 & 255; int green = color >> 8 & 255; int blue = color & 255; GL11.glColor4ub((byte)red, (byte)green, (byte)blue, (byte)255); RenderUtils.INSTANCE.renderBlock(renderInfo, worldObj, 0, 0, 0, false, true); }
public static FluidTankProperties[] convert(FluidTankInfo[] fluidTankInfos) { FluidTankProperties[] properties = new FluidTankProperties[fluidTankInfos.length]; for (int i = 0; i < fluidTankInfos.length; i++) { FluidTankInfo info = fluidTankInfos[i]; properties[i] = new FluidTankProperties(info.fluid, info.capacity); } return properties; }
public WidgetTank(final FluidTankInfo tankInfo, final int x, final int y, final int shape) { this.curFluid = null; this.curCapacity = 0; this.tankInfo = tankInfo; this.shape = shape; this.x = x; this.y = y; }
public DynamicContainerGenerator(final IInventory player, final TileEntityGenerator gen) { this.genFurnace = null; this.gen = gen; if (this.gen instanceof TileEntityGeneratorFurnace) { this.genFurnace = (TileEntityGeneratorFurnace)this.gen; } this.widgets.add(new WidgetText(5, 5, BlockGenerator.names[gen.getBlockMetadata()] + " Generator", 162)); int x = 5; final int y = 19; if (gen instanceof IInventory) { final IInventory inv = (IInventory)gen; for (int i = 0; i < inv.getSizeInventory(); ++i) { final IWidget widg = new WidgetSlot(inv, i, x, y); this.widgets.add(widg); x += widg.getW() + 5; } } if (gen instanceof IFluidHandler) { final FluidTankInfo[] arr$; final FluidTankInfo[] tanks = arr$ = gen.getTankInfo(null); for (final FluidTankInfo tank : arr$) { final IWidget widg2 = new WidgetTank(tank, x, y, 2); this.widgets.add(widg2); x += widg2.getW() + 5; } } final IWidget w = new WidgetTextCooldown(gen, x, y, 120); this.widgets.add(w); x += w.getW() + 5; this.widgets.add(new WidgetEnergy(gen, ForgeDirection.UP, x, y)); this.cropAndAddPlayerSlots(player); this.validate(); }
public FluidTankInfo[] getTankInfo(final ForgeDirection from) { final FluidTankInfo[] info = new FluidTankInfo[this.getTanks().length]; for (int i = 0; i < this.getTanks().length; ++i) { info[i] = this.getTanks()[i].getInfo(); } return info; }
@Override default FluidTankInfo[] getTankInfo(EnumFacing from) { if (hasOriginTE()) { return getOriginTE().getStructureTankInfo(from, getLocal()); } return emptyFluidTankInfo; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { FluidTankInfo[] tankInfo = new FluidTankInfo[] {}; int metaside = this.getBlockMetadata() - BlockMachine2.OXYGEN_STORAGE_MODULE_METADATA + 2; int side = from.ordinal(); if (metaside == side && GalacticraftCore.isPlanetsLoaded) { tankInfo = new FluidTankInfo[] { new FluidTankInfo(new FluidStack(AsteroidsModule.fluidLiquidOxygen, (int) (this.getOxygenStored() * Constants.LOX_GAS_RATIO)), (int) (OXYGEN_CAPACITY * Constants.LOX_GAS_RATIO)) }; } return tankInfo; }
public FluidTankInfo[] getTankInfo(EnumFacing from) { if(ModFluids.fluidXpJuice == null) { return new FluidTankInfo[0]; } return new FluidTankInfo[] { new FluidTankInfo(new FluidStack(ModFluids.fluidXpJuice, getFluidAmount()), getCapacity()) }; }
@Override public FluidTankInfo getInfo() { FluidStack fluid = this.getFluid(); int capacity2 = this.getCapacity() - this.getFluidAmount(); if (fluid != null) capacity2 += fluid.amount; return new FluidTankInfo(fluid, capacity2); }
public FluidTankInfo[] getAllTankInfo(EnumFacing arg0) { FluidTankInfo[] info = new FluidTankInfo[bigboiler.length]; for(int i = 0; i < bigboiler.length; i++) if(bigboiler[i] != null) if(worldObj.getTileEntity(bigboiler[i]) != null) info[i] = ((TileEntityBoiler)worldObj.getTileEntity(bigboiler[i])).waterTank.getInfo(); return info; }
@Override public void onNexusExportCall(TileEntityTransporter nexus) { ForgeDirection nexusOrientation = ForgeDirection.getOrientation(nexus.getBlockMetadata()); FluidTankInfo[] tankInfo = nexus.getTankInfo(nexusOrientation); FluidStack nexusFluid = tankInfo[0].fluid; if (nexusFluid != null && nexusFluid.amount > 0) { TileEntity tile = nexus.getAttachedTileEntity(); if (tile instanceof IFluidHandler) { IFluidHandler inv = (IFluidHandler) tile; if (inv.canFill(nexusOrientation, nexusFluid.getFluid())) { FluidStack toFill = new FluidStack(nexusFluid.getFluid(), Math.min(nexusFluid.amount, nexus.isHighCapacity() ? ConfigValues.highCapacityFluidPickup : ConfigValues.standardFluidPickup)); int filled = inv.fill(nexusOrientation, toFill, true); nexus.drain(nexusOrientation, filled, true); if (filled != 0) { nexus.resetCounter(); return; } } } attemptTeleport(nexus, nexusOrientation); } }
private boolean attemptTeleport(TileEntityTransporter nexus, ForgeDirection orientation) { FluidTankInfo[] tankInfo = nexus.getTankInfo(orientation); FluidStack nexusFluid = tankInfo[0].fluid; if (nexusFluid != null) { Collections.sort(nexus.getExportLocations()); for (DistanceHandler loc : nexus.getExportLocations()) { TileEntity tile = nexus.getWorldObj().getTileEntity(loc.getX(), loc.getY(), loc.getZ()); if (tile instanceof TileEntityTransporter) // should always be true { TileEntityTransporter transporter = (TileEntityTransporter) tile; if (transporter.getActiveCore() != null && transporter.getActiveCore().canHandleFluids()) { FluidStack transporterFluid = transporter.getTankInfo(orientation)[0].fluid; if (transporterFluid == null || transporterFluid.containsFluid(nexusFluid)) { FluidStack toFill = new FluidStack(nexusFluid.getFluid(), Math.min(nexusFluid.amount, nexus.isHighCapacity() ? ConfigValues.highCapacityFluidPickup : ConfigValues.standardFluidPickup)); int filled = transporter.fill(orientation, toFill, true); nexus.drain(orientation, filled, true); if (filled > 0) { transporter.resetCounter(); nexus.resetCounter(); } } } } } } return false; }
public static boolean doPull(IFluidHandler into, ForgeDirection fromDir, int maxVolume) { TileEntity te = (TileEntity) into; BlockCoord loc = new BlockCoord(te).getLocation(fromDir); IFluidHandler target = FluidUtil.getFluidHandler(te.getWorldObj(), loc); if (target != null) { FluidTankInfo[] infos = target.getTankInfo(fromDir.getOpposite()); if (infos != null) { for (FluidTankInfo info : infos) { if (info.fluid != null && info.fluid.amount > 0) { if (into.canFill(fromDir, info.fluid.getFluid())) { FluidStack canPull = info.fluid.copy(); canPull.amount = Math.min(maxVolume, canPull.amount); FluidStack drained = target.drain(fromDir.getOpposite(), canPull, false); if (drained != null && drained.amount > 0) { int filled = into.fill(fromDir, drained, false); if (filled > 0) { drained = target.drain(fromDir.getOpposite(), filled, true); into.fill(fromDir, drained, true); return true; } } } } } } } return false; }
@Override public FluidTankInfo[] getTankInfo() { if (isPassivelyCooled()) { return emptyTankInfo; } return coolantContainer.getTankInfo(-1); }
public FluidTankInfo[] getTankInfo() { FluidTankInfo[] infos = new FluidTankInfo[NUM_TANKS]; for (int i = 0; i < NUM_TANKS; i++) { infos[i] = tanks[i].getInfo(); } return infos; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { int metadata = getRotationMeta(); if(CoordHelper.rotateForgeDirection(ForgeDirection.NORTH, metadata).equals(from)) { return null; } return new FluidTankInfo[] { new FluidTankInfo(this.fuelTank) }; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { TileEntityMothershipEngineAbstract tile = this.getMasterTile(); if(tile == null) { return null; } return tile.getTankInfo(from); }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection direction) { if(direction == ForgeDirection.getOrientation(1)) { return new FluidTankInfo[] {fluidTank.getInfo()}; } return PipeUtils.EMPTY; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { SideData data = configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing); return data.getFluidTankInfo(this); }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(master == null) { return PipeUtils.EMPTY; } return new FluidTankInfo[] {new FluidTankInfo(master.inputTank), new FluidTankInfo(master.outputTank)}; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(from == MekanismUtils.getRight(facing)) { return new FluidTankInfo[] {fluidTank.getInfo()}; } return PipeUtils.EMPTY; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(from == ForgeDirection.UP) { return new FluidTankInfo[] {fluidTank.getInfo()}; } return PipeUtils.EMPTY; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection direction) { if(direction == ForgeDirection.UP) { return new FluidTankInfo[] {fluidTank.getInfo()}; } return PipeUtils.EMPTY; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(getConnectionType(from) != ConnectionType.NONE) { return new FluidTankInfo[] {buffer.getInfo()}; } return new FluidTankInfo[0]; }
public FluidTankInfo[] getFluidTankInfo(ITankManager manager) { Object[] tanks = manager.getTanks(); List<FluidTankInfo> infos = new ArrayList<FluidTankInfo>(); for(int slot : availableSlots) { if(slot <= tanks.length-1 && tanks[slot] instanceof IFluidTank) { infos.add(((IFluidTank)tanks[slot]).getInfo()); } } return infos.toArray(new FluidTankInfo[] {}); }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(from == ForgeDirection.getOrientation(facing)) { return PipeUtils.EMPTY; } return new FluidTankInfo[] {lavaTank.getInfo()}; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(getReactor() == null) { return new FluidTankInfo[0]; } return new FluidTankInfo[] {getReactor().getWaterTank().getInfo(), getReactor().getSteamTank().getInfo()}; }
@Override @Nonnull public FluidTankInfo[] getTankInfo(@Nullable ForgeDirection from) { if (from == null || isSideDisabled(from.ordinal())) { return new FluidTankInfo[0]; } return new FluidTankInfo[] { inputTank.getInfo(), outputTank.getInfo() }; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { if (sides.isDisabled(from)) return new FluidTankInfo[] {}; else return new FluidTankInfo[] { tank.getInfo() }; }
public FluidTankInfo getIronTank(TileEntity entity) { if (!_isApiAvailable || entity == null) return null; try { if (_tankTile.isAssignableFrom(entity.getClass())) { Method method = entity.getClass().getMethod("getTank"); FluidTank tank = (FluidTank) method.invoke(entity); if (tank != null) return tank.getInfo(); } return null; }catch (Exception e){ return null; } }
public static FluidTankInfo getStorageAt(World world, int x, int y, int z) { if (world == null) return null; TileEntity entity = world.getTileEntity(x, y, z); if (entity != null && entity instanceof IFluidHandler) { FluidTankInfo[] tanks = ((IFluidHandler) entity).getTankInfo(ForgeDirection.UNKNOWN); if (tanks == null || tanks.length == 0) return null; return tanks[0]; } return IC2NuclearControl.instance.crossRailcraft.getIronTank(entity); }