net.minecraftforge.fluids.FluidTank Java Examples
The following examples show how to use
net.minecraftforge.fluids.FluidTank.
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: ItemHelperTests.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Test public void test_extractFluidsFromTanks() { FluidTank tank1 = new FluidTank(FluidRegistry.WATER, 1000, 10000); FluidTank tank2 = new FluidTank(FluidRegistry.LAVA, 1000, 10000); ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2), Lists.newArrayList(FluidRegistry.getFluidStack("water", 400), FluidRegistry.getFluidStack("lava", 300))); assertEquals(600, tank1.getFluidAmount()); assertEquals(700, tank2.getFluidAmount()); ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2), Lists.newArrayList(FluidRegistry.getFluidStack("lava", 400), FluidRegistry.getFluidStack("water", 300))); assertEquals(300, tank1.getFluidAmount()); assertEquals(300, tank2.getFluidAmount()); }
Example #2
Source File: GuiTFBattery.java From TofuCraftReload with MIT License | 6 votes |
/** * Draws the background layer of this container (behind the items). */ @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { TextureManager manager = this.mc.getTextureManager(); manager.bindTexture(TXTURE); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); // int var7; if (this.tileBattery.inputTank.getFluid() != null) { FluidTank fluidTank = this.tileBattery.inputTank; int heightInd = (int) (72 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity())); if (heightInd > 0) { ClientUtils.drawRepeatedFluidSprite(fluidTank.getFluid(), var5 + 167 - 47 - heightInd, var6 + 54, heightInd, 16f); } } }
Example #3
Source File: RecipeMapCategory.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
public RecipeMapCategory(RecipeMap<?> recipeMap, IGuiHelper guiHelper) { this.recipeMap = recipeMap; FluidTank[] importFluidTanks = new FluidTank[recipeMap.getMaxFluidInputs()]; for (int i = 0; i < importFluidTanks.length; i++) importFluidTanks[i] = new FluidTank(16000); FluidTank[] exportFluidTanks = new FluidTank[recipeMap.getMaxFluidOutputs()]; for (int i = 0; i < exportFluidTanks.length; i++) exportFluidTanks[i] = new FluidTank(16000); this.modularUI = recipeMap.createJeiUITemplate( (importItems = new ItemStackHandler(recipeMap.getMaxInputs())), (exportItems = new ItemStackHandler(recipeMap.getMaxOutputs())), (importFluids = new FluidTankList(false, importFluidTanks)), (exportFluids = new FluidTankList(false, exportFluidTanks)) ).build(new BlankUIHolder(), Minecraft.getMinecraft().player); this.modularUI.initWidgets(); this.backgroundDrawable = guiHelper.createBlankDrawable(modularUI.getWidth(), modularUI.getHeight() * 2 / 3); }
Example #4
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void addDebugInfo(List<String> debugInfo) { debugInfo.add("IsController: " + isTankController()); debugInfo.add("ControllerPos: " + controllerPos); List<BlockPos> connectedTanks = new ArrayList<>(this.connectedTanks); while (!connectedTanks.isEmpty()) { int startIndex = Math.min(4, connectedTanks.size()); debugInfo.add("ConnectedBlocks: " + connectedTanks.subList(0, startIndex)); if (connectedTanks.size() > startIndex) { connectedTanks = connectedTanks.subList(startIndex, connectedTanks.size()); } else break; } debugInfo.add("Tank fluid: " + multiblockFluidTank.getFluidAmount() + "/" + multiblockFluidTank.getCapacity() + " #" + multiblockFluidTank.hashCode()); FluidTank actualTankFluid = getActualFluidTank(); debugInfo.add("Actual Tank fluid: " + actualTankFluid.getFluidAmount() + "/" + actualTankFluid.getCapacity() + " #" + actualTankFluid.hashCode()); debugInfo.add("FluidLevel: " + getFluidLevelForTank(getPos())); debugInfo.add("FluidInTank: " + getFluidStoredInTank(getPos())); }
Example #5
Source File: SemiBlockLogistics.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void addDrops(List<ItemStack> drops){ super.addDrops(drops); boolean shouldAddTag = false; for(int i = 0; i < filters.getSizeInventory(); i++) { if(filters.getStackInSlot(i) != null) {//Only set a tag when there are requests. shouldAddTag = true; break; } } for(FluidTank fluidFilter : fluidFilters) { if(fluidFilter.getFluidAmount() > 0) { shouldAddTag = true; break; } } if(invisible) shouldAddTag = true; if(shouldAddTag) { ItemStack drop = drops.get(0); NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); drop.setTagCompound(tag); } }
Example #6
Source File: MultiblockTurbine.java From BigReactors with MIT License | 5 votes |
public MultiblockTurbine(World world) { super(world); updatePlayers = new HashSet<EntityPlayer>(); ticksSinceLastUpdate = 0; tanks = new FluidTank[NUM_TANKS]; for(int i = 0; i < NUM_TANKS; i++) tanks[i] = new FluidTank(TANK_SIZE); attachedControllers = new HashSet<IMultiblockPart>(); attachedRotorBearings = new HashSet<TileEntityTurbineRotorBearing>(); attachedPowerTaps = new HashSet<TileEntityTurbinePowerTap>(); attachedTickables = new HashSet<ITickableMultiblockPart>(); attachedRotorShafts = new HashSet<TileEntityTurbineRotorPart>(); attachedRotorBlades = new HashSet<TileEntityTurbineRotorPart>(); attachedGlass = new HashSet<TileEntityTurbinePartGlass>(); energyStored = 0f; active = false; inductorEngaged = true; ventStatus = VentStatus.VentOverflow; rotorEnergy = 0f; maxIntakeRate = MAX_PERMITTED_FLOW; bladeSurfaceArea = 0; rotorMass = 0; coilSize = 0; energyGeneratedLastTick = 0f; fluidConsumedLastTick = 0; rotorEfficiencyLastTick = 1f; foundCoils = new HashSet<CoordTriplet>(); rpmUpdateTracker = new FloatUpdateTracker(100, 5, 10f, 100f); // Minimum 10RPM difference for slow updates, if change > 100 RPM, update every 5 ticks }
Example #7
Source File: GuiTFAdvancedAggreagator.java From TofuCraftReload with MIT License | 5 votes |
/** * Draws the background layer of this container (behind the items). */ @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { TextureManager manager = this.mc.getTextureManager(); manager.bindTexture(TXTURE); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int var7,var8; var8 = this.getEnergyScaled(55); this.drawTexturedModalRect(var5 + 88, var6 + 53, 176, 31, var8, 8); // Progress arrow var7 = this.getProgressScaled(55); this.drawTexturedModalRect(var5 + 62, var6 + 12, 176, 31, var7, 8); if (this.tileFurnace.getTank().getFluid() != null) { FluidTank fluidTank = this.tileFurnace.getTank(); int heightInd = (int) (55 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity())); if (heightInd > 0) { this.drawTexturedModalRect(var5 + 18, var6 + 66 - heightInd, 176, 39, 9, heightInd); } } }
Example #8
Source File: GuiTFStorage.java From TofuCraftReload with MIT License | 5 votes |
/** * Draws the background layer of this container (behind the items). */ @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { TextureManager manager = this.mc.getTextureManager(); manager.bindTexture(TXTURE); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int var7,var8; var8 = this.getEnergyScaled(55); this.drawTexturedModalRect(var5 + 87, var6 + 34, 176, 31, var8 , 8); // Progress arrow var7 = this.tileFurnace.getProgressScaled(24); this.drawTexturedModalRect(var5 + 53, var6 + 30, 176, 15, var7 + 1, 16); if (this.tileFurnace.getTank().getFluid() != null) { FluidTank fluidTank = this.tileFurnace.getTank(); int heightInd = (int) (41 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity())); if (heightInd > 0) { this.drawTexturedModalRect(var5 + 9, var6 + 52 - heightInd, 176, 40, 9, heightInd); } } }
Example #9
Source File: GuiTFAggreagator.java From TofuCraftReload with MIT License | 5 votes |
/** * Draws the background layer of this container (behind the items). */ @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { TextureManager manager = this.mc.getTextureManager(); manager.bindTexture(TXTURE); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int var7,var8; var8 = this.getEnergyScaled(55); this.drawTexturedModalRect(var5 + 61, var6 + 58, 176, 31, var8 , 8); // Progress arrow var7 = this.getProgressScaled(55); this.drawTexturedModalRect(var5 + 62, var6 + 16, 176, 31, var7, 8); if (this.tileFurnace.getTank().getFluid() != null) { FluidTank fluidTank = this.tileFurnace.getTank(); int heightInd = (int) (55 * ((float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity())); if (heightInd > 0) { this.drawTexturedModalRect(var5 + 18, var6 + 66 - heightInd, 176, 39, 9, heightInd); } } }
Example #10
Source File: NetworkUtils.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private static SyncedField getSyncedFieldForField(Field field, Object te){ if(int.class.isAssignableFrom(field.getType())) return new SyncedInt(te, field); if(float.class.isAssignableFrom(field.getType())) return new SyncedFloat(te, field); if(double.class.isAssignableFrom(field.getType())) return new SyncedDouble(te, field); if(boolean.class.isAssignableFrom(field.getType())) return new SyncedBoolean(te, field); if(String.class.isAssignableFrom(field.getType())) return new SyncedString(te, field); if(field.getType().isEnum()) return new SyncedEnum(te, field); if(ItemStack.class.isAssignableFrom(field.getType())) return new SyncedItemStack(te, field); if(FluidTank.class.isAssignableFrom(field.getType())) return new SyncedFluidTank(te, field); return null; }
Example #11
Source File: TileEntityPoweredInventoryFluid.java From BigReactors with MIT License | 5 votes |
public TileEntityPoweredInventoryFluid() { super(); tanks = new FluidTank[getNumTanks()]; tankExposureCache = new FluidTank[getNumTanks()][1]; for(int i = 0; i < getNumTanks(); i++) { tanks[i] = new FluidTank(getTankSize(i)); tankExposureCache[i][0] = tanks[i]; } }
Example #12
Source File: NetworkUtils.java From Signals with GNU General Public License v3.0 | 5 votes |
private static SyncedField<?> getSyncedFieldForField(Field field, Object te){ if(int.class.isAssignableFrom(field.getType())) return new SyncedInt(te, field); if(float.class.isAssignableFrom(field.getType())) return new SyncedFloat(te, field); if(double.class.isAssignableFrom(field.getType())) return new SyncedDouble(te, field); if(boolean.class.isAssignableFrom(field.getType())) return new SyncedBoolean(te, field); if(String.class.isAssignableFrom(field.getType())) return new SyncedString(te, field); if(field.getType().isEnum()) return new SyncedEnum(te, field); if(ItemStack.class.isAssignableFrom(field.getType())) return new SyncedItemStack(te, field); if(FluidTank.class.isAssignableFrom(field.getType())) return new SyncedFluidTank(te, field); return null; }
Example #13
Source File: DiffuserHelper.java From EmergingTechnology with MIT License | 5 votes |
private static int doBoost(World world, BlockPos pos, FluidTank gasHandler, int probability, int range) { int plantsBoosted = 0; for (EnumFacing facing : EnumFacing.HORIZONTALS) { for (int i = 1; i < range + 1; i++) { // Not enough gas if (gasHandler .getFluidAmount() < EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserGasBaseUsage) { break; } BlockPos position = pos.offset(facing, i); IBlockState blockState = world.getBlockState(position); Block block = blockState.getBlock(); if (PlantHelper.isPlantBlock(blockState.getBlock())) { boolean success = growBlock(world, blockState, block, position, gasHandler, probability); if (success) plantsBoosted += 1; } else if (!blockState.getBlock().isFullBlock(blockState)) { continue; } else { break; } } } return plantsBoosted; }
Example #14
Source File: DiffuserHelper.java From EmergingTechnology with MIT License | 5 votes |
private static boolean growBlock(World world, IBlockState blockState, Block block, BlockPos position, FluidTank gasHandler, int probability) { boolean isValidPlant = false; if (!PlantHelper.isCropAtPositionReadyForHarvest(world, position)) { isValidPlant = true; if (rollForGrow(probability) == true) { block.updateTick(world, position, blockState, new Random()); gasHandler.drain(EmergingTechnologyConfig.HYDROPONICS_MODULE.DIFFUSER.diffuserGasBaseUsage, true); } } return isValidPlant; }
Example #15
Source File: WorkableTieredMetaTileEntity.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected FluidTankList createExportFluidHandler() { if (workable == null) return new FluidTankList(false); FluidTank[] fluidExports = new FluidTank[workable.recipeMap.getMaxFluidOutputs()]; for (int i = 0; i < fluidExports.length; i++) { fluidExports[i] = new FluidTank(getOutputTankCapacity(i)); } return new FluidTankList(false, fluidExports); }
Example #16
Source File: FluidTankList.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void deserializeNBT(NBTTagCompound nbt) { NBTTagList tanks = nbt.getTagList("Tanks", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < Math.min(fluidTanks.size(), nbt.getInteger("TankAmount")); i++) { NBTBase nbtTag = tanks.get(i); IFluidTank fluidTank = fluidTanks.get(i); if (fluidTank instanceof FluidTank) { ((FluidTank) fluidTank).readFromNBT((NBTTagCompound) nbtTag); } else if (fluidTank instanceof INBTSerializable) { ((INBTSerializable) fluidTank).deserializeNBT(nbtTag); } } }
Example #17
Source File: MultiblockTurbineSimulator.java From reactor_simulator with MIT License | 5 votes |
public MultiblockTurbineSimulator(World world) { super(world); updatePlayers = new HashSet<EntityPlayer>(); ticksSinceLastUpdate = 0; tanks = new FluidTank[NUM_TANKS]; for (int i = 0; i < NUM_TANKS; i++) { tanks[i] = new FluidTank(TANK_SIZE); } attachedControllers = new HashSet<IMultiblockPart>(); attachedRotorBearings = new HashSet<TileEntityTurbineRotorBearing>(); attachedPowerTaps = new HashSet<TileEntityTurbinePowerTap>(); attachedTickables = new HashSet<ITickableMultiblockPart>(); attachedRotorShafts = new HashSet<TileEntityTurbineRotorPart>(); attachedRotorBlades = new HashSet<TileEntityTurbineRotorPart>(); attachedGlass = new HashSet<TileEntityTurbinePartGlass>(); energyStored = 0f; active = false; inductorEngaged = true; ventStatus = VentStatus.VentOverflow; rotorEnergy = 0f; maxIntakeRate = MAX_PERMITTED_FLOW; bladeSurfaceArea = 0; rotorMass = 0; coilSize = 0; energyGeneratedLastTick = 0f; fluidConsumedLastTick = 0; rotorEfficiencyLastTick = 1f; foundCoils = new HashSet<CoordTriplet>(); rpmUpdateTracker = new FloatUpdateTracker(100, 5, 10f, 100f); // Minimum 10RPM difference for slow updates, if change > 100 RPM, update every 5 ticks }
Example #18
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private FluidTank getActualFluidTank() { if (controllerPos != null) { MetaTileEntityTank metaTileEntityTank = getControllerEntity(); return metaTileEntityTank == null ? new FluidTank(0) : metaTileEntityTank.getActualFluidTank(); } else { return multiblockFluidTank; } }
Example #19
Source File: MetaTileEntityQuantumTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public int getActualComparatorValue() { FluidTank fluidTank = this.fluidTank; int fluidAmount = fluidTank.getFluidAmount(); int maxCapacity = fluidTank.getCapacity(); float f = fluidAmount / (maxCapacity * 1.0f); return MathHelper.floor(f * 14.0f) + (fluidAmount > 0 ? 1 : 0); }
Example #20
Source File: MetaTileEntityQuantumTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void initializeInventory() { super.initializeInventory(); this.fluidTank = new FluidTank(maxFluidCapacity); this.fluidInventory = fluidTank; this.importFluids = new FluidTankList(false, fluidTank); this.exportFluids = new FluidTankList(false, fluidTank); }
Example #21
Source File: TileCrucible.java From ExNihiloAdscensio with MIT License | 4 votes |
public TileCrucible() { tank = new FluidTank(4*Fluid.BUCKET_VOLUME); tank.setCanFill(false); itemHandler = new CrucibleItemHandler(); itemHandler.setTe(this); }
Example #22
Source File: BarrelModeFluidTransform.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public FluidTank getFluidHandler(TileBarrel barrel) { return null; }
Example #23
Source File: SyncedField.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override protected void setValueForArray(Object array, int index, FluidStack value) { ((FluidTank[])array)[index].setFluid(value); }
Example #24
Source File: WidgetFluidStack.java From Signals with GNU General Public License v3.0 | 4 votes |
public WidgetFluidStack(int id, int x, int y, FluidStack stack){ super(id, x, y); tank = new FluidTank(stack.amount); tank.fill(stack, true); }
Example #25
Source File: SyncedField.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override protected void injectValue(Field field, Object te, FluidStack value) throws Exception{ FluidTank tank = (FluidTank)field.get(te); tank.setFluid(value); }
Example #26
Source File: SyncedField.java From Signals with GNU General Public License v3.0 | 4 votes |
@Override protected FluidStack getValueForArray(Object array, int index){ return ((FluidTank[])array)[index].getFluid(); }
Example #27
Source File: BarrelModeCompost.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public FluidTank getFluidHandler(TileBarrel barrel) { return null; }
Example #28
Source File: BarrelModeBlock.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public FluidTank getFluidHandler(TileBarrel barrel) { return null; }
Example #29
Source File: FluidPipeFluidHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
protected FluidTank getNetFluidTank() { FluidPipeNet fluidPipeNet = getFluidPipeNet(); return fluidPipeNet == null ? null : fluidPipeNet.getFluidNetTank(); }
Example #30
Source File: BarrelModeMobSpawn.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public FluidTank getFluidHandler(TileBarrel barrel) { return null; }