mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 11:19:28 +00:00
Updated to Forestry 157
This commit is contained in:
commit
3dbedba7be
74 files changed
+1380
-1003
No files matched your search
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 ChickenBones
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,38 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class VisiblityData
|
||||
{
|
||||
public boolean showUtilityButtons = true;
|
||||
public boolean showStateButtons = true;
|
||||
/**
|
||||
* Item panel and associated buttons
|
||||
*/
|
||||
public boolean showItemPanel = true;
|
||||
/**
|
||||
* Item and search section
|
||||
*/
|
||||
public boolean showItemSection = true;
|
||||
/**
|
||||
* Dropdown and Item search field
|
||||
*/
|
||||
public boolean showSearchSection = true;
|
||||
/**
|
||||
* All widgets except options button
|
||||
*/
|
||||
public boolean showWidgets = true;
|
||||
/**
|
||||
* The entire NEI interface, aka hidden
|
||||
*/
|
||||
public boolean showNEI = true;
|
||||
public boolean enableDeleteMode = true;
|
||||
|
||||
public void translateDependancies()
|
||||
{
|
||||
if(!showNEI)
|
||||
showWidgets = false;
|
||||
if(!showWidgets)
|
||||
showItemSection = showUtilityButtons = showStateButtons = false;
|
||||
if(!showItemSection)
|
||||
showSearchSection = showItemPanel = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* If this is implemented on a gui, it will be automatically registered
|
||||
*/
|
||||
public interface INEIGuiHandler
|
||||
{
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
|
||||
|
||||
/**
|
||||
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
|
||||
* return null for no range
|
||||
*/
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
|
||||
|
||||
/**
|
||||
* @return A list of TaggedInventoryAreas that will be used with the savestates.
|
||||
*/
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
|
||||
|
||||
/**
|
||||
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
|
||||
* Changes made to the stackSize of the dragged stack will be kept
|
||||
* @param gui The current gui instance
|
||||
* @param mousex The x position of the mouse
|
||||
* @param mousey The y position of the mouse
|
||||
* @param draggedStack The stack being dragged from the item panel
|
||||
* @param button The button presed
|
||||
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
|
||||
*/
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
|
||||
|
||||
/**
|
||||
* Used to prevent the item panel from drawing on top of other gui elements.
|
||||
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
|
||||
* @param x The x coordinate of the rectangle bounding the slot
|
||||
* @param y The y coordinate of the rectangle bounding the slot
|
||||
* @param w The w coordinate of the rectangle bounding the slot
|
||||
* @param h The h coordinate of the rectangle bounding the slot
|
||||
* @return true if the item panel slot within the specified rectangle should not be rendered.
|
||||
*/
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TaggedInventoryArea
|
||||
{
|
||||
public HashSet<Integer> slots = new HashSet<Integer>();
|
||||
public String tagName;
|
||||
/**
|
||||
* Only for player inventories.
|
||||
*/
|
||||
private IInventory inventory;
|
||||
/**
|
||||
* Other inventories
|
||||
*/
|
||||
private Container container;
|
||||
|
||||
public TaggedInventoryArea(InventoryPlayer invPlayer)
|
||||
{
|
||||
this("InventoryPlayer", 0, 39, null);
|
||||
inventory = invPlayer;
|
||||
}
|
||||
|
||||
public TaggedInventoryArea(String name, int first, int last, Container container)
|
||||
{
|
||||
this.container = container;
|
||||
tagName = name;
|
||||
for(int i = first; i <= last; i++)
|
||||
slots.add(i);
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
if(inventory != null)
|
||||
return inventory.getStackInSlot(i);
|
||||
return container.getSlot(i).getStack();
|
||||
}
|
||||
|
||||
public boolean isContainer()
|
||||
{
|
||||
return inventory == null;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import forestry.api.fuels.EngineBronzeFuel;
|
||||
import forestry.api.fuels.EngineCopperFuel;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.fuels.RainSubstrate;
|
||||
import forestry.core.ForestryCore;
|
||||
@@ -66,6 +67,7 @@ public class Forestry {
|
||||
FuelManager.rainSubstrate = new ItemStackMap<RainSubstrate>();
|
||||
FuelManager.bronzeEngineFuel = new FluidMap<EngineBronzeFuel>();
|
||||
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
|
||||
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
|
||||
}
|
||||
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
|
||||
public static ForestryCore core = new ForestryCore();
|
||||
|
||||
@@ -18,14 +18,17 @@ 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 net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -57,7 +60,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
|
||||
/* MEMBERS */
|
||||
InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
|
||||
private StandardTank liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
private final TankManager tankManager;
|
||||
private FilteredTank liquidTank;
|
||||
|
||||
private HygroregulatorRecipe currentRecipe;
|
||||
private int transferTime;
|
||||
@@ -65,9 +69,16 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
public TileAlvearyHygroregulator() {
|
||||
super(BLOCK_META);
|
||||
|
||||
recipes = new HygroregulatorRecipe[] { new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_WATER), 1), 1, 0.01f, -0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_LAVA), 1), 10, -0.01f, +0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_ICE), 1), 10, 0.02f, -0.01f) };
|
||||
Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER);
|
||||
Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA);
|
||||
Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE);
|
||||
|
||||
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
|
||||
tankManager = new TankManager(liquidTank);
|
||||
|
||||
recipes = new HygroregulatorRecipe[] { new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,9 +157,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
|
||||
canInventory.readFromNBT(nbttagcompound);
|
||||
|
||||
liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("LiquidTank"))
|
||||
liquidTank.readFromNBT(nbttagcompound.getCompoundTag("LiquidTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
transferTime = nbttagcompound.getInteger("TransferTime");
|
||||
|
||||
@@ -164,9 +173,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
|
||||
canInventory.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
liquidTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("LiquidTank", NBTresourceSlot);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("TransferTime", transferTime);
|
||||
if (currentRecipe != null) {
|
||||
@@ -268,30 +275,54 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
if (slotIndex == 0) {
|
||||
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
|
||||
if (fluid == null || fluid.amount <= 0)
|
||||
return false;
|
||||
return liquidTank.accepts(fluid.getFluid());
|
||||
}
|
||||
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return liquidTank.fill(resource, 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 liquidTank.drain(maxDrain, doDrain);
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { liquidTank };
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGUINetworkData(int messageId, int data) {}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {}
|
||||
}
|
||||
@@ -37,17 +37,4 @@ public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ public class BlockTypeLeaf extends BlockType {
|
||||
|
||||
public BlockTypeLeaf(GameProfile owner) {
|
||||
super(ForestryBlock.leaves, 0);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,10 +58,10 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
|
||||
|
||||
private GameProfile getOwner() {
|
||||
TileEntity tile = world.getTileEntity(startX, startY, startZ);
|
||||
if (!(tile instanceof TileSapling))
|
||||
return Utils.getForestryPlayerProfile();
|
||||
|
||||
return ((TileSapling) tile).getOwnerProfile();
|
||||
if (tile instanceof TileSapling)
|
||||
return ((TileSapling) tile).getOwnerProfile();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void preGenerate();
|
||||
|
||||
@@ -104,9 +104,6 @@ public class Config {
|
||||
// Mail
|
||||
public static boolean mailAlertEnabled = true;
|
||||
|
||||
public static String fakeUserLogin = "[Forestry]";
|
||||
public static boolean fakeUserAutoop = true;
|
||||
|
||||
// Hints
|
||||
public static boolean disableHints = false;
|
||||
public static HashMap<String, String[]> hints = new HashMap<String, String[]>();
|
||||
@@ -258,17 +255,8 @@ public class Config {
|
||||
for (String str : disabledStructures)
|
||||
Proxies.log.finer("Disabled structure '%s'.", str);
|
||||
|
||||
property = config.get("permissions.login", CATEGORY_COMMON, "[Forestry]");
|
||||
property.Comment = "set the default login used by Forestry.";
|
||||
Config.fakeUserLogin = property.Value;
|
||||
|
||||
property = config.get("permissions.autoop", CATEGORY_COMMON, true);
|
||||
property.Comment = "set to false to prevent Forestry's user from autooping.";
|
||||
Config.fakeUserAutoop = Boolean.parseBoolean(property.Value);
|
||||
|
||||
Config.MJ_RF_Ratio = Double.parseDouble(config.get("MJ_RF_Ratio", CATEGORY_COMMON, 10F).Value);
|
||||
Config.MJ_EU_Ratio = Double.parseDouble(config.get("MJ_EU_Ratio", CATEGORY_COMMON, 2.5F).Value);
|
||||
|
||||
registerClimates();
|
||||
ForestryTrigger.initialize();
|
||||
|
||||
|
||||
@@ -11,8 +11,11 @@
|
||||
package forestry.core.fluids;
|
||||
|
||||
import com.google.common.collect.ForwardingList;
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.inventory.ITileFilter;
|
||||
import forestry.core.network.PacketGuiInteger;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.NBTUtil;
|
||||
import forestry.core.utils.NBTUtil.NBTList;
|
||||
import java.io.DataInputStream;
|
||||
@@ -20,6 +23,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -64,6 +68,15 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
return tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends StandardTank> collection) {
|
||||
boolean changed = false;
|
||||
for (StandardTank tank : collection)
|
||||
changed |= add(tank);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(StandardTank tank) {
|
||||
boolean added = tanks.add(tank);
|
||||
@@ -74,6 +87,10 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
return added;
|
||||
}
|
||||
|
||||
public int maxMessageId() {
|
||||
return NETWORK_DATA * tanks.size();
|
||||
}
|
||||
|
||||
public void writeTanksToNBT(NBTTagCompound data) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (byte slot = 0; slot < tanks.size(); slot++) {
|
||||
@@ -132,6 +149,11 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
tank.setFluid(null);
|
||||
}
|
||||
|
||||
public void initGuiData(Container container, ICrafting player) {
|
||||
for (StandardTank tank : tanks)
|
||||
initGuiData(container, player, tank.getTankIndex());
|
||||
}
|
||||
|
||||
public void initGuiData(Container container, ICrafting player, int tankIndex) {
|
||||
if (tankIndex >= tanks.size())
|
||||
return;
|
||||
@@ -144,7 +166,13 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
}
|
||||
|
||||
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
|
||||
PacketBuilder.instance().sendGuiIntegerPacket((EntityPlayerMP) player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
|
||||
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
|
||||
Proxies.net.sendToPlayer(packet, (EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
public void updateGuiData(Container container, List crafters) {
|
||||
for (StandardTank tank : tanks)
|
||||
updateGuiData(container, crafters, tank.getTankIndex());
|
||||
}
|
||||
|
||||
public void updateGuiData(Container container, List crafters, int tankIndex) {
|
||||
@@ -165,14 +193,19 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
fluidAmount = fluidStack.amount;
|
||||
}
|
||||
crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
|
||||
PacketBuilder.instance().sendGuiIntegerPacket(player, container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
|
||||
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
} 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);
|
||||
if (fluidStack.amount != prev.amount) {
|
||||
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
if (color != pColor) {
|
||||
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 2, color);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,26 +250,41 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return fill(0, resource, doFill);
|
||||
for (StandardTank tank : tanks)
|
||||
if (tankAcceptsFluid(tank, resource))
|
||||
return fill(tank.getTankIndex(), resource, doFill);
|
||||
|
||||
return FakeTank.INSTANCE.fill(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);
|
||||
StandardTank tank = tanks.get(tankIndex);
|
||||
if (!tank.canBeFilledExternally())
|
||||
return 0;
|
||||
|
||||
return tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return drain(0, maxDrain, doDrain);
|
||||
for (StandardTank tank : tanks)
|
||||
if (tankCanDrain(tank))
|
||||
return drain(tank.getTankIndex(), maxDrain, doDrain);
|
||||
return FakeTank.INSTANCE.drain(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);
|
||||
StandardTank tank = tanks.get(tankIndex);
|
||||
if (!tank.canBeDrainedExternally())
|
||||
return null;
|
||||
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,10 +317,16 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
return getTankInfo(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
|
||||
public FluidTankInfo getTankInfo(int tankIndex) {
|
||||
return get(tankIndex).getInfo();
|
||||
}
|
||||
|
||||
public FluidStack getFluid(int tankIndex) {
|
||||
return get(tankIndex).getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank get(int tankIndex) {
|
||||
if (tankIndex < 0 || tankIndex >= tanks.size())
|
||||
return null;
|
||||
return tanks.get(tankIndex);
|
||||
}
|
||||
|
||||
@@ -284,24 +338,6 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
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)
|
||||
@@ -309,25 +345,18 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
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) {
|
||||
private boolean tankAcceptsFluid(StandardTank tank, FluidStack fluidStack) {
|
||||
if (fluidStack == null)
|
||||
return false;
|
||||
if (!tank.canBeFilledExternally())
|
||||
return false;
|
||||
if (tank.fill(fluidStack, false) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tankCanDrainFluid(IFluidTank tank, FluidStack fluidStack) {
|
||||
if (fluidStack == null)
|
||||
private boolean tankCanDrain(StandardTank tank) {
|
||||
if (!tank.canBeDrainedExternally())
|
||||
return false;
|
||||
FluidStack drained = tank.drain(1, false);
|
||||
if (drained != null && drained.amount > 0)
|
||||
@@ -335,4 +364,8 @@ public class TankManager extends ForwardingList<StandardTank> implements IFluidH
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tankCanDrainFluid(StandardTank tank, FluidStack fluidStack) {
|
||||
return fluidStack != null && tankCanDrain(tank);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,11 @@ 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.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -22,49 +26,66 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
*/
|
||||
public class FilteredTank extends StandardTank {
|
||||
|
||||
private final Fluid filter;
|
||||
private HashSet<Fluid> filters;
|
||||
|
||||
public FilteredTank(int capacity, Fluid filter) {
|
||||
this(capacity, filter, null);
|
||||
}
|
||||
public FilteredTank(int capacity, Fluid... filters) {
|
||||
this(capacity, Arrays.asList(filters), null);
|
||||
}
|
||||
|
||||
public FilteredTank(int capacity, Fluid filter, TileEntity tile) {
|
||||
super(capacity, tile);
|
||||
this.filter = filter;
|
||||
}
|
||||
public FilteredTank(int capacity, Collection<Fluid> filters) {
|
||||
this(capacity, filters, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (liquidMatchesFilter(resource))
|
||||
return super.fill(resource, doFill);
|
||||
return 0;
|
||||
}
|
||||
public FilteredTank(int capacity, Collection<Fluid> filters, TileEntity tile) {
|
||||
super(capacity, tile);
|
||||
this.filters = new HashSet<Fluid>(filters);
|
||||
}
|
||||
|
||||
public Fluid getFilter() {
|
||||
return filter;
|
||||
}
|
||||
public void addFilter(Fluid filter) {
|
||||
if (!accepts(filter))
|
||||
filters.add(filter);
|
||||
}
|
||||
|
||||
public boolean liquidMatchesFilter(FluidStack resource) {
|
||||
if (resource == null || filter == null)
|
||||
return false;
|
||||
return resource.getFluid() == filter;
|
||||
}
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (liquidMatchesFilter(resource))
|
||||
return super.fill(resource, doFill);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@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())));
|
||||
}
|
||||
@Override
|
||||
public boolean accepts(Fluid fluid) {
|
||||
return filters.contains(fluid);
|
||||
}
|
||||
|
||||
public boolean liquidMatchesFilter(FluidStack resource) {
|
||||
if (resource == null || filters == null)
|
||||
return false;
|
||||
return filters.contains(resource.getFluid());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshTooltip() {
|
||||
if (hasFluid()) {
|
||||
super.refreshTooltip();
|
||||
return;
|
||||
}
|
||||
|
||||
toolTip.clear();
|
||||
int amount = 0;
|
||||
for (Fluid filter : filters) {
|
||||
EnumRarity rarity = filter.getRarity();
|
||||
if (rarity == null)
|
||||
rarity = EnumRarity.common;
|
||||
FluidStack filterFluidStack = FluidRegistry.getFluidStack(filter.getName(), 0);
|
||||
ToolTipLine name = new ToolTipLine(filter.getLocalizedName(filterFluidStack), 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())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,12 @@ import net.minecraftforge.fluids.FluidTank;
|
||||
*/
|
||||
public class StandardTank extends FluidTank {
|
||||
|
||||
// defines how the tank responds to IFluidHandler requests
|
||||
public enum TankMode {
|
||||
DEFAULT, OUTPUT, INPUT, INTERNAL
|
||||
}
|
||||
|
||||
public TankMode tankMode = TankMode.DEFAULT;
|
||||
public static final int DEFAULT_COLOR = 0xFFFFFF;
|
||||
public int colorCache = DEFAULT_COLOR;
|
||||
private int tankIndex;
|
||||
@@ -92,9 +98,33 @@ public class StandardTank extends FluidTank {
|
||||
return 0;
|
||||
if (resource.amount <= 0)
|
||||
return 0;
|
||||
if (!accepts(resource.getFluid()))
|
||||
return 0;
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
|
||||
public boolean accepts(Fluid fluid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canBeFilledExternally() {
|
||||
switch (tankMode) {
|
||||
case DEFAULT:
|
||||
case INPUT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canBeDrainedExternally() {
|
||||
switch (tankMode) {
|
||||
case DEFAULT:
|
||||
case OUTPUT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
if (maxDrain <= 0)
|
||||
@@ -111,15 +141,20 @@ public class StandardTank extends FluidTank {
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
protected boolean hasFluid() {
|
||||
FluidStack fluid = getFluid();
|
||||
return fluid != null && fluid.amount > 0 && fluid.getFluid() != null;
|
||||
}
|
||||
|
||||
protected void refreshTooltip() {
|
||||
toolTip.clear();
|
||||
int amount = 0;
|
||||
if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) {
|
||||
if (hasFluid()) {
|
||||
Fluid fluidType = getFluidType();
|
||||
EnumRarity rarity = fluidType.getRarity();
|
||||
if (rarity == null)
|
||||
rarity = EnumRarity.common;
|
||||
ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(), rarity.rarityColor);
|
||||
ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(getFluid()), rarity.rarityColor);
|
||||
fluidName.setSpacing(2);
|
||||
toolTip.add(fluidName);
|
||||
amount = getFluid().amount;
|
||||
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
@@ -31,7 +30,6 @@ 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;
|
||||
@@ -52,7 +50,6 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
payload.intPayload[2] = heat;
|
||||
|
||||
payload.floatPayload[0] = pistonSpeedServer;
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
@@ -96,20 +93,7 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
powerProvider.configure(10, 200, 10, 100000);
|
||||
}
|
||||
|
||||
protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) {
|
||||
if (container == null)
|
||||
return inventoryStack;
|
||||
|
||||
if (tank.fill(container.fluid, false) >= container.fluid.amount) {
|
||||
tank.fill(container.fluid, true);
|
||||
if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer))
|
||||
inventoryStack = container.emptyContainer.copy();
|
||||
else
|
||||
inventoryStack.stackSize--;
|
||||
}
|
||||
|
||||
return inventoryStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotateAfterPlacement(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
|
||||
|
||||
@@ -22,15 +22,18 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
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 net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.EntityNetData;
|
||||
@@ -38,11 +41,10 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
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.StringUtil;
|
||||
|
||||
public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -65,13 +67,17 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
private final short inputSlot1 = 2;
|
||||
private final short outputSlot1 = 8;
|
||||
|
||||
public FluidStack resource = FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, HONEY_REQUIRED);
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
|
||||
private final TankManager tankManager;
|
||||
|
||||
private final Stack<ItemStack> pendingProducts = new Stack<ItemStack>();
|
||||
|
||||
/* CONSTRUCTOR */
|
||||
public TileAnalyzer() {
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.getFluid(Defaults.LIQUID_HONEY));
|
||||
tankManager = new TankManager(resourceTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,8 +98,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
|
||||
nbttagcompound.setInteger("AnalyzeTime", analyzeTime);
|
||||
|
||||
// / Resource tank
|
||||
resourceTank.writeToNBT(nbttagcompound);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
|
||||
// / Pending Products
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@@ -117,8 +122,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
|
||||
analyzeTime = nbttagcompound.getInteger("AnalyzeTime");
|
||||
|
||||
// / Resource tank
|
||||
resourceTank.readFromNBT(nbttagcompound);
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
// / Pending Products
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10);
|
||||
@@ -146,7 +150,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
// Check if we have suitable items waiting in the can slot
|
||||
if (getStackInSlot(canSlot) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(getStackInSlot(canSlot));
|
||||
if (container != null && resource.isFluidEqual(container.fluid)) {
|
||||
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
|
||||
|
||||
setInventorySlotContents(canSlot, StackUtils.replenishByContainer(this, getStackInSlot(canSlot), container, resourceTank));
|
||||
if (getStackInSlot(canSlot).stackSize <= 0)
|
||||
@@ -187,7 +191,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
return;
|
||||
|
||||
// We need our liquid honey
|
||||
if (resourceTank.getFluidAmount() < resource.amount) {
|
||||
if (resourceTank.getFluidAmount() < HONEY_REQUIRED) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
return;
|
||||
}
|
||||
@@ -208,7 +212,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
|
||||
setInventorySlotContents(analyzeSlot, getStackInSlot(i));
|
||||
setInventorySlotContents(i, null);
|
||||
resourceTank.drain(resource.amount, true);
|
||||
resourceTank.drain(HONEY_REQUIRED, true);
|
||||
analyzeTime = TIME_TO_ANALYZE;
|
||||
sendNetworkUpdate();
|
||||
return;
|
||||
@@ -251,6 +255,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
|
||||
/* SMP */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
analyzeTime = j;
|
||||
@@ -259,7 +264,8 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, analyzeTime);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, analyzeTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -388,7 +394,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
if (!AlleleManager.alleleRegistry.isIndividual(stack)) {
|
||||
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container == null || !container.fluid.isFluidEqual(resource))
|
||||
if (container == null || !resourceTank.accepts(container.fluid.getFluid()))
|
||||
return 0;
|
||||
|
||||
if (getStackInSlot(canSlot) == null) {
|
||||
@@ -423,33 +429,39 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
|
||||
// We only accept what is already in the tank or valid ingredients
|
||||
if (resourceTank.getFluidAmount() > 0 && !resourceTank.getFluid().isFluidEqual(resource))
|
||||
return 0;
|
||||
else if (!LiquidHelper.isLiquid(Defaults.LIQUID_HONEY, resource))
|
||||
return 0;
|
||||
|
||||
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 FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) {
|
||||
return 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 FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -352,37 +352,4 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
return getInternalInventory().getSizeInventorySide(side);
|
||||
|
||||
}
|
||||
|
||||
/* IFLUIDHANDLER BASICS */
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
if (this instanceof ILiquidTankContainer) {
|
||||
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 FakeTank.INFO;
|
||||
}
|
||||
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return resource != null ? drain(from, resource.amount, doDrain) : null;
|
||||
}
|
||||
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,17 +54,4 @@ public class ContainerAnalyzer extends ContainerLiquidTanks {
|
||||
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -206,11 +206,4 @@ public class ContainerForestry extends Container {
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return inventory.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
public void onTankUpdate(NBTTagCompound nbt) {
|
||||
}
|
||||
|
||||
public StandardTank getTank(int slot) {
|
||||
return FakeTank.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -10,36 +10,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
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;
|
||||
|
||||
public class ContainerLiquidTanks extends ContainerForestry {
|
||||
|
||||
private ILiquidTankContainer tanks;
|
||||
private ILiquidTankContainer tile;
|
||||
|
||||
public ContainerLiquidTanks(IInventory inventory, ILiquidTankContainer tanks) {
|
||||
public ContainerLiquidTanks(IInventory inventory, ILiquidTankContainer tile) {
|
||||
super(inventory);
|
||||
this.tanks = tanks;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void handlePipetteClick(int slot, EntityPlayer player) {
|
||||
@@ -53,74 +46,52 @@ public class ContainerLiquidTanks extends ContainerForestry {
|
||||
return;
|
||||
|
||||
if (!Proxies.common.isSimulating(player.worldObj)) {
|
||||
|
||||
PacketPayload payload = new PacketPayload(1, 0, 0);
|
||||
payload.intPayload[0] = slot;
|
||||
Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
IToolPipette pipette = (IToolPipette) held;
|
||||
int liquidAmount = tanks.getTanks()[slot].getFluid().amount;
|
||||
StandardTank tank = tile.getTankManager().get(slot);
|
||||
int liquidAmount = tank.getFluid().amount;
|
||||
|
||||
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
|
||||
|
||||
if (liquidAmount > 0) {
|
||||
int filled = pipette.fill(itemstack, tanks.getTanks()[slot].drain(1000, false),
|
||||
true);
|
||||
tanks.getTanks()[slot].drain(filled, true);
|
||||
FluidStack fillAmount = tank.drain(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
IFluidTank tank = tanks.getTanks()[slot];
|
||||
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
|
||||
if (potential != null)
|
||||
pipette.drain(itemstack, tank.fill(potential, true), true);
|
||||
|
||||
}
|
||||
}
|
||||
private Map<Integer, StandardTank> syncedFluids = new HashMap<Integer, StandardTank>();
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int messageId, int data) {
|
||||
super.updateProgressBar(messageId, data);
|
||||
|
||||
tile.getTankManager().processGuiUpdate(messageId, data);
|
||||
tile.getGUINetworkData(messageId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < tanks.getTanks().length; i++) {
|
||||
StandardTank tank = tanks.getTanks()[i];
|
||||
|
||||
// If null has been synced
|
||||
if (tank.getFluid() == null && getTank(i).getFluidAmount() <= 0)
|
||||
continue;
|
||||
// If fluid has been synced
|
||||
if (tank.getFluid() != null && tank.getFluid().isFluidStackIdentical(getTank(i).getFluid()))
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < this.crafters.size(); ++j) {
|
||||
if (this.crafters.get(j) instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) this.crafters.get(j);
|
||||
Proxies.net.sendToPlayer(new PacketTankUpdate(i, tank), player);
|
||||
}
|
||||
}
|
||||
|
||||
syncedFluids.put(i, new StandardTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity()));
|
||||
|
||||
}
|
||||
tile.getTankManager().updateGuiData(this, crafters);
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTankUpdate(NBTTagCompound nbt) {
|
||||
int tankID = nbt.getByte("tank");
|
||||
int capacity = nbt.getShort("capacity");
|
||||
tanks.getTanks()[tankID].readFromNBT(nbt);
|
||||
|
||||
StandardTank tank = new StandardTank(capacity);
|
||||
tank.readFromNBT(nbt);
|
||||
syncedFluids.put(tankID, tank);
|
||||
public void addCraftingToCrafters(ICrafting icrafting) {
|
||||
super.addCraftingToCrafters(icrafting);
|
||||
tile.getTankManager().initGuiData(this, icrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank getTank(int slot) {
|
||||
return syncedFluids.get(slot) == null ? FakeTank.INSTANCE : syncedFluids.get(slot);
|
||||
return tile.getTankManager().get(slot);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
@@ -44,7 +49,7 @@ import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.FontColour;
|
||||
|
||||
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
/* WIDGETS */
|
||||
protected WidgetManager widgetManager;
|
||||
@@ -320,38 +325,40 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
|
||||
int left = this.guiLeft;
|
||||
int top = this.guiTop;
|
||||
int lenght = 0;
|
||||
int length = 0;
|
||||
int height = 0;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
y = this.fontRendererObj.getStringWidth(tip.text);
|
||||
|
||||
if (y > lenght)
|
||||
lenght = y;
|
||||
height += 10 + tip.getSpacing();
|
||||
if (y > length)
|
||||
length = y;
|
||||
}
|
||||
|
||||
x = mouseX - left + 12;
|
||||
y = mouseY - top - 12;
|
||||
int var14 = 8;
|
||||
|
||||
if (toolTips.size() > 1)
|
||||
var14 += 2 + (toolTips.size() - 1) * 10;
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRender.zLevel = 300.0F;
|
||||
int var15 = -267386864;
|
||||
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
|
||||
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
|
||||
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
|
||||
int var16 = 1347420415;
|
||||
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
|
||||
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
|
||||
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
|
||||
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
|
||||
Color backgroundColor = new Color(16, 0, 16, 240);
|
||||
int backgroundColorInt = backgroundColor.getRGB();
|
||||
this.drawGradientRect(x - 3, y - 4, x + length + 2, y - 3, backgroundColorInt, backgroundColorInt);
|
||||
this.drawGradientRect(x - 3, y + height + 1, x + length + 2, y + height + 2, backgroundColorInt, backgroundColorInt);
|
||||
this.drawGradientRect(x - 3, y - 3, x + length + 2, y + height + 1, backgroundColorInt, backgroundColorInt);
|
||||
this.drawGradientRect(x - 4, y - 3, x - 3, y + height + 1, backgroundColorInt, backgroundColorInt);
|
||||
this.drawGradientRect(x + length + 2, y - 3, x + length + 3, y + height + 1, backgroundColorInt, backgroundColorInt);
|
||||
|
||||
Color borderColorTop = new Color(80, 0, 255, 80);
|
||||
int borderColorTopInt = borderColorTop.getRGB();
|
||||
Color borderColorBottom = new Color((borderColorTopInt & 0xfefefe) >> 1 | borderColorTopInt & -0x1000000, true);
|
||||
int borderColorBottomInt = borderColorBottom.getRGB();
|
||||
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + height, borderColorTopInt, borderColorBottomInt);
|
||||
this.drawGradientRect(x + length + 1, y - 3 + 1, x + length + 2, y + height, borderColorTopInt, borderColorBottomInt);
|
||||
this.drawGradientRect(x - 3, y - 3, x + length + 2, y - 3 + 1, borderColorTopInt, borderColorTopInt);
|
||||
this.drawGradientRect(x - 3, y + height, x + length + 2, y + height + 1, borderColorBottomInt, borderColorBottomInt);
|
||||
|
||||
for (ToolTipLine tip : toolTips) {
|
||||
String line = tip.text;
|
||||
@@ -569,4 +576,22 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
|
||||
/* NEI */
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { return null; }
|
||||
@Override
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) { return null; }
|
||||
@Override
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) { return null; }
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
if (gui instanceof GuiForestry)
|
||||
return ((GuiForestry)gui).ledgerManager.ledgerOverlaps(x, y, w, h);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public abstract class GuiForestryTitled<T extends TileForestry> extends GuiFores
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localizeTile(tile.getUnlocalizedName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
@@ -117,4 +117,8 @@ public class LedgerManager {
|
||||
|
||||
}
|
||||
|
||||
public boolean ledgerOverlaps(int x, int y, int width, int height) {
|
||||
return getAtPosition(x + width, y + height) != null || getAtPosition(x + width, y) != null || getAtPosition(x, y + height) != null || getAtPosition(x, y) != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.widgets;
|
||||
|
||||
import forestry.farming.gui.ContainerFarm;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -49,7 +51,12 @@ public class TankWidget extends Widget {
|
||||
}
|
||||
|
||||
public StandardTank getTank() {
|
||||
return ((ContainerForestry) manager.gui.inventorySlots).getTank(slot);
|
||||
Container container = manager.gui.inventorySlots;
|
||||
if (container instanceof ContainerLiquidTanks)
|
||||
return ((ContainerLiquidTanks) container).getTank(slot);
|
||||
else if (container instanceof ContainerFarm)
|
||||
return ((ContainerFarm) container).getTank(slot);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,11 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.interfaces;
|
||||
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface ILiquidTankContainer extends IFluidHandler {
|
||||
|
||||
StandardTank[] getTanks();
|
||||
TankManager getTankManager();
|
||||
void getGUINetworkData(int messageId, int data);
|
||||
void sendGUINetworkData(Container container, ICrafting iCrafting);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
|
||||
public class PacketGuiInteger extends ForestryPacket {
|
||||
|
||||
private int windowId, dataId, value;
|
||||
|
||||
public PacketGuiInteger() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PacketGuiInteger(int windowId, int dataId, int value) {
|
||||
this.windowId = windowId;
|
||||
this.dataId = dataId;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
data.writeByte(windowId);
|
||||
data.writeByte(dataId);
|
||||
data.writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
windowId = data.readByte();
|
||||
dataId = data.readByte();
|
||||
value = data.readInt();
|
||||
|
||||
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
|
||||
|
||||
if (player.openContainer != null && player.openContainer.windowId == windowId)
|
||||
player.openContainer.updateProgressBar(dataId, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() {
|
||||
return PacketIds.GUI_INTEGER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,10 +141,9 @@ public class PacketHandler {
|
||||
packetTR.readData(data);
|
||||
onGenomeTrackerUpdate(packetTR);
|
||||
break;
|
||||
case PacketIds.TANK_UPDATE:
|
||||
PacketTankUpdate packetAB = new PacketTankUpdate();
|
||||
packetAB.readData(data);
|
||||
onTankUpdate(packetAB);
|
||||
case PacketIds.GUI_INTEGER:
|
||||
PacketGuiInteger packet = new PacketGuiInteger();
|
||||
packet.readData(data);
|
||||
break;
|
||||
default:
|
||||
for (forestry.core.interfaces.IPacketHandler handler : PluginManager.packetHandlers)
|
||||
@@ -168,17 +167,6 @@ public class PacketHandler {
|
||||
channel.sendTo(packet, player);
|
||||
}
|
||||
|
||||
|
||||
private void onTankUpdate(PacketTankUpdate packetAB) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
|
||||
if (player.openContainer instanceof ContainerForestry) {
|
||||
((ContainerForestry)player.openContainer).onTankUpdate(packetAB.nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
private void onGenomeTrackerUpdate(PacketNBT packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PacketIds {
|
||||
|
||||
public static final int LEAF_UPDATE = 90;
|
||||
|
||||
public static final int TANK_UPDATE = 91;
|
||||
public static final int GUI_INTEGER = 92;
|
||||
|
||||
// Propolis pipe
|
||||
public static final int PROP_SEND_FILTER_SET = 100;
|
||||
|
||||
@@ -1,31 +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.network;
|
||||
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
public class PacketTankUpdate extends PacketNBT {
|
||||
|
||||
public PacketTankUpdate(int tankSlot, StandardTank tank) {
|
||||
super(PacketIds.TANK_UPDATE);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByte("tank", (byte) tankSlot);
|
||||
nbt.setShort("capacity", (short) tank.getCapacity());
|
||||
tank.writeToNBT(nbt);
|
||||
this.nbttagcompound = nbt;
|
||||
}
|
||||
|
||||
public PacketTankUpdate() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,8 @@ package forestry.core.proxy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
@@ -23,6 +25,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -90,6 +95,17 @@ public class ClientProxyCommon extends ProxyCommon {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
|
||||
if (player != null)
|
||||
return player;
|
||||
else if (world instanceof WorldServer)
|
||||
return FakePlayerFactory.get((WorldServer) world, profile);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBlockReachDistance(EntityPlayer entityplayer) {
|
||||
if (entityplayer instanceof EntityPlayerSP)
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.proxy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -37,6 +39,8 @@ import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
@@ -153,6 +157,19 @@ public class ProxyCommon {
|
||||
return server.getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a player for a given World and GameProfile.
|
||||
* If they are not in the World, returns a FakePlayer.
|
||||
* Do not store references to the return value, to prevent worlds staying in memory.
|
||||
*/
|
||||
public EntityPlayer getPlayer(World world, GameProfile profile) {
|
||||
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
|
||||
if (player != null)
|
||||
return player;
|
||||
else
|
||||
return FakePlayerFactory.get((WorldServer)world, profile);
|
||||
}
|
||||
|
||||
public double getBlockReachDistance(EntityPlayer entityplayer) {
|
||||
return 4f;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ItemInventory implements IInventory, INBTTagable {
|
||||
isItemInventory = true;
|
||||
|
||||
// Set an uid to identify the itemstack on SMP
|
||||
setUID(true);
|
||||
setUID(false);
|
||||
|
||||
readFromNBT(itemstack.getTagCompound());
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.util.Map;
|
||||
* @param <T> The thing this map maps onto
|
||||
* @param <P> The stack class (i.e. ItemStack, FluidStack) used for lookups
|
||||
*/
|
||||
public abstract class StackMap<P, T> extends HashMap<Object, T>{
|
||||
public abstract class StackMap<P, T> extends HashMap<P, T>{
|
||||
|
||||
@Override
|
||||
public final T put(Object key, T value) {
|
||||
public final T put(P key, T value) {
|
||||
if(isValidKey(key) && key != null && value != null)
|
||||
return super.put(key, value);
|
||||
return null;
|
||||
@@ -36,7 +36,7 @@ public abstract class StackMap<P, T> extends HashMap<Object, T>{
|
||||
public final boolean containsKey(Object key) {
|
||||
P stack = getStack(key);
|
||||
if(stack == null) return false;
|
||||
for (Map.Entry<Object, T> entry : this.entrySet())
|
||||
for (Map.Entry<P, T> entry : this.entrySet())
|
||||
if (areEqual(stack, entry.getKey()))
|
||||
return true;
|
||||
return super.containsKey(key);
|
||||
@@ -46,7 +46,7 @@ public abstract class StackMap<P, T> extends HashMap<Object, T>{
|
||||
public final T get(Object key) {
|
||||
P stack = getStack(key);
|
||||
if(stack == null) return null;
|
||||
for (Map.Entry<Object, T> entry : this.entrySet())
|
||||
for (Map.Entry<P, T> entry : this.entrySet())
|
||||
if (areEqual(stack, entry.getKey()))
|
||||
return entry.getValue();
|
||||
return super.get(key);
|
||||
|
||||
@@ -60,42 +60,6 @@ import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static EntityPlayer modPlayer;
|
||||
|
||||
public static GameProfile getForestryPlayerProfile() {
|
||||
return new GameProfile(UUID.nameUUIDFromBytes(Config.fakeUserLogin.getBytes(Charsets.UTF_8)),
|
||||
Config.fakeUserLogin);
|
||||
}
|
||||
|
||||
public static EntityPlayer getForestryPlayer(World world, int x, int y, int z) {
|
||||
if (modPlayer == null) {
|
||||
modPlayer = new EntityPlayer(world, getForestryPlayerProfile()) {
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(int var1, String var2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getPlayerCoordinates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChatMessage(IChatComponent var1) {
|
||||
}
|
||||
};
|
||||
modPlayer.posX = x;
|
||||
modPlayer.posY = y;
|
||||
modPlayer.posZ = z;
|
||||
Proxies.log.info("Created player '%s' for Forestry.", modPlayer.getGameProfile().getId());
|
||||
if (Config.fakeUserAutoop) {
|
||||
MinecraftServer.getServer().getConfigurationManager().func_152605_a(modPlayer.getGameProfile());
|
||||
Proxies.log.info("Opped player '%s'.", modPlayer.getGameProfile().getId());
|
||||
}
|
||||
}
|
||||
|
||||
return modPlayer;
|
||||
}
|
||||
private static Random rand;
|
||||
|
||||
public static int getUID() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
@@ -29,7 +30,9 @@ import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.gadgets.Engine;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
@@ -65,8 +68,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
else
|
||||
shutdown = false;
|
||||
}
|
||||
public StandardTank fuelTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY);
|
||||
public StandardTank heatingTank = new StandardTank(Defaults.ENGINE_TANK_CAPACITY);
|
||||
public FilteredTank fuelTank;
|
||||
public FilteredTank heatingTank;
|
||||
private final TankManager tankManager;
|
||||
private final TileInventoryAdapter inventory;
|
||||
public int burnTime;
|
||||
public int totalTime;
|
||||
@@ -81,6 +85,16 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
setHints(Config.hints.get("engine.bronze"));
|
||||
|
||||
inventory = new TileInventoryAdapter(this, 1, "Items");
|
||||
|
||||
fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet());
|
||||
fuelTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
heatingTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FluidRegistry.LAVA);
|
||||
heatingTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
this.tankManager = new TankManager(fuelTank, heatingTank);
|
||||
}
|
||||
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,9 +115,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
StandardTank tank = null;
|
||||
|
||||
if (container.fluid.isFluidEqual(LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1)))
|
||||
if (heatingTank.accepts(container.fluid.getFluid()))
|
||||
tank = heatingTank;
|
||||
else if (FuelManager.bronzeEngineFuel.containsKey(container.fluid))
|
||||
else if (fuelTank.accepts(container.fluid.getFluid()))
|
||||
tank = fuelTank;
|
||||
|
||||
if (tank != null) {
|
||||
@@ -219,7 +233,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
* Returns the fuel value (power per cycle) an item of the passed ItemStack
|
||||
* provides
|
||||
*
|
||||
* @param item
|
||||
* @param fluid
|
||||
* @return
|
||||
*/
|
||||
private int determineFuelValue(Fluid fluid) {
|
||||
@@ -231,16 +245,31 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fuelid
|
||||
* @param fluid
|
||||
* @return Duration of burn cycle of one bucket
|
||||
*/
|
||||
private int determineBurnTime(Fluid item) {
|
||||
if (FuelManager.bronzeEngineFuel.containsKey(item))
|
||||
return FuelManager.bronzeEngineFuel.get(item).burnDuration;
|
||||
private int determineBurnTime(Fluid fluid) {
|
||||
if (FuelManager.bronzeEngineFuel.containsKey(fluid))
|
||||
return FuelManager.bronzeEngineFuel.get(fluid).burnDuration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) {
|
||||
if (container == null)
|
||||
return inventoryStack;
|
||||
|
||||
if (tank.fill(container.fluid, false) >= container.fluid.amount) {
|
||||
tank.fill(container.fluid, true);
|
||||
if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer))
|
||||
inventoryStack = container.emptyContainer.copy();
|
||||
else
|
||||
inventoryStack.stackSize--;
|
||||
}
|
||||
|
||||
return inventoryStack;
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
@@ -284,13 +313,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
currentFluidId = fluid.getID();
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
tankManager.readTanksFromNBT(nbt);
|
||||
inventory.readFromNBT(nbt);
|
||||
|
||||
}
|
||||
@@ -310,21 +333,14 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
if (fluid != null)
|
||||
nbt.setString("currentFluid", fluid.getName());
|
||||
|
||||
NBTTagCompound nbtFuelSlot = new NBTTagCompound();
|
||||
NBTTagCompound nbtHeatingSlot = new NBTTagCompound();
|
||||
|
||||
fuelTank.writeToNBT(nbtFuelSlot);
|
||||
heatingTank.writeToNBT(nbtHeatingSlot);
|
||||
|
||||
nbt.setTag("FuelSlot", nbtFuelSlot);
|
||||
nbt.setTag("HeatingSlot", nbtHeatingSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbt);
|
||||
inventory.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
/* GUI */
|
||||
@Override
|
||||
public void getGUINetworkData(int id, int data) {
|
||||
id -= tankManager.maxMessageId() + 1;
|
||||
|
||||
switch (id) {
|
||||
case 0:
|
||||
@@ -350,12 +366,13 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, totalTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, (int) storedEnergy);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 4, heat);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 5, currentFluidId);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 1, totalTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 2, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 3, (int) storedEnergy);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 4, heat);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 5, currentFluidId);
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@@ -423,6 +440,13 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
|
||||
if (fluid == null || fluid.amount <= 0)
|
||||
return false;
|
||||
return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid());
|
||||
}
|
||||
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
@@ -441,23 +465,36 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
return null;
|
||||
}
|
||||
|
||||
// / ITANKCONTAINER
|
||||
// IFluidHandler
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
// We only accept biomass and water as fuel
|
||||
int used = 0;
|
||||
|
||||
if (FuelManager.bronzeEngineFuel.containsKey(resource))
|
||||
used = fuelTank.fill(resource, doFill);
|
||||
|
||||
if (LiquidHelper.isLiquid(Defaults.LIQUID_LAVA, resource))
|
||||
used = heatingTank.fill(resource, doFill);
|
||||
|
||||
return used;
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] { fuelTank, heatingTank };
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
/**
|
||||
* Returns the fuel value (power per cycle) an item of the passed ItemStack provides
|
||||
*
|
||||
* @param item
|
||||
* @param fuel
|
||||
* @return
|
||||
*/
|
||||
private int determineFuelValue(ItemStack fuel) {
|
||||
@@ -217,7 +217,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
/**
|
||||
* Returns the fuel value (power per cycle) an item of the passed ItemStack provides
|
||||
*
|
||||
* @param item
|
||||
* @param fuel
|
||||
* @return
|
||||
*/
|
||||
private int determineBurnDuration(ItemStack fuel) {
|
||||
|
||||
@@ -17,6 +17,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;
|
||||
|
||||
@@ -24,11 +25,14 @@ import ic2.api.energy.prefab.BasicSource;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
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.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.interfaces.IRenderableMachine;
|
||||
@@ -40,6 +44,8 @@ import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class MachineGenerator extends TileBase implements ISpecialInventory, ILiquidTankContainer, IRenderableMachine {
|
||||
|
||||
@@ -48,7 +54,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
public static final int maxEnergy = 30000;
|
||||
|
||||
@EntityNetData
|
||||
public StandardTank resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
public FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private int tickCount = 0;
|
||||
|
||||
InventoryAdapter inventory = new InventoryAdapter(1, "Items");
|
||||
@@ -57,6 +64,9 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
public MachineGenerator() {
|
||||
setHints(Config.hints.get("generator"));
|
||||
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
tankManager = new TankManager(resourceTank);
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
}
|
||||
@@ -78,10 +88,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
|
||||
if (ic2EnergySource != null) ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
resourceTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("ResourceTank", NBTresourceSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -91,10 +98,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
|
||||
if (ic2EnergySource != null) ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
|
||||
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("ResourceTank"))
|
||||
resourceTank.readFromNBT(nbttagcompound.getCompoundTag("ResourceTank"));
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -119,7 +123,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
if (inventory.getStackInSlot(SLOT_CAN) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
|
||||
if (container != null)
|
||||
if (GeneratorFuel.fuels.containsKey(container.fluid.fluidID)) {
|
||||
|
||||
if (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)
|
||||
inventory.setInventorySlotContents(SLOT_CAN, null);
|
||||
@@ -134,9 +139,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
|
||||
ic2EnergySource.updateEntity();
|
||||
|
||||
if (resourceTank.getFluidAmount() > 0 &&
|
||||
GeneratorFuel.fuels.containsKey(resourceTank.getFluid().fluidID)) {
|
||||
GeneratorFuel fuel = GeneratorFuel.fuels.get(resourceTank.getFluid().fluidID);
|
||||
if (resourceTank.getFluidAmount() > 0) {
|
||||
GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid());
|
||||
|
||||
if (resourceTank.getFluidAmount() >= fuel.fuelConsumed.amount &&
|
||||
ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
@@ -183,17 +187,16 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
if (i == firstMessageId) {
|
||||
if (ic2EnergySource != null) ic2EnergySource.setEnergyStored(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
if (ic2EnergySource != null) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored());
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId, (short) ic2EnergySource.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +242,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
if (container == null)
|
||||
return 0;
|
||||
|
||||
if (!GeneratorFuel.fuels.containsKey(container.fluid.fluidID))
|
||||
if (!FuelManager.generatorFuel.containsKey(container.fluid))
|
||||
return 0;
|
||||
|
||||
if (inventory.getStackInSlot(SLOT_CAN) == null) {
|
||||
@@ -268,24 +271,39 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER IMPLEMENTATION */
|
||||
/* ILiquidTankContainer */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
// We only accept water
|
||||
if (!GeneratorFuel.fuels.containsKey(resource.fluidID))
|
||||
return 0;
|
||||
|
||||
int used = resourceTank.fill(resource, doFill);
|
||||
|
||||
if (doFill && used > 0)
|
||||
// TODO: Slow down updates
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,17 +43,4 @@ public class ContainerEngineBronze extends ContainerLiquidTanks {
|
||||
return engine.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
engine.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
engine.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,19 +37,6 @@ public class ContainerGenerator extends ContainerLiquidTanks {
|
||||
this.addSlot(new Slot(player, i, 8 + i * 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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return tile.isUseableByPlayer(entityplayer);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -284,7 +284,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
@Override
|
||||
public ITileStructure getCentralTE() {
|
||||
|
||||
if (!isIntegratedIntoStructure())
|
||||
if (!isIntegratedIntoStructure() || !hasMaster())
|
||||
return null;
|
||||
|
||||
if (!isMaster) {
|
||||
|
||||
@@ -29,8 +29,11 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
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 net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
@@ -49,9 +52,12 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.DelayTimer;
|
||||
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;
|
||||
@@ -61,7 +67,7 @@ import forestry.farming.FarmTarget;
|
||||
import forestry.farming.logic.FarmLogicArboreal;
|
||||
import forestry.plugins.PluginFarming;
|
||||
|
||||
public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource {
|
||||
public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource, ILiquidTankContainer {
|
||||
|
||||
public static final int SLOT_RESOURCES_1 = 0;
|
||||
public static final int SLOT_GERMLINGS_1 = 6;
|
||||
@@ -74,8 +80,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
public static final int SLOT_COUNT = 22;
|
||||
|
||||
public static final FluidStack STACK_WATER = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1);
|
||||
|
||||
public static final int DELAY_HYDRATION = 100;
|
||||
public static final float RAINFALL_MODIFIER_CAP = 15f;
|
||||
public static final int BUFFER_FERTILIZER = 200;
|
||||
@@ -88,7 +92,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
|
||||
private StandardTank liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
private FilteredTank liquidTank;
|
||||
private final TankManager tankManager;
|
||||
|
||||
private IFarmLogic harvestProvider; // The farm logic which supplied the pending crops.
|
||||
private final Stack<ICrop> pendingCrops = new Stack<ICrop>();
|
||||
@@ -107,6 +112,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
public TileFarmPlain() {
|
||||
fertilizerValue = GameMode.getGameMode().getIntegerSetting("farms.fertilizer.value");
|
||||
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(liquidTank);
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -121,9 +128,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
refreshFarmLogics();
|
||||
|
||||
liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
if (nbttagcompound.hasKey("LiquidTank"))
|
||||
liquidTank.readFromNBT(nbttagcompound.getCompoundTag("LiquidTank"));
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,10 +140,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
nbttagcompound.setInteger("HydrationDelay", hydrationDelay);
|
||||
nbttagcompound.setInteger("TicksSinceRainfall", ticksSinceRainfall);
|
||||
|
||||
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
|
||||
liquidTank.writeToNBT(NBTresourceSlot);
|
||||
nbttagcompound.setTag("LiquidTank", NBTresourceSlot);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@@ -171,7 +173,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
// Check if we have suitable items waiting in the item slot
|
||||
if (inventory.getStackInSlot(SLOT_CAN) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
|
||||
if (container != null && LiquidHelper.isLiquid(Defaults.LIQUID_WATER, container.fluid)) {
|
||||
if (container != null && liquidTank.accepts(container.fluid.getFluid())) {
|
||||
|
||||
inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, liquidTank));
|
||||
if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0)
|
||||
@@ -666,8 +668,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
@Override
|
||||
public void makeMaster() {
|
||||
super.makeMaster();
|
||||
if (liquidTank == null)
|
||||
liquidTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
refreshFarmLogics();
|
||||
}
|
||||
|
||||
@@ -676,8 +676,13 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
super.onStructureReset();
|
||||
}
|
||||
|
||||
public StandardTank getTank() {
|
||||
return liquidTank;
|
||||
public StandardTank[] getTanks() {
|
||||
return new StandardTank[] {liquidTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -758,13 +763,13 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
@Override
|
||||
public void removeResources(ItemStack[] resources) {
|
||||
EntityPlayer player = worldObj.getPlayerEntityByName(owner.getName());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, owner);
|
||||
inventory.removeSets(1, resources, SLOT_RESOURCES_1, SLOT_RESOURCES_1, player, false, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLiquid(FluidStack liquid) {
|
||||
return liquidTank.getFluidAmount() >= liquid.amount && liquidTank.getFluid().isFluidEqual(liquid);
|
||||
return liquidTank.getFluidAmount() >= liquid.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -785,7 +790,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
if (!germling.isGermling(inventory.getStackInSlot(i)))
|
||||
continue;
|
||||
|
||||
if (!germling.plantSaplingAt(inventory.getStackInSlot(i), world, x, y, z))
|
||||
EntityPlayer player = Proxies.common.getPlayer(world, owner);
|
||||
if (!germling.plantSaplingAt(player, inventory.getStackInSlot(i), world, x, y, z))
|
||||
continue;
|
||||
|
||||
inventory.decrStackSize(i, 1);
|
||||
@@ -875,7 +881,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
/* NETWORK GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
storedFertilizer = j;
|
||||
@@ -893,10 +899,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, storedFertilizer);
|
||||
iCrafting.sendProgressBarUpdate(container, 3, Math.round(temperature * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 4, Math.round(humidity * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 5, ticksSinceRainfall);
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, storedFertilizer);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 3, Math.round(temperature * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, i + 4, Math.round(humidity * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, i + 5, ticksSinceRainfall);
|
||||
}
|
||||
|
||||
/* ICLIMATISED */
|
||||
@@ -967,4 +974,34 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ILiquidTankContainer */
|
||||
@Override
|
||||
public int fill(ForgeDirection direction, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(direction, 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);
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class TileValve extends TileFarm implements ILiquidTankContainer {
|
||||
|
||||
@@ -34,42 +38,74 @@ public class TileValve extends TileFarm implements ILiquidTankContainer {
|
||||
}
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
private StandardTank getMasterTank() {
|
||||
if (!isIntegratedIntoStructure() || !hasMaster())
|
||||
return null;
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return FakeTank.INSTANCE.fill(resource, doFill);
|
||||
|
||||
TileFarmPlain central = (TileFarmPlain) getCentralTE();
|
||||
if (central == null)
|
||||
return null;
|
||||
|
||||
return central.getTank();
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
StandardTank tank = getMasterTank();
|
||||
if (tank == null)
|
||||
return 0;
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return null;
|
||||
|
||||
return tank.fill(resource, doFill);
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
StandardTank tank = getMasterTank();
|
||||
if (tank == null)
|
||||
return null;
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
|
||||
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank[] getTanks() {
|
||||
StandardTank tank = getMasterTank();
|
||||
if (tank == null)
|
||||
return FakeTank.ARRAY;
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return true;
|
||||
|
||||
return new StandardTank[] { tank };
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return false;
|
||||
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
TankManager tankManager = getTankManager();
|
||||
if (tankManager == null)
|
||||
return FakeTank.INFO;
|
||||
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
TileFarmPlain central = (TileFarmPlain) getCentralTE();
|
||||
if (central == null)
|
||||
return null;
|
||||
|
||||
return central.getTankManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGUINetworkData(int messageId, int data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
}
|
||||
}
|
||||
@@ -10,28 +10,20 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gui;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gui.ContainerSocketed;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
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.fluids.tanks.StandardTank;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.farming.gadgets.TileFarmPlain;
|
||||
import forestry.plugins.PluginFarming;
|
||||
@@ -135,47 +127,32 @@ public class ContainerFarm extends ContainerSocketed {
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
TankManager tankManager = tile.getTankManager();
|
||||
if (tankManager != null)
|
||||
tankManager.processGuiUpdate(i, j);
|
||||
}
|
||||
private Map<Integer, StandardTank> syncedFluids = new HashMap<Integer, StandardTank>();
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
TankManager tankManager = tile.getTankManager();
|
||||
if (tankManager != null)
|
||||
tankManager.updateGuiData(this, crafters);
|
||||
|
||||
for (int i = 0; i < crafters.size(); i++) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
}
|
||||
|
||||
StandardTank tank = tile.getTank();
|
||||
|
||||
// If null has been synced
|
||||
if (tank.getFluid() == null && getTank(0).getFluidAmount() <= 0)
|
||||
return;
|
||||
// If fluid has been synced
|
||||
if (tank.getFluid() != null && tank.getFluid().isFluidStackIdentical(getTank(0).getFluid()))
|
||||
return;
|
||||
|
||||
for (int j = 0; j < this.crafters.size(); ++j) {
|
||||
if (this.crafters.get(j) instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) this.crafters.get(j);
|
||||
Proxies.net.sendToPlayer(new PacketTankUpdate(0, tank), player);
|
||||
}
|
||||
}
|
||||
syncedFluids.put(0, new StandardTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTankUpdate(NBTTagCompound nbt) {
|
||||
int tankID = nbt.getByte("tank");
|
||||
int capacity = nbt.getShort("capacity");
|
||||
StandardTank tank = new StandardTank(capacity);
|
||||
tank.readFromNBT(nbt);
|
||||
syncedFluids.put(tankID, tank);
|
||||
public void addCraftingToCrafters(ICrafting iCrafting) {
|
||||
super.addCraftingToCrafters(iCrafting);
|
||||
TankManager tankManager = tile.getTankManager();
|
||||
if (tankManager != null)
|
||||
tankManager.initGuiData(this, iCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardTank getTank(int slot) {
|
||||
return syncedFluids.get(slot) == null ? FakeTank.INSTANCE : syncedFluids.get(slot);
|
||||
return tile.getTankManager().get(slot);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -56,7 +57,7 @@ public class FarmableCocoa implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return BlockUtil.tryPlantPot(world, x, y, z, COCOA_PLANT);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
@@ -20,7 +21,6 @@ import net.minecraft.world.World;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.plugins.PluginFarmCraftory;
|
||||
|
||||
@@ -71,8 +71,8 @@ public class FarmableFarmCraftory implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(Utils.getForestryPlayer(world, x, y, z), world, x, y - 1, z, 1, 0, 0, 0);
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -18,7 +19,6 @@ import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
@@ -44,8 +44,8 @@ public class FarmableGE implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(Utils.getForestryPlayer(world, x, y, z), world, x, y - 1, z, 1, 0, 0, 0);
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
|
||||
public class FarmableGenericCrop implements IFarmable {
|
||||
@@ -65,8 +65,8 @@ public class FarmableGenericCrop implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(Utils.getForestryPlayer(world, x, y, z), world, x, y - 1, z, 1, 0, 0, 0);
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
|
||||
public class FarmableGenericSapling implements IFarmable {
|
||||
@@ -79,8 +79,8 @@ public class FarmableGenericSapling implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(Utils.getForestryPlayer(world, x, y, z), world, x, y - 1, z, 1, 0, 0, 0);
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return germling.copy().tryPlaceItemIntoWorld(player, world, x, y - 1, z, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -67,7 +68,7 @@ public class FarmableGourd implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return world.setBlock(x, y, z, StackUtils.getBlock(stem), 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class FarmableStacked implements IFarmable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
return world.setBlock(x, y, z, block, 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.farming.logic;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,7 +21,6 @@ import net.minecraft.world.World;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class FarmableVanillaSapling extends FarmableGenericSapling {
|
||||
@@ -33,7 +33,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
ITree tree = null;
|
||||
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet())
|
||||
if (entry.getKey().isItemEqual(germling) && entry.getValue() instanceof ITree) {
|
||||
@@ -44,7 +44,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
|
||||
if (tree == null)
|
||||
return false;
|
||||
|
||||
return PluginArboriculture.treeInterface.plantSapling(world, tree, Utils.getForestryPlayerProfile(), x, y, z);
|
||||
return PluginArboriculture.treeInterface.plantSapling(world, tree, player.getGameProfile(), x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -39,7 +40,7 @@ public class FarmableVanillaShroom extends FarmableGenericSapling {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) {
|
||||
int meta = 0;
|
||||
if (StackUtils.equals(Blocks.red_mushroom, germling))
|
||||
meta = 1;
|
||||
|
||||
@@ -18,9 +18,10 @@ import buildcraft.api.gates.ITriggerParameter;
|
||||
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.farming.gadgets.TileFarmPlain;
|
||||
import forestry.farming.gadgets.TileHatch;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class TriggerLowLiquid extends Trigger {
|
||||
|
||||
@@ -49,7 +50,8 @@ public class TriggerLowLiquid extends Trigger {
|
||||
if (central == null || !(central instanceof TileFarmPlain))
|
||||
return false;
|
||||
|
||||
StandardTank tank = ((TileFarmPlain) central).getTank();
|
||||
return ((float) tank.getFluidAmount() / tank.getCapacity()) <= threshold;
|
||||
TankManager tankManager = ((TileFarmPlain) central).getTankManager();
|
||||
FluidTankInfo info = tankManager.getTankInfo(0);
|
||||
return ((float) info.fluid.amount / info.capacity) <= threshold;
|
||||
}
|
||||
}
|
||||
@@ -143,18 +143,11 @@ public class MailAddress implements INBTTagable, IMailAddress {
|
||||
return address;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer(World world) {
|
||||
if (!this.isPlayer())
|
||||
return null;
|
||||
|
||||
return world.getPlayerEntityByName(this.gameProfile.getName());
|
||||
}
|
||||
|
||||
public boolean isClientPlayer(World world) {
|
||||
if (!this.isPlayer())
|
||||
return false;
|
||||
|
||||
EntityPlayer addressPlayer = this.getPlayer(world);
|
||||
EntityPlayer addressPlayer = Proxies.common.getPlayer(world, gameProfile);
|
||||
EntityPlayer clientPlayer = Proxies.common.getPlayer();
|
||||
|
||||
return addressPlayer != null && clientPlayer != null && clientPlayer.equals(addressPlayer);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ProxyMail {
|
||||
}
|
||||
|
||||
public void setPOBoxInfo(World world, IMailAddress address, POBoxInfo info) {
|
||||
EntityPlayer player = address.getPlayer(world);
|
||||
EntityPlayer player = Proxies.common.getPlayer(world, address.getPlayerProfile());
|
||||
if (player != null)
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfo(PacketIds.POBOX_INFO, info), player);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ package forestry.plugins;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
@@ -21,6 +22,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.PluginInfo;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.circuits.Circuit;
|
||||
@@ -146,10 +148,13 @@ public class PluginEnergy extends NativePlugin {
|
||||
definitionGenerator.register();
|
||||
definitionEngineClockwork.register();
|
||||
|
||||
GeneratorFuel.fuels.put(LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1).getFluid().getID(), new GeneratorFuel(LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1),
|
||||
(int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4));
|
||||
GeneratorFuel.fuels.put(LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 1).getFluid().getID(), new GeneratorFuel(LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 1),
|
||||
(int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1));
|
||||
FluidStack ethanol = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1);
|
||||
GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4);
|
||||
FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel);
|
||||
|
||||
FluidStack biomass = LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 1);
|
||||
GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1);
|
||||
FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel);
|
||||
|
||||
Circuit.energyElectricChoke1 = new CircuitElectricChoke("energyChoke1");
|
||||
Circuit.energyFireDampener1 = new CircuitFireDampener("energyDampener1");
|
||||
|
||||
@@ -157,7 +157,8 @@ public class ItemBackpack extends ItemInventoried {
|
||||
// Create our own backpack inventory
|
||||
ItemInventory backpackInventory = new ItemInventory(ItemBackpack.class, getBackpackSize(), stack);
|
||||
|
||||
if (stack.getItemDamage() == 2)
|
||||
BackpackMode mode = getMode(stack);
|
||||
if (mode == BackpackMode.RECEIVE)
|
||||
tryChestReceive(player, backpackInventory, inventory);
|
||||
else
|
||||
tryChestTransfer(backpackInventory, inventory);
|
||||
|
||||
Reference in new issue
Block a user