mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 23:33:00 +00:00
Giant multiblock refactor
This commit is contained in:
1 parent
201111cb83
commit
aa47599278
259 files changed
+10117
-6495
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package forestry.factory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -53,26 +52,6 @@ public class DummyManagers {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, HashMap<ItemStack, Integer> products) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack[] produce, int[] chances) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary, ItemStack secondary, int chance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Object[], Object[]> getRecipes() {
|
||||
return null;
|
||||
|
||||
@@ -58,34 +58,34 @@ public class GuiHandlerFactory extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case BottlerGUI:
|
||||
return new GuiBottler(player.inventory, getTileForestry(world, x, y, z, player, MachineBottler.class));
|
||||
return new GuiBottler(player.inventory, getTile(world, x, y, z, player, MachineBottler.class));
|
||||
|
||||
case CarpenterGUI:
|
||||
return new GuiCarpenter(player.inventory, getTileForestry(world, x, y, z, player, MachineCarpenter.class));
|
||||
return new GuiCarpenter(player.inventory, getTile(world, x, y, z, player, MachineCarpenter.class));
|
||||
|
||||
case CentrifugeGUI:
|
||||
return new GuiCentrifuge(player.inventory, getTileForestry(world, x, y, z, player, MachineCentrifuge.class));
|
||||
return new GuiCentrifuge(player.inventory, getTile(world, x, y, z, player, MachineCentrifuge.class));
|
||||
|
||||
case FabricatorGUI:
|
||||
return new GuiFabricator(player.inventory, getTileForestry(world, x, y, z, player, MachineFabricator.class));
|
||||
return new GuiFabricator(player.inventory, getTile(world, x, y, z, player, MachineFabricator.class));
|
||||
|
||||
case FermenterGUI:
|
||||
return new GuiFermenter(player.inventory, getTileForestry(world, x, y, z, player, MachineFermenter.class));
|
||||
return new GuiFermenter(player.inventory, getTile(world, x, y, z, player, MachineFermenter.class));
|
||||
|
||||
case MoistenerGUI:
|
||||
return new GuiMoistener(player.inventory, getTileForestry(world, x, y, z, player, MachineMoistener.class));
|
||||
return new GuiMoistener(player.inventory, getTile(world, x, y, z, player, MachineMoistener.class));
|
||||
|
||||
case RaintankGUI:
|
||||
return new GuiRaintank(player.inventory, getTileForestry(world, x, y, z, player, MachineRaintank.class));
|
||||
return new GuiRaintank(player.inventory, getTile(world, x, y, z, player, MachineRaintank.class));
|
||||
|
||||
case SqueezerGUI:
|
||||
return new GuiSqueezer(player.inventory, getTileForestry(world, x, y, z, player, MachineSqueezer.class));
|
||||
return new GuiSqueezer(player.inventory, getTile(world, x, y, z, player, MachineSqueezer.class));
|
||||
|
||||
case StillGUI:
|
||||
return new GuiStill(player.inventory, getTileForestry(world, x, y, z, player, MachineStill.class));
|
||||
return new GuiStill(player.inventory, getTile(world, x, y, z, player, MachineStill.class));
|
||||
|
||||
case WorktableGUI:
|
||||
return new GuiWorktable(player, getTileForestry(world, x, y, z, player, TileWorktable.class));
|
||||
return new GuiWorktable(player, getTile(world, x, y, z, player, TileWorktable.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
@@ -103,34 +103,34 @@ public class GuiHandlerFactory extends GuiHandlerBase {
|
||||
switch (GuiId.values()[id]) {
|
||||
|
||||
case BottlerGUI:
|
||||
return new ContainerBottler(player.inventory, getTileForestry(world, x, y, z, player, MachineBottler.class));
|
||||
return new ContainerBottler(player.inventory, getTile(world, x, y, z, player, MachineBottler.class));
|
||||
|
||||
case CarpenterGUI:
|
||||
return new ContainerCarpenter(player.inventory, getTileForestry(world, x, y, z, player, MachineCarpenter.class));
|
||||
return new ContainerCarpenter(player.inventory, getTile(world, x, y, z, player, MachineCarpenter.class));
|
||||
|
||||
case CentrifugeGUI:
|
||||
return new ContainerCentrifuge(player.inventory, getTileForestry(world, x, y, z, player, MachineCentrifuge.class));
|
||||
return new ContainerCentrifuge(player.inventory, getTile(world, x, y, z, player, MachineCentrifuge.class));
|
||||
|
||||
case FabricatorGUI:
|
||||
return new ContainerFabricator(player.inventory, getTileForestry(world, x, y, z, player, MachineFabricator.class));
|
||||
return new ContainerFabricator(player.inventory, getTile(world, x, y, z, player, MachineFabricator.class));
|
||||
|
||||
case FermenterGUI:
|
||||
return new ContainerFermenter(player.inventory, getTileForestry(world, x, y, z, player, MachineFermenter.class));
|
||||
return new ContainerFermenter(player.inventory, getTile(world, x, y, z, player, MachineFermenter.class));
|
||||
|
||||
case MoistenerGUI:
|
||||
return new ContainerMoistener(player.inventory, getTileForestry(world, x, y, z, player, MachineMoistener.class));
|
||||
return new ContainerMoistener(player.inventory, getTile(world, x, y, z, player, MachineMoistener.class));
|
||||
|
||||
case RaintankGUI:
|
||||
return new ContainerRaintank(player.inventory, getTileForestry(world, x, y, z, player, MachineRaintank.class));
|
||||
return new ContainerRaintank(player.inventory, getTile(world, x, y, z, player, MachineRaintank.class));
|
||||
|
||||
case SqueezerGUI:
|
||||
return new ContainerSqueezer(player.inventory, getTileForestry(world, x, y, z, player, MachineSqueezer.class));
|
||||
return new ContainerSqueezer(player.inventory, getTile(world, x, y, z, player, MachineSqueezer.class));
|
||||
|
||||
case StillGUI:
|
||||
return new ContainerStill(player.inventory, getTileForestry(world, x, y, z, player, MachineStill.class));
|
||||
return new ContainerStill(player.inventory, getTile(world, x, y, z, player, MachineStill.class));
|
||||
|
||||
case WorktableGUI:
|
||||
return new ContainerWorktable(player, getTileForestry(world, x, y, z, player, TileWorktable.class));
|
||||
return new ContainerWorktable(player, getTile(world, x, y, z, player, TileWorktable.class));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -47,6 +48,8 @@ import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.Utils;
|
||||
@@ -180,6 +183,18 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
@@ -210,7 +225,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
boolean added = InvTools.tryAddStack(this, currentRecipe.bottled, SLOT_OUTPUT, 1, true, false);
|
||||
|
||||
if (setErrorCondition(!added, EnumErrorCode.NOSPACE)) {
|
||||
if (getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,7 +251,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
resetRecipe();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -36,6 +37,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.ICarpenterManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
@@ -52,6 +54,8 @@ import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
@@ -80,7 +84,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Nullable
|
||||
public MachineCarpenter.Recipe currentRecipe;
|
||||
public MachineCarpenter.Recipe lastRecipe;
|
||||
private int packageTime;
|
||||
private int totalTime;
|
||||
private ItemStack pendingProduct;
|
||||
@@ -149,6 +152,18 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
setCurrentRecipe(RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), craftingInventory, worldObj));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
public void resetRecipe() {
|
||||
if (worldObj.isRemote) {
|
||||
return;
|
||||
@@ -162,7 +177,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
final ItemStack craftingResult;
|
||||
|
||||
if (currentRecipe != null) {
|
||||
lastRecipe = currentRecipe;
|
||||
craftingResult = currentRecipe.getCraftingResult();
|
||||
} else {
|
||||
craftingResult = null;
|
||||
@@ -195,8 +209,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
setErrorCondition(!validateResources(), EnumErrorCode.NORESOURCE);
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!validateResources(), EnumErrorCode.NORESOURCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,7 +311,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
private boolean removeSets(int count, ItemStack[] set) {
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwner());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getAccessHandler().getOwner());
|
||||
return InvTools.removeSets(getInternalInventory(), count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true);
|
||||
}
|
||||
|
||||
@@ -311,7 +326,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
pendingProduct = null;
|
||||
}
|
||||
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
return added;
|
||||
}
|
||||
|
||||
@@ -447,16 +462,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) {
|
||||
if (tile.lastRecipe != null) {
|
||||
return tile.lastRecipe.isIngredient(itemStack);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
|
||||
@@ -176,7 +176,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
resetRecipeTimes();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipeTimes() {
|
||||
@@ -203,7 +203,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
pendingProducts.pop();
|
||||
}
|
||||
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
return added;
|
||||
}
|
||||
|
||||
@@ -345,46 +345,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
addRecipe(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, HashMap<ItemStack, Integer> products) {
|
||||
Map<ItemStack, Float> floatProducts = new HashMap<ItemStack, Float>();
|
||||
for (Map.Entry<ItemStack, Integer> entry : products.entrySet()) {
|
||||
floatProducts.put(entry.getKey(), entry.getValue() / 100.0f);
|
||||
}
|
||||
|
||||
addRecipe(timePerItem, resource, floatProducts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack[] produce, int[] chances) {
|
||||
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||
|
||||
int i = 0;
|
||||
for (ItemStack prod : produce) {
|
||||
products.put(prod, chances[i] / 100f);
|
||||
i++;
|
||||
}
|
||||
|
||||
addRecipe(timePerItem, resource, products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary, ItemStack secondary, int chance) {
|
||||
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||
products.put(primary, 1.0f);
|
||||
if (secondary != null) {
|
||||
products.put(secondary, chance / 100f);
|
||||
}
|
||||
addRecipe(timePerItem, resource, products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary) {
|
||||
Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
|
||||
products.put(primary, 1.0f);
|
||||
addRecipe(timePerItem, resource, products);
|
||||
}
|
||||
|
||||
public static ICentrifugeRecipe findMatchingRecipe(ItemStack item) {
|
||||
for (ICentrifugeRecipe recipe : recipes) {
|
||||
ItemStack recipeInput = recipe.getInput();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +32,6 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.recipes.IFabricatorManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.TankManager;
|
||||
@@ -46,6 +46,8 @@ import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
@@ -295,6 +297,18 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
@@ -578,14 +592,14 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
} else if (slotIndex == SLOT_PLAN) {
|
||||
return RecipeManager.isPlan(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) {
|
||||
if (RecipeManager.isPlan(itemStack) ) {
|
||||
if (RecipeManager.isPlan(itemStack)) {
|
||||
return false;
|
||||
}else if (RecipeManager.findMatchingSmelting(itemStack) != null) {
|
||||
} else if (RecipeManager.findMatchingSmelting(itemStack) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -33,6 +34,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.recipes.IFermenterManager;
|
||||
import forestry.api.recipes.IVariableFermentable;
|
||||
@@ -49,6 +51,8 @@ import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.StackUtils;
|
||||
@@ -216,6 +220,18 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
@@ -238,14 +254,16 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
boolean hasRecipe = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null;
|
||||
setErrorCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
|
||||
boolean hasResource = resourceTank.getFluidAmount() >= fuelCurrentFerment;
|
||||
setErrorCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
|
||||
boolean hasFuel = inventory.getStackInSlot(SLOT_FUEL) != null || fuelBurnTime > 0;
|
||||
setErrorCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
errorLogic.setCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -28,6 +29,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.recipes.IMoistenerManager;
|
||||
@@ -43,6 +45,8 @@ import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
@@ -192,6 +196,18 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
|
||||
@@ -204,9 +220,11 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
// Let's get to work
|
||||
int lightvalue = worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// Not working in broad daylight
|
||||
boolean gloomy = lightvalue <= 11;
|
||||
if (setErrorCondition(!gloomy, EnumErrorCode.NOTGLOOMY)) {
|
||||
if (errorLogic.setCondition(!gloomy, EnumErrorCode.NOTGLOOMY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,7 +244,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
if (burnTime > 0 && pendingProduct == null) {
|
||||
// Not working if there is no water available.
|
||||
boolean hasLiquid = resourceTank.getFluidAmount() > 0;
|
||||
if (setErrorCondition(!hasLiquid, EnumErrorCode.NORESOURCE)) {
|
||||
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NORESOURCE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +287,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
}
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private boolean tryAddPending() {
|
||||
@@ -278,7 +296,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
boolean added = InvTools.tryAddStack(this, pendingProduct, SLOT_PRODUCT, 1, true);
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
|
||||
if (added) {
|
||||
pendingProduct = null;
|
||||
@@ -294,7 +312,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
resetRecipe();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
@@ -373,45 +391,46 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
private boolean rotateWorkingSlot() {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// Put working slot contents into inventory if space is available
|
||||
if (inventory.getStackInSlot(SLOT_WORKING) != null) {
|
||||
if (getStackInSlot(SLOT_WORKING) != null) {
|
||||
// Get the result of the consumed item in the working slot
|
||||
ItemStack deposit;
|
||||
if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) {
|
||||
MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING));
|
||||
if (FuelManager.moistenerResource.containsKey(getStackInSlot(SLOT_WORKING))) {
|
||||
MoistenerFuel res = FuelManager.moistenerResource.get(getStackInSlot(SLOT_WORKING));
|
||||
deposit = res.product.copy();
|
||||
} else {
|
||||
deposit = inventory.getStackInSlot(SLOT_WORKING).copy();
|
||||
deposit = getStackInSlot(SLOT_WORKING).copy();
|
||||
}
|
||||
|
||||
int targetSlot = getFreeReservoirSlot(deposit);
|
||||
// We stop the whole thing, if we don't have any room anymore.
|
||||
if (setErrorCondition(targetSlot < 0, EnumErrorCode.NOSPACE)) {
|
||||
if (errorLogic.setCondition(targetSlot < 0, EnumErrorCode.NOSPACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inventory.getStackInSlot(targetSlot) == null) {
|
||||
inventory.setInventorySlotContents(targetSlot, deposit);
|
||||
if (getStackInSlot(targetSlot) == null) {
|
||||
setInventorySlotContents(targetSlot, deposit);
|
||||
} else {
|
||||
inventory.getStackInSlot(targetSlot).stackSize++;
|
||||
getStackInSlot(targetSlot).stackSize++;
|
||||
}
|
||||
|
||||
decrStackSize(SLOT_WORKING, 1);
|
||||
}
|
||||
|
||||
if (inventory.getStackInSlot(SLOT_WORKING) != null) {
|
||||
if (getStackInSlot(SLOT_WORKING) != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Let's look for a new resource to put into the working slot.
|
||||
int resourceSlot = getNextResourceSlot(SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT);
|
||||
// Nothing found, stop.
|
||||
if (setErrorCondition(resourceSlot < 0, EnumErrorCode.NORESOURCE)) {
|
||||
if (errorLogic.setCondition(resourceSlot < 0, EnumErrorCode.NORESOURCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inventory.setInventorySlotContents(SLOT_WORKING, inventory.decrStackSize(resourceSlot, 1));
|
||||
setInventorySlotContents(SLOT_WORKING, decrStackSize(resourceSlot, 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -634,7 +653,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, (SLOT_STASH_COUNT+SLOT_RESERVOIR_COUNT))) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, (SLOT_STASH_COUNT + SLOT_RESERVOIR_COUNT))) {
|
||||
return !FuelManager.moistenerResource.containsKey(itemstack);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -26,6 +28,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
@@ -35,11 +38,11 @@ import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class MachineRaintank extends TileBase implements ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -69,7 +72,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
isValidBiome = BiomeHelper.canRainOrSnow(biome);
|
||||
setErrorCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
getErrorLogic().setCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
}
|
||||
|
||||
super.validate();
|
||||
@@ -98,6 +101,18 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
|
||||
@@ -105,14 +120,16 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
return;
|
||||
}
|
||||
|
||||
setErrorCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
errorLogic.setCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
|
||||
boolean hasSky = worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
|
||||
setErrorCondition(!hasSky, EnumErrorCode.NOSKY);
|
||||
errorLogic.setCondition(!hasSky, EnumErrorCode.NOSKY);
|
||||
|
||||
setErrorCondition(!worldObj.isRaining(), EnumErrorCode.NOTRAINING);
|
||||
errorLogic.setCondition(!worldObj.isRaining(), EnumErrorCode.NOTRAINING);
|
||||
|
||||
if (!hasErrorState()) {
|
||||
if (!errorLogic.hasErrors()) {
|
||||
resourceTank.fill(STACK_WATER, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -29,6 +30,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.ISqueezerManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
@@ -43,6 +45,8 @@ import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
@@ -182,6 +186,18 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
// / WORKING
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
@@ -210,9 +226,11 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
return false;
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
FluidStack resultFluid = currentRecipe.liquid;
|
||||
boolean canFill = productTank.fill(resultFluid, false) == resultFluid.amount;
|
||||
setErrorCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
|
||||
if (!canFill) {
|
||||
return false;
|
||||
@@ -222,7 +240,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
if (currentRecipe.remnants != null) {
|
||||
remnant = currentRecipe.remnants.copy();
|
||||
boolean canAdd = InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, false);
|
||||
setErrorCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
if (!canAdd) {
|
||||
return false;
|
||||
}
|
||||
@@ -266,7 +284,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
resetRecipeTimes();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
@@ -282,7 +300,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
}
|
||||
|
||||
private boolean removeResources(ItemStack[] stacks) {
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwner());
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getAccessHandler().getOwner());
|
||||
return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -28,6 +29,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.IStillManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
@@ -41,6 +43,8 @@ import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.Utils;
|
||||
@@ -165,6 +169,18 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
@@ -193,10 +209,12 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
checkRecipe();
|
||||
|
||||
// Ongoing process
|
||||
if (distillationTime > 0 && !hasErrorState()) {
|
||||
if (distillationTime > 0 && !errorLogic.hasErrors()) {
|
||||
|
||||
distillationTime -= currentRecipe.input.amount;
|
||||
productTank.fill(currentRecipe.output, true);
|
||||
@@ -208,12 +226,12 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
int resourceRequired = currentRecipe.timePerUnit * currentRecipe.input.amount;
|
||||
|
||||
boolean canFill = productTank.fill(currentRecipe.output, false) == currentRecipe.output.amount;
|
||||
setErrorCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
|
||||
boolean hasResource = resourceTank.getFluidAmount() >= resourceRequired;
|
||||
setErrorCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
|
||||
if (!hasErrorState()) {
|
||||
if (!errorLogic.hasErrors()) {
|
||||
// Start next cycle if enough bio mass is available
|
||||
distillationTime = distillationTotalTime = resourceRequired;
|
||||
resourceTank.drain(resourceRequired, true);
|
||||
@@ -238,7 +256,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
currentRecipe = matchingRecipe;
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
container.sendRecipeClick(mouseButton, slotNumber);
|
||||
ContainerWorktable.sendRecipeClick(mouseButton, slotNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user