From cac24a86730d082c8db7463c6bde6dfc99ae53f4 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 16 Sep 2014 13:53:57 -0700 Subject: [PATCH 1/6] Fixes #190. Stop crash if a mod with a required version isn't loaded --- src/main/java/forestry/core/proxy/ProxyCommon.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index fce377bab..009c53b9b 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -243,6 +243,9 @@ public class ProxyCommon { } public boolean isModLoaded(String modname, String versionRangeString) { + if (!isModLoaded(modname)) + return false; + if (versionRangeString != null) { ModContainer mod = Loader.instance().getIndexedModList().get(modname); ArtifactVersion modVersion = mod.getProcessedVersion(); @@ -254,7 +257,7 @@ public class ProxyCommon { return false; } - return isModLoaded(modname); + return true; } public Object instantiateIfModLoaded(String modname, String className) { From 62af4d6f474666b73da2ee41f29a71473325a9ee Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 16 Sep 2014 14:43:46 -0700 Subject: [PATCH 2/6] Fixes #191. Allow tropical trees to grow in tropical biomes --- .../arboriculture/genetics/GrowthProviderTropical.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java index d9eba5779..2c3125665 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java @@ -12,19 +12,20 @@ package forestry.arboriculture.genetics; import java.util.EnumSet; -import forestry.core.utils.StringUtil; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.World; import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.ITreeGenome; +import forestry.core.utils.StringUtil; public class GrowthProviderTropical extends GrowthProvider { @Override public EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, int xPos, int yPos, int zPos) { EnumGrowthConditions light = getConditionFromLight(world, xPos, yPos, zPos); - EnumGrowthConditions moisture = getConditionsFromRainfall(world, xPos, yPos, zPos, 0.9f, 2.0f); - EnumGrowthConditions temperature = getConditionsFromTemperature(world, xPos, yPos, zPos, 1.2f, 1.9f); + EnumGrowthConditions moisture = getConditionsFromRainfall(world, xPos, yPos, zPos, BiomeGenBase.jungle.rainfall, 2.0f); + EnumGrowthConditions temperature = getConditionsFromTemperature(world, xPos, yPos, zPos, BiomeGenBase.jungle.temperature, BiomeGenBase.desert.temperature - 0.1f); EnumSet conditions = EnumSet.of(light, moisture, temperature); From ce1d24952f0523aa4e8b767fe90046690a118ca0 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 16 Sep 2014 16:23:20 -0700 Subject: [PATCH 3/6] Renamed new GUI elements so that texture packs don't use the old version --- src/main/java/forestry/core/gui/GuiAlyzer.java | 2 +- .../java/forestry/factory/gui/GuiWorktable.java | 2 +- src/main/java/forestry/mail/gui/GuiTrader.java | 2 +- .../textures/gui/{beealyzer.png => beealyzer2.png} | Bin .../gui/{mailtrader.png => mailtrader2.png} | Bin .../textures/gui/{worktable.png => worktable2.png} | Bin 6 files changed, 3 insertions(+), 3 deletions(-) rename src/main/resources/assets/forestry/textures/gui/{beealyzer.png => beealyzer2.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/gui/{mailtrader.png => mailtrader2.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/gui/{worktable.png => worktable2.png} (100%) mode change 100755 => 100644 diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index e082aeb95..da6a4261d 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -56,7 +56,7 @@ public abstract class GuiAlyzer extends GuiForestry { protected HashMap iconStacks = new HashMap(); public GuiAlyzer(ISpeciesRoot speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, int pageMax, int pageSize) { - super(Defaults.TEXTURE_PATH_GUI + "/beealyzer.png", container); + super(Defaults.TEXTURE_PATH_GUI + "/beealyzer2.png", container); xSize = 246; ySize = 238; diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index b1b8495d7..dc1458003 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -103,7 +103,7 @@ public class GuiWorktable extends GuiForestryTitled { protected ContainerWorktable container; public GuiWorktable(EntityPlayer player, TileWorktable tile) { - super(Defaults.TEXTURE_PATH_GUI + "/worktable.png", new ContainerWorktable(player, tile), tile); + super(Defaults.TEXTURE_PATH_GUI + "/worktable2.png", new ContainerWorktable(player, tile), tile); ySize = 218; worktable = tile; diff --git a/src/main/java/forestry/mail/gui/GuiTrader.java b/src/main/java/forestry/mail/gui/GuiTrader.java index 4ce91a6b3..5e9999436 100755 --- a/src/main/java/forestry/mail/gui/GuiTrader.java +++ b/src/main/java/forestry/mail/gui/GuiTrader.java @@ -22,7 +22,7 @@ public class GuiTrader extends GuiForestry { private final ContainerTrader container; public GuiTrader(InventoryPlayer inventoryplayer, MachineTrader tile) { - super(Defaults.TEXTURE_PATH_GUI + "/mailtrader.png", new ContainerTrader(inventoryplayer, tile), tile); + super(Defaults.TEXTURE_PATH_GUI + "/mailtrader2.png", new ContainerTrader(inventoryplayer, tile), tile); this.xSize = 226; this.ySize = 220; diff --git a/src/main/resources/assets/forestry/textures/gui/beealyzer.png b/src/main/resources/assets/forestry/textures/gui/beealyzer2.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/gui/beealyzer.png rename to src/main/resources/assets/forestry/textures/gui/beealyzer2.png diff --git a/src/main/resources/assets/forestry/textures/gui/mailtrader.png b/src/main/resources/assets/forestry/textures/gui/mailtrader2.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/gui/mailtrader.png rename to src/main/resources/assets/forestry/textures/gui/mailtrader2.png diff --git a/src/main/resources/assets/forestry/textures/gui/worktable.png b/src/main/resources/assets/forestry/textures/gui/worktable2.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/gui/worktable.png rename to src/main/resources/assets/forestry/textures/gui/worktable2.png From 2f7ed2386c0ba6214a9f6590bac610bb463d1086 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 16 Sep 2014 17:14:00 -0700 Subject: [PATCH 4/6] Port Railcraft's Fluid utilities to Forestry. --- .../forestry/core/fluids/FluidHelper.java | 286 +++++++++++++++ .../java/forestry/core/fluids/Fluids.java | 79 ++++ .../forestry/core/fluids/TankManager.java | 338 ++++++++++++++++++ .../forestry/core/fluids/tanks/FakeTank.java | 38 ++ .../core/fluids/tanks/FilteredTank.java | 70 ++++ .../core/fluids/tanks/StandardTank.java | 121 +++++++ .../java/forestry/core/utils/NBTUtil.java | 77 ++++ 7 files changed, 1009 insertions(+) create mode 100644 src/main/java/forestry/core/fluids/FluidHelper.java create mode 100644 src/main/java/forestry/core/fluids/Fluids.java create mode 100644 src/main/java/forestry/core/fluids/TankManager.java create mode 100644 src/main/java/forestry/core/fluids/tanks/FakeTank.java create mode 100644 src/main/java/forestry/core/fluids/tanks/FilteredTank.java create mode 100644 src/main/java/forestry/core/fluids/tanks/StandardTank.java create mode 100644 src/main/java/forestry/core/utils/NBTUtil.java diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java new file mode 100644 index 000000000..15a01d0ad --- /dev/null +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -0,0 +1,286 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.InvTools; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.world.World; +import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; + +/** + * + * @author CovertJaguar + */ +public final class FluidHelper { + + public static final int BUCKET_FILL_TIME = 8; + public static final int NETWORK_UPDATE_INTERVAL = 128; + public static final int BUCKET_VOLUME = 1000; + + private FluidHelper() { + } + + public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) { + if (player == null) + return false; + ItemStack current = player.inventory.getCurrentItem(); + if (current != null) { + + FluidStack liquid = getFluidStackInContainer(current); + + if (fill && liquid != null) { + int used = tank.fill(side, liquid, true); + + if (used > 0) { + if (!player.capabilities.isCreativeMode) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current)); + player.inventory.markDirty(); + } + return true; + } + + } else if (drain) { + + FluidStack available = tank.drain(side, Integer.MAX_VALUE, false); + if (available != null) { + ItemStack filled = fillContainer(available, current); + + liquid = getFluidStackInContainer(filled); + if (liquid != null) { + + if (current.stackSize > 1) { + if (!player.inventory.addItemStackToInventory(filled)) + return false; + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current)); + player.inventory.markDirty(); + } else { + player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current)); + player.inventory.setInventorySlotContents(player.inventory.currentItem, filled); + player.inventory.markDirty(); + } + + tank.drain(side, liquid.amount, true); + return true; + } + } + } + } + return false; + } + + public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot) { + processContainers(tank, inv, inputSlot, outputSlot, tank.getFluidType(), true, true); + } + + public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) { + TankManager tankManger = new TankManager(); + tankManger.add(tank); + processContainers(tankManger, inv, inputSlot, outputSlot, fluidToFill, processFilled, processEmpty); + } + + public static void processContainers(TankManager tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { + processContainers(tank, inv, inputSlot, outputSlot, fluidToFill, true, true); + } + + public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) { + ItemStack input = inv.getStackInSlot(inputSlot); + + if (input == null) + return; + + if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot)) + return; + + if (processEmpty && fluidToFill != null) + fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill); + } + + public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { + ItemStack input = inv.getStackInSlot(inputSlot); + ItemStack output = inv.getStackInSlot(outputSlot); + ItemStack filled = getFilledContainer(fluidToFill, input); + if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(filled, output)))) { + FluidStack fluidInContainer = getFluidStackInContainer(filled); + FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false); + if (drain != null && drain.amount == fluidInContainer.amount) { + fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); + if (output == null) + inv.setInventorySlotContents(outputSlot, filled); + else + output.stackSize++; + inv.decrStackSize(inputSlot, 1); + return true; + } + } + return false; + } + + public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) { + ItemStack input = inv.getStackInSlot(inputSlot); + ItemStack output = inv.getStackInSlot(outputSlot); + + if (input != null) { + FluidStack fluidInContainer = getFluidStackInContainer(input); + ItemStack emptyItem = input.getItem().getContainerItem(input); + if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) { + int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); + if (used >= fluidInContainer.amount) { + fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); + if (emptyItem != null) + if (output == null) + inv.setInventorySlotContents(outputSlot, emptyItem); + else + output.stackSize++; + inv.decrStackSize(inputSlot, 1); + return true; + } + } + } + return false; + } + + public static boolean isBucket(ItemStack stack) { + return FluidContainerRegistry.isBucket(stack); + } + + public static boolean isContainer(ItemStack stack) { + if (stack != null && stack.getItem() instanceof IFluidContainerItem) + return true; + return FluidContainerRegistry.isContainer(stack); + } + + public static boolean isFilledContainer(ItemStack stack) { + return FluidContainerRegistry.isFilledContainer(stack); + } + + public static boolean isEmptyContainer(ItemStack stack) { + return FluidContainerRegistry.isEmptyContainer(stack); + } + + public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { + if (fluid == null || empty == null) return null; + return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty); + } + + public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) { + if (fluid == null || empty == null) return null; + fluid = fluid.copy(); + fluid.amount = Integer.MAX_VALUE; + return FluidContainerRegistry.fillFluidContainer(fluid, empty); + } + + public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) { + if (liquid == null || empty == null) return null; + return FluidContainerRegistry.fillFluidContainer(liquid, empty); + } + + public static FluidStack getFluidStackInContainer(ItemStack stack) { + return FluidContainerRegistry.getFluidForFilledItem(stack); + } + + public static Fluid getFluidInContianer(ItemStack stack) { + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); + return fluidStack != null ? fluidStack.getFluid() : null; + } + + public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) { + return FluidContainerRegistry.containsFluid(stack, fluidStack); + } + + public static boolean containsFluid(ItemStack stack, Fluid fluid) { + return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1)); + } + + public static boolean isFluidEqual(FluidStack L1, FluidStack L2) { + if (L1 == null || L2 == null) + return false; + return L1.isFluidEqual(L2); + } + + public static Collection getContainersFilledWith(FluidStack fluidStack) { + List containers = new ArrayList(); + for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + FluidStack inContainer = getFluidStackInContainer(data.filledContainer); + if (inContainer != null && inContainer.containsFluid(fluidStack)) + containers.add(data.filledContainer.copy()); + } + return containers; + } + + public static void nerfWaterBottle() { + for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) { + data.fluid.amount = 333; + return; + } + } + } + + public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) { + return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain); + } + + public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) { + if (block instanceof IFluidBlock) { + IFluidBlock fluidBlock = (IFluidBlock)block; + if (fluidBlock.canDrain(world, x, y, z)) + return fluidBlock.drain(world, x, y, z, doDrain); + } else if (block == Blocks.water || block == Blocks.flowing_water) { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 0) + return null; + if (doDrain) + world.setBlockToAir(x, y, z); + return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); + } else if (block == Blocks.lava || block == Blocks.flowing_lava) { + int meta = world.getBlockMetadata(x, y, z); + if (meta != 0) + return null; + if (doDrain) + world.setBlockToAir(x, y, z); + return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); + } + return null; + } + + public static boolean isFullFluidBlock(World world, int x, int y, int z) { + return isFullFluidBlock(world.getBlock(x, y, z), world, x, y, z); + } + + public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) { + if (block instanceof BlockLiquid || block instanceof IFluidBlock) + return world.getBlockMetadata(x, y, z) == 0; + return false; + } + + public static Fluid getFluid(Block block) { + if (block instanceof IFluidBlock) + return ((IFluidBlock) block).getFluid(); + else if (block == Blocks.water || block == Blocks.flowing_water) + return FluidRegistry.WATER; + else if (block == Blocks.lava || block == Blocks.flowing_lava) + return FluidRegistry.LAVA; + return null; + } + +} diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java new file mode 100644 index 000000000..6599a48ff --- /dev/null +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.util.Locale; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +/** + * + * @author CovertJaguar + */ +public enum Fluids { + + WATER, LAVA, FUEL, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, COAL, PYROTHEUM; + private final String tag; + + private Fluids() { + tag = name().toLowerCase(Locale.ENGLISH); + } + + public String getTag() { + return tag; + } + + public Fluid get() { + return FluidRegistry.getFluid(tag); + } + + /** + * Gets a FluidStack filled with qty milliBuckets worth of Fluid. + * + * @param qty + * @return + */ + public FluidStack get(int qty) { + return FluidRegistry.getFluidStack(tag, qty); + } + + /** + * Gets a FluidStack filled with n buckets worth of Fluid. + * + * @param n + * @return + */ + public FluidStack getB(int n) { + return FluidRegistry.getFluidStack(tag, n * FluidContainerRegistry.BUCKET_VOLUME); + } + + public boolean is(Fluid fluid) { + return get() == fluid; + } + + public boolean is(FluidStack fluidStack) { + return fluidStack != null && get() == fluidStack.getFluid(); + } + + public boolean isContained(ItemStack containerStack) { + return containerStack != null && FluidHelper.containsFluid(containerStack, get()); + } + + public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { + if (fluidStack != null && fluid == fluidStack.getFluid()) + return true; + return fluid == null && fluidStack == null; + } + +} diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java new file mode 100644 index 000000000..b18c079f5 --- /dev/null +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -0,0 +1,338 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import com.google.common.collect.ForwardingList; +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.ITileFilter; +import forestry.core.utils.NBTUtil; +import forestry.core.utils.NBTUtil.NBTList; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +/** + * + * @author CovertJaguar + */ +public class TankManager extends ForwardingList implements IFluidHandler, List { + + public static final ITileFilter TANK_FILTER = new ITileFilter() { + @Override + public boolean matches(TileEntity tile) { + return tile instanceof IFluidHandler; + } + + }; + private static final byte NETWORK_DATA = 3; + private final List tanks = new ArrayList(); + private final List prevFluidStacks = new ArrayList(); + private final List prevColor = new ArrayList(); + + public TankManager() { + } + + public TankManager(StandardTank... tanks) { + addAll(Arrays.asList(tanks)); + } + + @Override + protected List delegate() { + return tanks; + } + + @Override + public boolean add(StandardTank tank) { + boolean added = tanks.add(tank); + int index = tanks.indexOf(tank); + tank.setTankIndex(index); + prevFluidStacks.add(tank.getFluid() == null ? null : tank.getFluid().copy()); + prevColor.add(tank.getColor()); + return added; + } + + public void writeTanksToNBT(NBTTagCompound data) { + NBTTagList tagList = new NBTTagList(); + for (byte slot = 0; slot < tanks.size(); slot++) { + StandardTank tank = tanks.get(slot); + if (tank.getFluid() != null) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("tank", slot); + tank.writeToNBT(tag); + tagList.appendTag(tag); + } + } + data.setTag("tanks", tagList); + } + + public void readTanksFromNBT(NBTTagCompound data) { + NBTList tagList = NBTUtil.getNBTList(data, "tanks", NBTUtil.EnumNBTType.COMPOUND); + for (NBTTagCompound tag : tagList) { + int slot = tag.getByte("tank"); + if (slot >= 0 && slot < tanks.size()) + tanks.get(slot).readFromNBT(tag); + } + } + + public void writePacketData(DataOutputStream data) throws IOException { + for (int i = 0; i < tanks.size(); i++) + writePacketData(data, i); + } + + public void writePacketData(DataOutputStream data, int tankIndex) throws IOException { + if (tankIndex >= tanks.size()) + return; + StandardTank tank = tanks.get(tankIndex); + FluidStack fluidStack = tank.getFluid(); + if (fluidStack != null) { + data.writeShort(fluidStack.fluidID); + data.writeInt(fluidStack.amount); + data.writeInt(fluidStack.getFluid().getColor(fluidStack)); + } else + data.writeShort(-1); + } + + public void readPacketData(DataInputStream data) throws IOException { + for (int i = 0; i < tanks.size(); i++) + readPacketData(data, i); + } + + public void readPacketData(DataInputStream data, int tankIndex) throws IOException { + if (tankIndex >= tanks.size()) + return; + StandardTank tank = tanks.get(tankIndex); + int fluidId = data.readShort(); + if (fluidId != -1) { + tank.setFluid(new FluidStack(fluidId, data.readInt())); + tank.colorCache = data.readInt(); + } else + tank.setFluid(null); + } + + public void initGuiData(Container container, ICrafting player, int tankIndex) { + if (tankIndex >= tanks.size()) + return; + FluidStack fluidStack = tanks.get(tankIndex).getFluid(); + int fluidId = -1; + int fluidAmount = 0; + if (fluidStack != null && fluidStack.amount > 0) { + fluidId = fluidStack.getFluid().getID(); + fluidAmount = fluidStack.amount; + } + + player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId); + PacketBuilder.instance().sendGuiIntegerPacket((EntityPlayerMP) player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount); + } + + public void updateGuiData(Container container, List crafters, int tankIndex) { + StandardTank tank = tanks.get(tankIndex); + FluidStack fluidStack = tank.getFluid(); + FluidStack prev = prevFluidStacks.get(tankIndex); + int color = tank.getColor(); + int pColor = prevColor.get(tankIndex); + + for (Object crafter1 : crafters) { + ICrafting crafter = (ICrafting) crafter1; + EntityPlayerMP player = (EntityPlayerMP) crafter1; + if (fluidStack == null ^ prev == null) { + int fluidId = -1; + int fluidAmount = 0; + if (fluidStack != null) { + fluidId = fluidStack.fluidID; + fluidAmount = fluidStack.amount; + } + crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId); + PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount); + } else if (fluidStack != null && prev != null) { + if (fluidStack.getFluid() != prev.getFluid()) + crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidStack.fluidID); + if (fluidStack.amount != prev.amount) + PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount); + if (color != pColor) + PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 2, color); + } + } + + prevFluidStacks.set(tankIndex, tank.getFluid() == null ? null : tank.getFluid().copy()); + prevColor.set(tankIndex, color); + } + + public void processGuiUpdate(int messageId, int data) { + int tankIndex = messageId / NETWORK_DATA; + + if (tankIndex >= tanks.size()) + return; + StandardTank tank = tanks.get(tankIndex); + FluidStack fluidStack = tank.getFluid(); + if (fluidStack == null) { + fluidStack = new FluidStack(-1, 0); + tank.setFluid(fluidStack); + } + int fluidId = fluidStack.fluidID; + int amount = fluidStack.amount; + int color = tank.colorCache; + boolean newLiquid = false; + switch (messageId % NETWORK_DATA) { + case 0: + fluidId = data; + newLiquid = true; + break; + case 1: + amount = data; + break; + case 2: + color = data; + break; + } + if (newLiquid) { + fluidStack = new FluidStack(fluidId, 0); + tank.setFluid(fluidStack); + } + fluidStack.amount = amount; + tank.colorCache = color; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return fill(0, resource, doFill); + } + + public int fill(int tankIndex, FluidStack resource, boolean doFill) { + if (tankIndex < 0 || tankIndex >= tanks.size() || resource == null) + return 0; + + return tanks.get(tankIndex).fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return drain(0, maxDrain, doDrain); + } + + public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) { + if (tankIndex < 0 || tankIndex >= tanks.size()) + return null; + + return tanks.get(tankIndex).drain(maxDrain, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + for (StandardTank tank : tanks) + if (tankCanDrainFluid(tank, resource)) + return tank.drain(resource.amount, doDrain); + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection direction) { + FluidTankInfo[] info = new FluidTankInfo[size()]; + for (int i = 0; i < size(); i++) + info[i] = get(i).getInfo(); + return info; + } + + public FluidTankInfo[] getTankInfo() { + return getTankInfo(ForgeDirection.UNKNOWN); + } + + @Override + public StandardTank get(int tankIndex) { + if (tankIndex < 0 || tankIndex >= tanks.size()) + return null; + return tanks.get(tankIndex); + } + + public void setCapacity(int tankIndex, int capacity) { + StandardTank tank = get(tankIndex); + tank.setCapacity(capacity); + FluidStack fluidStack = tank.getFluid(); + if (fluidStack != null && fluidStack.amount > capacity) + fluidStack.amount = capacity; + } + +// Used to push fluids to surrounding blocks, missing code from Railcraft, if needed contact CovertJaguar +// public void outputLiquid(AdjacentTileCache cache, ITileFilter filter, ForgeDirection[] sides, int tankIndex, int amount) { +// for (ForgeDirection side : sides) { +// TileEntity tile = cache.getTileOnSide(side); +// if (!filter.matches(tile)) continue; +// IFluidHandler tank = getTankFromTile(tile); +// if (tank == null) continue; +// outputLiquid((IFluidHandler) tile, side, tankIndex, amount); +// } +// } + public void outputLiquid(IFluidHandler[] outputs, int tankIndex, int amount) { + for (int side = 0; side < 6; side++) { + IFluidHandler nearbyTank = outputs[side]; + if (nearbyTank != null) + outputLiquid(nearbyTank, ForgeDirection.getOrientation(side), tankIndex, amount); + } + } + + public static IFluidHandler getTankFromTile(TileEntity tile) { + IFluidHandler tank = null; + if (tile instanceof IFluidHandler) + tank = (IFluidHandler) tile; + return tank; + } + + private void outputLiquid(IFluidHandler tank, ForgeDirection side, int tankIndex, int amount) { + FluidStack available = drain(tankIndex, amount, false); + if (available != null) { + int used = tank.fill(side.getOpposite(), available, true); + if (used > 0) + drain(tankIndex, used, true); + } + } + + private boolean tankAcceptsFluid(IFluidTank tank, FluidStack fluidStack) { + if (fluidStack == null) + return false; + if (tank.fill(fluidStack, false) > 0) + return true; + return false; + } + + private boolean tankCanDrainFluid(IFluidTank tank, FluidStack fluidStack) { + if (fluidStack == null) + return false; + FluidStack drained = tank.drain(1, false); + if (drained != null && drained.amount > 0) + return true; + return false; + } + +} diff --git a/src/main/java/forestry/core/fluids/tanks/FakeTank.java b/src/main/java/forestry/core/fluids/tanks/FakeTank.java new file mode 100644 index 000000000..090b818f3 --- /dev/null +++ b/src/main/java/forestry/core/fluids/tanks/FakeTank.java @@ -0,0 +1,38 @@ +/* + * This code is the property of CovertJaguar + * and may only be used with explicit written + * permission unless otherwise specified on the + * license page at railcraft.wikispaces.com. + */ +package mods.railcraft.common.fluids.tanks; + +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidTank; + +/** + * + * @author CovertJaguar + */ +public final class FakeTank extends FluidTank { + + public static final IFluidTank INSTANCE = new FakeTank(); + public static final IFluidTank[] ARRAY = new IFluidTank[]{INSTANCE}; + public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()}; + + private FakeTank() { + super(1); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return null; + } + +} diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java new file mode 100644 index 000000000..6c7d5262c --- /dev/null +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids.tanks; + +import forestry.core.gui.tooltips.ToolTipLine; +import net.minecraft.item.EnumRarity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +/** + * + * @author CovertJaguar + */ +public class FilteredTank extends StandardTank { + + private final Fluid filter; + + public FilteredTank(int capacity, Fluid filter) { + this(capacity, filter, null); + } + + public FilteredTank(int capacity, Fluid filter, TileEntity tile) { + super(capacity, tile); + this.filter = filter; + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + if (liquidMatchesFilter(resource)) + return super.fill(resource, doFill); + return 0; + } + + public Fluid getFilter() { + return filter; + } + + public boolean liquidMatchesFilter(FluidStack resource) { + if (resource == null || filter == null) + return false; + return resource.getFluid() == filter; + } + + @Override + protected void refreshTooltip() { + toolTip.clear(); + int amount = 0; + if (filter != null) { + EnumRarity rarity = filter.getRarity(); + if (rarity == null) + rarity = EnumRarity.common; + ToolTipLine name = new ToolTipLine(filter.getLocalizedName(), rarity.rarityColor); + name.setSpacing(2); + toolTip.add(name); + if (getFluid() != null) + amount = getFluid().amount; + } + toolTip.add(new ToolTipLine(String.format("%,d", amount) + " / " + String.format("%,d", getCapacity()))); + } + +} diff --git a/src/main/java/forestry/core/fluids/tanks/StandardTank.java b/src/main/java/forestry/core/fluids/tanks/StandardTank.java new file mode 100644 index 000000000..8f53f0e5f --- /dev/null +++ b/src/main/java/forestry/core/fluids/tanks/StandardTank.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids.tanks; + +import forestry.core.gui.tooltips.ToolTip; +import forestry.core.gui.tooltips.ToolTipLine; +import java.util.Locale; +import net.minecraft.item.EnumRarity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; + +/** + * + * @author CovertJaguar + */ +public class StandardTank extends FluidTank { + + public static final int DEFAULT_COLOR = 0xFFFFFF; + public int colorCache = DEFAULT_COLOR; + private int tankIndex; + + public StandardTank(int capacity) { + super(capacity); + } + + public StandardTank(int capacity, TileEntity tile) { + this(capacity); + this.tile = tile; + } + + public void setTankIndex(int index) { + this.tankIndex = index; + } + + public int getTankIndex() { + return tankIndex; + } + + @Override + public void setFluid(FluidStack fluid) { + super.setFluid(fluid); + colorCache = StandardTank.DEFAULT_COLOR; + } + + public int getColor() { + Fluid f = getFluidType(); + if (f == null) + return DEFAULT_COLOR; + return f.getColor(getFluid()); + } + + public boolean isEmpty() { + return getFluid() == null || getFluid().amount <= 0; + } + + public boolean isFull() { + return getFluid() != null && getFluid().amount == getCapacity(); + } + + public int getRemainingSpace() { + return capacity - getFluidAmount(); + } + + public Fluid getFluidType() { + return getFluid() != null ? getFluid().getFluid() : null; + } + + @Override + public int fill(final FluidStack resource, final boolean doFill) { + if (resource == null) + return 0; + if (resource.amount <= 0) + return 0; + return super.fill(resource, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (maxDrain <= 0) + return null; + return super.drain(maxDrain, doDrain); + } + + public ToolTip getToolTip() { + return toolTip; + } + + protected void refreshTooltip() { + toolTip.clear(); + int amount = 0; + if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) { + Fluid fluidType = getFluidType(); + EnumRarity rarity = fluidType.getRarity(); + if (rarity == null) + rarity = EnumRarity.common; + ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(), rarity.rarityColor); + fluidName.setSpacing(2); + toolTip.add(fluidName); + amount = getFluid().amount; + } + toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity()))); + } + + protected final ToolTip toolTip = new ToolTip() { + @Override + public void refresh() { + refreshTooltip(); + } + + }; +} diff --git a/src/main/java/forestry/core/utils/NBTUtil.java b/src/main/java/forestry/core/utils/NBTUtil.java new file mode 100644 index 000000000..03ee22182 --- /dev/null +++ b/src/main/java/forestry/core/utils/NBTUtil.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import com.google.common.collect.ForwardingList; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.nbt.*; + +/** + * + * @author CovertJaguar + */ +public class NBTUtil { + + public enum EnumNBTType { + + END(NBTTagEnd.class), + BYTE(NBTTagByte.class), + SHORT(NBTTagShort.class), + INT(NBTTagInt.class), + LONG(NBTTagLong.class), + FLOAT(NBTTagFloat.class), + DOUBLE(NBTTagDouble.class), + BYTE_ARRAY(NBTTagByteArray.class), + STRING(NBTTagString.class), + LIST(NBTTagList.class), + COMPOUND(NBTTagCompound.class), + INT_ARRAY(NBTTagIntArray.class); + public static final EnumNBTType[] VALUES = values(); + public final Class classObject; + + private EnumNBTType(Class c) { + this.classObject = c; + } + + public static EnumNBTType fromClass(Class c) { + for (EnumNBTType type : VALUES) { + if (type.classObject == c) + return type; + } + return null; + } + + } + + public static NBTList getNBTList(NBTTagCompound nbt, String tag, EnumNBTType type) { + NBTTagList nbtList = nbt.getTagList(tag, type.ordinal()); + return new NBTList(nbtList); + } + + public static class NBTList extends ForwardingList { + + private final ArrayList backingList; + private final NBTTagList nbtList; + + public NBTList(NBTTagList nbtList) { + this.nbtList = nbtList; + backingList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtList, 0); + } + + @Override + protected List delegate() { + return backingList; + } + + } +} From 7947a66187be7e58e38f36afea72f1ee7dcbba7a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 16 Sep 2014 17:15:29 -0700 Subject: [PATCH 5/6] Missed one. --- .../forestry/core/fluids/tanks/FakeTank.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/core/fluids/tanks/FakeTank.java b/src/main/java/forestry/core/fluids/tanks/FakeTank.java index 090b818f3..afeba0a42 100644 --- a/src/main/java/forestry/core/fluids/tanks/FakeTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FakeTank.java @@ -1,10 +1,14 @@ -/* - * This code is the property of CovertJaguar - * and may only be used with explicit written - * permission unless otherwise specified on the - * license page at railcraft.wikispaces.com. - */ -package mods.railcraft.common.fluids.tanks; +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids.tanks; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; From 5442b9983765de762a037dde641bfe1de69af770 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 16 Sep 2014 17:40:39 -0700 Subject: [PATCH 6/6] Replace ForestryTank with StandardTank --- .../gadgets/TileAlvearyHygroregulator.java | 10 +- .../forestry/core/fluids/tanks/FakeTank.java | 8 +- .../core/fluids/tanks/StandardTank.java | 170 ++++++++++-------- .../java/forestry/core/gadgets/Engine.java | 4 +- .../forestry/core/gadgets/TileAnalyzer.java | 8 +- .../forestry/core/gadgets/TileForestry.java | 7 +- .../forestry/core/gadgets/TilePowered.java | 4 +- .../forestry/core/gui/ContainerForestry.java | 8 +- .../core/gui/ContainerLiquidTanks.java | 15 +- .../forestry/core/gui/widgets/TankWidget.java | 6 +- .../core/interfaces/ILiquidTankContainer.java | 7 +- .../core/network/PacketTankUpdate.java | 4 +- .../forestry/core/utils/ForestryTank.java | 86 --------- .../java/forestry/core/utils/StackUtils.java | 5 +- .../forestry/energy/gadgets/EngineBronze.java | 16 +- .../energy/gadgets/MachineGenerator.java | 11 +- .../factory/gadgets/MachineBottler.java | 10 +- .../factory/gadgets/MachineCarpenter.java | 10 +- .../factory/gadgets/MachineFabricator.java | 10 +- .../factory/gadgets/MachineFermenter.java | 14 +- .../factory/gadgets/MachineMoistener.java | 10 +- .../factory/gadgets/MachineRaintank.java | 10 +- .../factory/gadgets/MachineSqueezer.java | 10 +- .../factory/gadgets/MachineStill.java | 14 +- .../farming/gadgets/TileFarmPlain.java | 10 +- .../forestry/farming/gadgets/TileValve.java | 17 +- .../forestry/farming/gui/ContainerFarm.java | 15 +- .../farming/triggers/TriggerLowLiquid.java | 4 +- 28 files changed, 218 insertions(+), 285 deletions(-) delete mode 100755 src/main/java/forestry/core/utils/ForestryTank.java diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 49d1764d2..67ebee232 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -25,10 +25,10 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ForestryAPI; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -57,7 +57,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory /* MEMBERS */ InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv"); - private ForestryTank liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + private StandardTank liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private HygroregulatorRecipe currentRecipe; private int transferTime; @@ -146,7 +146,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory canInventory.readFromNBT(nbttagcompound); - liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("LiquidTank")) liquidTank.readFromNBT(nbttagcompound.getCompoundTag("LiquidTank")); @@ -283,8 +283,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { liquidTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { liquidTank }; } /* SMP GUI */ diff --git a/src/main/java/forestry/core/fluids/tanks/FakeTank.java b/src/main/java/forestry/core/fluids/tanks/FakeTank.java index afeba0a42..34086cc1e 100644 --- a/src/main/java/forestry/core/fluids/tanks/FakeTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FakeTank.java @@ -11,18 +11,16 @@ package forestry.core.fluids.tanks; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidTank; /** * * @author CovertJaguar */ -public final class FakeTank extends FluidTank { +public final class FakeTank extends StandardTank { - public static final IFluidTank INSTANCE = new FakeTank(); - public static final IFluidTank[] ARRAY = new IFluidTank[]{INSTANCE}; + public static final FakeTank INSTANCE = new FakeTank(); + public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE}; public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()}; private FakeTank() { diff --git a/src/main/java/forestry/core/fluids/tanks/StandardTank.java b/src/main/java/forestry/core/fluids/tanks/StandardTank.java index 8f53f0e5f..d4f226904 100644 --- a/src/main/java/forestry/core/fluids/tanks/StandardTank.java +++ b/src/main/java/forestry/core/fluids/tanks/StandardTank.java @@ -25,97 +25,113 @@ import net.minecraftforge.fluids.FluidTank; */ public class StandardTank extends FluidTank { - public static final int DEFAULT_COLOR = 0xFFFFFF; - public int colorCache = DEFAULT_COLOR; - private int tankIndex; + public static final int DEFAULT_COLOR = 0xFFFFFF; + public int colorCache = DEFAULT_COLOR; + private int tankIndex; - public StandardTank(int capacity) { - super(capacity); - } + public StandardTank(int capacity) { + super(capacity); + } - public StandardTank(int capacity, TileEntity tile) { - this(capacity); - this.tile = tile; - } + public StandardTank(FluidStack fluid, int capacity) { + this(capacity); + setFluid(fluid); + } - public void setTankIndex(int index) { - this.tankIndex = index; - } + public StandardTank(int capacity, TileEntity tile) { + this(capacity); + this.tile = tile; + } - public int getTankIndex() { - return tankIndex; - } + public StandardTank(FluidStack fluid, int capacity, TileEntity tile) { + this(capacity); + this.tile = tile; + setFluid(fluid); + } - @Override - public void setFluid(FluidStack fluid) { - super.setFluid(fluid); - colorCache = StandardTank.DEFAULT_COLOR; - } + public void setTankIndex(int index) { + this.tankIndex = index; + } - public int getColor() { - Fluid f = getFluidType(); - if (f == null) - return DEFAULT_COLOR; - return f.getColor(getFluid()); - } + public int getTankIndex() { + return tankIndex; + } - public boolean isEmpty() { - return getFluid() == null || getFluid().amount <= 0; - } + @Override + public void setFluid(FluidStack fluid) { + super.setFluid(fluid); + colorCache = StandardTank.DEFAULT_COLOR; + } - public boolean isFull() { - return getFluid() != null && getFluid().amount == getCapacity(); - } + public int getColor() { + Fluid f = getFluidType(); + if (f == null) + return DEFAULT_COLOR; + return f.getColor(getFluid()); + } - public int getRemainingSpace() { - return capacity - getFluidAmount(); - } + public boolean isEmpty() { + return getFluid() == null || getFluid().amount <= 0; + } - public Fluid getFluidType() { - return getFluid() != null ? getFluid().getFluid() : null; - } + public boolean isFull() { + return getFluid() != null && getFluid().amount == getCapacity(); + } - @Override - public int fill(final FluidStack resource, final boolean doFill) { - if (resource == null) - return 0; - if (resource.amount <= 0) - return 0; - return super.fill(resource, doFill); - } + public int getRemainingSpace() { + return capacity - getFluidAmount(); + } - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (maxDrain <= 0) - return null; - return super.drain(maxDrain, doDrain); - } + public Fluid getFluidType() { + return getFluid() != null ? getFluid().getFluid() : null; + } - public ToolTip getToolTip() { - return toolTip; - } + @Override + public int fill(final FluidStack resource, final boolean doFill) { + if (resource == null) + return 0; + if (resource.amount <= 0) + return 0; + return super.fill(resource, doFill); + } - protected void refreshTooltip() { - toolTip.clear(); - int amount = 0; - if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) { - Fluid fluidType = getFluidType(); - EnumRarity rarity = fluidType.getRarity(); - if (rarity == null) - rarity = EnumRarity.common; - ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(), rarity.rarityColor); - fluidName.setSpacing(2); - toolTip.add(fluidName); - amount = getFluid().amount; - } - toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity()))); - } + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (maxDrain <= 0) + return null; + return super.drain(maxDrain, doDrain); + } - protected final ToolTip toolTip = new ToolTip() { - @Override - public void refresh() { - refreshTooltip(); - } + @Override + public String toString() { + return String.format("Tank: %s, %d/%d", fluid != null && fluid.getFluid() != null ? fluid.getFluid().getName() : "Empty", getFluidAmount(), getCapacity()); + } - }; + public ToolTip getToolTip() { + return toolTip; + } + + protected void refreshTooltip() { + toolTip.clear(); + int amount = 0; + if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) { + Fluid fluidType = getFluidType(); + EnumRarity rarity = fluidType.getRarity(); + if (rarity == null) + rarity = EnumRarity.common; + ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(), rarity.rarityColor); + fluidName.setSpacing(2); + toolTip.add(fluidName); + amount = getFluid().amount; + } + toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity()))); + } + + protected final ToolTip toolTip = new ToolTip() { + @Override + public void refresh() { + refreshTooltip(); + } + + }; } diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index 23a013a7c..927462a71 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -31,11 +31,11 @@ import buildcraft.api.transport.IPipeTile.PipeType; import forestry.core.TemperatureState; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.interfaces.IPowerHandler; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.utils.BlockUtil; -import forestry.core.utils.ForestryTank; import forestry.plugins.PluginBuildCraft; public abstract class Engine extends TileBase implements IPowerHandler, IPipeConnection, IPowerEmitter { @@ -96,7 +96,7 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon powerProvider.configure(10, 200, 10, 100000); } - protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, ForestryTank tank) { + protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) { if (container == null) return inventoryStack; diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 03052832f..fc780deb3 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -38,7 +38,7 @@ import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -67,7 +67,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI public FluidStack resource = FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, HONEY_REQUIRED); @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final Stack pendingProducts = new Stack(); /* CONSTRUCTOR */ @@ -441,8 +441,8 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } /* diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index ffd3bc9d9..8b06c4b41 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -33,6 +33,7 @@ import com.mojang.authlib.GameProfile; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.FakeTank; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IOwnable; @@ -43,7 +44,7 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.Vect; @@ -355,14 +356,14 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit /* IFLUIDHANDLER BASICS */ public FluidTankInfo[] getTankInfo(ForgeDirection from) { if (this instanceof ILiquidTankContainer) { - ForestryTank[] tanks = ((ILiquidTankContainer) this).getTanks(); + StandardTank[] tanks = ((ILiquidTankContainer) this).getTanks(); FluidTankInfo[] info = new FluidTankInfo[tanks.length]; for (int i = 0; i < info.length; i++) { info[i] = tanks[i].getInfo(); } return info; } - return ForestryTank.DUMMY_TANKINFO_ARRAY; + return FakeTank.INFO; } public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index 999e3bfbe..3129fd1bf 100755 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -29,7 +29,7 @@ import forestry.core.network.IndexInPayload; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; public abstract class TilePowered extends TileBase implements IPowerHandler, IRenderableMachine { @@ -179,7 +179,7 @@ public abstract class TilePowered extends TileBase implements IPowerHandler, IRe } */ /* LIQUID CONTAINER HANDLING */ - protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, ForestryTank tank) { + protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) { if (tank.getFluidAmount() < container.fluid.amount) return outputStack; if (canStack.stackSize <= 0) diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 39c6e65b0..3d5c2e1d2 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.gui; +import forestry.core.fluids.tanks.FakeTank; +import forestry.core.fluids.tanks.StandardTank; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -19,8 +21,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import forestry.core.gui.slots.SlotForestry; -import forestry.core.utils.ForestryTank; import forestry.core.utils.StackUtils; +import net.minecraftforge.fluids.IFluidTank; public class ContainerForestry extends Container { @@ -208,7 +210,7 @@ public class ContainerForestry extends Container { public void onTankUpdate(NBTTagCompound nbt) { } - public ForestryTank getTank(int slot) { - return ForestryTank.FAKETANK; + public StandardTank getTank(int slot) { + return FakeTank.INSTANCE; } } diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 47a3f7273..4f3aa2a74 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -24,13 +24,14 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import forestry.api.core.IToolPipette; +import forestry.core.fluids.tanks.FakeTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketTankUpdate; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryTank; public class ContainerLiquidTanks extends ContainerForestry { @@ -79,14 +80,14 @@ public class ContainerLiquidTanks extends ContainerForestry { } } - private Map syncedFluids = new HashMap(); + private Map syncedFluids = new HashMap(); @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < tanks.getTanks().length; i++) { - ForestryTank tank = tanks.getTanks()[i]; + StandardTank tank = tanks.getTanks()[i]; // If null has been synced if (tank.getFluid() == null && getTank(i).getFluidAmount() <= 0) @@ -102,7 +103,7 @@ public class ContainerLiquidTanks extends ContainerForestry { } } - syncedFluids.put(i, new ForestryTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity())); + syncedFluids.put(i, new StandardTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity())); } } @@ -113,13 +114,13 @@ public class ContainerLiquidTanks extends ContainerForestry { int capacity = nbt.getShort("capacity"); tanks.getTanks()[tankID].readFromNBT(nbt); - ForestryTank tank = new ForestryTank(capacity); + StandardTank tank = new StandardTank(capacity); tank.readFromNBT(nbt); syncedFluids.put(tankID, tank); } @Override - public ForestryTank getTank(int slot) { - return syncedFluids.get(slot) == null ? ForestryTank.FAKETANK : syncedFluids.get(slot); + public StandardTank getTank(int slot) { + return syncedFluids.get(slot) == null ? FakeTank.INSTANCE : syncedFluids.get(slot); } } diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index 3d987bf2d..31642eee9 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -19,13 +19,13 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; import forestry.api.core.IToolPipette; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gui.ContainerForestry; import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.WidgetManager; import forestry.core.gui.tooltips.ToolTip; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; -import forestry.core.utils.ForestryTank; /** * Slot for liquid tanks @@ -48,7 +48,7 @@ public class TankWidget extends Widget { return this; } - public ForestryTank getTank() { + public StandardTank getTank() { return ((ContainerForestry) manager.gui.inventorySlots).getTank(slot); } @@ -96,7 +96,7 @@ public class TankWidget extends Widget { @Override public ToolTip getToolTip() { - ForestryTank tank = getTank(); + StandardTank tank = getTank(); if (tank == null) return null; return tank.getToolTip(); diff --git a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java index dc5c7601e..37fdb8164 100755 --- a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java +++ b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.interfaces; +import forestry.core.fluids.tanks.StandardTank; import net.minecraftforge.fluids.IFluidHandler; -import forestry.core.utils.ForestryTank; - public interface ILiquidTankContainer extends IFluidHandler { - ForestryTank[] getTanks(); - + StandardTank[] getTanks(); + } diff --git a/src/main/java/forestry/core/network/PacketTankUpdate.java b/src/main/java/forestry/core/network/PacketTankUpdate.java index bec6e939d..d7cecfbd5 100755 --- a/src/main/java/forestry/core/network/PacketTankUpdate.java +++ b/src/main/java/forestry/core/network/PacketTankUpdate.java @@ -10,13 +10,13 @@ ******************************************************************************/ package forestry.core.network; +import forestry.core.fluids.tanks.StandardTank; import net.minecraft.nbt.NBTTagCompound; -import forestry.core.utils.ForestryTank; public class PacketTankUpdate extends PacketNBT { - public PacketTankUpdate(int tankSlot, ForestryTank tank) { + public PacketTankUpdate(int tankSlot, StandardTank tank) { super(PacketIds.TANK_UPDATE); NBTTagCompound nbt = new NBTTagCompound(); nbt.setByte("tank", (byte) tankSlot); diff --git a/src/main/java/forestry/core/utils/ForestryTank.java b/src/main/java/forestry/core/utils/ForestryTank.java deleted file mode 100755 index a80d3ae57..000000000 --- a/src/main/java/forestry/core/utils/ForestryTank.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.utils; - -import java.util.Locale; - -import net.minecraft.item.EnumRarity; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.FluidTankInfo; - -import forestry.core.config.Config; -import forestry.core.gui.tooltips.ToolTip; -import forestry.core.gui.tooltips.ToolTipLine; - -public class ForestryTank extends FluidTank { - - public static final ForestryTank FAKETANK = new ForestryTank(0); - public static final ForestryTank[] FAKETANK_ARRAY = new ForestryTank[] { FAKETANK }; - public static final FluidTankInfo DUMMY_TANK_INFO = new FluidTankInfo(FAKETANK); - public static final FluidTankInfo[] DUMMY_TANKINFO_ARRAY = new FluidTankInfo[] { DUMMY_TANK_INFO }; - - public ForestryTank(FluidStack stack, int capacity) { - super(stack, capacity); - } - - public ForestryTank(int capacity) { - super(capacity); - } - - public ForestryTank(Fluid fluid, int amount, int capacity) { - super(fluid, amount, capacity); - } - - public boolean isEmpty() { - return getFluid() == null || getFluid().amount <= 0; - } - - public boolean isFull() { - return getFluid() != null && getFluid().amount == getCapacity(); - } - - public Fluid getFluidType() { - return getFluid() != null ? getFluid().getFluid() : null; - } - - @Override - public String toString() { - return String.format("Tank: %s, %d/%d", fluid != null && fluid.getFluid() != null ? fluid.getFluid().getName() : "Empty", getFluidAmount(), getCapacity()); - } - - public ToolTip getToolTip() { - return toolTip; - } - protected final ToolTip toolTip = new ToolTip() { - @Override - public void refresh() { - toolTip.clear(); - int amount = 0; - if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) { - Fluid fluidType = getFluidType(); - EnumRarity rarity = fluidType.getRarity(); - if (rarity == null) - rarity = EnumRarity.common; - ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(getFluid()), rarity.rarityColor); - fluidName.setSpacing(2); - toolTip.add(fluidName); - amount = getFluid().amount; - } else { - toolTip.add(new ToolTipLine(StringUtil.localize("gui.empty"))); - } - if (Config.tooltipLiquidAmount) - toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity()))); - } - }; -} diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 0eb820649..5fc271975 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -29,6 +29,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.oredict.OreDictionary; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileForestry; public class StackUtils { @@ -400,12 +401,12 @@ public class StackUtils { } - public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, ForestryTank tank) { + public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, StandardTank tank) { FluidContainerData container = LiquidHelper.getLiquidContainer(inventoryStack); replenishByContainer(tile, inventoryStack, container, tank); } - public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, ForestryTank tank) { + public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, StandardTank tank) { if (container == null) return inventoryStack; diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index cb0728de6..692391296 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -29,12 +29,12 @@ import forestry.api.fuels.FuelManager; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; -import forestry.core.utils.ForestryTank; import forestry.core.utils.LiquidHelper; import forestry.core.utils.TileInventoryAdapter; @@ -65,8 +65,8 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa else shutdown = false; } - public ForestryTank fuelTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY); - public ForestryTank heatingTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY); + public StandardTank fuelTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY); + public StandardTank heatingTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY); private final TileInventoryAdapter inventory; public int burnTime; public int totalTime; @@ -99,7 +99,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN)); if (container != null) { - ForestryTank tank = null; + StandardTank tank = null; if (container.fluid.isFluidEqual(LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1))) tank = heatingTank; @@ -284,8 +284,8 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa currentFluidId = fluid.getID(); } - fuelTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY); - heatingTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY); + fuelTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY); + heatingTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY); if (nbt.hasKey("FuelSlot")) { fuelTank.readFromNBT(nbt.getCompoundTag("FuelSlot")); heatingTank.readFromNBT(nbt.getCompoundTag("HeatingSlot")); @@ -457,7 +457,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { fuelTank, heatingTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { fuelTank, heatingTank }; } } diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index bab24cd96..76a8cffcf 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -28,17 +28,16 @@ import forestry.api.fuels.GeneratorFuel; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; @@ -49,7 +48,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi public static final int maxEnergy = 30000; @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private int tickCount = 0; InventoryAdapter inventory = new InventoryAdapter(1, "Items"); @@ -92,7 +91,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi if (ic2EnergySource != null) ic2EnergySource.readFromNBT(nbttagcompound); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); @@ -286,7 +285,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index d0e21c0f6..c59d455b9 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -39,6 +39,7 @@ import forestry.api.recipes.RecipeManagers; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; @@ -46,7 +47,6 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -149,7 +149,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); @@ -215,7 +215,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq fillingTotalTime = nbttagcompound.getInteger("FillingTotalTime"); productPending = nbttagcompound.getBoolean("ProductPending"); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); @@ -494,8 +494,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } // ITRIGGERPROVIDER diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index ac52592d0..3cd1a454a 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -40,6 +40,7 @@ import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; @@ -47,7 +48,6 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; @@ -214,7 +214,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL /* MEMBER */ @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final TileInventoryAdapter craftingInventory; private final TileInventoryAdapter accessibleInventory; public MachineCarpenter.Recipe currentRecipe; @@ -287,7 +287,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL packageTime = nbttagcompound.getInteger("PackageTime"); totalTime = nbttagcompound.getInteger("PackageTotalTime"); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); @@ -680,8 +680,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } // ITRIGGERPROVIDER diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index f4d4004bc..df22a17f7 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -37,7 +37,7 @@ import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.ICraftingPlan; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; @@ -230,7 +230,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial /* MEMBER */ private final InventoryAdapter inventory = new InventoryAdapter(30, "Items"); - private ForestryTank moltenTank = new ForestryTank(2 * Defaults.BUCKET_VOLUME); + private StandardTank moltenTank = new StandardTank(2 * Defaults.BUCKET_VOLUME); private int heat = 0; private int guiMeltingPoint = 0; @@ -284,7 +284,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial heat = nbttagcompound.getInteger("Heat"); // Tank - moltenTank = new ForestryTank(Defaults.BUCKET_VOLUME * 2); + moltenTank = new StandardTank(Defaults.BUCKET_VOLUME * 2); if (nbttagcompound.hasKey("MoltenTank")) moltenTank.readFromNBT(nbttagcompound.getCompoundTag("MoltenTank")); @@ -579,7 +579,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial /* ILIQUIDCONTAINER */ @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { moltenTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { moltenTank }; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index de78cb441..12b5d5e24 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -43,7 +43,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -180,9 +180,9 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } } @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); @EntityNetData - public ForestryTank productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(5, "Items"); private Recipe currentRecipe; private float currentResourceModifier; @@ -244,8 +244,8 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL fuelTotalTime = nbttagcompound.getInteger("FuelTotalTime"); fuelCurrentFerment = nbttagcompound.getInteger("FuelCurrentFerment"); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); - productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); + productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) { resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); productTank.readFromNBT(nbttagcompound.getCompoundTag("ProductTank")); @@ -685,8 +685,8 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank, productTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank, productTank }; } // ITRIGGERPROVIDER diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 95fb05177..2d557ceed 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -43,7 +43,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -127,7 +127,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory, } @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); //private ItemStack[] inventoryStacks = new ItemStack[12]; public MachineMoistener.Recipe currentRecipe; @@ -190,7 +190,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory, totalTime = nbttagcompound.getInteger("TotalTime"); productionTime = nbttagcompound.getInteger("ProductionTime"); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); @@ -687,8 +687,8 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory, } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } /* SMP GUI */ diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index bd0612c9a..34680308f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -35,7 +35,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.Fluids; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -49,7 +49,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private static final FluidStack STACK_WATER = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ - public ForestryTank resourceTank = new ForestryTank(Defaults.RAINTANK_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.RAINTANK_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); private boolean isValidBiome = true; private int fillingTime; @@ -97,7 +97,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui isValidBiome = nbttagcompound.getBoolean("IsValidBiome"); - resourceTank = new ForestryTank(Defaults.RAINTANK_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.RAINTANK_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); @@ -300,8 +300,8 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank }; } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 58776c862..40290943f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -44,7 +44,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -116,7 +116,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I /* MEMBER */ @EntityNetData - public ForestryTank productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); private Recipe currentRecipe; @@ -211,7 +211,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } // Product tank - productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ProductTank")) productTank.readFromNBT(nbttagcompound.getCompoundTag("ProductTank")); @@ -526,8 +526,8 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { productTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { productTank }; } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index e8ba3949b..031ed64ba 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -42,7 +42,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.triggers.ForestryTrigger; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -116,9 +116,9 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid /* MEMBER */ @EntityNetData - public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); @EntityNetData - public ForestryTank productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); @@ -172,8 +172,8 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid distillationTime = nbttagcompound.getInteger("DistillationTime"); distillationTotalTime = nbttagcompound.getInteger("DistillationTotalTime"); - resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); - productTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); + productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("ResourceTank")) { resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank")); productTank.readFromNBT(nbttagcompound.getCompoundTag("ProductTank")); @@ -483,8 +483,8 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid } @Override - public ForestryTank[] getTanks() { - return new ForestryTank[] { resourceTank, productTank }; + public StandardTank[] getTanks() { + return new StandardTank[] { resourceTank, productTank }; } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 30a48125b..b488b0173 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -51,7 +51,7 @@ import forestry.core.interfaces.IHintSource; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.core.utils.DelayTimer; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; @@ -88,7 +88,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); - private ForestryTank liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + private StandardTank liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); private IFarmLogic harvestProvider; // The farm logic which supplied the pending crops. private final Stack pendingCrops = new Stack(); @@ -121,7 +121,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable refreshFarmLogics(); - liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); if (nbttagcompound.hasKey("LiquidTank")) liquidTank.readFromNBT(nbttagcompound.getCompoundTag("LiquidTank")); } @@ -667,7 +667,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public void makeMaster() { super.makeMaster(); if (liquidTank == null) - liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY); + liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); refreshFarmLogics(); } @@ -676,7 +676,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable super.onStructureReset(); } - public ForestryTank getTank() { + public StandardTank getTank() { return liquidTank; } diff --git a/src/main/java/forestry/farming/gadgets/TileValve.java b/src/main/java/forestry/farming/gadgets/TileValve.java index 98977348f..fbd0cd174 100755 --- a/src/main/java/forestry/farming/gadgets/TileValve.java +++ b/src/main/java/forestry/farming/gadgets/TileValve.java @@ -10,11 +10,12 @@ ******************************************************************************/ package forestry.farming.gadgets; +import forestry.core.fluids.tanks.FakeTank; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; public class TileValve extends TileFarm implements ILiquidTankContainer { @@ -33,7 +34,7 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { } /* ILIQUIDTANKCONTAINER */ - private ForestryTank getMasterTank() { + private StandardTank getMasterTank() { if (!isIntegratedIntoStructure() || !hasMaster()) return null; @@ -46,7 +47,7 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - ForestryTank tank = getMasterTank(); + StandardTank tank = getMasterTank(); if (tank == null) return 0; @@ -55,7 +56,7 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - ForestryTank tank = getMasterTank(); + StandardTank tank = getMasterTank(); if (tank == null) return null; @@ -63,12 +64,12 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { } @Override - public ForestryTank[] getTanks() { - ForestryTank tank = getMasterTank(); + public StandardTank[] getTanks() { + StandardTank tank = getMasterTank(); if (tank == null) - return ForestryTank.FAKETANK_ARRAY; + return FakeTank.ARRAY; - return new ForestryTank[] { tank }; + return new StandardTank[] { tank }; } } diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index d045798f1..907612e50 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import forestry.api.farming.IFarmLogic; +import forestry.core.fluids.tanks.FakeTank; import forestry.core.gui.ContainerSocketed; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotForestry; @@ -30,7 +31,7 @@ import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; import forestry.core.network.PacketTankUpdate; import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.utils.TileInventoryAdapter; import forestry.farming.gadgets.TileFarmPlain; import forestry.plugins.PluginFarming; @@ -135,7 +136,7 @@ public class ContainerFarm extends ContainerSocketed { public void updateProgressBar(int i, int j) { tile.getGUINetworkData(i, j); } - private Map syncedFluids = new HashMap(); + private Map syncedFluids = new HashMap(); @Override public void detectAndSendChanges() { @@ -145,7 +146,7 @@ public class ContainerFarm extends ContainerSocketed { tile.sendGUINetworkData(this, (ICrafting) crafters.get(i)); } - ForestryTank tank = tile.getTank(); + StandardTank tank = tile.getTank(); // If null has been synced if (tank.getFluid() == null && getTank(0).getFluidAmount() <= 0) @@ -160,7 +161,7 @@ public class ContainerFarm extends ContainerSocketed { Proxies.net.sendToPlayer(new PacketTankUpdate(0, tank), player); } } - syncedFluids.put(0, new ForestryTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity())); + syncedFluids.put(0, new StandardTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity())); } @@ -168,13 +169,13 @@ public class ContainerFarm extends ContainerSocketed { public void onTankUpdate(NBTTagCompound nbt) { int tankID = nbt.getByte("tank"); int capacity = nbt.getShort("capacity"); - ForestryTank tank = new ForestryTank(capacity); + StandardTank tank = new StandardTank(capacity); tank.readFromNBT(nbt); syncedFluids.put(tankID, tank); } @Override - public ForestryTank getTank(int slot) { - return syncedFluids.get(slot) == null ? ForestryTank.FAKETANK : syncedFluids.get(slot); + public StandardTank getTank(int slot) { + return syncedFluids.get(slot) == null ? FakeTank.INSTANCE : syncedFluids.get(slot); } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java index 52c46865c..eec0b98e5 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java @@ -18,7 +18,7 @@ import buildcraft.api.gates.ITriggerParameter; import forestry.api.core.ITileStructure; import forestry.core.triggers.Trigger; -import forestry.core.utils.ForestryTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; @@ -49,7 +49,7 @@ public class TriggerLowLiquid extends Trigger { if (central == null || !(central instanceof TileFarmPlain)) return false; - ForestryTank tank = ((TileFarmPlain) central).getTank(); + StandardTank tank = ((TileFarmPlain) central).getTank(); return ((float) tank.getFluidAmount() / tank.getCapacity()) <= threshold; } }