mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 15:22:57 +00:00
Updated to Forestry 157
This commit is contained in:
commit
3dbedba7be
74 files changed
+1380
-1003
No files matched your search
@@ -12,10 +12,12 @@ package forestry.factory.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -25,10 +27,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
@@ -36,11 +39,11 @@ import buildcraft.api.power.PowerHandler;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.recipes.IBottlerManager;
|
||||
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.fluids.TankManager;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
@@ -87,10 +90,13 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
public static class RecipeManager implements IBottlerManager {
|
||||
public static ArrayList<MachineBottler.Recipe> recipes = new ArrayList<MachineBottler.Recipe>();
|
||||
public static HashSet<Fluid> recipeFluids = new HashSet<Fluid>();
|
||||
|
||||
@Override
|
||||
public void addRecipe(int cyclesPerUnit, FluidStack input, ItemStack can, ItemStack bottled) {
|
||||
recipes.add(new MachineBottler.Recipe(cyclesPerUnit, input, can, bottled));
|
||||
if (input != null)
|
||||
recipeFluids.add(input.getFluid());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +120,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
if(FluidContainerRegistry.isEmptyContainer(empty)) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(res, empty);
|
||||
if(filled != null) {
|
||||
RecipeManagers.bottlerManager.addRecipe(CYCLES_FILLING_DEFAULT, FluidContainerRegistry.getFluidForFilledItem(filled), empty, filled);
|
||||
return findMatchingRecipe(res, empty);
|
||||
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
return findMatchingRecipe(fluidStack, empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,14 +134,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
* @return true if any recipe has a matching input
|
||||
*/
|
||||
public static boolean isInput(FluidStack res) {
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
Recipe recipe = recipes.get(i);
|
||||
if (recipe.hasInput(res))
|
||||
return true;
|
||||
}
|
||||
|
||||
return FluidRegistry.isFluidRegistered(res.getFluid());
|
||||
|
||||
return recipeFluids.contains(res.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +149,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
}
|
||||
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(3, "Items");
|
||||
|
||||
@@ -164,6 +164,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
public MachineBottler() {
|
||||
energyStorage = new EnergyStorage(4000);
|
||||
setHints(Config.hints.get("bottler"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,10 +193,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
nbttagcompound.setInteger("FillingTotalTime", fillingTotalTime);
|
||||
nbttagcompound.setBoolean("ProductPending", productPending);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@@ -217,9 +216,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
fillingTotalTime = nbttagcompound.getInteger("FillingTotalTime");
|
||||
productPending = nbttagcompound.getBoolean("ProductPending");
|
||||
|
||||
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ResourceTank"))
|
||||
resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
|
||||
@@ -373,7 +370,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
fillingTime = j;
|
||||
@@ -385,8 +382,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, fillingTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, fillingTotalTime);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, fillingTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, fillingTotalTime);
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@@ -481,23 +479,37 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
|
||||
if (!RecipeManager.isInput(resource))
|
||||
return 0;
|
||||
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
// TODO: Slow down updates
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank };
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
// ITRIGGERPROVIDER
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.factory.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -27,9 +28,11 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
@@ -41,7 +44,9 @@ 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.proxy.Proxies;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
@@ -142,6 +147,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
public static class RecipeManager implements ICarpenterManager {
|
||||
|
||||
public static ArrayList<MachineCarpenter.Recipe> recipes = new ArrayList<MachineCarpenter.Recipe>();
|
||||
public static HashSet<Fluid> recipeFluids = new HashSet<Fluid>();
|
||||
|
||||
@Override
|
||||
public void addCrating(ItemStack itemStack) {
|
||||
@@ -171,6 +177,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
@Override
|
||||
public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object materials[]) {
|
||||
recipes.add(new Recipe(packagingTime, liquid, box, ShapedRecipeCustom.createShapedRecipe(product, materials)));
|
||||
if (liquid != null)
|
||||
recipeFluids.add(liquid.getFluid());
|
||||
}
|
||||
|
||||
public static Recipe findMatchingRecipe(FluidStack liquid, ItemStack item, InventoryCrafting inventorycrafting, World world) {
|
||||
@@ -183,12 +191,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
public static boolean isResourceLiquid(FluidStack liquid) {
|
||||
for (Recipe recipe : recipes) {
|
||||
if (recipe.hasLiquid(liquid))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return recipeFluids.contains(liquid.getFluid());
|
||||
}
|
||||
|
||||
public static boolean isBox(ItemStack resource) {
|
||||
@@ -215,7 +218,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
/* MEMBER */
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private final TileInventoryAdapter craftingInventory;
|
||||
private final TileInventoryAdapter accessibleInventory;
|
||||
public MachineCarpenter.Recipe currentRecipe;
|
||||
@@ -233,8 +237,11 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
public MachineCarpenter() {
|
||||
energyStorage = new EnergyStorage(4000);
|
||||
setHints(Config.hints.get("carpenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems");
|
||||
accessibleInventory = (TileInventoryAdapter) new TileInventoryAdapter(this, 30, "Items").configureSided(Defaults.FACINGS, SLOT_BOX, 20);
|
||||
|
||||
tankManager = new TankManager(resourceTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -260,10 +267,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
nbttagcompound.setInteger("PackageTime", packageTime);
|
||||
nbttagcompound.setInteger("PackageTotalTime", totalTime);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
|
||||
craftingInventory.writeToNBT(nbttagcompound);
|
||||
accessibleInventory.writeToNBT(nbttagcompound);
|
||||
@@ -289,9 +293,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
packageTime = nbttagcompound.getInteger("PackageTime");
|
||||
totalTime = nbttagcompound.getInteger("PackageTotalTime");
|
||||
|
||||
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ResourceTank"))
|
||||
resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
if (nbttagcompound.hasKey("CraftItems"))
|
||||
craftingInventory.readFromNBT(nbttagcompound);
|
||||
@@ -456,7 +458,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
private boolean removeSets(int count, ItemStack[] set) {
|
||||
EntityPlayer player = worldObj.getPlayerEntityByName(owner.getName());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, owner);
|
||||
return accessibleInventory.removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true);
|
||||
}
|
||||
|
||||
@@ -604,7 +606,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
packageTime = j;
|
||||
@@ -616,8 +618,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, packageTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, totalTime);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, packageTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, totalTime);
|
||||
}
|
||||
|
||||
/* ISIDEDINVENTORY */
|
||||
@@ -672,18 +675,40 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
// ILIQUIDCONTAINER IMPLEMENTATION
|
||||
@Override
|
||||
public int fill(ForgeDirection direction, FluidStack resource, boolean doFill) {
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
// TODO: Slow down updates
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
return tankManager.fill(direction, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank };
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
public void resetProductDisplay(InventoryCrafting craftMatrix) {
|
||||
setCurrentRecipe(RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), craftMatrix, getWorldObj()));
|
||||
}
|
||||
|
||||
// ITRIGGERPROVIDER
|
||||
|
||||
@@ -23,6 +23,8 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
@@ -38,10 +40,14 @@ import forestry.core.interfaces.ICrafter;
|
||||
import forestry.core.interfaces.ICraftingPlan;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineFabricator extends TilePowered implements ICrafter, ISpecialInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -230,8 +236,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
public static final short SLOT_INVENTORY_COUNT = 18;
|
||||
|
||||
/* MEMBER */
|
||||
private final TankManager tankManager;
|
||||
private FilteredTank moltenTank;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(30, "Items");
|
||||
private StandardTank moltenTank = new StandardTank(2 * Defaults.BUCKET_VOLUME);
|
||||
private final int moltenTankIndex;
|
||||
private int heat = 0;
|
||||
private int guiMeltingPoint = 0;
|
||||
|
||||
@@ -239,6 +247,11 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
|
||||
public MachineFabricator() {
|
||||
energyStorage = new EnergyStorage(3300);
|
||||
Fluid liquidGlass = FluidRegistry.getFluid(Defaults.LIQUID_GLASS);
|
||||
moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, liquidGlass);
|
||||
moltenTank.tankMode = StandardTank.TankMode.INTERNAL;
|
||||
tankManager = new TankManager(moltenTank);
|
||||
moltenTankIndex = moltenTank.getTankIndex();
|
||||
}
|
||||
|
||||
/*@Override //TODO
|
||||
@@ -264,9 +277,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
nbttagcompound.setInteger("Heat", heat);
|
||||
|
||||
// Tank
|
||||
NBTTagCompound nbtMoltenTank = new NBTTagCompound();
|
||||
moltenTank.writeToNBT(nbtMoltenTank);
|
||||
nbttagcompound.setTag("MoltenTank", nbtMoltenTank);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
|
||||
// Pending Smelt
|
||||
if (pendingSmelt != null) {
|
||||
@@ -286,9 +297,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
heat = nbttagcompound.getInteger("Heat");
|
||||
|
||||
// Tank
|
||||
moltenTank = new StandardTank(Defaults.BUCKET_VOLUME * 2);
|
||||
if (nbttagcompound.hasKey("MoltenTank"))
|
||||
moltenTank.readFromNBT(nbttagcompound.getCompoundTag("MoltenTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
// Pending Smelt
|
||||
if (nbttagcompound.hasKey("PendingSmelt")) {
|
||||
@@ -305,13 +314,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
|
||||
// Remove smelt if we have gone below metling point
|
||||
if (moltenTank.getFluidAmount() > 0) {
|
||||
Smelting smelt = RecipeManager.findMatchingSmelting(moltenTank.getFluid());
|
||||
if (smelt != null && heat < smelt.meltingPoint)
|
||||
moltenTank.drain(5, true);
|
||||
}
|
||||
|
||||
// Add pending smelt
|
||||
if (pendingSmelt != null) {
|
||||
|
||||
@@ -321,16 +323,19 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
if (pendingSmelt.amount <= 0)
|
||||
pendingSmelt = null;
|
||||
// Smelt if necessary and possible
|
||||
} else if (moltenTank.getFluidAmount() < moltenTank.getCapacity())
|
||||
if (inventory.getStackInSlot(SLOT_METAL) != null) {
|
||||
} else if (moltenTank.getFluidAmount() < moltenTank.getCapacity() && inventory.getStackInSlot(SLOT_METAL) != null) {
|
||||
Smelting smelt = RecipeManager.findMatchingSmelting(inventory.getStackInSlot(SLOT_METAL));
|
||||
if (smelt != null && smelt.meltingPoint <= heat) {
|
||||
|
||||
Smelting smelt = RecipeManager.findMatchingSmelting(inventory.getStackInSlot(SLOT_METAL));
|
||||
if (smelt != null && smelt.meltingPoint <= heat) {
|
||||
|
||||
this.decrStackSize(SLOT_METAL, 1);
|
||||
pendingSmelt = smelt.product.copy();
|
||||
}
|
||||
this.decrStackSize(SLOT_METAL, 1);
|
||||
pendingSmelt = smelt.product.copy();
|
||||
}
|
||||
} else if (moltenTank.getFluidAmount() > 0) {
|
||||
// Remove smelt if we have gone below melting point
|
||||
Smelting smelt = RecipeManager.findMatchingSmelting(moltenTank.getFluid());
|
||||
if (smelt != null && heat < smelt.meltingPoint)
|
||||
moltenTank.drain(5, true);
|
||||
}
|
||||
|
||||
this.dissipateHeat();
|
||||
}
|
||||
@@ -477,19 +482,18 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
|
||||
/* SMP */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
int messageId = tankManager.maxMessageId() + 1;
|
||||
|
||||
if (i == messageId)
|
||||
heat = j;
|
||||
break;
|
||||
case 1:
|
||||
else if (i == messageId + 1)
|
||||
guiMeltingPoint = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, heat);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, getMeltingPoint());
|
||||
int messageId = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, messageId, heat);
|
||||
iCrafting.sendProgressBarUpdate(container, messageId + 1, getMeltingPoint());
|
||||
}
|
||||
|
||||
// / ISPECIALINVENTORY
|
||||
@@ -504,7 +508,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
ItemStack taken;
|
||||
if (doRemove) {
|
||||
EntityPlayer player = worldObj.getPlayerEntityByName(owner.getName());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, owner);
|
||||
taken = this.takenFromSlot(SLOT_RESULT, false, player);
|
||||
} else {
|
||||
taken = this.getResult();
|
||||
@@ -581,7 +585,38 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { moltenTank };
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,9 +12,11 @@ package forestry.factory.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -23,6 +25,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -45,10 +48,12 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -118,10 +123,16 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
public static class RecipeManager implements IFermenterManager {
|
||||
|
||||
public static ArrayList<MachineFermenter.Recipe> recipes = new ArrayList<MachineFermenter.Recipe>();
|
||||
public static HashSet<Fluid> recipeFluidInputs = new HashSet<Fluid>();
|
||||
public static HashSet<Fluid> recipeFluidOutputs = new HashSet<Fluid>();
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid) {
|
||||
recipes.add(new Recipe(resource, fermentationValue, modifier, output, liquid));
|
||||
if (liquid != null)
|
||||
recipeFluidInputs.add(liquid.getFluid());
|
||||
if (output != null)
|
||||
recipeFluidOutputs.add(output.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,21 +163,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
public static boolean isLiquidResource(FluidStack liquid) {
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
Recipe recipe = recipes.get(i);
|
||||
if (recipe.liquid.isFluidEqual(liquid))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return recipeFluidInputs.contains(liquid.getFluid());
|
||||
}
|
||||
|
||||
public static boolean isLiquidProduct(FluidStack liquid) {
|
||||
for (int i = 0; i < recipes.size(); i++) {
|
||||
Recipe recipe = recipes.get(i);
|
||||
if (recipe.output.isFluidEqual(liquid))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return recipeFluidOutputs.contains(liquid.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,9 +182,12 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
}
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
@EntityNetData
|
||||
public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank productTank;
|
||||
|
||||
private final TankManager tankManager;
|
||||
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(5, "Items");
|
||||
private Recipe currentRecipe;
|
||||
private float currentResourceModifier;
|
||||
@@ -196,6 +200,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
public MachineFermenter() {
|
||||
energyStorage = new EnergyStorage(8000);
|
||||
setHints(Config.hints.get("fermenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidOutputs);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
tankManager = new TankManager(resourceTank, productTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,15 +232,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
nbttagcompound.setInteger("FuelTotalTime", fuelTotalTime);
|
||||
nbttagcompound.setInteger("FuelCurrentFerment", fuelCurrentFerment);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
NBTTagCompound NBTproductSlot = new NBTTagCompound();
|
||||
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
productTank.writeToNBT(NBTproductSlot);
|
||||
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
nbttagcompound.setTag("ProductTank", NBTproductSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
|
||||
}
|
||||
@@ -246,13 +247,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
fuelTotalTime = nbttagcompound.getInteger("FuelTotalTime");
|
||||
fuelCurrentFerment = nbttagcompound.getInteger("FuelCurrentFerment");
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -513,28 +508,25 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
if (i == firstMessageId)
|
||||
fuelBurnTime = j;
|
||||
break;
|
||||
case 1:
|
||||
else if (i == firstMessageId + 1)
|
||||
fuelTotalTime = j;
|
||||
break;
|
||||
case 2:
|
||||
else if (i == firstMessageId + 2)
|
||||
fermentationTime = j;
|
||||
break;
|
||||
case 3:
|
||||
else if (i == firstMessageId + 3)
|
||||
fermentationTotalTime = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, fuelBurnTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, fuelTotalTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 2, fermentationTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 3, fermentationTotalTime);
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId, fuelBurnTime);
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId + 1, fuelTotalTime);
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId + 2, fermentationTime);
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId + 3, fermentationTotalTime);
|
||||
}
|
||||
|
||||
/* INVENTORY */
|
||||
@@ -665,20 +657,15 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
// ILIQUIDCONTAINER IMPLEMENTATION
|
||||
/* ILiquidTankContainer */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return resourceTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
if (!RecipeManager.isLiquidResource(resource))
|
||||
return 0;
|
||||
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
// updateNetworkTime.markTime(worldObj);
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -687,8 +674,22 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank, productTank };
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
// ITRIGGERPROVIDER
|
||||
|
||||
@@ -23,7 +23,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
@@ -43,11 +45,13 @@ import forestry.core.network.EntityNetData;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineMoistener extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -127,7 +131,8 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
}
|
||||
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
//private ItemStack[] inventoryStacks = new ItemStack[12];
|
||||
public MachineMoistener.Recipe currentRecipe;
|
||||
@@ -141,6 +146,8 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
|
||||
public MachineMoistener() {
|
||||
setHints(Config.hints.get("moistener"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,11 +169,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
nbttagcompound.setInteger("TotalTime", totalTime);
|
||||
nbttagcompound.setInteger("ProductionTime", productionTime);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
|
||||
// Write pending product
|
||||
@@ -190,10 +193,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
totalTime = nbttagcompound.getInteger("TotalTime");
|
||||
productionTime = nbttagcompound.getInteger("ProductionTime");
|
||||
|
||||
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ResourceTank"))
|
||||
resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank"));
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
|
||||
// Load pending product
|
||||
@@ -215,7 +215,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
// Check if we have suitable water container waiting in the item slot
|
||||
if (inventory.getStackInSlot(SLOT_PRODUCT) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_PRODUCT));
|
||||
if (container != null && container.fluid.isFluidEqual(STACK_WATER)) {
|
||||
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
|
||||
|
||||
inventory.setInventorySlotContents(SLOT_PRODUCT, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_PRODUCT), container, resourceTank));
|
||||
if (inventory.getStackInSlot(SLOT_PRODUCT).stackSize <= 0)
|
||||
@@ -633,7 +633,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container != null && container.fluid.isFluidEqual(STACK_WATER)) {
|
||||
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
|
||||
return inventory.addStack(stack, SLOT_PRODUCT, 1, false, doAdd);
|
||||
}
|
||||
|
||||
@@ -675,24 +675,44 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
return StackUtils.EMPTY_STACK_ARRAY;
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
/* ILiquidTankContainer */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank };
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
@@ -711,10 +731,11 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, totalTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 2, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 3, timePerItem);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, totalTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 2, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 3, timePerItem);
|
||||
}
|
||||
|
||||
// ITRIGGERPROVIDER
|
||||
|
||||
@@ -21,6 +21,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
@@ -35,11 +37,13 @@ import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.Fluids;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineRaintank extends TileBase implements ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -49,7 +53,8 @@ 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 StandardTank resourceTank = new StandardTank(Defaults.RAINTANK_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(3, "Items");
|
||||
private boolean isValidBiome = true;
|
||||
private int fillingTime;
|
||||
@@ -58,6 +63,9 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
public MachineRaintank() {
|
||||
setHints(Config.hints.get("raintank"));
|
||||
|
||||
resourceTank = new FilteredTank(Defaults.RAINTANK_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
|
||||
// Raintanks in desert and snow biomes are useless
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
@@ -84,10 +92,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
nbttagcompound.setBoolean("IsValidBiome", isValidBiome);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -97,10 +102,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
isValidBiome = nbttagcompound.getBoolean("IsValidBiome");
|
||||
|
||||
resourceTank = new StandardTank(Defaults.RAINTANK_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ResourceTank"))
|
||||
resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank"));
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -267,6 +269,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
fillingTime = j;
|
||||
@@ -275,33 +278,43 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, fillingTime);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, fillingTime);
|
||||
}
|
||||
|
||||
// / ILIQUIDCONTAINER IMPLEMENTATION
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
// We only accept water
|
||||
if (!resource.isFluidEqual(STACK_WATER))
|
||||
return 0;
|
||||
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
// updateNetworkTime.markTime(worldObj);
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int quantityMax, boolean doEmpty) {
|
||||
return resourceTank.drain(quantityMax, doEmpty);
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank };
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
@@ -25,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -46,10 +49,14 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineSqueezer extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -83,10 +90,16 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
|
||||
public static class RecipeManager implements ISqueezerManager {
|
||||
public static ArrayList<MachineSqueezer.Recipe> recipes = new ArrayList<MachineSqueezer.Recipe>();
|
||||
public static HashSet<Fluid> recipeFluids = new HashSet<Fluid>();
|
||||
public static HashSet<ItemStack> recipeInputs = new HashSet<ItemStack>();
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance) {
|
||||
recipes.add(new MachineSqueezer.Recipe(timePerItem, resources, liquid, remnants, chance));
|
||||
if (liquid != null)
|
||||
recipeFluids.add(liquid.getFluid());
|
||||
if (resources != null)
|
||||
recipeInputs.addAll(Arrays.asList(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +117,15 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean canUse(ItemStack itemStack) {
|
||||
if (recipeInputs.contains(itemStack))
|
||||
return true;
|
||||
for (ItemStack recipeInput : recipeInputs)
|
||||
if (StackUtils.isCraftingEquivalent(recipeInput, itemStack))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Object[], Object[]> getRecipes() {
|
||||
HashMap<Object[], Object[]> recipeList = new HashMap<Object[], Object[]>();
|
||||
@@ -116,8 +138,9 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
}
|
||||
|
||||
/* MEMBER */
|
||||
private final TankManager tankManager;
|
||||
@EntityNetData
|
||||
public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank productTank;
|
||||
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
private Recipe currentRecipe;
|
||||
@@ -130,6 +153,9 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
public MachineSqueezer() {
|
||||
energyStorage = new EnergyStorage(4000);
|
||||
setHints(Config.hints.get("squeezer"));
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
tankManager = new TankManager(productTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,10 +208,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
}
|
||||
nbttagcompound.setTag("PendingLiquids", nbttaglist);
|
||||
|
||||
// ProductTank
|
||||
NBTTagCompound NBTproductSlot = new NBTTagCompound();
|
||||
productTank.writeToNBT(NBTproductSlot);
|
||||
nbttagcompound.setTag("ProductTank", NBTproductSlot);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,10 +235,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
pendingLiquids.add(FluidStack.loadFluidStackFromNBT(nbttagcompound1));
|
||||
}
|
||||
|
||||
// Product tank
|
||||
productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ProductTank"))
|
||||
productTank.readFromNBT(nbttagcompound.getCompoundTag("ProductTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
checkRecipe();
|
||||
}
|
||||
@@ -347,7 +367,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
}
|
||||
|
||||
private boolean removeResources(ItemStack[] stacks) {
|
||||
EntityPlayer player = worldObj.getPlayerEntityByName(owner.getName());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, owner);
|
||||
return inventory.removeSets(1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true);
|
||||
}
|
||||
|
||||
@@ -379,6 +399,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
productionTime = j;
|
||||
@@ -390,8 +411,9 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, timePerItem);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, timePerItem);
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@@ -420,12 +442,22 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
|
||||
if(slotIndex == SLOT_CAN_INPUT) {
|
||||
return LiquidHelper.isEmptyContainer(itemstack);
|
||||
}
|
||||
|
||||
if(slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
|
||||
if (LiquidHelper.isEmptyContainer(itemstack))
|
||||
return false;
|
||||
|
||||
if (RecipeManager.canUse(itemstack))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,16 +506,9 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
if(!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if(slotIndex == SLOT_CAN_INPUT) {
|
||||
return LiquidHelper.isEmptyContainer(itemstack);
|
||||
}
|
||||
|
||||
if(slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
|
||||
return !LiquidHelper.isEmptyContainer(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
return slotIndex == SLOT_CAN_INPUT || (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
@@ -523,13 +548,37 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
|
||||
/* ILIQUIDCONTAINER IMPLEMENTATION */
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int quantityMax, boolean doEmpty) {
|
||||
return productTank.drain(quantityMax, doEmpty);
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { productTank };
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.factory.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,6 +24,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -44,10 +46,13 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineStill extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -85,10 +90,16 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
|
||||
public static class RecipeManager implements IStillManager {
|
||||
public static ArrayList<MachineStill.Recipe> recipes = new ArrayList<MachineStill.Recipe>();
|
||||
public static HashSet<Fluid> recipeFluidInputs = new HashSet<Fluid>();
|
||||
public static HashSet<Fluid> recipeFluidOutputs = new HashSet<Fluid>();
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerUnit, FluidStack input, FluidStack output) {
|
||||
recipes.add(new MachineStill.Recipe(timePerUnit, input, output));
|
||||
if (input != null)
|
||||
recipeFluidInputs.add(input.getFluid());
|
||||
if (output != null)
|
||||
recipeFluidOutputs.add(output.getFluid());
|
||||
}
|
||||
|
||||
public static Recipe findMatchingRecipe(FluidStack item) {
|
||||
@@ -101,7 +112,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
}
|
||||
|
||||
public static boolean isInput(FluidStack res) {
|
||||
return findMatchingRecipe(res) != null;
|
||||
return recipeFluidInputs.contains(res.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,9 +128,10 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
|
||||
/* MEMBER */
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
@EntityNetData
|
||||
public StandardTank productTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank productTank;
|
||||
private final TankManager tankManager;
|
||||
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(3, "Items");
|
||||
|
||||
@@ -131,6 +143,11 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
public MachineStill() {
|
||||
energyStorage = new EnergyStorage(8000);
|
||||
setHints(Config.hints.get("still"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidOutputs);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
tankManager = new TankManager(resourceTank, productTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,15 +172,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
nbttagcompound.setInteger("DistillationTime", distillationTime);
|
||||
nbttagcompound.setInteger("DistillationTotalTime", distillationTotalTime);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
NBTTagCompound NBTproductSlot = new NBTTagCompound();
|
||||
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
productTank.writeToNBT(NBTproductSlot);
|
||||
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
nbttagcompound.setTag("ProductTank", NBTproductSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -174,13 +183,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
distillationTime = nbttagcompound.getInteger("DistillationTime");
|
||||
distillationTotalTime = nbttagcompound.getInteger("DistillationTotalTime");
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
|
||||
checkRecipe();
|
||||
@@ -193,7 +196,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
if (inventory.getStackInSlot(SLOT_CAN) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
|
||||
|
||||
if (container != null && RecipeManager.isInput(container.fluid)) {
|
||||
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
|
||||
|
||||
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, resourceTank));
|
||||
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
|
||||
@@ -321,7 +324,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
distillationTime = j;
|
||||
@@ -333,8 +336,9 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, distillationTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, distillationTotalTime);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, distillationTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, distillationTotalTime);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@@ -343,7 +347,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
int inventorySlot;
|
||||
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container != null && RecipeManager.isInput(container.fluid))
|
||||
if (container != null && resourceTank.accepts(container.fluid.getFluid()))
|
||||
inventorySlot = SLOT_CAN;
|
||||
else if (LiquidHelper.isEmptyContainer(stack))
|
||||
inventorySlot = SLOT_RESOURCE;
|
||||
@@ -458,35 +462,45 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
|
||||
if(slotIndex == SLOT_CAN) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack);
|
||||
return container != null && RecipeManager.isInput(container.fluid);
|
||||
return container != null && resourceTank.accepts(container.fluid.getFluid());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
/* ILiquidTankContainer */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
if (!MachineStill.RecipeManager.isInput(resource))
|
||||
return 0;
|
||||
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
sendNetworkUpdate();
|
||||
|
||||
return used;
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int quantityMax, boolean doEmpty) {
|
||||
return productTank.drain(quantityMax, doEmpty);
|
||||
return tankManager.drain(from, quantityMax, doEmpty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { resourceTank, productTank };
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
|
||||
@@ -42,19 +42,6 @@ public class ContainerBottler extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.factory.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCraftResult;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -110,19 +109,9 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
machine.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++) {
|
||||
machine.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
updateProductSlot();
|
||||
}
|
||||
|
||||
@@ -150,8 +139,7 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain
|
||||
|
||||
private void resetProductDisplay() {
|
||||
if (machine != null) {
|
||||
machine.setCurrentRecipe(MachineCarpenter.RecipeManager.findMatchingRecipe(machine.resourceTank.getFluid(), machine.getBoxStack(), craftMatrix,
|
||||
machine.getWorldObj()));
|
||||
machine.resetProductDisplay(craftMatrix);
|
||||
updateProductSlot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,17 +55,4 @@ public class ContainerFabricator extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,19 +43,6 @@ public class ContainerFermenter extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
fermenter.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
fermenter.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return fermenter.isUseableByPlayer(entityplayer);
|
||||
|
||||
@@ -57,19 +57,6 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain
|
||||
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory iinventory, int slot) {
|
||||
inventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot));
|
||||
|
||||
@@ -40,19 +40,6 @@ public class ContainerRaintank extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
|
||||
@@ -50,17 +50,4 @@ public class ContainerSqueezer extends ContainerLiquidTanks {
|
||||
addSlot(new Slot(player, j1, 8 + j1 * 18, 142));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,19 +39,6 @@ public class ContainerStill extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
// @Override client side only
|
||||
public void updateProgressBar(int i, int j) {
|
||||
processor.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
processor.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return processor.isUseableByPlayer(entityplayer);
|
||||
|
||||
Reference in new issue
Block a user