From 034cdf2860f68d91e16f5c468767902dcbff58de Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 30 Nov 2014 17:19:16 -0800 Subject: [PATCH 001/175] Intial stages of an cleanup of the inventory code, this commit is very broken. --- .../apiculture/gadgets/TileAlveary.java | 14 +- .../gadgets/TileAlvearyHygroregulator.java | 89 +++++------ .../apiculture/gadgets/TileAlvearyPlain.java | 149 +++++++----------- .../apiculture/gadgets/TileAlvearySieve.java | 7 +- .../gadgets/TileAlvearySwarmer.java | 137 ++++++++-------- .../apiculture/gadgets/TileBeehouse.java | 2 +- .../apiculture/gadgets/TileSwarm.java | 2 +- .../apiculture/gui/ContainerAlvearySieve.java | 4 - .../apiculture/gui/ContainerApiary.java | 32 ++-- .../apiculture/items/ItemBeealyzer.java | 2 +- .../apiculture/items/ItemBiomefinder.java | 2 +- .../arboriculture/items/ItemTreealyzer.java | 2 +- .../core/circuits/ItemSolderingIron.java | 2 +- .../java/forestry/core/gadgets/BlockBase.java | 3 +- .../forestry/core/gadgets/BlockForestry.java | 1 - .../forestry/core/gadgets/BlockStructure.java | 3 +- .../forestry/core/gadgets/TileAnalyzer.java | 109 ++++--------- .../java/forestry/core/gadgets/TileBase.java | 10 -- .../forestry/core/gadgets/TileEscritoire.java | 4 +- .../forestry/core/gadgets/TileForestry.java | 82 +++------- .../forestry/core/gadgets/TileMachine.java | 88 +---------- .../forestry/core/gui/ContainerAlyzer.java | 2 +- .../forestry/core/gui/ContainerForestry.java | 2 +- .../core/gui/ContainerItemInventory.java | 2 +- .../{utils => inventory}/AlyzerInventory.java | 2 +- .../InventoryAdapter.java | 25 ++- .../{utils => inventory}/ItemInventory.java | 3 +- .../TileInventoryAdapter.java | 27 +++- .../java/forestry/core/utils/StackUtils.java | 1 + src/main/java/forestry/core/utils/Utils.java | 10 +- .../forestry/energy/gadgets/EngineBronze.java | 93 ++--------- .../forestry/energy/gadgets/EngineCopper.java | 4 +- .../forestry/energy/gadgets/EngineTin.java | 2 +- .../energy/gadgets/MachineGenerator.java | 2 +- .../energy/gui/ContainerEngineBronze.java | 25 ++- .../energy/gui/ContainerEngineCopper.java | 25 ++- .../energy/gui/ContainerGenerator.java | 20 ++- .../factory/gadgets/MachineBottler.java | 117 ++++++++------ .../factory/gadgets/MachineCarpenter.java | 4 +- .../factory/gadgets/MachineCentrifuge.java | 2 +- .../factory/gadgets/MachineFabricator.java | 2 +- .../factory/gadgets/MachineFermenter.java | 2 +- .../factory/gadgets/MachineMoistener.java | 2 +- .../factory/gadgets/MachineRaintank.java | 2 +- .../factory/gadgets/MachineSqueezer.java | 2 +- .../factory/gadgets/MachineStill.java | 2 +- .../factory/gadgets/TileWorktable.java | 4 +- .../factory/gui/ContainerBottler.java | 19 ++- .../factory/gui/ContainerFermenter.java | 24 ++- .../factory/gui/ContainerMoistener.java | 24 +-- .../factory/gui/ContainerRaintank.java | 15 +- .../forestry/factory/gui/ContainerStill.java | 16 +- .../forestry/farming/gadgets/TileFarm.java | 2 +- .../farming/gadgets/TileFarmPlain.java | 4 +- .../forestry/farming/gadgets/TileHatch.java | 2 +- .../forestry/farming/gui/ContainerFarm.java | 2 +- .../items/ItemFlutterlyzer.java | 2 +- src/main/java/forestry/mail/Letter.java | 2 +- src/main/java/forestry/mail/MailAddress.java | 26 ++- src/main/java/forestry/mail/POBox.java | 2 +- src/main/java/forestry/mail/PostRegistry.java | 5 + src/main/java/forestry/mail/TradeStation.java | 2 +- .../forestry/mail/gadgets/MachineMailbox.java | 2 +- .../mail/gadgets/MachinePhilatelist.java | 2 +- .../forestry/mail/gadgets/MachineTrader.java | 2 +- .../forestry/mail/gui/ContainerTradeName.java | 8 +- .../forestry/mail/gui/ContainerTrader.java | 47 ++++-- .../java/forestry/mail/items/ItemLetter.java | 2 +- .../pipes/gui/ContainerPropolisPipe.java | 19 +-- .../forestry/storage/GuiHandlerStorage.java | 2 +- .../forestry/storage/ResupplyHandler.java | 2 +- .../storage/gui/ContainerBackpack.java | 2 +- .../forestry/storage/items/ItemBackpack.java | 2 +- 73 files changed, 606 insertions(+), 759 deletions(-) rename src/main/java/forestry/core/{utils => inventory}/AlyzerInventory.java (97%) rename src/main/java/forestry/core/{utils => inventory}/InventoryAdapter.java (95%) rename src/main/java/forestry/core/{utils => inventory}/ItemInventory.java (98%) rename src/main/java/forestry/core/{utils => inventory}/TileInventoryAdapter.java (59%) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index a4a28c98e..6f9b246e0 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -23,9 +23,6 @@ import forestry.core.config.ForestryBlock; import forestry.core.gadgets.TileForestry; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import forestry.core.utils.TileInventoryAdapter; -import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -40,8 +37,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon private boolean isMaster; protected int masterX, masterZ; protected int masterY = -99; - - protected TileInventoryAdapter inventory; protected final int componentBlockMeta; public TileAlveary(int componentBlockMeta) { @@ -147,7 +142,7 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon setCentralTE(null); isMaster = true; - if (inventory == null) + if (getInternalInventory() == null) createInventory(); } @@ -215,7 +210,7 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public IInventory getInventory() { - return inventory; + return getInternalInventory(); } /* IALVEARY COMPONENT */ @@ -258,9 +253,4 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon return res; } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord); - } - } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 64f6aa013..cb85c3437 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -32,9 +32,10 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; +import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.utils.Utils; public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer { @@ -43,6 +44,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory /* RECIPE MANAGMENT */ private static class HygroregulatorRecipe { + public final FluidStack liquid; public final int transferTime; public final float humidChange; @@ -59,7 +61,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory private final HygroregulatorRecipe[] recipes; /* MEMBERS */ - private final InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv"); private final TankManager tankManager; private final FilteredTank liquidTank; @@ -69,6 +70,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory public TileAlvearyHygroregulator() { super(BLOCK_META); + setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv")); + Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER); Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA); Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE); @@ -76,9 +79,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory 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) }; + 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 @@ -94,11 +97,12 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory /* UPDATING */ private HygroregulatorRecipe getRecipe(FluidStack liquid) { HygroregulatorRecipe recipe = null; - for (HygroregulatorRecipe rec : recipes) + for (HygroregulatorRecipe rec : recipes) { if (rec.liquid.isFluidEqual(liquid)) { recipe = rec; break; } + } return recipe; } @@ -131,11 +135,13 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; + TileInventoryAdapter canInventory = getInternalInventory(); + // Check if we have suitable items waiting in the item slot if (canInventory.getStackInSlot(0) != null) { FluidContainerData container = LiquidHelper.getLiquidContainer(canInventory.getStackInSlot(0)); - if (container != null && - (container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) { + if (container != null + && (container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) { canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank)); if (canInventory.getStackInSlot(0).stackSize <= 0) @@ -154,9 +160,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - - canInventory.readFromNBT(nbttagcompound); - tankManager.readTanksFromNBT(nbttagcompound); transferTime = nbttagcompound.getInteger("TransferTime"); @@ -170,9 +173,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - - canInventory.writeToNBT(nbttagcompound); - tankManager.writeTanksToNBT(nbttagcompound); nbttagcompound.setInteger("TransferTime", transferTime); @@ -192,38 +192,38 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public IInventory getInventory() { - return canInventory; + return getInternalInventory(); } /* IINVENTORY */ @Override public int getSizeInventory() { - if (canInventory != null) - return canInventory.getSizeInventory(); + if (getInternalInventory() != null) + return getInternalInventory().getSizeInventory(); else return 0; } @Override public ItemStack getStackInSlot(int slotIndex) { - if (canInventory != null) - return canInventory.getStackInSlot(slotIndex); + if (getInternalInventory() != null) + return getInternalInventory().getStackInSlot(slotIndex); else return null; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { - if (canInventory != null) - return canInventory.decrStackSize(slotIndex, amount); + if (getInternalInventory() != null) + return getInternalInventory().decrStackSize(slotIndex, amount); else return null; } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { - if (canInventory != null) - return canInventory.getStackInSlotOnClosing(slotIndex); + if (getInternalInventory() != null) + return getInternalInventory().getStackInSlotOnClosing(slotIndex); else return null; } @@ -231,21 +231,26 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { // Client side handling for container synch - if (canInventory == null && !Proxies.common.isSimulating(worldObj)) + if (getInternalInventory() == null && !Proxies.common.isSimulating(worldObj)) createInventory(); - if (canInventory != null) - canInventory.setInventorySlotContents(slotIndex, itemstack); + if (getInternalInventory() != null) + getInternalInventory().setInventorySlotContents(slotIndex, itemstack); } @Override public int getInventoryStackLimit() { - if (canInventory != null) - return canInventory.getInventoryStackLimit(); + if (getInternalInventory() != null) + return getInternalInventory().getInventoryStackLimit(); else return 0; } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return Utils.isUseableByPlayer(player, this); + } + @Override public void openInventory() { } @@ -254,27 +259,16 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); - } - - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + if (slotIndex == 0) { FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack); if (fluid == null || fluid.amount <= 0) @@ -282,7 +276,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory return liquidTank.accepts(fluid.getFluid()); } - return super.isItemValidForSlot(slotIndex, itemstack); + return false; } /* ILIQUIDTANKCONTAINER */ @@ -296,6 +290,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory return tankManager.fill(from, resource, doFill); } + @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return tankManager.drain(from, resource, doDrain); } @@ -321,8 +316,10 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory } @Override - public void getGUINetworkData(int messageId, int data) {} + public void getGUINetworkData(int messageId, int data) { + } @Override - public void sendGUINetworkData(Container container, ICrafting iCrafting) {} + public void sendGUINetworkData(Container container, ICrafting iCrafting) { + } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 97b73f9ea..7286dc25d 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -27,6 +27,7 @@ import forestry.api.core.ITileStructure; import forestry.api.genetics.IIndividual; import forestry.apiculture.gui.ContainerAlveary; import forestry.core.config.Config; +import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IErrorSource; @@ -35,8 +36,8 @@ import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; import net.minecraft.entity.player.EntityPlayer; @@ -47,11 +48,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.util.ForgeDirection; import java.util.LinkedHashSet; import java.util.Set; +import scala.collection.SortedMap; public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource { @@ -90,8 +91,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS this.tempChange = nbttagcompound.getFloat("TempChange"); this.humidChange = nbttagcompound.getFloat("HumidChange"); - if (inventory != null) - inventory.readFromNBT(nbttagcompound); if (beekeepingLogic != null) beekeepingLogic.readFromNBT(nbttagcompound); @@ -104,8 +103,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS nbttagcompound.setFloat("TempChange", tempChange); nbttagcompound.setFloat("HumidChange", humidChange); - if (inventory != null) - inventory.writeToNBT(nbttagcompound); if (beekeepingLogic != null) beekeepingLogic.writeToNBT(nbttagcompound); @@ -139,7 +136,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS // Add swarm effects if (worldObj.getTotalWorldTime() % 200 * 10 == 0) - onQueenChange(inventory.getStackInSlot(SLOT_QUEEN)); + onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN)); if (getErrorState() == EnumErrorCode.OK) queen.doFX(beekeepingLogic.getEffectData(), this); @@ -164,16 +161,15 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS if (!isMaster()) return; - if (inventory == null) + if (getInternalInventory() == null) return; // / Multiplayer FX - if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) { + if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) { - IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)); + IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN)); displayQueen.doFX(beekeepingLogic.getEffectData(), this); } - } } private void equalizeTemperature() { @@ -196,6 +192,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS /* STATE INFORMATION */ private int getHealthDisplay() { + IInventory inventory = getInternalInventory(); if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -208,6 +205,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS } private int getMaxHealthDisplay() { + IInventory inventory = getInternalInventory(); if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -237,7 +235,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS /* STRUCTURE MANAGMENT */ @Override protected void createInventory() { - this.inventory = new TileInventoryAdapter(this, 9, "Items"); + setInternalInventory(new TileInventoryAdapter(this, 9, "Items")); } @Override @@ -425,6 +423,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public boolean addProduct(ItemStack product, boolean all) { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory == null) return false; @@ -523,13 +522,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS } /* IINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return (InventoryAdapter) getStructureInventory(); - } - private IInventory getStructureInventory() { - + TileInventoryAdapter inventory = getInternalInventory(); if (inventory != null) { if (isMaster() || !Proxies.common.isSimulating(worldObj)) return inventory; @@ -580,6 +574,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { + TileInventoryAdapter inventory = getInternalInventory(); // Client side handling for container synch if (inventory == null && !Proxies.common.isSimulating(worldObj)) createInventory(); @@ -603,33 +598,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS return 0; } - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE) - return true; - - return false; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) - && !PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - - return false; - } - @Override public void openInventory() { } @@ -638,52 +606,53 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + TileInventoryAdapter inventory = getInternalInventory(); + if (inventory == null) + return false; + + if (!inventory.isItemValidForSlot(slotIndex, itemstack)) + return false; + + if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) + && !PluginApiculture.beeInterface.isDrone(itemstack)) + return true; + return slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + TileInventoryAdapter inventory = getInternalInventory(); + if (inventory == null) + return false; + if (!inventory.canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE; } - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + TileInventoryAdapter inventory = getInternalInventory(); + if (inventory == null) + return Defaults.FACINGS_NONE; + return inventory.getAccessibleSlotsFromSide(side); } /* ISPECIALINVENTORY */ @@ -755,28 +724,28 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS break; } - return new ItemStack[] { product }; + return new ItemStack[]{product}; } /* SMP GUI */ public void getGUINetworkData(int i, int j) { switch (i) { - case 0: - displayHealth = j; - break; - case 1: - displayHealthMax = j; - break; - case 4: - this.tempChange = (float) j / 100; - break; - case 5: - this.humidChange = (float) j / 100; - break; - case 6: { - this.biome = BiomeGenBase.getBiome(j); - break; - } + case 0: + displayHealth = j; + break; + case 1: + displayHealthMax = j; + break; + case 4: + this.tempChange = (float) j / 100; + break; + case 5: + this.humidChange = (float) j / 100; + break; + case 6: { + this.biome = BiomeGenBase.getBiome(j); + break; + } } } @@ -836,7 +805,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS public boolean isOwnable() { return true; } - + /* IHousing */ @Override public GameProfile getOwnerName() { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index d5d21d206..dd8536ea9 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -23,7 +23,7 @@ import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.core.interfaces.ICrafter; import forestry.core.network.GuiId; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener { @@ -125,11 +125,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } } } - - /* INVENTORY */ - public InventoryAdapter getInternalInventory() { - return inventory; - } /* ICRAFTER */ @Override diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index a7339d22f..93572e7f8 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.ForgeDirection; import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; @@ -27,20 +26,25 @@ import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.apiculture.worldgen.WorldGenHive; import forestry.apiculture.worldgen.WorldGenHiveSwamer; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.inventory.wrappers.IInvSlot; +import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.utils.StackUtils; +import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; +import net.minecraft.inventory.ISidedInventory; -public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory { +public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { /* CONSTANTS */ public static final int BLOCK_META = 2; - TileInventoryAdapter swarmerInventory; private final Stack pendingSpawns = new Stack(); public TileAlvearySwarmer() { @@ -50,7 +54,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory @Override public void initialize() { super.initialize(); - if (swarmerInventory == null) + if (getInternalInventory() == null) createInventory(); } @@ -89,10 +93,10 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory int slot = getInducerSlot(); if (slot < 0) return; - int chance = getChanceFor(swarmerInventory.getStackInSlot(slot)); + int chance = getChanceFor(getInternalInventory().getStackInSlot(slot)); // Remove resource - swarmerInventory.decrStackSize(slot, 1); + getInternalInventory().decrStackSize(slot, 1); // Try to spawn princess if (worldObj.rand.nextInt(1000) >= chance) @@ -115,12 +119,13 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory } private int getInducerSlot() { - for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) { - if (swarmerInventory.getStackInSlot(i) == null) + for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) { + ItemStack stack = slot.getStackInSlot(); + if (stack == null) continue; for (Entry entry : BeeManager.inducers.entrySet()) { - if (entry.getKey().isItemEqual(swarmerInventory.getStackInSlot(i))) - return i; + if (entry.getKey().isItemEqual(stack)) + return slot.getIndex(); } } @@ -130,7 +135,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory private void trySpawnSwarm() { ItemStack toSpawn = pendingSpawns.peek(); - WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[] { toSpawn }); + WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[]{toSpawn}); int i = 0; while (i < 10) { @@ -154,7 +159,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - if(side == 0 || side == 1) + if (side == 0 || side == 1) return BlockAlveary.BOTTOM; if (pendingSpawns.size() > 0) @@ -166,10 +171,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - if (swarmerInventory == null) + if (getInternalInventory() == null) createInventory(); - swarmerInventory.readFromNBT(nbttagcompound); + super.readFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { @@ -182,75 +186,60 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (swarmerInventory != null) - swarmerInventory.writeToNBT(nbttagcompound); NBTTagList nbttaglist = new NBTTagList(); ItemStack[] offspring = pendingSpawns.toArray(new ItemStack[pendingSpawns.size()]); - for (int i = 0; i < offspring.length; i++) + for (int i = 0; i < offspring.length; i++) { if (offspring[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); offspring[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingSpawns", nbttaglist); } @Override protected void createInventory() { - swarmerInventory = new TileInventoryAdapter(this, 4, "SwarmInv"); + setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv")); } @Override public IInventory getInventory() { - return swarmerInventory; - } - - /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (swarmerInventory != null) - return swarmerInventory.addStack(stack, false, doAdd); - else - return 0; - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - return null; + return getInternalInventory(); } /* IINVENTORY */ @Override public int getSizeInventory() { - if (swarmerInventory != null) - return swarmerInventory.getSizeInventory(); + if (getInternalInventory() != null) + return getInternalInventory().getSizeInventory(); else return 0; } @Override public ItemStack getStackInSlot(int slotIndex) { - if (swarmerInventory != null) - return swarmerInventory.getStackInSlot(slotIndex); + if (getInternalInventory() != null) + return getInternalInventory().getStackInSlot(slotIndex); else return null; } @Override public ItemStack decrStackSize(int slotIndex, int amount) { - if (swarmerInventory != null) - return swarmerInventory.decrStackSize(slotIndex, amount); + if (getInternalInventory() != null) + return getInternalInventory().decrStackSize(slotIndex, amount); else return null; } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { - if (swarmerInventory != null) - return swarmerInventory.getStackInSlotOnClosing(slotIndex); + if (getInternalInventory() != null) + return getInternalInventory().getStackInSlotOnClosing(slotIndex); else return null; } @@ -258,11 +247,11 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { // Client side handling for container synch - if (swarmerInventory == null && !Proxies.common.isSimulating(worldObj)) + if (getInternalInventory() == null && !Proxies.common.isSimulating(worldObj)) createInventory(); - if (swarmerInventory != null) - swarmerInventory.setInventorySlotContents(slotIndex, itemstack); + if (getInternalInventory() != null) + getInternalInventory().setInventorySlotContents(slotIndex, itemstack); } @Override @@ -272,36 +261,56 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory @Override public int getInventoryStackLimit() { - if (swarmerInventory != null) - return swarmerInventory.getInventoryStackLimit(); + if (getInternalInventory() != null) + return getInternalInventory().getInventoryStackLimit(); else return 0; } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { + if (getInternalInventory() != null) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) + return false; + return StackUtils.isIdenticalItem(stack, ForestryItem.royalJelly.getItemStack()); + } + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (getInternalInventory() != null) + return getInternalInventory().getAccessibleSlotsFromSide(side); + return Defaults.FACINGS_NONE; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + if (getInternalInventory() != null) + return getInternalInventory().isItemValidForSlot(slot, stack); + return false; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return false; } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index d343f4a03..44898033d 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -29,7 +29,7 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java index 509566fe9..e9595c0cf 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java +++ b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java @@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; public class TileSwarm extends TileEntity { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index 20eeedf67..0db2433b3 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -50,8 +50,4 @@ public class ContainerAlvearySieve extends ContainerForestry { } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return tile.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index 7a3af8172..414118aca 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; @@ -22,7 +21,6 @@ import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotCustom; -import forestry.core.utils.Utils; public class ContainerApiary extends ContainerForestry { @@ -33,29 +31,29 @@ public class ContainerApiary extends ContainerForestry { this.tile = tile; tile.sendNetworkUpdate(); - IInventory inventory = tile.getInternalInventory(); + IInventory inv = tile.getInternalInventory(); // Queen/Princess - this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); // Drone - this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); // Frames if (hasFrames) { - this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); - this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); - this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); + this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); + this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); + this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); } // Product Inventory - this.addSlot(new SlotClosed(inventory, 2, 116, 52)); - this.addSlot(new SlotClosed(inventory, 3, 137, 39)); - this.addSlot(new SlotClosed(inventory, 4, 137, 65)); - this.addSlot(new SlotClosed(inventory, 5, 116, 78)); - this.addSlot(new SlotClosed(inventory, 6, 95, 65)); - this.addSlot(new SlotClosed(inventory, 7, 95, 39)); - this.addSlot(new SlotClosed(inventory, 8, 116, 26)); + this.addSlot(new SlotClosed(inv, 2, 116, 52)); + this.addSlot(new SlotClosed(inv, 3, 137, 39)); + this.addSlot(new SlotClosed(inv, 4, 137, 65)); + this.addSlot(new SlotClosed(inv, 5, 116, 78)); + this.addSlot(new SlotClosed(inv, 6, 95, 65)); + this.addSlot(new SlotClosed(inv, 7, 95, 39)); + this.addSlot(new SlotClosed(inv, 8, 116, 26)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { @@ -82,8 +80,4 @@ public class ContainerApiary extends ContainerForestry { } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return Utils.isUseableByPlayer(entityplayer, tile, tile.getWorld(), tile.xCoord, tile.yCoord, tile.zCoord); - } } diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index d5a8210d5..64aa13eb8 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.apiculture.items; -import forestry.core.utils.AlyzerInventory; +import forestry.core.inventory.AlyzerInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java index a77af1765..24b86c762 100755 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java @@ -38,7 +38,7 @@ import forestry.core.interfaces.IHintSource; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.core.utils.Vect; import forestry.plugins.PluginApiculture; diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index d9156069e..dd051c3b1 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -15,7 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import forestry.core.utils.AlyzerInventory; +import forestry.core.inventory.AlyzerInventory; import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index 0a6e3413e..91a5bda2b 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -30,7 +30,7 @@ import forestry.core.interfaces.IErrorSource; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; public class ItemSolderingIron extends ItemForestry implements ISolderingIron { diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 404db46d6..5cf9aee0e 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -37,6 +37,7 @@ import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StringUtil; +import forestry.core.utils.Utils; public class BlockBase extends BlockForestry { @@ -161,7 +162,7 @@ public class BlockBase extends BlockForestry { return false; TileBase tile = (TileBase) world.getTileEntity(x, y, z); - if (!tile.isUseableByPlayer(player)) + if (!Utils.isUseableByPlayer(player, tile)) return false; ItemStack current = player.getCurrentEquippedItem(); diff --git a/src/main/java/forestry/core/gadgets/BlockForestry.java b/src/main/java/forestry/core/gadgets/BlockForestry.java index ba26d000a..ae1832255 100755 --- a/src/main/java/forestry/core/gadgets/BlockForestry.java +++ b/src/main/java/forestry/core/gadgets/BlockForestry.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.core.gadgets; -import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index 4f1a8ed17..a26f5b69f 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -20,6 +20,7 @@ import net.minecraft.world.World; import forestry.api.core.ITileStructure; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import forestry.core.utils.Utils; public abstract class BlockStructure extends BlockForestry { @@ -60,7 +61,7 @@ public abstract class BlockStructure extends BlockForestry { return false; TileForestry tile = (TileForestry) world.getTileEntity(x, y, z); - if (!tile.isUseableByPlayer(player)) + if (!Utils.isUseableByPlayer(player, tile)) return false; if (!Proxies.common.isSimulating(world)) diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 22a1c007b..582f54356 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -42,7 +42,7 @@ import forestry.core.inventory.InvTools; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import net.minecraft.inventory.IInventory; public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -57,8 +57,6 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public static final short SLOT_OUTPUT_1 = 8; /* MEMBER */ - private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); - private int analyzeTime; @EntityNetData @@ -68,13 +66,15 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui private final Stack pendingProducts = new Stack(); - private final IInventory invInput = new InventoryMapper(inventory, SLOT_INPUT_1, 6); + private final IInventory invInput; /* CONSTRUCTOR */ public TileAnalyzer() { super(800, 40, Defaults.MACHINE_MAX_ENERGY); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.get()); tankManager = new TankManager(resourceTank); + invInput = new InventoryMapper(getInternalInventory(), SLOT_INPUT_1, 6); } @Override @@ -100,17 +100,15 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui // / Pending Products NBTTagList nbttaglist = new NBTTagList(); ItemStack[] pending = pendingProducts.toArray(new ItemStack[pendingProducts.size()]); - for (int i = 0; i < pending.length; i++) + for (int i = 0; i < pending.length; i++) { if (pending[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); pending[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingProducts", nbttaglist); - - // / Inventory - inventory.writeToNBT(nbttagcompound); } @Override @@ -127,9 +125,6 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); pendingProducts.add(ItemStack.loadItemStackFromNBT(nbttagcompound1)); } - - // / Inventory - inventory.readFromNBT(nbttagcompound); } @Override @@ -249,7 +244,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui return false; ItemStack next = pendingProducts.peek(); - if (inventory.tryAddStack(next, SLOT_OUTPUT_1, inventory.getSizeInventory() - SLOT_OUTPUT_1, true)) { + if (getInternalInventory().tryAddStack(next, SLOT_OUTPUT_1, getInternalInventory().getSizeInventory() - SLOT_OUTPUT_1, true)) { pendingProducts.pop(); return true; } @@ -270,7 +265,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui if (analyzeTime > 0) return true; - return getErrorState() == EnumErrorCode.OK ||getErrorState() == EnumErrorCode.NOPOWER; + return getErrorState() == EnumErrorCode.OK || getErrorState() == EnumErrorCode.NOPOWER; } public int getProgressScaled(int i) { @@ -304,62 +299,34 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui } /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - return slotIndex >= SLOT_OUTPUT_1 && slotIndex < SLOT_OUTPUT_1 + 4; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack stack, int side) { - - if (!super.canPutStackFromSide(slotIndex, stack, side)) - return false; - - if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + 6) - return AlleleManager.alleleRegistry.isIndividual(stack); - - if (slotIndex == SLOT_CAN) - return Fluids.HONEY.isContained(stack); - - return false; - } - @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override @@ -370,52 +337,46 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + public boolean isItemValidForSlot(int slot, ItemStack stack) { + if (!getInternalInventory().isItemValidForSlot(slot, stack)) + return false; + + if (slot >= SLOT_INPUT_1 && slot < SLOT_INPUT_1 + 6) + return AlleleManager.alleleRegistry.isIndividual(stack); + + if (slot == SLOT_CAN) + return Fluids.HONEY.isContained(stack); + + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return isItemValidForSlot(side, stack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, stack, side)) + return false; + + return slotIndex >= SLOT_OUTPUT_1 && slotIndex < SLOT_OUTPUT_1 + 4; } - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILIQUIDCONTAINER */ diff --git a/src/main/java/forestry/core/gadgets/TileBase.java b/src/main/java/forestry/core/gadgets/TileBase.java index a88799bae..1761487f7 100755 --- a/src/main/java/forestry/core/gadgets/TileBase.java +++ b/src/main/java/forestry/core/gadgets/TileBase.java @@ -89,16 +89,6 @@ public abstract class TileBase extends TileForestry implements IHintSource { public void openGui(EntityPlayer player, TileBase tile) { } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (!Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord)) - return false; - if (getAccess() == EnumAccess.PRIVATE) - return PlayerUtil.isSameGameProfile(owner, player.getGameProfile()); - - return true; - } - public boolean canDrainWithBucket() { return false; } diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 6fdde0480..0bbed58cc 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -29,9 +29,9 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StringUtil; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; public class TileEscritoire extends TileBase implements ISidedInventory, IRenderableMachine, ICrafter { diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index a6e1aedcd..940b9c831 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -18,7 +18,6 @@ import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.Optional; import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; -import forestry.core.config.Defaults; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IOwnable; import forestry.core.network.ForestryPacket; @@ -27,7 +26,7 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Vect; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -46,6 +45,7 @@ import java.util.Collection; public abstract class TileForestry extends TileEntity implements INetworkedEntity, IOwnable, IErrorSource, ITriggerProvider { protected boolean isInited = false; + private TileInventoryAdapter inventory; public Vect Coords() { return new Vect(xCoord, yCoord, zCoord); @@ -79,44 +79,43 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit initialize(); isInited = true; } - - if (!Proxies.common.isSimulating(worldObj)) - return; } public abstract void initialize(); // / SAVING & LOADING @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + + if(inventory != null) inventory.readFromNBT(data); - if (nbttagcompound.hasKey("Access")) - access = EnumAccess.values()[nbttagcompound.getInteger("Access")]; + if (data.hasKey("Access")) + access = EnumAccess.values()[data.getInteger("Access")]; else access = EnumAccess.SHARED; - if (nbttagcompound.hasKey("owner")) { - owner = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("owner")); - } + if (data.hasKey("owner")) + owner = NBTUtil.func_152459_a(data.getCompoundTag("owner")); - if (nbttagcompound.hasKey("Orientation")) - orientation = ForgeDirection.values()[nbttagcompound.getInteger("Orientation")]; + if (data.hasKey("Orientation")) + orientation = ForgeDirection.values()[data.getInteger("Orientation")]; else orientation = ForgeDirection.WEST; } @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - nbttagcompound.setInteger("Access", access.ordinal()); + public void writeToNBT(NBTTagCompound data) { + super.writeToNBT(data); + if(inventory != null) inventory.writeToNBT(data); + data.setInteger("Access", access.ordinal()); if (this.owner != null) { NBTTagCompound nbt = new NBTTagCompound(); NBTUtil.func_152460_a(nbt, owner); - nbttagcompound.setTag("owner", nbt); + data.setTag("owner", nbt); } if (orientation != null) - nbttagcompound.setInteger("Orientation", orientation.ordinal()); + data.setInteger("Orientation", orientation.ordinal()); } // / SMP @@ -205,7 +204,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit return errorState; } // / OWNERSHIP - public GameProfile owner = null; + private GameProfile owner = null; private EnumAccess access = EnumAccess.SHARED; @Override @@ -285,52 +284,21 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } /* NAME */ - /** * Gets the tile's unlocalized name, based on the block at the location of this entity (client-only). + * @return */ public String getUnlocalizedName() { - String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.",""); + String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.", ""); return blockUnlocalizedName + "." + getBlockMetadata() + ".name"; } - public boolean hasCustomInventoryName() { - return true; - } - - /* ACCESS */ - public abstract boolean isUseableByPlayer(EntityPlayer player); - /* INVENTORY BASICS */ - public InventoryAdapter getInternalInventory() { - return null; + public final TileInventoryAdapter getInternalInventory() { + return inventory; } - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return true; - } - - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return canPutStackFromSide(i, itemstack, j); - } - - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - return getAccess() == EnumAccess.SHARED; - } - - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return canTakeStackFromSide(i, itemstack, j); - } - - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - return getAccess() == EnumAccess.SHARED; - } - - public int[] getAccessibleSlotsFromSide(int side) { - if (getInternalInventory() == null) - return Defaults.FACINGS_NONE; - else - return getInternalInventory().getSizeInventorySide(side); - + public final void setInternalInventory(TileInventoryAdapter inv) { + this.inventory = inv; } } diff --git a/src/main/java/forestry/core/gadgets/TileMachine.java b/src/main/java/forestry/core/gadgets/TileMachine.java index 54d250006..532cfc120 100755 --- a/src/main/java/forestry/core/gadgets/TileMachine.java +++ b/src/main/java/forestry/core/gadgets/TileMachine.java @@ -12,32 +12,26 @@ package forestry.core.gadgets; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; -import forestry.api.core.ISpecialInventory; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IHintSource; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumAccess; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; import forestry.plugins.PluginEnergy; import forestry.plugins.PluginFactory; import forestry.plugins.PluginIC2; import forestry.plugins.PluginMail; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; import java.util.HashMap; -public abstract class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource { +public abstract class TileMachine extends TileForestry implements IClimatised, IHintSource { public TileMachine() { } @@ -275,86 +269,6 @@ public abstract class TileMachine extends TileForestry implements ISpecialInvent return false; } - // IINVENTORY IMPLEMENTATION - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(int i) { - return null; - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return null; - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return null; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - // IPARTICULARINVENTORY IMPLEMENTATION - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (getAccess() == EnumAccess.PRIVATE) - return 0; - - return 0; - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - if (getAccess() == EnumAccess.PRIVATE) - return new ItemStack[0]; - - return new ItemStack[0]; - } // INETWORKEDTILE IMPLEMENTATION @Override diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index 91f95b2a0..eddc05d5f 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -2,7 +2,7 @@ package forestry.core.gui; import forestry.core.gui.slots.SlotCustom; import forestry.core.proxy.Proxies; -import forestry.core.utils.AlyzerInventory; +import forestry.core.inventory.AlyzerInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 15a947fcb..b4d915402 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -213,7 +213,7 @@ public class ContainerForestry extends Container { } @Override - public boolean canInteractWith(EntityPlayer entityplayer) { + public final boolean canInteractWith(EntityPlayer entityplayer) { return inventory.isUseableByPlayer(entityplayer); } } diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index eb7a26704..755b88708 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack; import forestry.core.gui.slots.SlotItemInventory; import forestry.core.gui.slots.SlotLocked; import forestry.core.proxy.Proxies; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; public abstract class ContainerItemInventory extends ContainerForestry { diff --git a/src/main/java/forestry/core/utils/AlyzerInventory.java b/src/main/java/forestry/core/inventory/AlyzerInventory.java similarity index 97% rename from src/main/java/forestry/core/utils/AlyzerInventory.java rename to src/main/java/forestry/core/inventory/AlyzerInventory.java index 398ab4764..3423427c1 100644 --- a/src/main/java/forestry/core/utils/AlyzerInventory.java +++ b/src/main/java/forestry/core/inventory/AlyzerInventory.java @@ -1,4 +1,4 @@ -package forestry.core.utils; +package forestry.core.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; diff --git a/src/main/java/forestry/core/utils/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java similarity index 95% rename from src/main/java/forestry/core/utils/InventoryAdapter.java rename to src/main/java/forestry/core/inventory/InventoryAdapter.java index ea2b606cd..dc35a1fbb 100755 --- a/src/main/java/forestry/core/utils/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.core.utils; +package forestry.core.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -18,13 +18,16 @@ import net.minecraft.nbt.NBTTagList; import forestry.api.core.INBTTagable; import forestry.core.config.Defaults; +import forestry.core.utils.PlainInventory; +import forestry.core.utils.StackUtils; +import net.minecraft.inventory.ISidedInventory; /** * With permission from Krapht. */ -public class InventoryAdapter implements IInventory, INBTTagable { +public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagable { - private IInventory inventory = null; + private final IInventory inventory; //private boolean debug = false; public InventoryAdapter(int size, String name) { @@ -44,7 +47,6 @@ public class InventoryAdapter implements IInventory, INBTTagable { // this.debug = true; // return this; // } - /** * @return Copy of this inventory. Stacks are copies. */ @@ -333,7 +335,7 @@ public class InventoryAdapter implements IInventory, INBTTagable { @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return false; + return true; } @Override @@ -357,7 +359,8 @@ public class InventoryAdapter implements IInventory, INBTTagable { /* ISIDEDINVENTORY */ private int[][] slotMap; - public int[] getSizeInventorySide(int side) { + @Override + public int[] getAccessibleSlotsFromSide(int side) { return slotMap[side]; } @@ -407,6 +410,16 @@ public class InventoryAdapter implements IInventory, INBTTagable { return this; } + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + return isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return true; + } + /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { diff --git a/src/main/java/forestry/core/utils/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java similarity index 98% rename from src/main/java/forestry/core/utils/ItemInventory.java rename to src/main/java/forestry/core/inventory/ItemInventory.java index e7fcb75ff..b8d489157 100755 --- a/src/main/java/forestry/core/utils/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.core.utils; +package forestry.core.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -18,6 +18,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import forestry.api.core.INBTTagable; +import forestry.core.utils.Utils; public class ItemInventory implements IInventory, INBTTagable { diff --git a/src/main/java/forestry/core/utils/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java similarity index 59% rename from src/main/java/forestry/core/utils/TileInventoryAdapter.java rename to src/main/java/forestry/core/inventory/TileInventoryAdapter.java index d88b17f40..20bcfc26e 100755 --- a/src/main/java/forestry/core/utils/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -8,19 +8,22 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.core.utils; +package forestry.core.inventory; import net.minecraft.entity.player.EntityPlayer; import forestry.core.gadgets.TileForestry; +import forestry.core.utils.EnumAccess; +import forestry.core.utils.PlayerUtil; +import forestry.core.utils.Utils; +import net.minecraft.item.ItemStack; public class TileInventoryAdapter extends InventoryAdapter { private final TileForestry tile; public TileInventoryAdapter(TileForestry tile, int size, String name) { - super(size, name); - this.tile = tile; + this(tile, size, name, 64); } public TileInventoryAdapter(TileForestry tile, int size, String name, int stackLimit) { @@ -29,8 +32,12 @@ public class TileInventoryAdapter extends InventoryAdapter { } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return tile.isUseableByPlayer(entityplayer); + public boolean isUseableByPlayer(EntityPlayer player) { + if (!Utils.isUseableByPlayer(player, tile)) + return false; + if (tile.getAccess() == EnumAccess.PRIVATE) + return PlayerUtil.isSameGameProfile(tile.getOwnerProfile(), player.getGameProfile()); + return true; } @Override @@ -38,4 +45,14 @@ public class TileInventoryAdapter extends InventoryAdapter { super.markDirty(); tile.markDirty(); } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return tile.getAccess() == EnumAccess.SHARED; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return tile.getAccess() == EnumAccess.SHARED; + } } diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 14ea1fbaf..ed4b946c5 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.core.utils; +import forestry.core.inventory.InventoryAdapter; import java.util.ArrayList; import java.util.Random; diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 06bc7b70f..06b216d55 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -229,7 +229,15 @@ public class Utils { return block == Blocks.water || block == Blocks.flowing_water || block == Blocks.lava || block == Blocks.flowing_lava; } - public static boolean isUseableByPlayer(EntityPlayer player, TileEntity tile, World world, int x, int y, int z) { + public static boolean isUseableByPlayer(EntityPlayer player, TileEntity tile) { + int x = tile.xCoord; + int y = tile.yCoord; + int z = tile.zCoord; + World world = tile.getWorldObj(); + + if(tile.isInvalid()) + return false; + if (world.getTileEntity(x, y, z) != tile) return false; diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index a07753998..530b758c2 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -25,8 +25,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.utils.LiquidHelper; -import forestry.core.utils.TileInventoryAdapter; -import static forestry.factory.gadgets.MachineBottler.SLOT_PRODUCT; +import forestry.core.inventory.TileInventoryAdapter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -70,7 +69,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank public FilteredTank fuelTank; public FilteredTank heatingTank; private final TankManager tankManager; - private final TileInventoryAdapter inventory; public int burnTime; public int totalTime; public int currentFluidId = -1; @@ -83,7 +81,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank super(Defaults.ENGINE_BRONZE_HEAT_MAX, 300000, 5000); setHints(Config.hints.get("engine.bronze")); - inventory = new TileInventoryAdapter(this, 1, "Items"); + setInternalInventory(new TileInventoryAdapter(this, 1, "Items")); fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet()); fuelTank.tankMode = StandardTank.TankMode.INPUT; @@ -107,6 +105,8 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank super.updateServerSide(); + TileInventoryAdapter inventory = getInternalInventory(); + // Check if we have suitable items waiting in the item slot if (inventory.getStackInSlot(SLOT_CAN) != null) { @@ -304,7 +304,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank */ @Override public void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); burnTime = nbt.getInteger("EngineBurnTime"); @@ -317,7 +316,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } tankManager.readTanksFromNBT(nbt); - inventory.readFromNBT(nbt); } @@ -327,7 +325,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank */ @Override public void writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbt); nbt.setInteger("EngineBurnTime", burnTime); @@ -338,7 +335,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank nbt.setString("currentFluid", fluid.getName()); tankManager.writeTanksToNBT(nbt); - inventory.writeToNBT(nbt); } /* GUI */ @@ -382,32 +378,32 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -418,14 +414,9 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank public void closeInventory() { } - /** - * TODO: just a specialsource workaround - * @param player - * @return - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } @Override @@ -433,21 +424,11 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank return getUnlocalizedName(); } - /** - * TODO: just a specialsource workaround - * @return - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - * @param slotIndex - * @param itemstack - * @return - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { if (slotIndex == SLOT_CAN) { @@ -457,65 +438,25 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid()); } - return super.isItemValidForSlot(slotIndex, itemstack); + return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); } /* ISIDEDINVENTORY */ @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack stack, int side) { + public boolean canExtractItem(int i, ItemStack itemstack, int j) { return false; } @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack stack, int side) { - if (!super.canTakeStackFromSide(slotIndex, stack, side)) - return false; - - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - return container != null; + public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { + return isItemValidForSlot(slotIndex, stack); } - /** - * TODO: just a specialsource workaround - * @return - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - * @return - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - * @return - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); //To change body of generated methods, choose Tools | Templates. + return getInternalInventory().getAccessibleSlotsFromSide(side); } - /* ISPECIALINVENTORY */ -// @Override -// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { -// FluidContainerData container = LiquidHelper.getLiquidContainer(stack); -// if (container == null) -// return 0; -// -// return inventory.addStack(stack, false, doAdd); -// } -// -// @Override -// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { -// return null; -// } // IFluidHandler @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 9e98ee7f9..7be670b65 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -24,8 +24,8 @@ import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.network.GuiId; import forestry.core.utils.BlockUtil; -import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.factory.triggers.FactoryTriggers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index e584daadc..a210889d2 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -32,7 +32,7 @@ import forestry.core.interfaces.ISocketable; import forestry.core.network.GuiId; import forestry.core.utils.DelayTimer; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.plugins.PluginIC2; public class EngineTin extends Engine implements ISocketable, IInventory { diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index bcec54700..3a94775fa 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -38,7 +38,7 @@ import forestry.core.interfaces.IRenderableMachine; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index c0f4c498e..adb70f8d0 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.energy.gui; +<<<<<<< Updated upstream +======= +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +>>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.energy.gadgets.EngineBronze; @@ -18,7 +24,12 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; public class ContainerEngineBronze extends ContainerLiquidTanks { +<<<<<<< Updated upstream protected final EngineBronze engine; +======= + + protected EngineBronze engine; +>>>>>>> Stashed changes public ContainerEngineBronze(InventoryPlayer player, EngineBronze engine) { super(engine, engine); @@ -27,18 +38,16 @@ public class ContainerEngineBronze extends ContainerLiquidTanks { this.addSlot(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); int i; - for (i = 0; i < 3; ++i) - for (int var4 = 0; var4 < 9; ++var4) + for (i = 0; i < 3; ++i) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) + for (i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return engine.isUseableByPlayer(entityplayer); - } - } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index bd678ff3d..bdd46cbe9 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; @@ -20,7 +19,12 @@ import forestry.core.gui.slots.SlotClosed; import forestry.energy.gadgets.EngineCopper; public class ContainerEngineCopper extends ContainerForestry { +<<<<<<< Updated upstream protected final EngineCopper engine; +======= + + protected EngineCopper engine; +>>>>>>> Stashed changes public ContainerEngineCopper(InventoryPlayer player, EngineCopper tile) { super(tile); @@ -33,12 +37,15 @@ public class ContainerEngineCopper extends ContainerForestry { this.addSlot(new SlotClosed(tile, 3, 116, 35)); this.addSlot(new SlotClosed(tile, 4, 116, 53)); - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 9; ++j) + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + } } @@ -52,12 +59,14 @@ public class ContainerEngineCopper extends ContainerForestry { public void detectAndSendChanges() { super.detectAndSendChanges(); +<<<<<<< Updated upstream for (Object crafter : crafters) engine.sendGUINetworkData(this, (ICrafting) crafter); +======= + for (Object crafter : crafters) { + engine.sendGUINetworkData(this, (ICrafting) crafter); + } +>>>>>>> Stashed changes } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return engine.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index 570a909d2..53f6efdaa 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.energy.gui; +<<<<<<< Updated upstream +======= +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +>>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.energy.gadgets.MachineGenerator; @@ -27,17 +33,15 @@ public class ContainerGenerator extends ContainerLiquidTanks { this.tile = tile; this.addSlot(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); - for (int i = 0; i < 3; ++i) - for (int var4 = 0; var4 < 9; ++var4) + for (int i = 0; i < 3; ++i) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return tile.isUseableByPlayer(entityplayer); + } } } diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 0e9d01fcd..8b7348bae 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -25,7 +25,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; @@ -64,6 +64,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq /* RECIPE MANAGMENT */ public static class Recipe { + public final int cyclesPerUnit; public final FluidStack input; public final ItemStack can; @@ -86,7 +87,12 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } public static class RecipeManager implements ICraftingProvider { +<<<<<<< Updated upstream public static final ArrayList recipes = new ArrayList(); +======= + + public static ArrayList recipes = new ArrayList(); +>>>>>>> Stashed changes /** * @@ -105,9 +111,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } // No recipe matched. See if the liquid dictionary has anything. - if(FluidContainerRegistry.isEmptyContainer(empty)) { + if (FluidContainerRegistry.isEmptyContainer(empty)) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(res, empty); - if(filled != null) { + if (filled != null) { FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(filled); Recipe recipe = new Recipe(CYCLES_FILLING_DEFAULT, fluidStack, empty, filled); recipes.add(recipe); @@ -133,8 +139,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public Map getRecipes() { HashMap recipeList = new HashMap(); - for (Recipe recipe : recipes) - recipeList.put(new Object[] { recipe.input, recipe.can }, new Object[] { recipe.bottled }); + for (Recipe recipe : recipes) { + recipeList.put(new Object[]{recipe.input, recipe.can}, new Object[]{recipe.bottled}); + } return recipeList; } @@ -184,13 +191,14 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq NBTTagList nbttaglist = new NBTTagList(); ItemStack[] offspring = pendingProducts.toArray(new ItemStack[pendingProducts.size()]); - for (int i = 0; i < offspring.length; i++) + for (int i = 0; i < offspring.length; i++) { if (offspring[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); offspring[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingProducts", nbttaglist); } @@ -379,14 +387,43 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } /* IINVENTORY */ - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public int getSizeInventory() { + return inventory.getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int i) { + return inventory.getStackInSlot(i); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + return inventory.decrStackSize(i, j); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + inventory.setInventorySlotContents(i, itemstack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return inventory.getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return inventory.getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } /** * TODO: just a specialsource workaround @@ -404,36 +441,38 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq return super.hasCustomInventoryName(); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + if (slotIndex == SLOT_RESOURCE) + return FluidContainerRegistry.isEmptyContainer(itemstack); + + if (slotIndex == SLOT_CAN) { + FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); + return container != null && RecipeManager.isInput(container.fluid); + } + + return false; } - /** - * TODO: just a specialsource workaround - */ + @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } - /** - * TODO: just a specialsource workaround - */ + @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return getInternalInventory().canExtractItem(side, itemstack, side) && slotIndex == SLOT_PRODUCT; } - /** - * TODO: just a specialsource workaround - */ + @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ISIDEDINVENTORY */ @@ -445,7 +484,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) + if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) return false; return slotIndex == SLOT_PRODUCT; @@ -454,18 +493,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if(slotIndex == SLOT_RESOURCE) - return FluidContainerRegistry.isEmptyContainer(itemstack); - - if(slotIndex == SLOT_CAN) { - FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); - return container != null && RecipeManager.isInput(container.fluid); - } - - return false; } /* ILIQUIDCONTAINER */ diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 3ce691173..2bc174197 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -25,11 +25,11 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; import forestry.factory.gui.ContainerCarpenter; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index cf1b0a6e7..e54ea176d 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -21,7 +21,7 @@ import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.network.GuiId; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.factory.triggers.FactoryTriggers; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index f591b17db..927374790 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -42,7 +42,7 @@ 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.inventory.InventoryAdapter; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; import net.minecraftforge.fluids.FluidTankInfo; diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 3b1925a95..af22edc69 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -28,7 +28,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index c3970bdec..d34065cf0 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -26,7 +26,7 @@ import forestry.core.interfaces.IRenderableMachine; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 64d5ae494..45d208b1e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -21,7 +21,7 @@ import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.utils.Fluids; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index b51346295..7f523433e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -26,7 +26,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index bf5ded4ea..231ea79a6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -25,7 +25,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 8249834e3..c670c3a2a 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -34,10 +34,10 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.PlainInventory; import forestry.core.utils.StackUtils; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; public class TileWorktable extends TileBase implements ICrafter { diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index 7d4d2e27f..565b3801b 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; +<<<<<<< Updated upstream +======= +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +>>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; @@ -31,17 +37,16 @@ public class ContainerBottler extends ContainerLiquidTanks { this.addSlot(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); int var3; - for (var3 = 0; var3 < 3; ++var3) - for (int var4 = 0; var4 < 9; ++var4) + for (var3 = 0; var3 < 3; ++var3) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } - for (var3 = 0; var3 < 9; ++var3) + for (var3 = 0; var3 < 9; ++var3) { this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return tile.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index 5d43389d3..90c58931e 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; +<<<<<<< Updated upstream +======= +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +>>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotLiquidContainer; @@ -20,7 +26,12 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; public class ContainerFermenter extends ContainerLiquidTanks { +<<<<<<< Updated upstream protected final MachineFermenter fermenter; +======= + + protected MachineFermenter fermenter; +>>>>>>> Stashed changes public ContainerFermenter(InventoryPlayer player, MachineFermenter fermenter) { super(fermenter, fermenter); @@ -32,17 +43,16 @@ public class ContainerFermenter extends ContainerLiquidTanks { this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); - for (int i = 0; i < 3; ++i) - for (int var4 = 0; var4 < 9; ++var4) + for (int i = 0; i < 3; ++i) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return fermenter.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 0a12d2390..b94d3152d 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -30,12 +29,15 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain this.tile = tile; // Stash - for (int l = 0; l < 2; l++) - for (int k1 = 0; k1 < 3; k1++) + for (int l = 0; l < 2; l++) { + for (int k1 = 0; k1 < 3; k1++) { addSlot(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); + } + } // Reservoir - for (int k1 = 0; k1 < 3; k1++) + for (int k1 = 0; k1 < 3; k1++) { addSlot(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); + } // Working slot this.addSlot(new SlotWorking(tile, 9, 105, 37)); @@ -47,12 +49,15 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain // Player inventory int var3; - for (var3 = 0; var3 < 3; ++var3) - for (int var4 = 0; var4 < 9; ++var4) + for (var3 = 0; var3 < 3; ++var3) { + for (int var4 = 0; var4 < 9; ++var4) { this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } - for (var3 = 0; var3 < 9; ++var3) + for (var3 = 0; var3 < 9; ++var3) { this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + } } @@ -62,9 +67,4 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain tile.checkRecipe(); } - @Override - public boolean canInteractWith(EntityPlayer player) { - return this.tile.isUseableByPlayer(player); - } - } diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index ad0b0afa6..b3ade0028 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -10,9 +10,7 @@ ******************************************************************************/ 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.Slot; import forestry.core.gui.ContainerLiquidTanks; @@ -31,17 +29,16 @@ public class ContainerRaintank extends ContainerLiquidTanks { this.addSlot(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); this.addSlot(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 9; ++j) + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return tile.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/factory/gui/ContainerStill.java b/src/main/java/forestry/factory/gui/ContainerStill.java index fa384ee0f..41dcb6217 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -10,9 +10,7 @@ ******************************************************************************/ 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.Slot; import forestry.core.gui.ContainerLiquidTanks; @@ -20,6 +18,7 @@ import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineStill; public class ContainerStill extends ContainerLiquidTanks { + protected MachineStill processor; public ContainerStill(InventoryPlayer player, MachineStill tile) { @@ -30,17 +29,16 @@ public class ContainerStill extends ContainerLiquidTanks { this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 9; ++j) + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (int i = 0; i < 9; ++i) + for (int i = 0; i < 9; ++i) { this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + } } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return processor.isUseableByPlayer(entityplayer); - } } diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 15e94981e..e55409480 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -33,7 +33,7 @@ import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; public abstract class TileFarm extends TileForestry implements IFarmComponent { diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 0638c4766..5bf242b7e 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -60,10 +60,10 @@ 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.inventory.InventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; -import forestry.core.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Vect; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index f80f814f0..117dc30fc 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -14,7 +14,7 @@ import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import forestry.api.core.ITileStructure; import forestry.core.utils.BlockUtil; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.farming.triggers.FarmingTriggers; diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index b2e55fa4d..89ebd1148 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -24,7 +24,7 @@ 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.utils.TileInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.farming.gadgets.TileFarmPlain; import forestry.plugins.PluginFarming; diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index a7f66e480..6375ab031 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -15,7 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import forestry.core.utils.AlyzerInventory; +import forestry.core.inventory.AlyzerInventory; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.api.lepidopterology.IButterfly; diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 237b93273..05f5610c9 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -20,7 +20,7 @@ import forestry.api.core.INBTTagable; import forestry.api.mail.ILetter; import forestry.api.mail.IStamps; import forestry.api.mail.IMailAddress; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StringUtil; import org.apache.commons.lang3.StringUtils; diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index d5ea3a8fd..c76491e9e 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -23,6 +23,7 @@ import java.util.Locale; import java.util.UUID; public class MailAddress implements INBTTagable, IMailAddress { + private static final GameProfile invalidGameProfile = new GameProfile(new UUID(0, 0), ""); @EntityNetData private EnumAddressee type; @@ -47,17 +48,16 @@ public class MailAddress implements INBTTagable, IMailAddress { throw new IllegalArgumentException("name must not be null"); this.type = EnumAddressee.TRADER; - this.gameProfile = new GameProfile(new UUID(0, 0), name); + this.gameProfile = new GameProfile(null, name); } public MailAddress(IMailAddress address) { this.type = address.getType(); if (type == EnumAddressee.TRADER) { String name = address.getName(); - this.gameProfile = new GameProfile(new UUID(0, 0), name); - } else if (type == EnumAddressee.PLAYER) { + this.gameProfile = new GameProfile(null, name); + } else if (type == EnumAddressee.PLAYER) this.gameProfile = address.getPlayerProfile(); - } } public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) { @@ -100,7 +100,7 @@ public class MailAddress implements INBTTagable, IMailAddress { @Override public int hashCode() { - return gameProfile.hashCode(); + return gameProfile.getName().hashCode(); } @Override @@ -108,18 +108,28 @@ public class MailAddress implements INBTTagable, IMailAddress { if (!(o instanceof MailAddress)) return false; +<<<<<<< Updated upstream MailAddress address = (MailAddress) o; return PlayerUtil.isSameGameProfile(address.gameProfile, gameProfile); +======= + MailAddress other = (MailAddress) o; + return isSamePlayer(gameProfile, other.gameProfile); + } + + private static boolean isSamePlayer(GameProfile a, GameProfile b) { + if (a.getId() != null && b.getId() != null) + return a.getId().equals(b.getId()); + return a.getName() != null && a.getName().equals(b.getName()); +>>>>>>> Stashed changes } @Override public String toString() { String name = getName().toLowerCase(Locale.ENGLISH); - if (isPlayer()) { + if (isPlayer()) return type + "-" + name + "-" + gameProfile.getId(); - } else { + else return type + "-" + name; - } } @Override diff --git a/src/main/java/forestry/mail/POBox.java b/src/main/java/forestry/mail/POBox.java index 5fbc694f2..a229d5308 100755 --- a/src/main/java/forestry/mail/POBox.java +++ b/src/main/java/forestry/mail/POBox.java @@ -19,7 +19,7 @@ import net.minecraft.world.WorldSavedData; import forestry.api.mail.ILetter; import forestry.api.mail.PostManager; import forestry.api.mail.IMailAddress; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; public class POBox extends WorldSavedData implements IInventory { diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 507f78daf..ac8761653 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -35,8 +35,13 @@ import forestry.plugins.PluginMail; public class PostRegistry implements IPostRegistry { public static PostOffice cachedPostOffice; +<<<<<<< Updated upstream public static final HashMap cachedPOBoxes = new HashMap(); public static final HashMap cachedTradeStations = new HashMap(); +======= + public static Map cachedPOBoxes = new HashMap(); + public static Map cachedTradeStations = new HashMap(); +>>>>>>> Stashed changes /** * @param world the Minecraft world the PO box will be in diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index 4325a891e..002014b2f 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -20,7 +20,7 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; import forestry.core.config.ForestryItem; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StackUtils; import forestry.mail.items.ItemLetter; diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 39fb314fb..b4e5facfe 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -23,7 +23,7 @@ import forestry.core.config.Config; import forestry.core.gadgets.TileBase; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.mail.EnumDeliveryState; import forestry.mail.IMailContainer; import forestry.mail.POBox; diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 5352cf720..14f03818e 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -20,7 +20,7 @@ import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.core.gadgets.TileBase; import forestry.core.network.GuiId; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; public class MachinePhilatelist extends TileBase implements IInventory { diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 224a2d780..7b813ef3a 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -22,7 +22,7 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.mail.MailAddress; import forestry.mail.TradeStation; diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index b97913f2e..1ea386864 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import forestry.core.gui.ContainerForestry; @@ -18,7 +17,7 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.mail.gadgets.MachineTrader; import forestry.api.mail.PostManager; import forestry.api.mail.IMailAddress; @@ -61,9 +60,4 @@ public class ContainerTradeName extends ContainerForestry { machine.setAddress(address); } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } - } diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 18d34328a..3e48c9d6d 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; @@ -37,11 +36,14 @@ public class ContainerTrader extends ContainerForestry { this.addSlot(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); // Exchange - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { addSlot(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); + } + } // Stamps +<<<<<<< Updated upstream for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); @@ -50,24 +52,45 @@ public class ContainerTrader extends ContainerForestry { for (int i = 0; i < 3; i++) for (int j = 0; j < 2; j++) addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); +======= + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, new Object[]{ItemStamps.class})); + } + } + + // Letters + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, new Object[]{Items.paper})); + } + } +>>>>>>> Stashed changes // Buffers final int bufCols = 5; - for (int i = 0; i < 3; i++) - for (int j = 0; j < bufCols; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < bufCols; j++) { addSlot(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); + } + } - for (int i = 0; i < 2; i++) - for (int j = 0; j < bufCols; j++) + for (int i = 0; i < 2; i++) { + for (int j = 0; j < bufCols; j++) { addSlot(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); + } + } // Player inventory - for (int i = 0; i < 3; i++) - for (int j = 0; j < 9; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { addSlot(new Slot(player, j + i * 9 + 9, 33 + j * 18, 138 + i * 18)); + } + } // Player hotbar - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { addSlot(new Slot(player, i, 33 + i * 18, 196)); + } } @@ -79,8 +102,4 @@ public class ContainerTrader extends ContainerForestry { return machine.getAddress(); } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } } diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index d143399e1..f2002f732 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -33,7 +33,7 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.core.utils.StringUtil; import forestry.mail.Letter; diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index 165d9c609..8af254003 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -6,15 +6,12 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package forestry.pipes.gui; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -import buildcraft.transport.Pipe; import forestry.core.gui.ContainerForestry; -import forestry.core.utils.InventoryAdapter; +import forestry.core.inventory.InventoryAdapter; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; @@ -28,17 +25,15 @@ public class ContainerPropolisPipe extends ContainerForestry { this.playerIInventory = playerInventory; this.pipeLogic = pipe.pipeLogic; - for (int l = 0; l < 3; l++) - for (int k1 = 0; k1 < 9; k1++) + for (int l = 0; l < 3; l++) { + for (int k1 = 0; k1 < 9; k1++) { addSlot(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18)); + } + } - for (int i1 = 0; i1 < 9; i1++) + for (int i1 = 0; i1 < 9; i1++) { addSlot(new Slot(playerInventory, i1, 8 + i1 * 18, 198)); - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; + } } } diff --git a/src/main/java/forestry/storage/GuiHandlerStorage.java b/src/main/java/forestry/storage/GuiHandlerStorage.java index 330452d45..835145b0c 100755 --- a/src/main/java/forestry/storage/GuiHandlerStorage.java +++ b/src/main/java/forestry/storage/GuiHandlerStorage.java @@ -23,7 +23,7 @@ import forestry.core.config.Defaults; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.gui.IPagedInventory; import forestry.core.network.GuiId; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.storage.gui.ContainerBackpack; import forestry.storage.gui.ContainerNaturalistBackpack; import forestry.storage.gui.GuiBackpack; diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index 54be8eb05..aefbf8ba7 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -22,7 +22,7 @@ import forestry.api.storage.BackpackManager; import forestry.api.storage.BackpackResupplyEvent; import forestry.api.storage.IBackpackDefinition; import forestry.core.interfaces.IResupplyHandler; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.storage.items.ItemBackpack; public class ResupplyHandler implements IResupplyHandler { diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index 63d4ce780..0ce3de1f5 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack; import forestry.core.config.Defaults; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotForestry; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.storage.items.ItemBackpack; public class ContainerBackpack extends ContainerItemInventory { diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 871321ab8..b4dd85a75 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -40,7 +40,7 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; -import forestry.core.utils.ItemInventory; +import forestry.core.inventory.ItemInventory; import forestry.core.utils.StringUtil; import forestry.storage.BackpackMode; From 3636af5b9cb4c1f54051333d5e53d77471dafaf1 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sun, 30 Nov 2014 17:59:31 -0800 Subject: [PATCH 002/175] More work on inventory stuff, and fix all the broken merge stuff --- .../apiculture/gadgets/TileApiary.java | 134 +-------------- .../apiculture/gadgets/TileBeehouse.java | 124 +++++++++++--- .../worldgen/ComponentVillageBeeHouse.java | 10 +- .../forestry/core/gadgets/BlockForestry.java | 3 +- .../forestry/core/gadgets/TileEscritoire.java | 136 +++++++-------- .../forestry/core/gadgets/TileForestry.java | 16 +- .../core/gadgets/TileNaturalistChest.java | 11 +- .../forestry/core/gui/ContainerForestry.java | 9 +- .../core/inventory/TileInventoryAdapter.java | 4 +- .../core/network/PacketTileUpdate.java | 2 +- .../forestry/energy/gadgets/EngineCopper.java | 94 ++++------- .../forestry/energy/gadgets/EngineTin.java | 70 ++++---- .../energy/gadgets/MachineGenerator.java | 156 ++++++++++-------- .../energy/gui/ContainerEngineBronze.java | 13 +- .../energy/gui/ContainerEngineCopper.java | 12 +- .../energy/gui/ContainerGenerator.java | 7 - .../factory/gui/ContainerBottler.java | 7 - .../factory/gui/ContainerFermenter.java | 13 +- src/main/java/forestry/mail/MailAddress.java | 11 -- src/main/java/forestry/mail/PostRegistry.java | 12 +- .../forestry/mail/gui/ContainerTrader.java | 15 +- 21 files changed, 352 insertions(+), 507 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileApiary.java b/src/main/java/forestry/apiculture/gadgets/TileApiary.java index 0f59ae39a..00d09357d 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileApiary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileApiary.java @@ -17,18 +17,17 @@ import forestry.api.apiculture.IHiveFrame; import forestry.api.core.ForestryAPI; import forestry.apiculture.trigger.ApicultureTriggers; import forestry.core.gadgets.TileBase; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.plugins.PluginApiculture; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import java.util.Collection; import java.util.LinkedList; -public class TileApiary extends TileBeehouse implements ISidedInventory { +public class TileApiary extends TileBeehouse { @Override public String getInventoryName() { @@ -43,6 +42,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { /* IBEEHOUSING */ @Override public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -55,6 +55,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public float getProductionModifier(IBeeGenome genome, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 0.1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -67,6 +68,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -79,6 +81,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -91,6 +94,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public float getFloweringModifier(IBeeGenome genome, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -103,6 +107,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public float getGeneticDecay(IBeeGenome genome, float currentModifier) { + TileInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -115,6 +120,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { @Override public void wearOutEquipment(int amount) { + TileInventoryAdapter inventory = getInternalInventory(); int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier()); for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { @@ -130,128 +136,6 @@ public class TileApiary extends TileBeehouse implements ISidedInventory { } } - /* IINVENTORY */ - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - switch (slotIndex) { - case SLOT_QUEEN: - case SLOT_DRONE: - case SLOT_FRAMES_1: - case SLOT_FRAMES_2: - case SLOT_FRAMES_3: - return false; - default: - return true; - } - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) - && !PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - - if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - - return false; - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public ItemStack getStackInSlot(int i) { - return super.getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - super.setSlotContents(i, itemstack); - } - - @Override - public int getSizeInventory() { - return inventory.getSizeInventory(); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - /* ISPECIALINVENTORY */ // @Override // public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 44898033d..09fd3a571 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -29,18 +29,19 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { +public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, ISidedInventory { // CONSTANTS public static final int SLOT_QUEEN = 0; @@ -53,9 +54,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public static final int SLOT_FRAMES_3 = 11; public static final int SLOT_INVENTORY_COUNT = 7; public static final int SLOT_FRAMES_COUNT = 3; - - // Inventory - protected final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); private final IBeekeepingLogic logic; private BiomeGenBase biome; private int displayHealthMax = 0; @@ -64,6 +62,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public TileBeehouse() { setHints(Config.hints.get("apiary")); logic = PluginApiculture.beeInterface.createBeekeepingLogic(this); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); } @Override @@ -77,8 +76,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { super.writeToNBT(nbttagcompound); nbttagcompound.setInteger("BiomeId", biome.biomeID); - - inventory.writeToNBT(nbttagcompound); if (logic != null) logic.writeToNBT(nbttagcompound); } @@ -89,8 +86,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { int biomeId = nbttagcompound.getInteger("BiomeId"); biome = BiomeGenBase.getBiome(biomeId); - - inventory.readFromNBT(nbttagcompound); logic.readFromNBT(nbttagcompound); } @@ -137,12 +132,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public void updateClientSide() { // / Multiplayer FX - if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) { + if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) { - IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)); + IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN)); displayQueen.doFX(logic.getEffectData(), this); } - } } @@ -157,7 +151,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { // Add swarm effects if (worldObj.getTotalWorldTime() % 200 * 10 == 0) - onQueenChange(inventory.getStackInSlot(SLOT_QUEEN)); + onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN)); /* These should get already done on the client / doesn't work server-side anyway if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) queen.doFX(logic.getEffectData(), this); @@ -184,7 +178,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { @Override public boolean addProduct(ItemStack product, boolean all) { - return inventory.tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true); + return getInternalInventory().tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true); } /* NETWORK SYNCH */ @@ -200,6 +194,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { /* STATE INFORMATION */ private int getHealthDisplay() { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -212,6 +207,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { } private int getMaxHealthDisplay() { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -281,16 +277,95 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { /* INVENTORY MANAGMENT */ @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } - public void setSlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); + } + + @Override + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack decrStackSize(int slotIndex, int amount) { + return getInternalInventory().decrStackSize(slotIndex, amount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slotIndex) { + return getInternalInventory().getStackInSlotOnClosing(slotIndex); + } + + @Override + public void setInventorySlotContents(int slotIndex, ItemStack stack) { + getInternalInventory().setInventorySlotContents(slotIndex, stack); + } + + @Override + public String getInventoryName() { + return getUnlocalizedName(); + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return getInternalInventory().isUseableByPlayer(player); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) + && !PluginApiculture.beeInterface.isDrone(itemstack)) + return true; + + return slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(side, itemstack, side)) + return false; + + switch (slotIndex) { + case SLOT_QUEEN: + case SLOT_DRONE: + case SLOT_FRAMES_1: + case SLOT_FRAMES_2: + case SLOT_FRAMES_3: + return false; + default: + return true; + } + } + + @Override + public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { + return isItemValidForSlot(slotIndex, stack); } // / IBEEHOUSING @@ -331,12 +406,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { @Override public void setQueen(ItemStack itemstack) { - setSlotContents(SLOT_QUEEN, itemstack); + setInventorySlotContents(SLOT_QUEEN, itemstack); } @Override public void setDrone(ItemStack itemstack) { - setSlotContents(SLOT_DRONE, itemstack); + setInventorySlotContents(SLOT_DRONE, itemstack); } @Override @@ -430,10 +505,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { public boolean onEggLaid(IBee queen) { return false; } - + /* IHousing */ @Override public GameProfile getOwnerName() { return this.getOwnerProfile(); } + } diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index f3001bb05..bb5eeb796 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -276,19 +276,19 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { if (tile instanceof TileBeehouse) { TileBeehouse apiary = ((TileBeehouse) tile); apiary.initialize(); - apiary.setSlotContents(TileBeehouse.SLOT_QUEEN, + apiary.setInventorySlotContents(TileBeehouse.SLOT_QUEEN, PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.PRINCESS.ordinal())); - apiary.setSlotContents(TileBeehouse.SLOT_DRONE, + apiary.setInventorySlotContents(TileBeehouse.SLOT_DRONE, PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.DRONE.ordinal())); for (int i = TileBeehouse.SLOT_FRAMES_1; i < TileBeehouse.SLOT_FRAMES_1 + TileBeehouse.SLOT_FRAMES_COUNT; i++) { float roll = world.rand.nextFloat(); if (roll < 0.2f) - apiary.setSlotContents(i, ForestryItem.frameUntreated.getItemStack()); + apiary.setInventorySlotContents(i, ForestryItem.frameUntreated.getItemStack()); else if (roll < 0.4f) - apiary.setSlotContents(i, ForestryItem.frameImpregnated.getItemStack()); + apiary.setInventorySlotContents(i, ForestryItem.frameImpregnated.getItemStack()); else if (roll < 0.6) - apiary.setSlotContents(i, ForestryItem.frameProven.getItemStack()); + apiary.setInventorySlotContents(i, ForestryItem.frameProven.getItemStack()); } } diff --git a/src/main/java/forestry/core/gadgets/BlockForestry.java b/src/main/java/forestry/core/gadgets/BlockForestry.java index ae1832255..5c9fab2e3 100755 --- a/src/main/java/forestry/core/gadgets/BlockForestry.java +++ b/src/main/java/forestry/core/gadgets/BlockForestry.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.core.gadgets; - import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -65,6 +64,6 @@ public abstract class BlockForestry extends BlockContainer { TileForestry tile = (TileForestry) world.getTileEntity(i, j, k); if (entityliving instanceof EntityPlayer) - tile.owner = ((EntityPlayer) entityliving).getGameProfile(); + tile.setOwner(((EntityPlayer) entityliving)); } } diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 0bbed58cc..047f0c9c2 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -29,8 +29,6 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.StringUtil; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; @@ -44,14 +42,14 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender /* MEMBER */ private final NaturalistGame game = new NaturalistGame(); - private final InventoryAdapter inventory; + @Override public String getInventoryName() { return getUnlocalizedName(); } public TileEscritoire() { - inventory = new TileInventoryAdapter(this, 12, "Items"); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); } /* GUI */ @@ -66,7 +64,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender super.writeToNBT(nbttagcompound); game.writeToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); } @Override @@ -74,7 +71,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender super.readFromNBT(nbttagcompound); game.readFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); } /* GAME */ @@ -83,42 +79,43 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender } public void processTurnResult(GameProfile gameProfile) { - if(!game.isWon()) + if (!game.isWon()) return; - IIndividual individual = AlleleManager.alleleRegistry.getIndividual(inventory.getStackInSlot(SLOT_ANALYZE)); - if(individual == null) + IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getInternalInventory().getStackInSlot(SLOT_ANALYZE)); + if (individual == null) return; - for(ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel())) - inventory.addStack(itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true); + for (ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel())) { + getInternalInventory().addStack(itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true); + } } private boolean areProbeSlotsFilled() { int filledSlots = 0; int required = game.getSampleSize() < SLOTS_INPUT_COUNT ? game.getSampleSize() : SLOTS_INPUT_COUNT; - for(int i = SLOT_INPUT_1; i < SLOT_INPUT_1 + required; i++) - if(inventory.getStackInSlot(i) != null) + for (int i = SLOT_INPUT_1; i < SLOT_INPUT_1 + required; i++) { + if (getInternalInventory().getStackInSlot(i) != null) filledSlots++; + } return filledSlots >= required; } public void probe() { - if (!worldObj.isRemote && inventory.getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled()) { - game.probe(inventory.getStackInSlot(SLOT_ANALYZE), this, SLOT_INPUT_1, SLOTS_INPUT_COUNT); - } + if (!worldObj.isRemote && getInternalInventory().getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled()) + game.probe(getInternalInventory().getStackInSlot(SLOT_ANALYZE), this, SLOT_INPUT_1, SLOTS_INPUT_COUNT); } /* NETWORK */ @Override public void fromPacket(ForestryPacket packetRaw) { - if(packetRaw instanceof PacketTileUpdate) { + if (packetRaw instanceof PacketTileUpdate) { super.fromPacket(packetRaw); return; } - PacketTileNBT packet = (PacketTileNBT)packetRaw; + PacketTileNBT packet = (PacketTileNBT) packetRaw; readFromNBT(packet.getTagCompound()); } @@ -127,97 +124,89 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender } /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if(slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + SLOTS_INPUT_COUNT) - return slotIndex < SLOT_INPUT_1 + game.getSampleSize(); + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + SLOTS_INPUT_COUNT) + return slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT); return true; } @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) return false; return slotIndex >= SLOT_RESULTS_1 && slotIndex < SLOT_RESULTS_1 + SLOTS_RESULTS_COUNT; } @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - int samples = game.getSampleSize(); - return slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + (samples < SLOTS_INPUT_COUNT ? samples : SLOTS_INPUT_COUNT); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { + TileInventoryAdapter inventory = getInternalInventory(); inventory.setInventorySlotContents(slotIndex, itemstack); - if(slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { - if(!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE)) + if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { + if (!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE)) && inventory.getStackInSlot(SLOT_ANALYZE) != null) { ItemStack ersatz = Utils.convertSaplingToGeneticEquivalent(inventory.getStackInSlot(SLOT_ANALYZE)); - if(ersatz != null) + if (ersatz != null) inventory.setInventorySlotContents(SLOT_ANALYZE, ersatz); } game.initialize(inventory.getStackInSlot(SLOT_ANALYZE)); } } - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInternalInventory().getStackInSlot(i); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + return getInternalInventory().decrStackSize(i, j); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + return getInternalInventory().getAccessibleSlotsFromSide(side); } @Override @@ -232,7 +221,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - if(slotIndex == SLOT_ANALYZE) + if (slotIndex == SLOT_ANALYZE) game.reset(); return null; } @@ -247,5 +236,4 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender return true; } - } diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 940b9c831..5eb6d16b5 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -27,6 +27,7 @@ import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.utils.PlayerUtil; import forestry.core.utils.Vect; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -87,8 +88,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); - - if(inventory != null) inventory.readFromNBT(data); + + if (inventory != null) + inventory.readFromNBT(data); if (data.hasKey("Access")) access = EnumAccess.values()[data.getInteger("Access")]; @@ -107,7 +109,8 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); - if(inventory != null) inventory.writeToNBT(data); + if (inventory != null) + inventory.writeToNBT(data); data.setInteger("Access", access.ordinal()); if (this.owner != null) { NBTTagCompound nbt = new NBTTagCompound(); @@ -264,10 +267,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public boolean isOwner(EntityPlayer player) { - if (owner != null) - return owner.getId().compareTo(player.getPersistentID()) == 0; - else - return false; + if (owner != null && player != null) + return PlayerUtil.isSameGameProfile(owner, player.getGameProfile()); + return false; } @Override diff --git a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java index 152f0fa8c..e3ea31c2c 100755 --- a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java +++ b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java @@ -21,7 +21,6 @@ import forestry.api.genetics.ISpeciesRoot; import forestry.core.GuiHandler; import forestry.core.config.Config; import forestry.core.gui.IPagedInventory; -import forestry.core.utils.StringUtil; public abstract class TileNaturalistChest extends TileBase implements IInventory, IPagedInventory { @@ -157,19 +156,13 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } } diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index b4d915402..8d6f81e8a 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -30,9 +30,9 @@ public class ContainerForestry extends Container { public ContainerForestry(IInventory inventory) { this.inventory = inventory; if (inventory instanceof TileForestry) - this.inventoryForestry = (TileForestry)inventory; + this.inventoryForestry = (TileForestry) inventory; else - this.inventoryForestry = null; + this.inventoryForestry = null; } /** @@ -50,16 +50,15 @@ public class ContainerForestry extends Container { return null; if ((inventoryForestry != null) && (inventoryForestry.getAccess() != EnumAccess.SHARED)) - if ((inventoryForestry.owner != null) && !PlayerUtil.isSameGameProfile(inventoryForestry.owner, player.getGameProfile())) + if (!inventoryForestry.isOwner(player)) return null; Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex); if (slot instanceof SlotForestry) { ((SlotForestry) slot).onSlotClick(slotIndex, button, modifier, player); - if (((SlotForestry) slot).isPhantom()) { + if (((SlotForestry) slot).isPhantom()) return slotClickPhantom(slot, button, modifier, player); - } } return super.slotClick(slotIndex, button, modifier, player); } diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index 20bcfc26e..4e225033c 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -47,12 +47,12 @@ public class TileInventoryAdapter extends InventoryAdapter { } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { return tile.getAccess() == EnumAccess.SHARED; } @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { return tile.getAccess() == EnumAccess.SHARED; } } diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index e9443ca13..4e67a37cc 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -47,7 +47,7 @@ public class PacketTileUpdate extends PacketUpdate { isOwnable = tile.isOwnable(); access = tile.getAccess(); - owner = tile.owner; + owner = tile.getOwnerProfile(); } @Override diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 7be670b65..f4293e4e3 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -24,7 +24,6 @@ import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.network.GuiId; import forestry.core.utils.BlockUtil; -import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.factory.triggers.FactoryTriggers; import net.minecraft.entity.player.EntityPlayer; @@ -56,14 +55,12 @@ public class EngineCopper extends Engine implements ISidedInventory { private int ashProduction; private final int ashForItem; - private final TileInventoryAdapter inventory; - public EngineCopper() { super(Defaults.ENGINE_COPPER_HEAT_MAX, 200000, 4000); setHints(Config.hints.get("engine.copper")); ashForItem = Defaults.ENGINE_COPPER_ASH_FOR_ITEM; - inventory = new TileInventoryAdapter(this, 5, "Items"); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items")); } @Override @@ -72,7 +69,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } private int getFuelSlot() { - + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_FUEL) == null) return -1; @@ -83,7 +80,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } private int getFreeWasteSlot() { - + TileInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_WASTE_1; i <= SLOT_WASTE_COUNT; i++) { if (inventory.getStackInSlot(i) == null) return i; @@ -99,7 +96,6 @@ public class EngineCopper extends Engine implements ISidedInventory { @Override public void updateServerSide() { - super.updateServerSide(); if (worldObj.getTotalWorldTime() % 20 * 10 != 0) @@ -114,7 +110,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } int fuelSlot = getFuelSlot(); - if (fuelSlot >= 0 && determineBurnDuration(inventory.getStackInSlot(fuelSlot)) > 0) + if (fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0) setErrorState(EnumErrorCode.OK); else setErrorState(EnumErrorCode.NOFUEL); @@ -138,6 +134,7 @@ public class EngineCopper extends Engine implements ISidedInventory { int wasteslot = getFreeWasteSlot(); if (fuelslot >= 0 && wasteslot >= 0) { + TileInventoryAdapter inventory = getInternalInventory(); burnTime = totalBurnTime = determineBurnDuration(inventory.getStackInSlot(fuelslot)); if (burnTime > 0) { fuelItem = inventory.getStackInSlot(fuelslot).getItem(); @@ -188,11 +185,13 @@ public class EngineCopper extends Engine implements ISidedInventory { // If we have reached the necessary amount, we need to add ash int wasteslot = getFreeWasteSlot(); - if (wasteslot >= 0) + if (wasteslot >= 0) { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(wasteslot) == null) inventory.setInventorySlotContents(wasteslot, ForestryItem.ash.getItemStack()); else inventory.getStackInSlot(wasteslot).stackSize++; + } // Reset ashProduction = 0; // try to dump stash @@ -233,7 +232,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } private void dumpToPipe(ForgeDirection[] pipes) { - + TileInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_WASTE_1; i < SLOT_WASTE_1 + SLOT_WASTE_COUNT; i++) { if (inventory.getStackInSlot(i) == null) continue; @@ -272,6 +271,7 @@ public class EngineCopper extends Engine implements ISidedInventory { if (fuelSlot < 0) return false; + TileInventoryAdapter inventory = getInternalInventory(); return ((float) inventory.getStackInSlot(fuelSlot).stackSize / (float) inventory.getStackInSlot(fuelSlot).getMaxStackSize()) > percentage; } @@ -294,9 +294,6 @@ public class EngineCopper extends Engine implements ISidedInventory { totalBurnTime = nbttagcompound.getInteger("EngineTotalTime"); if (nbttagcompound.hasKey("AshProduction")) ashProduction = nbttagcompound.getInteger("AshProduction"); - - // Fuel - inventory.readFromNBT(nbttagcompound); } /** @@ -314,8 +311,6 @@ public class EngineCopper extends Engine implements ISidedInventory { nbttagcompound.setInteger("EngineBurnTime", burnTime); nbttagcompound.setInteger("EngineTotalTime", totalBurnTime); nbttagcompound.setInteger("AshProduction", ashProduction); - - inventory.writeToNBT(nbttagcompound); } // / SMP GUI @@ -353,32 +348,32 @@ public class EngineCopper extends Engine implements ISidedInventory { // / IINVENTORY @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -389,12 +384,9 @@ public class EngineCopper extends Engine implements ISidedInventory { public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } @Override @@ -402,69 +394,39 @@ public class EngineCopper extends Engine implements ISidedInventory { return getUnlocalizedName(); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack); } - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } /* ISIDEDINVENTORY */ @Override - public InventoryAdapter getInternalInventory() { - return inventory; + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return isItemValidForSlot(xCoord, itemstack); } @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) return false; return slotIndex >= SLOT_WASTE_1 && slotIndex < SLOT_WASTE_1 + SLOT_WASTE_COUNT; } @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack); + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); } - /* ITRIGGERPROVIDER */ @Optional.Method(modid = "BuildCraftAPI|statements") @Override diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index a210889d2..a4f4be397 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -33,11 +33,13 @@ import forestry.core.network.GuiId; import forestry.core.utils.DelayTimer; import forestry.core.utils.EnumTankLevel; import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.plugins.PluginIC2; public class EngineTin extends Engine implements ISocketable, IInventory { protected static class EuConfig { + public int euForCycle; public int rfPerCycle; public int euStorage; @@ -51,7 +53,6 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } private final short batterySlot = 0; - private final InventoryAdapter inventory = new InventoryAdapter(1, "electrical"); private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(Defaults.ENGINE_TIN_EU_FOR_CYCLE, Defaults.ENGINE_TIN_ENERGY_PER_CYCLE, Defaults.ENGINE_TIN_MAX_EU_STORED); @@ -63,7 +64,10 @@ public class EngineTin extends Engine implements ISocketable, IInventory { super(Defaults.ENGINE_TIN_HEAT_MAX, 100000, 4000); setHints(Config.hints.get("engine.tin")); - if (PluginIC2.instance.isAvailable()) ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); + setInternalInventory(new TileInventoryAdapter(this, 1, "electrical")); + + if (PluginIC2.instance.isAvailable()) + ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); } @Override @@ -76,8 +80,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySink != null) ic2EnergySink.readFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); + if (ic2EnergySink != null) + ic2EnergySink.readFromNBT(nbttagcompound); sockets.readFromNBT(nbttagcompound); ItemStack chip = sockets.getStackInSlot(0); @@ -92,21 +96,23 @@ public class EngineTin extends Engine implements ISocketable, IInventory { public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySink != null) ic2EnergySink.writeToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); + if (ic2EnergySink != null) + ic2EnergySink.writeToNBT(nbttagcompound); sockets.writeToNBT(nbttagcompound); } @Override public void onChunkUnload() { - if (ic2EnergySink != null) ic2EnergySink.onChunkUnload(); + if (ic2EnergySink != null) + ic2EnergySink.onChunkUnload(); super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySink != null) ic2EnergySink.invalidate(); + if (ic2EnergySink != null) + ic2EnergySink.invalidate(); super.invalidate(); } @@ -162,7 +168,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { return; } - if (inventory.getStackInSlot(batterySlot) != null) + if (getInternalInventory().getStackInSlot(batterySlot) != null) replenishFromBattery(batterySlot); // Updating of gui delayed to prevent it from going crazy @@ -194,7 +200,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { if (!isActivated()) return; - ic2EnergySink.discharge(inventory.getStackInSlot(slot), euConfig.euForCycle * 3); + ic2EnergySink.discharge(getInternalInventory().getStackInSlot(slot), euConfig.euForCycle * 3); } // / STATE INFORMATION @@ -204,7 +210,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } public int getStorageScaled(int i) { - if (ic2EnergySink == null) return 0; + if (ic2EnergySink == null) + return 0; return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); } @@ -239,7 +246,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { heat = j; break; case 3: - if (ic2EnergySink != null) ic2EnergySink.setEnergyStored(j); + if (ic2EnergySink != null) + ic2EnergySink.setEnergyStored(j); break; } @@ -250,9 +258,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput); iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toPacketInt()); iCrafting.sendProgressBarUpdate(containerEngine, 2, heat); - if (ic2EnergySink != null) { + if (ic2EnergySink != null) iCrafting.sendProgressBarUpdate(containerEngine, 3, (short) ic2EnergySink.getEnergyStored()); - } } // / ENERGY CONFIG CHANGE @@ -261,38 +268,39 @@ public class EngineTin extends Engine implements ISocketable, IInventory { euConfig.rfPerCycle += rfChange; euConfig.euStorage += storageChange; - if (ic2EnergySink != null) ic2EnergySink.setCapacity(euConfig.euStorage); + if (ic2EnergySink != null) + ic2EnergySink.setCapacity(euConfig.euStorage); } /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override @@ -303,12 +311,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory { public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } @Override @@ -316,21 +321,17 @@ public class EngineTin extends Engine implements ISocketable, IInventory { return getUnlocalizedName(); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); } + + //TODO: Add ISideInventory and clarify allowed items /* ISOCKETABLE */ @Override @@ -358,9 +359,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } sockets.setInventorySlotContents(slot, stack); - if (stack == null) { + if (stack == null) return; - } ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack); if (chipset != null) diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index 3a94775fa..05dc141a0 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -24,7 +24,6 @@ import net.minecraftforge.fluids.FluidStack; 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.api.core.EnumErrorCode; @@ -38,14 +37,15 @@ import forestry.core.interfaces.IRenderableMachine; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; +import net.minecraft.inventory.ISidedInventory; import net.minecraftforge.fluids.FluidTankInfo; -public class MachineGenerator extends TileBase implements ISpecialInventory, ILiquidTankContainer, IRenderableMachine { +public class MachineGenerator extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine { // / CONSTANTS public static final short SLOT_CAN = 0; @@ -56,18 +56,18 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi private final TankManager tankManager; private int tickCount = 0; - private final InventoryAdapter inventory = new InventoryAdapter(1, "Items"); protected BasicSource ic2EnergySource; public MachineGenerator() { setHints(Config.hints.get("generator")); + setInternalInventory(new TileInventoryAdapter(this, 1, "Items")); + resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet()); tankManager = new TankManager(resourceTank); - if (PluginIC2.instance.isAvailable()) { + if (PluginIC2.instance.isAvailable()) ic2EnergySource = new BasicSource(this, maxEnergy, 1); - } } @Override @@ -84,40 +84,44 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySource != null) ic2EnergySource.writeToNBT(nbttagcompound); + if (ic2EnergySource != null) + ic2EnergySource.writeToNBT(nbttagcompound); tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySource != null) ic2EnergySource.readFromNBT(nbttagcompound); + if (ic2EnergySource != null) + ic2EnergySource.readFromNBT(nbttagcompound); tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); } @Override public void onChunkUnload() { - if (ic2EnergySource != null) ic2EnergySource.onChunkUnload(); + if (ic2EnergySource != null) + ic2EnergySource.onChunkUnload(); super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySource != null) ic2EnergySource.invalidate(); + if (ic2EnergySource != null) + ic2EnergySource.invalidate(); super.invalidate(); } + @Override public void updateServerSide() { // Check inventory slots for fuel // Check if we have suitable items waiting in the item slot + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_CAN) != null) { FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN)); if (container != null) @@ -140,8 +144,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi if (resourceTank.getFluidAmount() > 0) { GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); - if (resourceTank.getFluidAmount() >= fuel.fuelConsumed.amount && - ic2EnergySource.getFreeCapacity() >= fuel.eu) { + if (resourceTank.getFluidAmount() >= fuel.fuelConsumed.amount + && ic2EnergySource.getFreeCapacity() >= fuel.eu) { ic2EnergySource.addEnergy(fuel.eu); this.tickCount++; @@ -168,7 +172,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi } public int getStoredScaled(int i) { - if (ic2EnergySource == null) return 0; + if (ic2EnergySource == null) + return 0; return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; } @@ -186,87 +191,95 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi /* SMP GUI */ public void getGUINetworkData(int i, int j) { int firstMessageId = tankManager.maxMessageId() + 1; - if (i == firstMessageId) { - if (ic2EnergySource != null) ic2EnergySource.setEnergyStored(j); - } + if (i == firstMessageId) + if (ic2EnergySource != null) + ic2EnergySource.setEnergyStored(j); } public void sendGUINetworkData(Container container, ICrafting iCrafting) { int firstMessageId = tankManager.maxMessageId() + 1; - if (ic2EnergySource != null) { + if (ic2EnergySource != null) iCrafting.sendProgressBarUpdate(container, firstMessageId, (short) ic2EnergySource.getEnergyStored()); - } } /* IINVENTORY */ - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public ItemStack getStackInSlot(int i) { + return getInternalInventory().getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(i, itemstack); + } + + @Override + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + return getInternalInventory().decrStackSize(i, j); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } + public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) + return false; - /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { + if (slotIndex == SLOT_CAN) { + FluidContainerData container = LiquidHelper.getLiquidContainer(stack); + if (container == null) + return false; - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - if (container == null) - return 0; - - if (container.fluid == null || !FuelManager.generatorFuel.containsKey(container.fluid.getFluid())) - return 0; - - if (inventory.getStackInSlot(SLOT_CAN) == null) { - if (doAdd) - inventory.setInventorySlotContents(SLOT_CAN, stack.copy()); - - return stack.stackSize; + return container.fluid != null && FuelManager.generatorFuel.containsKey(container.fluid.getFluid()); } + return false; + } - if (!inventory.getStackInSlot(SLOT_CAN).isItemEqual(stack)) - return 0; - - int space = inventory.getStackInSlot(SLOT_CAN).getMaxStackSize() - inventory.getStackInSlot(SLOT_CAN).stackSize; - if (space <= 0) - return 0; - - if (doAdd) - inventory.getStackInSlot(SLOT_CAN).stackSize += stack.stackSize; - - return Math.min(space, stack.stackSize); - + /* ISIDEDINVENTORY */ + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + return false; } @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - return null; + public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { + return isItemValidForSlot(slotIndex, stack); + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILiquidTankContainer */ @@ -280,6 +293,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi return tankManager; } + @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return tankManager.drain(from, resource, doDrain); } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index adb70f8d0..d8fdcffce 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -10,26 +10,15 @@ ******************************************************************************/ package forestry.energy.gui; -<<<<<<< Updated upstream -======= -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - ->>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.energy.gadgets.EngineBronze; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; public class ContainerEngineBronze extends ContainerLiquidTanks { -<<<<<<< Updated upstream - protected final EngineBronze engine; -======= - protected EngineBronze engine; ->>>>>>> Stashed changes + protected final EngineBronze engine; public ContainerEngineBronze(InventoryPlayer player, EngineBronze engine) { super(engine, engine); diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index bdd46cbe9..f73280ee4 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -17,14 +17,11 @@ import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.energy.gadgets.EngineCopper; +import scala.collection.parallel.ParSeqLike.Updated; public class ContainerEngineCopper extends ContainerForestry { -<<<<<<< Updated upstream - protected final EngineCopper engine; -======= - protected EngineCopper engine; ->>>>>>> Stashed changes + protected final EngineCopper engine; public ContainerEngineCopper(InventoryPlayer player, EngineCopper tile) { super(tile); @@ -59,14 +56,9 @@ public class ContainerEngineCopper extends ContainerForestry { public void detectAndSendChanges() { super.detectAndSendChanges(); -<<<<<<< Updated upstream - for (Object crafter : crafters) - engine.sendGUINetworkData(this, (ICrafting) crafter); -======= for (Object crafter : crafters) { engine.sendGUINetworkData(this, (ICrafting) crafter); } ->>>>>>> Stashed changes } } diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index 53f6efdaa..a02e15d65 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -10,16 +10,9 @@ ******************************************************************************/ package forestry.energy.gui; -<<<<<<< Updated upstream -======= -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - ->>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.energy.gadgets.MachineGenerator; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index 565b3801b..d842a3a2b 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -10,17 +10,10 @@ ******************************************************************************/ package forestry.factory.gui; -<<<<<<< Updated upstream -======= -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - ->>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineBottler; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index 90c58931e..c467b7710 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -10,28 +10,17 @@ ******************************************************************************/ package forestry.factory.gui; -<<<<<<< Updated upstream -======= -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - ->>>>>>> Stashed changes import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; import forestry.factory.gadgets.MachineFermenter; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; public class ContainerFermenter extends ContainerLiquidTanks { -<<<<<<< Updated upstream - protected final MachineFermenter fermenter; -======= - protected MachineFermenter fermenter; ->>>>>>> Stashed changes + protected final MachineFermenter fermenter; public ContainerFermenter(InventoryPlayer player, MachineFermenter fermenter) { super(fermenter, fermenter); diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index c76491e9e..073f120e0 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -108,19 +108,8 @@ public class MailAddress implements INBTTagable, IMailAddress { if (!(o instanceof MailAddress)) return false; -<<<<<<< Updated upstream MailAddress address = (MailAddress) o; return PlayerUtil.isSameGameProfile(address.gameProfile, gameProfile); -======= - MailAddress other = (MailAddress) o; - return isSamePlayer(gameProfile, other.gameProfile); - } - - private static boolean isSamePlayer(GameProfile a, GameProfile b) { - if (a.getId() != null && b.getId() != null) - return a.getId().equals(b.getId()); - return a.getName() != null && a.getName().equals(b.getName()); ->>>>>>> Stashed changes } @Override diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index ac8761653..72b0fed5e 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -35,13 +35,8 @@ import forestry.plugins.PluginMail; public class PostRegistry implements IPostRegistry { public static PostOffice cachedPostOffice; -<<<<<<< Updated upstream - public static final HashMap cachedPOBoxes = new HashMap(); - public static final HashMap cachedTradeStations = new HashMap(); -======= - public static Map cachedPOBoxes = new HashMap(); - public static Map cachedTradeStations = new HashMap(); ->>>>>>> Stashed changes + public static final Map cachedPOBoxes = new HashMap(); + public static final Map cachedTradeStations = new HashMap(); /** * @param world the Minecraft world the PO box will be in @@ -101,7 +96,7 @@ public class PostRegistry implements IPostRegistry { @Override public TradeStation getTradeStation(World world, IMailAddress address) { if (cachedTradeStations.containsKey(address)) - return (TradeStation)cachedTradeStations.get(address); + return (TradeStation) cachedTradeStations.get(address); TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address); @@ -227,5 +222,4 @@ public class PostRegistry implements IPostRegistry { return ForestryItem.letters.isItemEqual(itemstack); } - } diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 3e48c9d6d..eee985f89 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -43,29 +43,18 @@ public class ContainerTrader extends ContainerForestry { } // Stamps -<<<<<<< Updated upstream - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) - addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); - - // Letters - for (int i = 0; i < 3; i++) - for (int j = 0; j < 2; j++) - addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); -======= for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, new Object[]{ItemStamps.class})); + addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); } } // Letters for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, new Object[]{Items.paper})); + addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); } } ->>>>>>> Stashed changes // Buffers final int bufCols = 5; From 874a49262d06ebf9bcac05db796e44b6479606eb Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 30 Nov 2014 18:31:05 -0800 Subject: [PATCH 003/175] Cleanup *alyzers --- api | 2 +- .../apiculture/genetics/AlleleBeeSpecies.java | 2 +- .../apiculture/genetics/ApiaristTracker.java | 9 ++-- .../forestry/apiculture/genetics/Bee.java | 14 +++--- .../apiculture/genetics/BeeGenome.java | 28 +++++------ .../forestry/apiculture/gui/GuiBeealyzer.java | 50 ++++++++----------- .../arboriculture/FruitProviderPod.java | 2 +- .../genetics/AlleleTreeSpecies.java | 2 +- .../forestry/arboriculture/genetics/Tree.java | 16 +++--- .../arboriculture/genetics/TreeGenome.java | 26 +++++----- .../arboriculture/gui/GuiTreealyzer.java | 47 ++++++++--------- .../arboriculture/worldgen/WorldGenTree.java | 2 +- .../java/forestry/core/genetics/Genome.java | 11 +++- .../forestry/core/genetics/Individual.java | 6 +++ .../forestry/core/genetics/SpeciesRoot.java | 25 +++++++--- .../java/forestry/core/gui/GuiAlyzer.java | 37 +++++++------- .../core/gui/GuiNaturalistInventory.java | 6 +-- .../lepidopterology/genetics/Butterfly.java | 12 ++--- .../genetics/ButterflyGenome.java | 28 +++++------ .../lepidopterology/gui/GuiFlutterlyzer.java | 44 ++++++++-------- .../forestry/pipes/PipeLogicPropolis.java | 8 +-- 21 files changed, 195 insertions(+), 182 deletions(-) diff --git a/api b/api index 2bb45e18b..d6d724bbd 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 2bb45e18be423c110d61a5b393671dd11ffa7dc8 +Subproject commit d6d724bbd787f432e08a38304ba6bac3cf5bf303 diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index d8178791f..6686924aa 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -112,7 +112,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies int highest = 0; exclude.add(species); - for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) { + for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { if(!exclude.contains(mutation.getAllele0())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); if(otherAdvance > highest) diff --git a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java index f8e85a44b..56ca40a02 100755 --- a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java +++ b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java @@ -10,16 +10,15 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; - import com.mojang.authlib.GameProfile; - +import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; public class ApiaristTracker extends BreedingTracker implements IApiaristTracker { @@ -61,7 +60,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker public void registerPickup(IIndividual individual) { if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) return; - if(!individual.isPureBred(0)) + if(!individual.isPureBred(EnumBeeChromosome.SPECIES)) return; if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) return; diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 45e056863..9a774a9bd 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -131,7 +131,7 @@ public class Bee extends IndividualLiving implements IBee { if (!effect.isCombinable()) return storedData; - IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal()); + IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT); if (!secondary.isCombinable()) return storedData; @@ -158,7 +158,7 @@ public class Bee extends IndividualLiving implements IBee { if (!effect.isCombinable()) return storedData; - IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal()); + IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT); if (!secondary.isCombinable()) return storedData; @@ -351,22 +351,22 @@ public class Bee extends IndividualLiving implements IBee { // You analyzed it? Juicy tooltip coming up! IAlleleBeeSpecies primary = genome.getPrimary(); IAlleleBeeSpecies secondary = genome.getSecondary(); - if (!isPureBred(EnumBeeChromosome.SPECIES.ordinal())) + if (!isPureBred(EnumBeeChromosome.SPECIES)) list.add("\u00A79" + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); - IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED.ordinal()); + IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED); String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", ""); if (StringUtil.canTranslate(customWorker)) list.add(StringUtil.localize(customWorker)); else list.add(speed.getName() + " " + StringUtil.localize("gui.worker")); - list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName() + " " + StringUtil.localize("gui.life")); + list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); - IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); - IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); list.add(genome.getFlowerProvider().getDescription()); diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java index 6a698b69b..b41ee9b22 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java +++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java @@ -82,73 +82,73 @@ public class BeeGenome extends Genome implements IBeeGenome { // / INFORMATION RETRIEVAL @Override public IAlleleBeeSpecies getPrimary() { - return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES.ordinal()); + return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES); } @Override public IAlleleBeeSpecies getSecondary() { - return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES.ordinal()); + return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES); } @Override public float getSpeed() { - return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED)).getValue(); } @Override public int getLifespan() { - return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN)).getValue(); } @Override public int getFertility() { - return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY)).getValue(); } @Override public EnumTolerance getToleranceTemp() { - return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal())).getValue(); + return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue(); } @Override public boolean getNocturnal() { - return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue(); } @Override public EnumTolerance getToleranceHumid() { - return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal())).getValue(); + return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue(); } @Override public boolean getTolerantFlyer() { - return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue(); } @Override public boolean getCaveDwelling() { - return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(); } @Override public IFlowerProvider getFlowerProvider() { - return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER.ordinal())).getProvider(); + return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider(); } @Override public int getFlowering() { - return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING)).getValue(); } @Override public int[] getTerritory() { - Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY.ordinal())).getArea(); + Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea(); return new int[] { area.x, area.y, area.z }; } @Override public IAlleleBeeEffect getEffect() { - return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT.ordinal()); + return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT); } @Override diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 2c0e012a2..01deaf8d2 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -12,7 +12,6 @@ package forestry.apiculture.gui; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; -import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBee; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleFlowers; @@ -35,13 +34,8 @@ import java.util.ArrayList; public class GuiBeealyzer extends GuiAlyzer { - private ItemStack[] tempProductList; - public GuiBeealyzer(EntityPlayer player, BeealyzerInventory inventory) { - super(AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"), player, - new ContainerBeealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory()); - - guiName = "gui.beealyzer"; + super("rootBees", player, new ContainerBeealyzer(player.inventory, inventory), inventory, "gui.beealyzer"); ArrayList beeList = new ArrayList(); ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); @@ -111,36 +105,36 @@ public class GuiBeealyzer extends GuiAlyzer { drawSpeciesRow(StringUtil.localize("gui.species"), bee, EnumBeeChromosome.SPECIES, checkCustomName(customPrimaryBeeKey), checkCustomName(customSecondaryBeeKey)); } - drawRow(StringUtil.localize("gui.lifespan"), bee.getGenome().getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName(), bee, + drawRow(StringUtil.localize("gui.lifespan"), bee.getGenome().getActiveAllele(EnumBeeChromosome.LIFESPAN).getName(), + bee.getGenome().getInactiveAllele(EnumBeeChromosome.LIFESPAN).getName(), bee, EnumBeeChromosome.LIFESPAN); - drawRow(StringUtil.localize("gui.speed"), bee.getGenome().getActiveAllele(EnumBeeChromosome.SPEED.ordinal()).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.SPEED.ordinal()).getName(), bee, EnumBeeChromosome.SPEED); + drawRow(StringUtil.localize("gui.speed"), bee.getGenome().getActiveAllele(EnumBeeChromosome.SPEED).getName(), + bee.getGenome().getInactiveAllele(EnumBeeChromosome.SPEED).getName(), bee, EnumBeeChromosome.SPEED); - drawRow(StringUtil.localize("gui.pollination"), bee.getGenome().getActiveAllele(EnumBeeChromosome.FLOWERING.ordinal()).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWERING.ordinal()).getName(), bee, + drawRow(StringUtil.localize("gui.pollination"), bee.getGenome().getActiveAllele(EnumBeeChromosome.FLOWERING).getName(), + bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWERING).getName(), bee, EnumBeeChromosome.FLOWERING); drawRow(StringUtil.localize("gui.flowers"), bee.getGenome().getFlowerProvider().getDescription(), - ((IAlleleFlowers) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWER_PROVIDER.ordinal())).getProvider() + ((IAlleleFlowers) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider() .getDescription(), bee, EnumBeeChromosome.FLOWER_PROVIDER); drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); - drawFertilityInfo(bee.getGenome().getFertility(), COLUMN_1, getColorCoding(bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY.ordinal()) + drawFertilityInfo(bee.getGenome().getFertility(), COLUMN_1, getColorCoding(bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY) .isDominant()), 0); - drawFertilityInfo(((IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY.ordinal())).getValue(), COLUMN_2, getColorCoding(bee - .getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY.ordinal()).isDominant()), 0); + drawFertilityInfo(((IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY)).getValue(), COLUMN_2, getColorCoding(bee + .getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY).isDominant()), 0); newLine(); int[] areaAr = bee.getGenome().getTerritory(); Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]); - drawRow(StringUtil.localize("gui.area"), area.toString(), ((AlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY.ordinal())) + drawRow(StringUtil.localize("gui.area"), area.toString(), ((AlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY)) .getArea().toString(), bee, EnumBeeChromosome.TERRITORY); drawRow(StringUtil.localize("gui.effect"), bee.getGenome().getEffect().getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal()).getName(), bee, + bee.getGenome().getInactiveAllele(EnumBeeChromosome.EFFECT).getName(), bee, EnumBeeChromosome.EFFECT); newLine(); @@ -161,8 +155,8 @@ public class GuiBeealyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES); - IAlleleTolerance tempToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()); - IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance tempToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); drawLine(StringUtil.localize("gui.temptol"), COLUMN_0); drawToleranceInfo(tempToleranceActive, COLUMN_1); drawToleranceInfo(tempToleranceInactive, COLUMN_2); @@ -172,8 +166,8 @@ public class GuiBeealyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES); - IAlleleTolerance humidToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()); - IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()); + IAlleleTolerance humidToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0); drawToleranceInfo(humidToleranceActive, COLUMN_1); drawToleranceInfo(humidToleranceInactive, COLUMN_2); @@ -191,7 +185,7 @@ public class GuiBeealyzer extends GuiAlyzer { nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no; diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no; } - if(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL.ordinal())).getValue()) { + if(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue()) { nocturnal1 = diurnal1 = yes; } else { nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no; @@ -209,13 +203,13 @@ public class GuiBeealyzer extends GuiAlyzer { newLine(); String primary = StringUtil.readableBoolean(bee.getGenome().getTolerantFlyer(), yes, no); - String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERANT_FLYER.ordinal())).getValue(), yes, + String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue(), yes, no); drawRow(StringUtil.localize("gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERANT_FLYER); primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no); - secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING.ordinal())).getValue(), yes, + secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no); drawRow(StringUtil.localize("gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING); @@ -246,8 +240,6 @@ public class GuiBeealyzer extends GuiAlyzer { float factor = this.factor; this.setFactor(1.0f); - tempProductList = bee.getProduceList(); - startPage(COLUMN_0, COLUMN_1, COLUMN_2); drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0); @@ -255,7 +247,7 @@ public class GuiBeealyzer extends GuiAlyzer { newLine(); int x = COLUMN_0; - for (ItemStack stack : tempProductList) { + for (ItemStack stack : bee.getProduceList()) { widgetManager.add(new ItemStackWidget(adjustToFactor(x), adjustToFactor(getLineY()), stack)); x += 18; diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index 8e3b8ab1d..128630dc2 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -82,7 +82,7 @@ public class FruitProviderPod extends FruitProviderNone { if (type == EnumPodType.COCOA) return BlockUtil.tryPlantPot(world, x, y, z, Blocks.cocoa); else { - return PluginArboriculture.treeInterface.setFruitBlock(world, (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS.ordinal()), + return PluginArboriculture.treeInterface.setFruitBlock(world, (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS), genome.getSappiness(), type.uids, x, y, z); } } diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java index d42d2e990..08e001ca3 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java @@ -144,7 +144,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci int highest = 0; exclude.add(species); - for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) { + for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) { if(!exclude.contains(mutation.getAllele0())) { int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude); if(otherAdvance > highest) diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 993d6150a..4f3e71e83 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -108,7 +108,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable /* EFFECTS */ @Override public IEffectData[] doEffect(IEffectData[] storedData, World world, int biomeid, int x, int y, int z) { - IAlleleLeafEffect effect = (IAlleleLeafEffect) getGenome().getActiveAllele(EnumTreeChromosome.EFFECT.ordinal()); + IAlleleLeafEffect effect = (IAlleleLeafEffect) getGenome().getActiveAllele(EnumTreeChromosome.EFFECT); if (effect == null) return null; @@ -119,7 +119,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable if (!effect.isCombinable()) return storedData; - IAlleleLeafEffect secondary = (IAlleleLeafEffect) getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT.ordinal()); + IAlleleLeafEffect secondary = (IAlleleLeafEffect) getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT); if (!secondary.isCombinable()) return storedData; @@ -255,7 +255,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable @Override public boolean isPureBred(EnumTreeChromosome chromosome) { - return genome.getActiveAllele(chromosome.ordinal()).getUID().equals(genome.getInactiveAllele(chromosome.ordinal()).getUID()); + return genome.getActiveAllele(chromosome).getUID().equals(genome.getInactiveAllele(chromosome).getUID()); } @Override @@ -279,16 +279,16 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable IAlleleTreeSpecies secondary = genome.getSecondary(); if (!isPureBred(EnumTreeChromosome.SPECIES)) list.add("\u00A79" + StringUtil.localize("trees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); - list.add(String.format("\u00A76S: %s, \u00A7cM: %s", genome.getActiveAllele(EnumTreeChromosome.SAPPINESS.ordinal()).getName(), genome.getActiveAllele(EnumTreeChromosome.MATURATION.ordinal()).getName())); - list.add(String.format("\u00A7dH: %s, \u00A7bG: %sx%s", genome.getActiveAllele(EnumTreeChromosome.HEIGHT.ordinal()).getName(), genome.getGirth(), genome.getGirth())); + list.add(String.format("\u00A76S: %s, \u00A7cM: %s", genome.getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(), genome.getActiveAllele(EnumTreeChromosome.MATURATION).getName())); + list.add(String.format("\u00A7dH: %s, \u00A7bG: %sx%s", genome.getActiveAllele(EnumTreeChromosome.HEIGHT).getName(), genome.getGirth(), genome.getGirth())); - list.add(String.format("\u00A7eS: %s, \u00A7fY: %s", genome.getActiveAllele(EnumTreeChromosome.FERTILITY.ordinal()).getName(), genome.getActiveAllele(EnumTreeChromosome.YIELD.ordinal()).getName())); + list.add(String.format("\u00A7eS: %s, \u00A7fY: %s", genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName(), genome.getActiveAllele(EnumTreeChromosome.YIELD).getName())); - IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal()); + IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); if (primaryFireproof.getValue()) list.add(String.format("\u00A7c%s", StatCollector.translateToLocal("for.gui.fireresist"))); - IAllele fruit = getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal()); + IAllele fruit = getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if(fruit != Allele.fruitNone) { String strike = ""; if (!canBearFruit()) diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java index d569fe62f..c1d3586d4 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java @@ -57,37 +57,37 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public IAlleleTreeSpecies getPrimary() { - return (IAlleleTreeSpecies) getActiveAllele(EnumTreeChromosome.SPECIES.ordinal()); + return (IAlleleTreeSpecies) getActiveAllele(EnumTreeChromosome.SPECIES); } @Override public IAlleleTreeSpecies getSecondary() { - return (IAlleleTreeSpecies) getInactiveAllele(EnumTreeChromosome.SPECIES.ordinal()); + return (IAlleleTreeSpecies) getInactiveAllele(EnumTreeChromosome.SPECIES); } @Override public IFruitProvider getFruitProvider() { - return ((IAlleleFruit) getActiveAllele(EnumTreeChromosome.FRUITS.ordinal())).getProvider(); + return ((IAlleleFruit) getActiveAllele(EnumTreeChromosome.FRUITS)).getProvider(); } @Override public IGrowthProvider getGrowthProvider() { - return ((IAlleleGrowth) getActiveAllele(EnumTreeChromosome.GROWTH.ordinal())).getProvider(); + return ((IAlleleGrowth) getActiveAllele(EnumTreeChromosome.GROWTH)).getProvider(); } @Override public float getHeight() { - return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.HEIGHT.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.HEIGHT)).getValue(); } @Override public float getFertility() { - return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.FERTILITY.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.FERTILITY)).getValue(); } @Override public float getYield() { - return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.YIELD.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.YIELD)).getValue(); } @Override @@ -96,7 +96,7 @@ public class TreeGenome extends Genome implements ITreeGenome { if (getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] == null) getChromosomes()[EnumTreeChromosome.SAPPINESS.ordinal()] = new Chromosome(Allele.sappinessLowest); - IAllele allele = getActiveAllele(EnumTreeChromosome.SAPPINESS.ordinal()); + IAllele allele = getActiveAllele(EnumTreeChromosome.SAPPINESS); // FIXME: More legacy handling if (allele instanceof IAlleleFloat) return ((IAlleleFloat) allele).getValue(); @@ -109,10 +109,10 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public EnumSet getPlantTypes() { // / FIXME: Needs some legacy handling. - if (!(getActiveAllele(EnumTreeChromosome.PLANT.ordinal()) instanceof AllelePlantType)) + if (!(getActiveAllele(EnumTreeChromosome.PLANT) instanceof AllelePlantType)) getChromosomes()[EnumTreeChromosome.PLANT.ordinal()] = new Chromosome(Allele.plantTypeNone); - return ((AllelePlantType) getActiveAllele(EnumTreeChromosome.PLANT.ordinal())).getPlantTypes(); + return ((AllelePlantType) getActiveAllele(EnumTreeChromosome.PLANT)).getPlantTypes(); } @Override @@ -120,7 +120,7 @@ public class TreeGenome extends Genome implements ITreeGenome { if (getChromosomes()[EnumTreeChromosome.MATURATION.ordinal()] == null) getChromosomes()[EnumTreeChromosome.MATURATION.ordinal()] = new Chromosome(Allele.maturationSlowest); - return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.MATURATION.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.MATURATION)).getValue(); } private IAllele translateGirth(int girth) { @@ -136,12 +136,12 @@ public class TreeGenome extends Genome implements ITreeGenome { @Override public int getGirth() { - return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.GIRTH.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.GIRTH)).getValue(); } @Override public IAlleleLeafEffect getEffect() { - return (IAlleleLeafEffect) getActiveAllele(EnumTreeChromosome.EFFECT.ordinal()); + return (IAlleleLeafEffect) getActiveAllele(EnumTreeChromosome.EFFECT); } @Override diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index bae895bae..34e130e7b 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -42,10 +42,7 @@ import java.util.Locale; public class GuiTreealyzer extends GuiAlyzer { public GuiTreealyzer(EntityPlayer player, TreealyzerInventory inventory) { - super(AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"), player, - new ContainerTreealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory()); - - guiName = "gui.treealyzer"; + super("rootTrees", player, new ContainerTreealyzer(player.inventory, inventory), inventory, "gui.treealyzer"); ArrayList treeList = new ArrayList(); ((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false); @@ -127,42 +124,42 @@ public class GuiTreealyzer extends GuiAlyzer { newLine(); drawLine(StringUtil.localize("gui.saplings"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY.ordinal()).getName(), COLUMN_1, tree, EnumTreeChromosome.FERTILITY, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FERTILITY.ordinal()).getName(), COLUMN_2, tree, + drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY).getName(), COLUMN_1, tree, EnumTreeChromosome.FERTILITY, false); + drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FERTILITY).getName(), COLUMN_2, tree, EnumTreeChromosome.FERTILITY, true); newLine(); - drawRow(StringUtil.localize("gui.maturity"), tree.getGenome().getActiveAllele(EnumTreeChromosome.MATURATION.ordinal()).getName(), - tree.getGenome().getInactiveAllele(EnumTreeChromosome.MATURATION.ordinal()).getName(), tree, + drawRow(StringUtil.localize("gui.maturity"), tree.getGenome().getActiveAllele(EnumTreeChromosome.MATURATION).getName(), + tree.getGenome().getInactiveAllele(EnumTreeChromosome.MATURATION).getName(), tree, EnumTreeChromosome.MATURATION); drawLine(StringUtil.localize("gui.height"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT.ordinal()).getName(), COLUMN_1, tree, EnumTreeChromosome.HEIGHT, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.HEIGHT.ordinal()).getName(), COLUMN_2, tree, + drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT).getName(), COLUMN_1, tree, EnumTreeChromosome.HEIGHT, false); + drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.HEIGHT).getName(), COLUMN_2, tree, EnumTreeChromosome.HEIGHT, true); newLine(); drawLine(StringUtil.localize("gui.girth"), COLUMN_0); drawLine(String.format("%sx%s", tree.getGenome().getGirth(), tree.getGenome().getGirth()), COLUMN_1, tree, EnumTreeChromosome.FERTILITY, false); - int secondGirth = ((IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH.ordinal())).getValue(); + int secondGirth = ((IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH)).getValue(); drawLine(String.format("%sx%s", secondGirth, secondGirth), COLUMN_2, tree, EnumTreeChromosome.FERTILITY, true); newLine(); drawLine(StringUtil.localize("gui.yield"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.YIELD.ordinal()).getName(), COLUMN_1, tree, EnumTreeChromosome.YIELD, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.YIELD.ordinal()).getName(), COLUMN_2, tree, + drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.YIELD).getName(), COLUMN_1, tree, EnumTreeChromosome.YIELD, false); + drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.YIELD).getName(), COLUMN_2, tree, EnumTreeChromosome.YIELD, true); newLine(); drawLine(StringUtil.localize("gui.sappiness"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS.ordinal()).getName(), COLUMN_1, tree, EnumTreeChromosome.SAPPINESS, false); + drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(), COLUMN_1, tree, EnumTreeChromosome.SAPPINESS, false); // FIXME: Legacy handling - IAllele sappiness = tree.getGenome().getInactiveAllele(EnumTreeChromosome.SAPPINESS.ordinal()); + IAllele sappiness = tree.getGenome().getInactiveAllele(EnumTreeChromosome.SAPPINESS); String sap; if (sappiness instanceof IAlleleFloat) sap = sappiness.getName(); @@ -176,8 +173,8 @@ public class GuiTreealyzer extends GuiAlyzer { String yes = StringUtil.localize("yes"); String no = StringUtil.localize("no"); - AlleleBoolean primaryFireproof = (AlleleBoolean)tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal()); - AlleleBoolean secondaryFireproof = (AlleleBoolean)tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF.ordinal()); + AlleleBoolean primaryFireproof = (AlleleBoolean)tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); + AlleleBoolean secondaryFireproof = (AlleleBoolean)tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF); drawLine(StringUtil.localize("gui.fireproof"), COLUMN_0); drawLine(StringUtil.readableBoolean(primaryFireproof.getValue(), yes, no), COLUMN_1, tree, EnumTreeChromosome.FIREPROOF, false); @@ -186,7 +183,7 @@ public class GuiTreealyzer extends GuiAlyzer { newLine(); drawRow(StringUtil.localize("gui.effect"), tree.getGenome().getEffect().getName(), - tree.getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT.ordinal()).getName(), tree, + tree.getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT).getName(), tree, EnumTreeChromosome.EFFECT); newLine(); @@ -210,7 +207,7 @@ public class GuiTreealyzer extends GuiAlyzer { drawLine(StringUtil.localize("gui.growth"), COLUMN_0); drawLine(tree.getGenome().getGrowthProvider().getDescription(), COLUMN_1, tree, EnumTreeChromosome.GROWTH, false); - drawLine(((IAlleleGrowth) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GROWTH.ordinal())).getProvider().getDescription(), COLUMN_2, tree, + drawLine(((IAlleleGrowth) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GROWTH)).getProvider().getDescription(), COLUMN_2, tree, EnumTreeChromosome.GROWTH, true); newLine(); @@ -228,7 +225,7 @@ public class GuiTreealyzer extends GuiAlyzer { List tolerated0 = new ArrayList(tree.getGenome().getPlantTypes()); List tolerated1 = Collections.emptyList(); - IAllele allele1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT.ordinal()); + IAllele allele1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT); if (allele1 instanceof AllelePlantType) { tolerated1 = new ArrayList(((AllelePlantType) allele1).getPlantTypes()); } @@ -264,18 +261,18 @@ public class GuiTreealyzer extends GuiAlyzer { newLine(); newLine(); - int fruitDominance0 = getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal()).isDominant()); - int fruitDominance1 = getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS.ordinal()).isDominant()); + int fruitDominance0 = getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant()); + int fruitDominance1 = getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant()); drawLine(StringUtil.localize("gui.fruits"), COLUMN_0); String strike = ""; - IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal()); + IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if (!tree.canBearFruit() && fruit0 != Allele.fruitNone) strike = "\u00A7m"; drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0); strike = ""; - IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS.ordinal()); + IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS); if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != Allele.fruitNone) strike = "\u00A7m"; drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1); @@ -284,7 +281,7 @@ public class GuiTreealyzer extends GuiAlyzer { drawLine(StringUtil.localize("gui.family"), COLUMN_0); IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily(); - IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS.ordinal())).getProvider().getFamily(); + IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily(); if (primary != null) drawLine(primary.getName(), COLUMN_1, fruitDominance0); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java index f0bde07ce..d0cf8d808 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java @@ -109,7 +109,7 @@ public abstract class WorldGenTree extends WorldGenArboriculture { // if we have a fireproof tree, return the fireproof log if (block instanceof BlockLog) { - IAlleleBoolean fireproof = (IAlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal()); + IAlleleBoolean fireproof = (IAlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); if (fireproof.getValue()) { BlockLog blockLog = (BlockLog) block; ForestryBlock fireproofLogBlock = BlockFireproofLog.getFireproofLog(blockLog); diff --git a/src/main/java/forestry/core/genetics/Genome.java b/src/main/java/forestry/core/genetics/Genome.java index af3ca541e..6cf5952fc 100755 --- a/src/main/java/forestry/core/genetics/Genome.java +++ b/src/main/java/forestry/core/genetics/Genome.java @@ -16,7 +16,6 @@ import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IChromosome; import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IGenome; -import forestry.apiculture.items.ItemBeeGE; import forestry.core.config.Config; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -136,11 +135,21 @@ public abstract class Genome implements IGenome { return chromosomes[chromosome].getActiveAllele(); } + @Override + public IAllele getActiveAllele(IChromosomeType chromosomeType) { + return chromosomes[chromosomeType.ordinal()].getActiveAllele(); + } + @Override public IAllele getInactiveAllele(int chromosome) { return chromosomes[chromosome].getInactiveAllele(); } + @Override + public IAllele getInactiveAllele(IChromosomeType chromosomeType) { + return chromosomes[chromosomeType.ordinal()].getInactiveAllele(); + } + @Override public boolean isGeneticEqual(IGenome other) { IChromosome[] genetics = other.getChromosomes(); diff --git a/src/main/java/forestry/core/genetics/Individual.java b/src/main/java/forestry/core/genetics/Individual.java index 9931f3473..bb03a385f 100755 --- a/src/main/java/forestry/core/genetics/Individual.java +++ b/src/main/java/forestry/core/genetics/Individual.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.core.genetics; +import forestry.api.genetics.IChromosomeType; import net.minecraft.nbt.NBTTagCompound; import forestry.api.genetics.IIndividual; @@ -74,8 +75,13 @@ public abstract class Individual implements IIndividual { } @Override + @SuppressWarnings("deprecated") public boolean isPureBred(int chromosomeOrdinal) { return getGenome().getActiveAllele(chromosomeOrdinal).getUID().equals(getGenome().getInactiveAllele(chromosomeOrdinal).getUID()); } + @Override + public boolean isPureBred(IChromosomeType chromosomeType) { + return getGenome().getActiveAllele(chromosomeType).getUID().equals(getGenome().getInactiveAllele(chromosomeType).getUID()); + } } diff --git a/src/main/java/forestry/core/genetics/SpeciesRoot.java b/src/main/java/forestry/core/genetics/SpeciesRoot.java index 20556ffa1..62c5ce923 100755 --- a/src/main/java/forestry/core/genetics/SpeciesRoot.java +++ b/src/main/java/forestry/core/genetics/SpeciesRoot.java @@ -10,6 +10,13 @@ ******************************************************************************/ package forestry.core.genetics; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import net.minecraft.item.ItemStack; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -18,13 +25,6 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; -import net.minecraft.item.ItemStack; - -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IChromosome; -import forestry.api.genetics.IMutation; -import forestry.api.genetics.ISpeciesRoot; - public abstract class SpeciesRoot implements ISpeciesRoot { /* RESEARCH */ @@ -74,6 +74,7 @@ public abstract class SpeciesRoot implements ISpeciesRoot { return combinations; } + @Deprecated @Override public Collection getPaths(IAllele result, int chromosomeOrdinal) { ArrayList paths = new ArrayList(); @@ -84,6 +85,16 @@ public abstract class SpeciesRoot implements ISpeciesRoot { return paths; } + @Override + public Collection getPaths(IAllele result, IChromosomeType chromosomeType) { + ArrayList paths = new ArrayList(); + for (IMutation mutation : getMutations(false)) + if(mutation.getTemplate()[chromosomeType.ordinal()] == result) + paths.add(mutation); + + return paths; + } + /* GENOME CONVERSIONS */ @Override public IChromosome[] templateAsChromosomes(IAllele[] template) { diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index ee3b0b258..10d3fa55b 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -17,6 +17,7 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IAlleleTolerance; import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IClassification; import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.genetics.IIndividual; @@ -49,19 +50,21 @@ public abstract class GuiAlyzer extends GuiForestry { protected ISpeciesRoot speciesRoot; protected IBreedingTracker breedingTracker; - protected String guiName; + protected final String guiName; protected HashMap iconStacks = new HashMap(); - public GuiAlyzer(ISpeciesRoot speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, int pageMax, int pageSize) { + public GuiAlyzer(String speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, String guiName) { super(Defaults.TEXTURE_PATH_GUI + "/beealyzer2.png", container); - xSize = 246; - ySize = 238; + this.xSize = 246; + this.ySize = 238; + + this.guiName = guiName; this.inventory = inventory; - this.speciesRoot = speciesRoot; - this.breedingTracker = speciesRoot.getBreedingTracker(player.worldObj, player.getGameProfile()); + this.speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRoot); + this.breedingTracker = this.speciesRoot.getBreedingTracker(player.worldObj, player.getGameProfile()); } protected final int getColorCoding(boolean dominant) { @@ -71,26 +74,26 @@ public abstract class GuiAlyzer extends GuiForestry { return fontColor.get("gui.beealyzer.recessive"); } - protected final void drawLine(String text, int x, IIndividual individual, Enum chromosome, boolean inactive) { + protected final void drawLine(String text, int x, IIndividual individual, IChromosomeType chromosome, boolean inactive) { if (!inactive) - drawLine(text, x, getColorCoding(individual.getGenome().getActiveAllele(chromosome.ordinal()).isDominant())); + drawLine(text, x, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); else - drawLine(text, x, getColorCoding(individual.getGenome().getInactiveAllele(chromosome.ordinal()).isDominant())); + drawLine(text, x, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } - protected final void drawSplitLine(String text, int x, int maxWidth, IIndividual individual, Enum chromosome, boolean inactive) { + protected final void drawSplitLine(String text, int x, int maxWidth, IIndividual individual, IChromosomeType chromosome, boolean inactive) { if (!inactive) - drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getActiveAllele(chromosome.ordinal()).isDominant())); + drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); else - drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getInactiveAllele(chromosome.ordinal()).isDominant())); + drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } - protected final void drawRow(String text0, String text1, String text2, IIndividual individual, Enum chromosome) { - drawRow(text0, text1, text2, fontColor.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome.ordinal()).isDominant()), - getColorCoding(individual.getGenome().getInactiveAllele(chromosome.ordinal()).isDominant())); + protected final void drawRow(String text0, String text1, String text2, IIndividual individual, IChromosomeType chromosome) { + drawRow(text0, text1, text2, fontColor.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant()), + getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } - protected final void drawSpeciesRow(String text0, IIndividual individual, Enum chromosome, String customPrimaryName, String customSecondaryName) { + protected final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome, String customPrimaryName, String customSecondaryName) { IAlleleSpecies primary = individual.getGenome().getPrimary(); IAlleleSpecies secondary = individual.getGenome().getSecondary(); @@ -116,7 +119,7 @@ public abstract class GuiAlyzer extends GuiForestry { } - protected final void drawSpeciesRow(String text0, IIndividual individual, Enum chromosome){ + protected final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome){ drawSpeciesRow(text0, individual, chromosome, null, null); } diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index e2b8e0f16..9f94c4f2e 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -12,6 +12,7 @@ package forestry.core.gui; import java.util.HashMap; +import forestry.api.arboriculture.EnumTreeChromosome; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; @@ -74,9 +75,8 @@ public class GuiNaturalistInventory extends GuiForestry { startPage(); displaySpeciesInformation(true, individual.getGenome().getPrimary(), iconStacks.get(individual.getIdent()), 10); - if (!individual.isPureBred(0)) - displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), - 10); + if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) + displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), 10); endPage(); } diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index 4d1627593..6ce4fcf00 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -67,19 +67,19 @@ public class Butterfly extends IndividualLiving implements IButterfly { public void addTooltip(List list) { IAlleleButterflySpecies primary = genome.getPrimary(); IAlleleButterflySpecies secondary = genome.getSecondary(); - if (!isPureBred(EnumButterflyChromosome.SPECIES.ordinal())) + if (!isPureBred(EnumButterflyChromosome.SPECIES)) list.add("\u00A79" + StringUtil.localize("butterflies.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); if(getMate() != null) list.add("\u00A7c" + StringUtil.localize("gui.fecundated").toUpperCase(Locale.ENGLISH)); - list.add("\u00A7e" + genome.getActiveAllele(EnumButterflyChromosome.SIZE.ordinal()).getName()); - list.add("\u00A7f" + genome.getActiveAllele(EnumButterflyChromosome.SPEED.ordinal()).getName() + " " + StringUtil.localize("gui.flyer")); - list.add(genome.getActiveAllele(EnumButterflyChromosome.LIFESPAN.ordinal()).getName() + " " + StringUtil.localize("gui.life")); + list.add("\u00A7e" + genome.getActiveAllele(EnumButterflyChromosome.SIZE).getName()); + list.add("\u00A7f" + genome.getActiveAllele(EnumButterflyChromosome.SPEED).getName() + " " + StringUtil.localize("gui.flyer")); + list.add(genome.getActiveAllele(EnumButterflyChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); - IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); - IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), genome.getPrimary().isNocturnal())); diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java index f0fff48eb..b30d9fac6 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java @@ -52,72 +52,72 @@ public class ButterflyGenome extends Genome implements IButterflyGenome { /* SPECIES */ @Override public IAlleleButterflySpecies getPrimary() { - return (IAlleleButterflySpecies) getActiveAllele(EnumButterflyChromosome.SPECIES.ordinal()); + return (IAlleleButterflySpecies) getActiveAllele(EnumButterflyChromosome.SPECIES); } @Override public IAlleleButterflySpecies getSecondary() { - return (IAlleleButterflySpecies) getInactiveAllele(EnumButterflyChromosome.SPECIES.ordinal()); + return (IAlleleButterflySpecies) getInactiveAllele(EnumButterflyChromosome.SPECIES); } @Override public float getSize() { - return ((IAlleleFloat) getActiveAllele(EnumButterflyChromosome.SIZE.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumButterflyChromosome.SIZE)).getValue(); } @Override public int getLifespan() { - return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.LIFESPAN.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.LIFESPAN)).getValue(); } @Override public float getSpeed() { - return ((IAlleleFloat) getActiveAllele(EnumButterflyChromosome.SPEED.ordinal())).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumButterflyChromosome.SPEED)).getValue(); } @Override public int getMetabolism() { - return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.METABOLISM.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.METABOLISM)).getValue(); } @Override public int getFertility() { - return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.FERTILITY.ordinal())).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumButterflyChromosome.FERTILITY)).getValue(); } @Override public EnumTolerance getToleranceTemp() { - return ((AlleleTolerance) getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE.ordinal())).getValue(); + return ((AlleleTolerance) getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE)).getValue(); } @Override public EnumTolerance getToleranceHumid() { - return ((AlleleTolerance) getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE.ordinal())).getValue(); + return ((AlleleTolerance) getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE)).getValue(); } @Override public boolean getNocturnal() { - return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.NOCTURNAL.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue(); } @Override public boolean getTolerantFlyer() { - return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.TOLERANT_FLYER.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.TOLERANT_FLYER)).getValue(); } @Override public boolean getFireResist() { - return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.FIRE_RESIST.ordinal())).getValue(); + return ((AlleleBoolean) getActiveAllele(EnumButterflyChromosome.FIRE_RESIST)).getValue(); } @Override public IFlowerProvider getFlowerProvider() { - return ((IAlleleFlowers) getActiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER.ordinal())).getProvider(); + return ((IAlleleFlowers) getActiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER)).getProvider(); } @Override public IAlleleButterflyEffect getEffect() { - return (IAlleleButterflyEffect) getActiveAllele(EnumButterflyChromosome.EFFECT.ordinal()); + return (IAlleleButterflyEffect) getActiveAllele(EnumButterflyChromosome.EFFECT); } @Override diff --git a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java index a14049745..3d9f1acfe 100755 --- a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java @@ -12,7 +12,6 @@ package forestry.lepidopterology.gui; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlleleEffect; import forestry.api.genetics.IAlleleFlowers; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleTolerance; @@ -39,10 +38,7 @@ import java.util.Map; public class GuiFlutterlyzer extends GuiAlyzer { public GuiFlutterlyzer(EntityPlayer player, FlutterlyzerInventory inventory) { - super(AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"), player, - new ContainerFlutterlyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory()); - - guiName = "gui.flutterlyzer"; + super("rootButterflies", player, new ContainerFlutterlyzer(player.inventory, inventory), inventory, "gui.flutterlyzer"); ArrayList butterflyList = new ArrayList(); ((ItemButterflyGE) ForestryItem.butterflyGE.item()).addCreativeItems(butterflyList, false); @@ -105,33 +101,33 @@ public class GuiFlutterlyzer extends GuiAlyzer { drawSpeciesRow(StringUtil.localize("gui.species"), butterfly, EnumButterflyChromosome.SPECIES); newLine(); - drawRow(StringUtil.localize("gui.size"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SIZE.ordinal()).getName(), - butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SIZE.ordinal()).getName(), butterfly, EnumButterflyChromosome.SPEED); + drawRow(StringUtil.localize("gui.size"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SIZE).getName(), + butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SIZE).getName(), butterfly, EnumButterflyChromosome.SPEED); - drawRow(StringUtil.localize("gui.lifespan"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.LIFESPAN.ordinal()).getName(), - butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.LIFESPAN.ordinal()).getName(), butterfly, + drawRow(StringUtil.localize("gui.lifespan"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.LIFESPAN).getName(), + butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.LIFESPAN).getName(), butterfly, EnumButterflyChromosome.LIFESPAN); - drawRow(StringUtil.localize("gui.speed"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SPEED.ordinal()).getName(), - butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SPEED.ordinal()).getName(), butterfly, EnumButterflyChromosome.SPEED); + drawRow(StringUtil.localize("gui.speed"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SPEED).getName(), + butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SPEED).getName(), butterfly, EnumButterflyChromosome.SPEED); drawRow(StringUtil.localize("gui.metabolism"), GenericRatings.rateMetabolism(butterfly.getGenome().getMetabolism()), - GenericRatings.rateMetabolism(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.METABOLISM.ordinal())).getValue()), butterfly, EnumButterflyChromosome.METABOLISM); + GenericRatings.rateMetabolism(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.METABOLISM)).getValue()), butterfly, EnumButterflyChromosome.METABOLISM); drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); - drawFertilityInfo(butterfly.getGenome().getFertility(), COLUMN_1, getColorCoding(butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.FERTILITY.ordinal()) + drawFertilityInfo(butterfly.getGenome().getFertility(), COLUMN_1, getColorCoding(butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.FERTILITY) .isDominant()), 8); - drawFertilityInfo(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY.ordinal())).getValue(), COLUMN_2, getColorCoding(butterfly - .getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY.ordinal()).isDominant()), 8); + drawFertilityInfo(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY)).getValue(), COLUMN_2, getColorCoding(butterfly + .getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY).isDominant()), 8); newLine(); drawRow(StringUtil.localize("gui.flowers"), butterfly.getGenome().getFlowerProvider().getDescription(), - ((IAlleleFlowers) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER.ordinal())).getProvider() + ((IAlleleFlowers) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER)).getProvider() .getDescription(), butterfly, EnumButterflyChromosome.FLOWER_PROVIDER); drawRow(StringUtil.localize("gui.effect"), butterfly.getGenome().getEffect().getName(), - butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.EFFECT.ordinal()).getName(), butterfly, + butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.EFFECT).getName(), butterfly, EnumButterflyChromosome.EFFECT); newLine(); @@ -152,8 +148,8 @@ public class GuiFlutterlyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), butterfly, EnumButterflyChromosome.SPECIES); - IAlleleTolerance tempToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE.ordinal()); - IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE.ordinal()); + IAlleleTolerance tempToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); drawLine(StringUtil.localize("gui.temptol"), COLUMN_0); drawToleranceInfo(tempToleranceActive, COLUMN_1); drawToleranceInfo(tempToleranceInactive, COLUMN_2); @@ -163,8 +159,8 @@ public class GuiFlutterlyzer extends GuiAlyzer { drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), butterfly, EnumButterflyChromosome.SPECIES); - IAlleleTolerance humidToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE.ordinal()); - IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE.ordinal()); + IAlleleTolerance humidToleranceActive = (IAlleleTolerance)butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); + IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE); drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0); drawToleranceInfo(humidToleranceActive, COLUMN_1); drawToleranceInfo(humidToleranceInactive, COLUMN_2); @@ -182,7 +178,7 @@ public class GuiFlutterlyzer extends GuiAlyzer { nocturnal0 = butterfly.getGenome().getPrimary().isNocturnal() ? yes : no; diurnal0 = !butterfly.getGenome().getPrimary().isNocturnal() ? yes : no; } - if(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL.ordinal())).getValue()) { + if(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.NOCTURNAL)).getValue()) { nocturnal1 = diurnal1 = yes; } else { nocturnal1 = butterfly.getGenome().getSecondary().isNocturnal() ? yes : no; @@ -200,13 +196,13 @@ public class GuiFlutterlyzer extends GuiAlyzer { newLine(); String primary = StringUtil.readableBoolean(butterfly.getGenome().getTolerantFlyer(), yes, no); - String secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TOLERANT_FLYER.ordinal())).getValue(), yes, + String secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TOLERANT_FLYER)).getValue(), yes, no); drawRow(StringUtil.localize("gui.flyer"), primary, secondary, butterfly, EnumButterflyChromosome.TOLERANT_FLYER); primary = StringUtil.readableBoolean(butterfly.getGenome().getFireResist(), yes, no); - secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FIRE_RESIST.ordinal())).getValue(), yes, + secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FIRE_RESIST)).getValue(), yes, no); drawRow(StringUtil.localize("gui.fireresist"), primary, secondary, butterfly, EnumButterflyChromosome.FIRE_RESIST); diff --git a/src/main/java/forestry/pipes/PipeLogicPropolis.java b/src/main/java/forestry/pipes/PipeLogicPropolis.java index a051d89fd..86a5d79d8 100755 --- a/src/main/java/forestry/pipes/PipeLogicPropolis.java +++ b/src/main/java/forestry/pipes/PipeLogicPropolis.java @@ -86,19 +86,19 @@ public class PipeLogicPropolis { // Special bee filtering if (bee != null) { if (filter == EnumFilterType.PURE_BREED) - return bee.isPureBred(EnumBeeChromosome.SPECIES.ordinal()); + return bee.isPureBred(EnumBeeChromosome.SPECIES); if (filter == EnumFilterType.NOCTURNAL) return bee.getGenome().getNocturnal(); if (filter == EnumFilterType.PURE_NOCTURNAL) - return bee.getGenome().getNocturnal() && bee.isPureBred(EnumBeeChromosome.NOCTURNAL.ordinal()); + return bee.getGenome().getNocturnal() && bee.isPureBred(EnumBeeChromosome.NOCTURNAL); if (filter == EnumFilterType.FLYER) return bee.getGenome().getTolerantFlyer(); if (filter == EnumFilterType.PURE_FLYER) - return bee.getGenome().getTolerantFlyer() && bee.isPureBred(EnumBeeChromosome.TOLERANT_FLYER.ordinal()); + return bee.getGenome().getTolerantFlyer() && bee.isPureBred(EnumBeeChromosome.TOLERANT_FLYER); if (filter == EnumFilterType.CAVE) return bee.getGenome().getCaveDwelling(); if (filter == EnumFilterType.PURE_CAVE) - return bee.getGenome().getCaveDwelling() && bee.isPureBred(EnumBeeChromosome.CAVE_DWELLING.ordinal()); + return bee.getGenome().getCaveDwelling() && bee.isPureBred(EnumBeeChromosome.CAVE_DWELLING); if (filter == EnumFilterType.NATURAL) return bee.isNatural(); } From f8a9bf44c341061bb259aa189b775bb02d60ee3c Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 30 Nov 2014 18:31:42 -0800 Subject: [PATCH 004/175] Suppress unhandled exception warnings --- .../apiculture/VillageHandlerApiculture.java | 28 +++++++++---------- .../utils/ForestryModEnvWarningCallable.java | 2 +- .../forestry/pipes/PipeItemsPropolis.java | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java index c592a3229..55e0a0640 100755 --- a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java @@ -10,9 +10,17 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.List; -import java.util.Random; - +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; +import forestry.api.apiculture.EnumBeeType; +import forestry.apiculture.genetics.BeeTemplates; +import forestry.apiculture.items.ItemHoneycomb; +import forestry.apiculture.worldgen.ComponentVillageBeeHouse; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginApiculture; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -23,17 +31,8 @@ import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraft.world.gen.structure.StructureVillagePieces; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; - -import forestry.api.apiculture.EnumBeeType; -import forestry.apiculture.genetics.BeeTemplates; -import forestry.apiculture.items.ItemHoneycomb; -import forestry.apiculture.worldgen.ComponentVillageBeeHouse; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.plugins.PluginApiculture; +import java.util.List; +import java.util.Random; public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler { @@ -41,6 +40,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla try { MapGenStructureIO.func_143031_a(ComponentVillageBeeHouse.class, "Forestry:BeeHouse"); } catch (Throwable e) { + Proxies.log.severe("Failed to register village beehouse."); } } diff --git a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java index 10aeaffaf..f6ad50df2 100755 --- a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java +++ b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java @@ -41,7 +41,7 @@ public class ForestryModEnvWarningCallable implements ICrashCallable { Class c = Class.forName("org.bukkit.Bukkit"); modIDs.add("Bukkit, Cauldron, or other Bukkit replacement"); } - catch (Throwable t) {} // No need to do anything. + catch (Throwable ignored) {} // No need to do anything. // Add other bad mods here. diff --git a/src/main/java/forestry/pipes/PipeItemsPropolis.java b/src/main/java/forestry/pipes/PipeItemsPropolis.java index b223e3b94..6f4f7a1b9 100755 --- a/src/main/java/forestry/pipes/PipeItemsPropolis.java +++ b/src/main/java/forestry/pipes/PipeItemsPropolis.java @@ -147,7 +147,7 @@ public class PipeItemsPropolis extends Pipe { // A bit of speed to perhaps prevent bees from popping out of the pipe. try { event.item.setSpeed(TransportConstants.PIPE_NORMAL_SPEED * 20F); - } catch (Throwable error) { + } catch (Throwable ignored) { } } From 891c0c6133d9519fab08aaf337adf56dcababde8 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 2 Dec 2014 22:09:53 -0800 Subject: [PATCH 005/175] Add beePrincessGE.name for trader's princess trade for monastic drone --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index af11df9b5..f214c11b1 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit af11df9b5f7e8e57d511f34484bcb4cd77893aee +Subproject commit f214c11b191887d80df4e265042e9b5326990fdc From d827a0f132d80247a830d66054008e3c55e3b066 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 2 Dec 2014 23:22:58 -0800 Subject: [PATCH 006/175] Fix #352 Backpack deletion/duplication bug --- .../forestry/core/utils/ItemInventory.java | 19 +++++++++++++++++++ .../forestry/storage/items/ItemBackpack.java | 16 +--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/forestry/core/utils/ItemInventory.java b/src/main/java/forestry/core/utils/ItemInventory.java index e7fcb75ff..5b122489a 100755 --- a/src/main/java/forestry/core/utils/ItemInventory.java +++ b/src/main/java/forestry/core/utils/ItemInventory.java @@ -47,6 +47,25 @@ public class ItemInventory implements IInventory, INBTTagable { readFromNBT(itemstack.getTagCompound()); } + public static int getOccupiedSlotCount(ItemStack itemStack) { + NBTTagCompound nbt = itemStack.getTagCompound(); + if (nbt == null) + return 0; + + int count = 0; + if (nbt.hasKey("Items")) { + NBTTagList nbttaglist = nbt.getTagList("Items", 10); + for (int i = 0; i < nbttaglist.tagCount(); i++) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + ItemStack itemStack1 = ItemStack.loadItemStackFromNBT(nbttagcompound1); + if (itemStack1 != null && itemStack1.stackSize > 0) { + count++; + } + } + } + return count; + } + protected void setUID(boolean override) { if (parent.getTagCompound() == null) parent.setTagCompound(new NBTTagCompound()); diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 871321ab8..e3bb49819 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -222,21 +222,7 @@ public class ItemBackpack extends ItemInventoried { @SuppressWarnings({"rawtypes", "unchecked"}) @Override public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) { - ItemInventory inventory = new ItemInventory(ItemBackpack.class, getBackpackSize(), itemstack); - - // HashMap contents = new HashMap(); - int occupied = 0; - - for (int i = 0; i < inventory.getSizeInventory(); i++) { - if (inventory.getStackInSlot(i) == null) - continue; - if (inventory.getStackInSlot(i).stackSize <= 0) - continue; - - // Count the slot as occupied - occupied++; - } + int occupied = ItemInventory.getOccupiedSlotCount(itemstack); BackpackMode mode = getMode(itemstack); if (mode == BackpackMode.LOCKED) From d132a0ae62ebe6b9f94ea1775bbcbac05399f330 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 2 Dec 2014 23:23:11 -0800 Subject: [PATCH 007/175] Cleanup --- src/main/java/forestry/core/utils/Utils.java | 6 +----- src/main/java/forestry/storage/items/ItemBackpack.java | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 06bc7b70f..fce743002 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -28,7 +28,6 @@ import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -37,7 +36,6 @@ import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -45,7 +43,6 @@ import net.minecraft.world.biome.BiomeGenBase; import java.security.MessageDigest; import java.security.cert.Certificate; import java.util.Arrays; -import java.util.Iterator; import java.util.Map; import java.util.Random; @@ -57,8 +54,7 @@ public class Utils { if (rand == null) rand = new Random(); - int uid = rand.nextInt(); - return uid; + return rand.nextInt(); } public static void dropInventory(TileForestry tile, World world, int x, int y, int z) { diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index e3bb49819..e579f56b5 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -85,10 +85,7 @@ public class ItemBackpack extends ItemInventoried { @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (getInventoryHit(world, x, y, z, side) != null) - return true; - else - return false; + return getInventoryHit(world, x, y, z, side) != null; } @Override From 38009bb32ac97d013a814922f3da43b59f75e662 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 20:46:10 -0800 Subject: [PATCH 008/175] Safety check for IC2 Plugin. #351 --- src/main/java/forestry/plugins/PluginIC2.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index dc670c89d..227192bcc 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -173,12 +173,6 @@ public class PluginIC2 extends ForestryPlugin { ChipsetManager.circuitRegistry.registerLegacyMapping(CircuitId.ELECTRIC_EFFICIENCY_I, "forestry.energyEfficiency1"); ChipsetManager.circuitRegistry.registerLegacyMapping(CircuitId.ELECTRIC_BOOST_I, "forestry.energyBoost1"); ChipsetManager.circuitRegistry.registerLegacyMapping(CircuitId.ELECTRIC_BOOST_II, "forestry.energyBoost2"); - - // Remove some items from the recycler - if (PluginManager.Module.APICULTURE.isEnabled()) { - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beeQueenGE.getItemStack())); - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beePrincessGE.getItemStack())); - } } @Override @@ -188,6 +182,16 @@ public class PluginIC2 extends ForestryPlugin { config = Config.config; + // Remove some items from the recycler + if (Recipes.recyclerBlacklist != null) { + if (PluginManager.Module.APICULTURE.isEnabled()) { + Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beeQueenGE.getItemStack())); + Recipes.recyclerBlacklist.add(new RecipeInputItemStack(ForestryItem.beePrincessGE.getItemStack())); + } + } else { + Proxies.log.severe("IC2 Recipes.recyclerBlacklist not found."); + } + definitionEngineTin.register(); definitionGenerator.register(); From ab3ba0c4dbece12818e697fcfa7e53d12f534e1f Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 21:22:21 -0800 Subject: [PATCH 009/175] Fix #357 Forestry stained glass not silk touchable --- src/main/java/forestry/core/gadgets/BlockStainedGlass.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java index e169b5f27..ff4e31e05 100755 --- a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java +++ b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java @@ -101,4 +101,9 @@ public class BlockStainedGlass extends BlockBreakable { return false; } + @Override + protected boolean canSilkHarvest() { + return true; + } + } From 0105f36668a75e4ca71be5d5e7fde48ba3bab39d Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 21:56:41 -0800 Subject: [PATCH 010/175] Fix #356 Worktable using the wrong wood with Shift-use all --- src/main/java/forestry/factory/gadgets/TileWorktable.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 8249834e3..6f5bb7282 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -43,6 +43,7 @@ public class TileWorktable extends TileBase implements ICrafter { /* CONSTANTS */ public final static int SLOT_CRAFTING_1 = 0; + public final static int SLOT_CRAFTING_COUNT = 9; public final static int SLOT_CRAFTING_RESULT = 9; public final static short SLOT_INVENTORY_1 = 0; public final static short SLOT_INVENTORY_COUNT = 18; @@ -135,7 +136,7 @@ public class TileWorktable extends TileBase implements ICrafter { return false; ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, world); - return recipeOutput != null && cachedRecipeOutput.isItemEqual(recipeOutput); + return ItemStack.areItemStacksEqual(cachedRecipeOutput, recipeOutput); } @Override @@ -447,7 +448,7 @@ public class TileWorktable extends TileBase implements ICrafter { return false; // Need at least one matched set - ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, 9); + ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); ItemStack[] stock = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); if (StackUtils.containsSets(set, stock, true, true) == 0) return false; @@ -495,7 +496,7 @@ public class TileWorktable extends TileBase implements ICrafter { if (recipeOutput == null) return false; - return recipeOutput.isItemEqual(currentRecipe.getRecipeOutput()); + return ItemStack.areItemStacksEqual(recipeOutput, currentRecipe.getRecipeOutput()); } private boolean removeResources(EntityPlayer player) { From 4f95ceab29a048c11c1f4de5a2bcf9444eb207c8 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 22:45:32 -0800 Subject: [PATCH 011/175] Cleanup --- .../apiculture/gadgets/BlockAlveary.java | 22 +++++++++---------- .../apiculture/gadgets/TileAlvearyFan.java | 2 +- .../apiculture/gadgets/TileAlvearyHeater.java | 5 +---- .../gadgets/TileAlvearyHygroregulator.java | 2 +- .../gadgets/TileAlvearySwarmer.java | 4 ++-- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java index 9b3013afb..231e9ae1f 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java @@ -105,13 +105,13 @@ public class BlockAlveary extends BlockStructure { public static final int BOTTOM = 2; public static final int LEFT = 3; public static final int RIGHT = 4; - public static final int TX_55_SWOF = 5; - public static final int TX_56_SWON = 6; - public static final int TX_57_HTOF = 7; - public static final int TX_58_HTON = 8; - public static final int TX_71_FNOF = 9; - public static final int TX_72_FNON = 10; - public static final int TX_73_VLVE = 11; + public static final int ALVEARY_SWARMER_OFF = 5; + public static final int ALVEARY_SWARMER_ON = 6; + public static final int ALVEARY_HEATER_OFF = 7; + public static final int ALVEARY_HEATER_ON = 8; + public static final int ALVEARY_FAN_OFF = 9; + public static final int ALVEARY_FAN_ON = 10; + public static final int ALVEARY_HYGRO = 11; public static final int STABILISER = 12; public static final int SIEVE = 13; @@ -152,13 +152,13 @@ public class BlockAlveary extends BlockStructure { case 1: return icons[ENTRANCE]; case TileAlvearySwarmer.BLOCK_META: - return icons[TX_55_SWOF]; + return icons[ALVEARY_SWARMER_OFF]; case TileAlvearyFan.BLOCK_META: - return icons[TX_71_FNOF]; + return icons[ALVEARY_FAN_OFF]; case TileAlvearyHeater.BLOCK_META: - return icons[TX_57_HTOF]; + return icons[ALVEARY_HEATER_OFF]; case TileAlvearyHygroregulator.BLOCK_META: - return icons[TX_73_VLVE]; + return icons[ALVEARY_HYGRO]; case TileAlvearyStabiliser.BLOCK_META: return icons[STABILISER]; case TileAlvearySieve.BLOCK_META: diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java index ed8e62bb1..5923c310a 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyFan.java @@ -16,7 +16,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser { public static final int BLOCK_META = 3; public TileAlvearyFan() { - super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.TX_71_FNOF, BlockAlveary.TX_72_FNON, BLOCK_META); + super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.ALVEARY_FAN_OFF, BlockAlveary.ALVEARY_FAN_ON, BLOCK_META); } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java index 47e1aae93..0e5d065a5 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHeater.java @@ -12,14 +12,11 @@ package forestry.apiculture.gadgets; public class TileAlvearyHeater extends TileAlvearyClimatiser { - public static final int TEXTURE_OFF = 57; - public static final int TEXTURE_ON = 58; - /* CONSTANTS */ public static final int BLOCK_META = 4; public TileAlvearyHeater() { - super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.TX_57_HTOF, BlockAlveary.TX_58_HTON, BLOCK_META); + super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.ALVEARY_HEATER_OFF, BlockAlveary.ALVEARY_HEATER_ON, BLOCK_META); } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 64f6aa013..823693d88 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -187,7 +187,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - return BlockAlveary.TX_73_VLVE; + return BlockAlveary.ALVEARY_HYGRO; } @Override diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index a7339d22f..a4f1983e6 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -158,9 +158,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory return BlockAlveary.BOTTOM; if (pendingSpawns.size() > 0) - return BlockAlveary.TX_56_SWON; + return BlockAlveary.ALVEARY_SWARMER_ON; else - return BlockAlveary.TX_55_SWOF; + return BlockAlveary.ALVEARY_SWARMER_OFF; } /* SAVING & LOADING */ From d0244ece326296793e52d70284d95337c5fb56bb Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 23:50:00 -0800 Subject: [PATCH 012/175] Fix biome error in Alveary --- .../apiculture/gadgets/TileAlvearyPlain.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 97b73f9ea..13c3ff600 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -47,7 +47,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.util.ForgeDirection; import java.util.LinkedHashSet; @@ -82,6 +81,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ); } + @Override + public void validate() { + super.validate(); + setBiomeInformation(); + } + + private void setBiomeInformation() { + this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord); + setErrorState(EnumErrorCode.OK); + } + /* LOADING & SAVING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { @@ -115,8 +125,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public void initialize() { super.initialize(); - this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord); - setErrorState(EnumErrorCode.OK); + setBiomeInformation(); } @Override From 475d99eae81162f28338d140cf555b40e3454d28 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 3 Dec 2014 23:50:39 -0800 Subject: [PATCH 013/175] Fix #353 Alveary heater/fan energy consumption, animation --- .../gadgets/TileAlvearyClimatiser.java | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java index a6a487c0e..161f1bc84 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyClimatiser.java @@ -34,15 +34,14 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner } protected final EnergyManager energyManager; private final ClimateControl climateControl; - private int transferTime = 0; - private int animationDelay = 0; + private int workingTime = 0; private final int textureOff; private final int textureOn; public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) { super(componentBlockMeta); this.climateControl = control; - energyManager = new EnergyManager(1000, 250, 2000); + energyManager = new EnergyManager(1000, 50, 2000); energyManager.setReceiveOnly(); this.textureOff = textureOff; this.textureOn = textureOn; @@ -60,28 +59,22 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner if (!this.hasMaster()) return; - if (energyManager.consumeEnergyToDoWork()) { + boolean wasInactive = (workingTime == 0); - transferTime = energyManager.getEnergyPerWork(); - - if (animationDelay <= 0) { - animationDelay = 100; - sendNetworkUpdate(); - } else - animationDelay = 100; + if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) { + // consume 10 RF per tick of work + workingTime += energyManager.getEnergyPerWork() / 10; } - if (transferTime > 0) { - transferTime--; + if (workingTime > 0) { + workingTime--; IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE(); if (component != null) component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp); } - if (animationDelay > 0) { - animationDelay--; - if (animationDelay <= 0) - sendNetworkUpdate(); + if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) { + sendNetworkUpdate(); } } @@ -93,7 +86,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner /* TEXTURES */ @Override public int getIcon(int side, int metadata) { - if (animationDelay > 0) + if (workingTime > 0) return textureOn; else return textureOff; @@ -104,23 +97,23 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); energyManager.readFromNBT(nbttagcompound); - transferTime = nbttagcompound.getInteger("Heating"); + workingTime = nbttagcompound.getInteger("Heating"); } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); energyManager.writeToNBT(nbttagcompound); - nbttagcompound.setInteger("Heating", transferTime); + nbttagcompound.setInteger("Heating", workingTime); } /* NETWORK */ @Override public void fromPacketPayload(PacketPayload payload) { - short delay = payload.shortPayload[0]; - if (animationDelay != delay) { - animationDelay = delay; + short workingTime = payload.shortPayload[0]; + if (this.workingTime != workingTime) { + this.workingTime = workingTime; worldObj.func_147479_m(xCoord, yCoord, zCoord); } } @@ -128,7 +121,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner @Override public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayload(0, 1); - payload.shortPayload[0] = (short) animationDelay; + payload.shortPayload[0] = (short) workingTime; return payload; } From b2d722a4c596289670a0a3dbe458b9ade759009e Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 4 Dec 2014 00:12:07 -0800 Subject: [PATCH 014/175] Make Apiarist's Armor protect against potion effects from bees --- .../genetics/AlleleEffectPotion.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java index 568d8b91c..e32e30f0f 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java @@ -10,25 +10,25 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.apiculture.items.ItemArmorApiarist; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; +import java.util.List; public class AlleleEffectPotion extends AlleleEffectThrottled { - private int potionId = 0; + private final Potion potion; private final int duration; public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) { super(uid, name, isDominant, 200, requiresWorking, false); - potionId = potion.getId(); + this.potion = potion; this.duration = duration; } @@ -39,12 +39,29 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { return storedData; AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f); - @SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox); - for (Object obj : list) { - EntityPlayer player = (EntityPlayer) obj; - player.addPotionEffect(new PotionEffect(potionId, duration, 0)); + for (Object entity : list) { + if (!(entity instanceof EntityPlayer)) + continue; + + EntityPlayer player = (EntityPlayer) entity; + + int duration = this.duration; + if (potion.isBadEffect()) { + // Players are not attacked if they wear a full set of apiarist's armor. + int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); + if (count >= 4) + continue; // Full set, no damage/effect + else if (count == 3) + duration = this.duration / 4; + else if (count == 2) + duration = this.duration / 2; + else if (count == 1) + duration = this.duration * 3 / 4; + } + + player.addPotionEffect(new PotionEffect(potion.getId(), duration, 0)); } return storedData; From 8ff72af9d24fc48a4fd9f8d1ea0ae9f758060323 Mon Sep 17 00:00:00 2001 From: MysteriousAges Date: Thu, 4 Dec 2014 01:13:29 -0800 Subject: [PATCH 015/175] Farmerly & Agrarian bees. Buzz buzz --- lang | 2 +- .../genetics/AlleleEffectFertile.java | 59 +++++++++++++++++++ .../apiculture/genetics/BeeTemplates.java | 18 ++++++ .../java/forestry/core/genetics/Allele.java | 5 +- .../forestry/plugins/PluginApiculture.java | 14 ++++- 5 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java diff --git a/lang b/lang index f214c11b1..f56f4422e 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit f214c11b191887d80df4e265042e9b5326990fdc +Subproject commit f56f4422e412e7ec158e53c029d023e77a8dfb16 diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java new file mode 100644 index 000000000..be009ac43 --- /dev/null +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java @@ -0,0 +1,59 @@ +package forestry.apiculture.genetics; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; + +public class AlleleEffectFertile extends AlleleEffectThrottled { + + public static final int MAX_BLOCK_FIND_TRIES = 5; + + public AlleleEffectFertile(String uid) { + super(uid, "fertile", false, 6, true, false); + } + + @Override + public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { + + if (isHalted(storedData, housing)) { + return storedData; + } + + World world = housing.getWorld(); + int territorySize[] = genome.getTerritory(); + + int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]); + int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); + int blockMaxY = housing.getYCoord() + territorySize[1] / 2 + 1; + int blockMinY = housing.getYCoord() - (territorySize[1] / 2) - 1; + + for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) { + if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) { + break; + } + blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]); + blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); + } + + return storedData; + } + + private int getRandomOffset(Random random, int centrePos, int offset) { + return centrePos + random.nextInt(offset) - (offset / 2); + } + + private boolean tryTickColumn(World world, int x, int z, int maxY, int minY) { + for (int y = maxY; y >= minY; --y) { + if (!world.isAirBlock(x, y, z)) { + Block block = world.getBlock(x, y, z); + world.scheduleBlockUpdate(x, y, z, block, 5); + return true; + } + } + return false; + } + +} diff --git a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java index 7a57519bf..0021abb01 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java +++ b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java @@ -548,6 +548,24 @@ public class BeeTemplates { alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesRural; return alleles; } + + public static IAllele[] getFarmerlyTemplate() { + IAllele[] alleles = getAgrarianBranchTemplate(); + alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFarmerly; + alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow; + alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge; + return alleles; + } + + public static IAllele[] getAgrarianTemplate() { + IAllele[] alleles = getAgrarianBranchTemplate(); + alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesArgrarian; + alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow; + alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth2; + alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFertile; + alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge; + return alleles; + } // / BOGGY BRANCH public static IAllele[] getBoggyBranchTemplate() { diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index e5e3b8d9a..a90fdb1a9 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -118,8 +118,8 @@ public class Allele implements IAllele { // Agrarian branch public static AlleleSpecies speciesRural; - // 41 Farmerly - // 42 Agrarian + public static AlleleSpecies speciesFarmerly; + public static AlleleSpecies speciesArgrarian; // Boggy branch public static AlleleSpecies speciesMarshy; @@ -391,6 +391,7 @@ public class Allele implements IAllele { public static Allele effectReanimation; public static Allele effectResurrection; public static Allele effectRepulsion; + public static Allele effectFertile; // / TREES // EFFECTS public static Allele leavesNone; diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index a51f7eae6..ea7a598a6 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -82,6 +82,7 @@ import forestry.apiculture.genetics.AlleleEffectRadioactive; import forestry.apiculture.genetics.AlleleEffectRepulsion; import forestry.apiculture.genetics.AlleleEffectResurrection; import forestry.apiculture.genetics.AlleleEffectSnowing; +import forestry.apiculture.genetics.AlleleEffectFertile; import forestry.apiculture.genetics.AlleleFlowers; import forestry.apiculture.genetics.Bee; import forestry.apiculture.genetics.BeeHelper; @@ -1028,8 +1029,10 @@ public class PluginApiculture extends ForestryPlugin { // Agrarian branch Allele.speciesRural = new AlleleBeeSpecies("speciesRural", false, "bees.species.rural", agrarian, "rustico", 0xfeff8f, 0xffdc16).addProduct( ForestryItem.beeComb.getItemStack(1, 14), 20).setIsSecret(); - // 41 Farmerly - // 42 Agrarian + Allele.speciesFarmerly = new AlleleBeeSpecies("speciesFarmerly", true, "bees.species.farmerly", agrarian, "arator", 0xD39728, 0xffdc16).addProduct( + ForestryItem.beeComb.getItemStack(1, 14), 27).setIsSecret(); + Allele.speciesArgrarian = new AlleleBeeSpecies("speciesArgrarian", true, "bees.species.agrarian", agrarian, "arator", 0xFFCA75, 0xFFE047).addProduct( + ForestryItem.beeComb.getItemStack(1, 14), 35).setIsSecret().setHasEffect(); // Boggy branch Allele.speciesMarshy = new AlleleBeeSpecies("speciesMarshy", true, "bees.species.marshy", boggy, "adorasti", 0x546626, 0xffdc16).addProduct( @@ -1075,6 +1078,7 @@ public class PluginApiculture extends ForestryPlugin { Allele.effectReanimation = new AlleleEffectResurrection("effectReanimation", "reanimation", AlleleEffectResurrection.getReanimationList()); Allele.effectResurrection = new AlleleEffectResurrection("effectResurrection", "resurrection", AlleleEffectResurrection.getResurrectionList()); Allele.effectRepulsion = new AlleleEffectRepulsion("effectRepulsion"); + Allele.effectFertile = new AlleleEffectFertile("effectFertile"); } @@ -1160,6 +1164,10 @@ public class PluginApiculture extends ForestryPlugin { // Agrarian branch BeeTemplates.ruralA = new BeeMutation(Allele.speciesMeadows, Allele.speciesDiligent, BeeTemplates.getRuralTemplate(), 12) .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); + new BeeMutation(Allele.speciesRural, Allele.speciesUnweary, BeeTemplates.getFarmerlyTemplate(), 10) + .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); + new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianBranchTemplate(), 6) + .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); // Monastic branch BeeTemplates.secludedA = new BeeMutation(Allele.speciesMonastic, Allele.speciesAustere, BeeTemplates.getSecludedTemplate(), 12); @@ -1210,6 +1218,8 @@ public class PluginApiculture extends ForestryPlugin { beeInterface.registerTemplate(BeeTemplates.getReddenedTemplate()); beeInterface.registerTemplate(BeeTemplates.getOmegaTemplate()); beeInterface.registerTemplate(BeeTemplates.getRuralTemplate()); + beeInterface.registerTemplate(BeeTemplates.getFarmerlyTemplate()); + beeInterface.registerTemplate(BeeTemplates.getAgrarianTemplate()); beeInterface.registerTemplate(BeeTemplates.getLeporineTemplate()); beeInterface.registerTemplate(BeeTemplates.getMerryTemplate()); beeInterface.registerTemplate(BeeTemplates.getTipsyTemplate()); From fafee3480343983930a46f3200b123d2a697c473 Mon Sep 17 00:00:00 2001 From: MysteriousAges Date: Thu, 4 Dec 2014 01:56:43 -0800 Subject: [PATCH 016/175] Swapping out deprecated method for non-deprecated call. --- lang | 2 +- .../forestry/apiculture/genetics/AlleleEffectThrottled.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lang b/lang index f56f4422e..daa0110f8 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit f56f4422e412e7ec158e53c029d023e77a8dfb16 +Subproject commit daa0110f88483df2e18d0235869e2846c7d191ef diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index dfd554053..ec5a9382d 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -55,7 +55,7 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee public boolean isHalted(IEffectData storedData, IBeeHousing housing) { - if (requiresWorkingQueen && housing.getErrorOrdinal() != EnumErrorCode.OK.ordinal()) + if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) return true; int throttle = storedData.getInteger(0); From 8be4298ca9732ab918742fd4782cac1524ac43ea Mon Sep 17 00:00:00 2001 From: Vexatos Date: Thu, 4 Dec 2014 17:54:33 +0100 Subject: [PATCH 017/175] Update PluginApiculture.java --- src/main/java/forestry/plugins/PluginApiculture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index ea7a598a6..545c959da 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -1166,7 +1166,7 @@ public class PluginApiculture extends ForestryPlugin { .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); new BeeMutation(Allele.speciesRural, Allele.speciesUnweary, BeeTemplates.getFarmerlyTemplate(), 10) .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); - new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianBranchTemplate(), 6) + new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianTemplate(), 6) .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); // Monastic branch From 4c6a4614255fa83ceb1d888dcd5f795de626238a Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 4 Dec 2014 18:28:39 -0800 Subject: [PATCH 018/175] Partially Revert "Swapping out deprecated method for non-deprecated call." This reverts commit fafee3480343983930a46f3200b123d2a697c473. There are 3rd party housings that don't implement the new getErrorState() yet. We can only get rid of this with the next major API change. --- .../forestry/apiculture/genetics/AlleleEffectThrottled.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index ec5a9382d..dfd554053 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -55,7 +55,7 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee public boolean isHalted(IEffectData storedData, IBeeHousing housing) { - if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) + if (requiresWorkingQueen && housing.getErrorOrdinal() != EnumErrorCode.OK.ordinal()) return true; int throttle = storedData.getInteger(0); From 48d6230ed1f8458abe11af7b54c0af89af12a4af Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 5 Dec 2014 12:43:00 -0800 Subject: [PATCH 019/175] Update lang --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index daa0110f8..0fcab1386 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit daa0110f88483df2e18d0235869e2846c7d191ef +Subproject commit 0fcab1386ffdc61d8ce231c7839ce197bb0977ec From 4f48cd5890b7c6c8c4867cc9a6512b9e2ee95523 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 5 Dec 2014 12:43:23 -0800 Subject: [PATCH 020/175] More progress on inventory rework --- .../factory/gadgets/MachineBottler.java | 73 +++---- .../factory/gadgets/MachineCarpenter.java | 182 +++++++----------- 2 files changed, 98 insertions(+), 157 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 8b7348bae..c8a99662b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -25,7 +25,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; @@ -87,12 +87,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } public static class RecipeManager implements ICraftingProvider { -<<<<<<< Updated upstream - public static final ArrayList recipes = new ArrayList(); -======= - public static ArrayList recipes = new ArrayList(); ->>>>>>> Stashed changes + public static final ArrayList recipes = new ArrayList(); /** * @@ -151,8 +147,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public final StandardTank resourceTank; private final TankManager tankManager; - private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); - private boolean productPending = false; private Recipe currentRecipe; @@ -162,6 +156,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public MachineBottler() { super(1100, 50, 4000); + + setInternalInventory(new TileInventoryAdapter(this, 3, "Items")); + setHints(Config.hints.get("bottler")); resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); tankManager = new TankManager(resourceTank); @@ -187,7 +184,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq nbttagcompound.setBoolean("ProductPending", productPending); tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); NBTTagList nbttaglist = new NBTTagList(); ItemStack[] offspring = pendingProducts.toArray(new ItemStack[pendingProducts.size()]); @@ -212,8 +208,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); @@ -227,7 +221,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public void updateServerSide() { if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - + + TileInventoryAdapter inventory = getInternalInventory(); + // 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)); @@ -280,6 +276,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq // We are done, add products to queue and remove resources pendingProducts.push(currentRecipe.bottled.copy()); + TileInventoryAdapter inventory = getInternalInventory(); inventory.decrStackSize(SLOT_RESOURCE, 1); resourceTank.drain(currentRecipe.input.amount, true); checkRecipe(); @@ -291,6 +288,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } public void checkRecipe() { + TileInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), inventory.getStackInSlot(SLOT_RESOURCE)); if (sameRec == null) @@ -328,7 +326,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } private boolean addProduct(ItemStack product, boolean all) { - return inventory.tryAddStack(product, SLOT_PRODUCT, 1, all); + return getInternalInventory().tryAddStack(product, SLOT_PRODUCT, 1, all); } // / STATE INFORMATION @@ -339,6 +337,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public boolean hasResourcesMin(float percentage) { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; @@ -368,6 +367,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { @@ -380,6 +380,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int i = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, i, fillingTime); @@ -389,32 +390,32 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -425,20 +426,14 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } @Override @@ -458,43 +453,22 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } + /* ISIDEDINVENTORY */ @Override public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { return isItemValidForSlot(slotIndex, itemstack); } - @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { return getInternalInventory().canExtractItem(side, itemstack, side) && slotIndex == SLOT_PRODUCT; } - @Override public int[] getAccessibleSlotsFromSide(int side) { return getInternalInventory().getAccessibleSlotsFromSide(side); } - /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_PRODUCT; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - } - /* ILIQUIDCONTAINER */ @Override public TankManager getTankManager() { @@ -506,6 +480,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq return tankManager.fill(from, resource, doFill); } + @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return tankManager.drain(from, resource, doDrain); } diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 2bc174197..cc5e21011 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -145,15 +145,15 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void addCrating(ItemStack itemStack) { ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), - ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated }); - addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", Character.valueOf('#'), itemStack }); + ForestryItem.crate.getItemStack(), itemStack, new Object[]{"###", "###", "###", '#', uncrated}); + addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[]{"#", Character.valueOf('#'), itemStack}); } @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), - ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate }); - addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated }); + ForestryItem.crate.getItemStack(), crated, new Object[]{"###", "###", "###", '#', toCrate}); + addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[]{"#", '#', crated}); } @Override @@ -200,7 +200,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL HashMap recipeList = new HashMap(); for (Recipe recipe : recipes) { - recipeList.put(recipe.internal.getIngredients(), new Object[] { recipe.getCraftingResult() }); + recipeList.put(recipe.internal.getIngredients(), new Object[]{recipe.getCraftingResult()}); } return recipeList; @@ -212,7 +212,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public final FilteredTank resourceTank; private final TankManager tankManager; private final TileInventoryAdapter craftingInventory; - private final TileInventoryAdapter accessibleInventory; public MachineCarpenter.Recipe currentRecipe; public MachineCarpenter.Recipe lastRecipe; public ContainerCarpenter activeContainer; @@ -222,7 +221,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL private ItemStack pendingProduct; public ItemStack getBoxStack() { - return accessibleInventory.getStackInSlot(SLOT_BOX); + return getInternalInventory().getStackInSlot(SLOT_BOX); } public MachineCarpenter() { @@ -230,7 +229,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL 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); + setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); + getInternalInventory().configureSided(Defaults.FACINGS, SLOT_BOX, 20); tankManager = new TankManager(resourceTank); } @@ -256,7 +256,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL tankManager.writeTanksToNBT(nbttagcompound); craftingInventory.writeToNBT(nbttagcompound); - accessibleInventory.writeToNBT(nbttagcompound); // Write pending product if (pendingProduct != null) { @@ -295,7 +294,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } } - accessibleInventory.readFromNBT(nbttagcompound); // Load pending product if (nbttagcompound.hasKey("PendingProduct")) { @@ -315,7 +313,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void setCurrentRecipe(MachineCarpenter.Recipe currentRecipe) { this.currentRecipe = currentRecipe; - if(currentRecipe != null) + if (currentRecipe != null) lastRecipe = currentRecipe; } @@ -324,7 +322,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - + TileInventoryAdapter accessibleInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidContainerData container = LiquidHelper.getLiquidContainer(accessibleInventory.getStackInSlot(SLOT_CAN_INPUT)); @@ -416,6 +414,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (resourceTank.getFluidAmount() < currentRecipe.liquid.amount) return false; + TileInventoryAdapter accessibleInventory = getInternalInventory(); // Check whether boxes are available if (currentRecipe.box != null) if (accessibleInventory.getStackInSlot(SLOT_BOX) == null) @@ -439,7 +438,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } // Remove boxes if (recipe.box != null) { - ItemStack removed = accessibleInventory.decrStackSize(SLOT_BOX, 1); + ItemStack removed = getInternalInventory().decrStackSize(SLOT_BOX, 1); if (removed == null || removed.stackSize == 0) return false; } @@ -448,11 +447,12 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } private boolean removeSets(int count, ItemStack[] set) { - EntityPlayer player = Proxies.common.getPlayer(worldObj, owner); - return accessibleInventory.removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); + EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); + return getInternalInventory().removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); } private boolean tryAddPending() { + TileInventoryAdapter accessibleInventory = getInternalInventory(); if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) == null) { accessibleInventory.setInventorySlotContents(SLOT_PRODUCT, pendingProduct.copy()); pendingProduct = null; @@ -481,6 +481,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (currentRecipe == null) return false; + TileInventoryAdapter accessibleInventory = getInternalInventory(); // Stop working if the output slot cannot take more if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) != null && accessibleInventory.getStackInSlot(SLOT_PRODUCT).getMaxStackSize() - accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize < currentRecipe @@ -510,32 +511,32 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL /* IINVENTORY */ @Override public int getSizeInventory() { - return accessibleInventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return accessibleInventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - accessibleInventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack decrStackSize(int i, int j) { - return accessibleInventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return accessibleInventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return accessibleInventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -546,102 +547,19 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return getInternalInventory().isUseableByPlayer(player); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - - /* SMP GUI */ - public void getGUINetworkData(int i, int j) { - i -= tankManager.maxMessageId() + 1; - switch (i) { - case 0: - packageTime = j; - break; - case 1: - totalTime = j; - break; - } - } - - public void sendGUINetworkData(Container container, ICrafting iCrafting) { - int i = tankManager.maxMessageId() + 1; - iCrafting.sendProgressBarUpdate(container, i, packageTime); - iCrafting.sendProgressBarUpdate(container, i + 1, totalTime); - } - - /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return accessibleInventory; - } - - /** - * @return Inaccessible crafting inventory for the craft grid. - */ - public InventoryAdapter getCraftingInventory() { - return craftingInventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_PRODUCT) - return true; - return false; } @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) + public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) return false; if (slotIndex == SLOT_PRODUCT) @@ -662,7 +580,54 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return false; } - // ILIQUIDCONTAINER IMPLEMENTATION + /* ISIDEDINVENTORY */ + @Override + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex == SLOT_PRODUCT; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); + } + + /* SMP GUI */ + @Override + public void getGUINetworkData(int i, int j) { + i -= tankManager.maxMessageId() + 1; + switch (i) { + case 0: + packageTime = j; + break; + case 1: + totalTime = j; + break; + } + } + + @Override + public void sendGUINetworkData(Container container, ICrafting iCrafting) { + int i = tankManager.maxMessageId() + 1; + iCrafting.sendProgressBarUpdate(container, i, packageTime); + iCrafting.sendProgressBarUpdate(container, i + 1, totalTime); + } + + /** + * @return Inaccessible crafting inventory for the craft grid. + */ + public InventoryAdapter getCraftingInventory() { + return craftingInventory; + } + + // IFLUIDCONTAINER IMPLEMENTATION @Override public int fill(ForgeDirection direction, FluidStack resource, boolean doFill) { return tankManager.fill(direction, resource, doFill); @@ -673,6 +638,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return tankManager; } + @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return tankManager.drain(from, resource, doDrain); } From 46256bac4174206cee5374594bdefbc4fc198b3f Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 18:52:32 -0800 Subject: [PATCH 021/175] Fix crash from checking Potion.isBadEffect on server --- .../apiculture/genetics/AlleleEffectPotion.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java index e32e30f0f..c55961d14 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java @@ -10,10 +10,12 @@ ******************************************************************************/ package forestry.apiculture.genetics; +import cpw.mods.fml.relauncher.ReflectionHelper; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; +import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -24,11 +26,13 @@ import java.util.List; public class AlleleEffectPotion extends AlleleEffectThrottled { private final Potion potion; + private final boolean isBadEffect; private final int duration; public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) { super(uid, name, isDominant, 200, requiresWorking, false); this.potion = potion; + this.isBadEffect = isBadEffect(potion); this.duration = duration; } @@ -48,7 +52,7 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { EntityPlayer player = (EntityPlayer) entity; int duration = this.duration; - if (potion.isBadEffect()) { + if (isBadEffect) { // Players are not attacked if they wear a full set of apiarist's armor. int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); if (count >= 4) @@ -67,4 +71,14 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { return storedData; } + //FIXME: remove when Potion.isBadEffect() is available server-side + private static boolean isBadEffect(Potion potion) { + try { + return ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect"); + } catch (ReflectionHelper.UnableToFindFieldException e) { + Proxies.log.severe("Could not access potion field isBadEffect."); + return false; + } + } + } From 54e4aafc0eb10846c3ae4200786e0c029c43d100 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 19:54:53 -0800 Subject: [PATCH 022/175] Improve bee give command format --- lang | 2 +- .../commands/CommandBeekeepingGiveBee.java | 52 +++++++++++-------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/lang b/lang index daa0110f8..76e231c90 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit daa0110f88483df2e18d0235869e2846c7d191ef +Subproject commit 76e231c9050dd0f2a9674657409bd8c62867637e diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java b/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java index 4c94c1db9..b82f4d9b5 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java @@ -61,26 +61,46 @@ public class CommandBeekeepingGiveBee extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] arguments) { - if (arguments.length < 3) { + if (arguments.length < 2) { printHelp(sender); return; } - EnumBeeType beeType = getBeeType(arguments[0]); + IBeeGenome beeGenome = getBeeGenome(arguments[0]); + EnumBeeType beeType = getBeeType(arguments[1]); if (beeType == EnumBeeType.NONE) { printHelp(sender); return; } - EntityPlayer player = CommandHelpers.getPlayer(sender, arguments[1]); + EntityPlayer player; + if (arguments.length == 3) { + player = CommandHelpers.getPlayer(sender, arguments[2]); + } else { + player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName()); + } + if (player == null) { + printHelp(sender); + return; + } - String parameter = arguments[2]; + IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome); + if(beeType == EnumBeeType.QUEEN) + bee.mate(bee); + + ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal()); + player.dropPlayerItemWithRandomChoice(beeStack, true); + + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName()); + } + + private static IBeeGenome getBeeGenome(String speciesName) { IAlleleBeeSpecies species = null; for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { - if (!uid.equals(parameter)) + if (!uid.equals(speciesName)) continue; if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) { @@ -91,7 +111,7 @@ public class CommandBeekeepingGiveBee extends SubCommand { if (species == null) { for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { - if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(parameter)) { + if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(speciesName)) { species = (IAlleleBeeSpecies) allele; break; } @@ -99,36 +119,26 @@ public class CommandBeekeepingGiveBee extends SubCommand { } if (species == null) - throw new SpeciesNotFoundException(parameter); + throw new SpeciesNotFoundException(speciesName); IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID()); if (template == null) throw new TemplateNotFoundException(species); - IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template); - - IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome); - - if(beeType == EnumBeeType.QUEEN) - bee.mate(bee); - - ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal()); - player.dropPlayerItemWithRandomChoice(beeStack, true); - - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), template[0].getName(), beeType.getName()); + return PluginApiculture.beeInterface.templateAsGenome(template); } @Override public List addTabCompletionOptions(ICommandSender sender, String[] parameters) { if (parameters.length == 1) { - List tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr); + List tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies()); tabCompletion.add("help"); return tabCompletion; } else if (parameters.length == 2) { - return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers()); + return CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr); } else if (parameters.length == 3) { - return CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies()); + return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers()); } return null; } From 84e9673454a659070032dd2db77a4d70ce4c7463 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 20:01:18 -0800 Subject: [PATCH 023/175] Fix lang typo: agrarain -> agrarian --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 76e231c90..cc09174a2 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 76e231c9050dd0f2a9674657409bd8c62867637e +Subproject commit cc09174a2503a4e2df1aad1cc2b662cb607e9f27 From c010977a0ba2663c7374b98d937d274dcf33249d Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 23:28:05 -0800 Subject: [PATCH 024/175] Fix #359 Crafting with a worktable does not trigger achievements. --- .../forestry/core/gui/slots/SlotCrafter.java | 16 ++++++++++------ .../factory/gui/ContainerFabricator.java | 8 ++++---- .../forestry/factory/gui/ContainerWorktable.java | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/core/gui/slots/SlotCrafter.java b/src/main/java/forestry/core/gui/slots/SlotCrafter.java index 91bc54acf..fdd507836 100755 --- a/src/main/java/forestry/core/gui/slots/SlotCrafter.java +++ b/src/main/java/forestry/core/gui/slots/SlotCrafter.java @@ -10,20 +10,22 @@ ******************************************************************************/ package forestry.core.gui.slots; +import cpw.mods.fml.common.FMLCommonHandler; +import forestry.core.interfaces.ICrafter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; -import forestry.core.interfaces.ICrafter; - -public class SlotCrafter extends Slot { +public class SlotCrafter extends SlotCrafting { private final ICrafter crafter; + private final IInventory craftMatrix; - public SlotCrafter(IInventory inventory, ICrafter crafter, int slot, int xPos, int yPos) { - super(inventory, slot, xPos, yPos); + public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafter crafter, int slot, int xPos, int yPos) { + super(player, craftMatrix, craftMatrix, slot, xPos, yPos); this.crafter = crafter; + this.craftMatrix = craftMatrix; } @Override @@ -56,6 +58,8 @@ public class SlotCrafter extends Slot { @Override public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) { + FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, craftMatrix); + this.onCrafting(itemStack, itemStack.stackSize); // handles crafting achievements, maps, and statistics crafter.takenFromSlot(getSlotIndex(), true, player); } } diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 6833d140e..1fa32ba2a 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -20,7 +20,7 @@ public class ContainerFabricator extends ContainerLiquidTanks { private final MachineFabricator tile; - public ContainerFabricator(InventoryPlayer player, MachineFabricator tile) { + public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) { super(tile, tile); this.tile = tile; @@ -36,7 +36,7 @@ public class ContainerFabricator extends ContainerLiquidTanks { this.addSlot(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); // Result - this.addSlot(new SlotCrafter(tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); + this.addSlot(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); // Crafting matrix for (int l = 0; l < 3; l++) @@ -46,10 +46,10 @@ public class ContainerFabricator extends ContainerLiquidTanks { // Player inventory for (int i = 0; i < 3; i++) for (int k = 0; k < 9; k++) - addSlot(new Slot(player, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); + addSlot(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); // Player hotbar for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j, 8 + j * 18, 187)); + addSlot(new Slot(playerInventory, j, 8 + j * 18, 187)); } diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index 62a190aec..472064ebe 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -60,7 +60,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC } // CraftResult display - addSlot(new SlotCrafter(craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); + addSlot(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { From 4cc318bc1d7b594bc6745616f6acb40036623864 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 23:31:56 -0800 Subject: [PATCH 025/175] Fix crash when crafting with a Map on a Worktable --- .../factory/gadgets/TileWorktable.java | 339 ++---------------- .../forestry/factory/gui/GuiWorktable.java | 9 +- .../factory/recipes/RecipeMemory.java | 229 ++++++++++++ 3 files changed, 256 insertions(+), 321 deletions(-) create mode 100644 src/main/java/forestry/factory/recipes/RecipeMemory.java diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 6f5bb7282..931537582 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -10,21 +10,7 @@ ******************************************************************************/ package forestry.factory.gadgets; -import java.util.LinkedList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; - import forestry.api.core.ForestryAPI; -import forestry.api.core.INBTTagable; import forestry.core.gadgets.TileBase; import forestry.core.gui.ContainerDummy; import forestry.core.interfaces.ICrafter; @@ -35,9 +21,16 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.PlainInventory; import forestry.core.utils.StackUtils; import forestry.core.utils.TileInventoryAdapter; +import forestry.factory.recipes.RecipeMemory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; public class TileWorktable extends TileBase implements ICrafter { @@ -48,297 +41,9 @@ public class TileWorktable extends TileBase implements ICrafter { public final static short SLOT_INVENTORY_1 = 0; public final static short SLOT_INVENTORY_COUNT = 18; private final static Container DUMMY_CONTAINER = new ContainerDummy(); - private final static RecipeBridge RECIPE_BRIDGE = new RecipeBridge(); - private static class RecipeBridge { - public ItemStack findMatchingRecipe(InventoryCrafting crafting, World world) { - return CraftingManager.getInstance().findMatchingRecipe(crafting, world); - } - } - - /* RECIPE MEMORY */ - public static final class Recipe implements INBTTagable { - - private InventoryAdapter matrix; - private long lastUsed; - private boolean locked; - private World cachedWorld; - private ItemStack cachedRecipeOutput; - - public Recipe(InventoryCrafting crafting) { - this.matrix = new InventoryAdapter(new PlainInventory(crafting)); - } - - public Recipe(NBTTagCompound nbttagcompound) { - readFromNBT(nbttagcompound); - } - - public void setCacheWorld(World world) { - this.cachedWorld = world; - } - - private boolean updateCachedRecipeOutput() { - - if (cachedRecipeOutput != null) - return true; - - InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3); - for (int i = 0; i < crafting.getSizeInventory(); i++) { - crafting.setInventorySlotContents(i, matrix.getStackInSlot(i)); - } - - cachedRecipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, cachedWorld); - return cachedRecipeOutput != null; - } - - public void updateLastUse(World world) { - lastUsed = world.getTotalWorldTime(); - setCacheWorld(world); - } - - public void toogleLock() { - locked = !locked; - } - - public InventoryAdapter getMatrix() { - return matrix; - } - - public ItemStack getCraftingResult(InventoryCrafting inventorycrafting) { - if (updateCachedRecipeOutput()) - return cachedRecipeOutput; - - return null; - } - - public ItemStack getRecipeOutput() { - if (updateCachedRecipeOutput()) - return cachedRecipeOutput; - - return null; - } - - public long getLastUsed() { - return this.lastUsed; - } - - public boolean isLocked() { - return this.locked; - } - - public int getRecipeSize() { - return matrix.getSizeInventory(); - } - - public boolean hasSameOutput(InventoryCrafting crafting, World world) { - - if (!updateCachedRecipeOutput()) - return false; - - ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, world); - return ItemStack.areItemStacksEqual(cachedRecipeOutput, recipeOutput); - } - - @Override - public final void readFromNBT(NBTTagCompound nbttagcompound) { - matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3)); - matrix.readFromNBT(nbttagcompound); - sanitizeMatrix(); - lastUsed = nbttagcompound.getLong("LastUsed"); - locked = nbttagcompound.getBoolean("Locked"); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - sanitizeMatrix(); - matrix.writeToNBT(nbttagcompound); - nbttagcompound.setLong("LastUsed", lastUsed); - nbttagcompound.setBoolean("Locked", locked); - } - - /** - * This is a nasty hack to hide a bug where the recipe stacks somehow - * get the stackSize set to -1. Which makes the recipe no longer work, - * ever. I've seen the bug, even inspected the NBT data of an afflicted - * worktable, but can't duplicate it, and can't trace it. -CovertJaguar - */ - private void sanitizeMatrix() { - for (int slot = 0; slot < matrix.getSizeInventory(); slot++) { - ItemStack stack = matrix.getStackInSlot(slot); - if (stack != null) - stack.stackSize = 1; - } - } - } - - public static class RecipeMemory implements INBTTagable, IInventory { - - private LinkedList recipes = new LinkedList(); - private long lastUpdate; - public final int capacity = 9; - - public long getLastUpdate() { - return lastUpdate; - } - - public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) { - - lastUpdate = world.getTotalWorldTime(); - recipe.updateLastUse(world); - - Recipe memory = getMemorized(crafting, world); - if (memory != null) { - int index = recipes.indexOf(memory); - recipes.set(index, recipe); - return; - } - - if (recipes.size() < capacity) { - recipes.add(recipe); - return; - } - - Recipe oldest = null; - for (Recipe existing : recipes) { - if (oldest != null && oldest.getLastUsed() < existing.getLastUsed()) - continue; - if (existing.isLocked()) - continue; - - oldest = existing; - } - if (oldest != null) { - recipes.remove(oldest); - recipes.add(recipe); - } - - } - - public Recipe getRecipe(int recipeIndex) { - if (recipes.size() > recipeIndex) - return recipes.get(recipeIndex); - - return null; - } - - public ItemStack getRecipeOutput(int recipeIndex) { - if (recipes.size() > recipeIndex) - return recipes.get(recipeIndex).getRecipeOutput(); - else - return null; - } - - public boolean isLocked(int recipeIndex) { - if (recipes.size() > recipeIndex) - return recipes.get(recipeIndex).isLocked(); - - return false; - } - - public void toggleLock(World world, int recipeIndex) { - lastUpdate = world.getTotalWorldTime(); - if (recipes.size() > recipeIndex) - recipes.get(recipeIndex).toogleLock(); - } - - private Recipe getMemorized(InventoryCrafting crafting, World world) { - for (Recipe recipe : recipes) { - if (recipe.hasSameOutput(crafting, world)) - return recipe; - } - - return null; - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - recipes = new LinkedList(); - if (!nbttagcompound.hasKey("RecipeMemory")) - return; - - NBTTagList nbttaglist = nbttagcompound.getTagList("RecipeMemory", 10); - for (int j = 0; j < nbttaglist.tagCount(); ++j) { - NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j); - recipes.add(new Recipe(nbttagcompound2)); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - NBTTagList nbttaglist = new NBTTagList(); - for (Recipe recipe : recipes) { - if (recipe != null) { - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); - recipe.writeToNBT(nbttagcompound2); - nbttaglist.appendTag(nbttagcompound2); - } - } - nbttagcompound.setTag("RecipeMemory", nbttaglist); - } - - @Override - public int getSizeInventory() { - return recipes.size(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getRecipeOutput(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - } - - @Override - public String getInventoryName() { - return ""; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public void markDirty() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return false; - } - } /* MEMBERS */ - private Recipe currentRecipe; + private RecipeMemory.Recipe currentRecipe; private InventoryCrafting currentCrafting; private final RecipeMemory memorized; private final TileInventoryAdapter craftingInventory; @@ -406,9 +111,7 @@ public class TileWorktable extends TileBase implements ICrafter { return; } - Recipe recipe = memorized.getRecipe(recipeIndex); - recipe.sanitizeMatrix(); - IInventory matrix = recipe.getMatrix(); + IInventory matrix = memorized.getRecipeMatrix(recipeIndex); if (matrix == null) return; @@ -420,20 +123,20 @@ public class TileWorktable extends TileBase implements ICrafter { /* CRAFTING */ public void setRecipe(InventoryCrafting crafting) { - ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, worldObj); + ItemStack recipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, worldObj); if (recipeOutput == null) { currentRecipe = null; currentCrafting = null; } else { - currentRecipe = new Recipe(crafting); + currentRecipe = new RecipeMemory.Recipe(crafting, worldObj); currentCrafting = crafting; } - updateCraftResult(currentCrafting); + updateCraftResult(); } - private void updateCraftResult(InventoryCrafting inventorycrafting) { + private void updateCraftResult() { if (currentRecipe != null) { - ItemStack result = currentRecipe.getCraftingResult(inventorycrafting); + ItemStack result = currentRecipe.getRecipeOutput(worldObj); if (result != null) { craftingInventory.setInventorySlotContents(SLOT_CRAFTING_RESULT, result.copy()); return; @@ -492,11 +195,11 @@ public class TileWorktable extends TileBase implements ICrafter { } } } - ItemStack recipeOutput = RECIPE_BRIDGE.findMatchingRecipe(crafting, worldObj); + ItemStack recipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, worldObj); if (recipeOutput == null) return false; - return ItemStack.areItemStacksEqual(recipeOutput, currentRecipe.getRecipeOutput()); + return ItemStack.areItemStacksEqual(recipeOutput, currentRecipe.getRecipeOutput(worldObj)); } private boolean removeResources(EntityPlayer player) { @@ -519,8 +222,8 @@ public class TileWorktable extends TileBase implements ICrafter { if (Proxies.common.isSimulating(worldObj)) memorized.memorizeRecipe(worldObj, currentRecipe, currentCrafting); - updateCraftResult(currentCrafting); - return currentRecipe.getRecipeOutput().copy(); + updateCraftResult(); + return currentRecipe.getRecipeOutput(worldObj).copy(); } @Override @@ -528,8 +231,8 @@ public class TileWorktable extends TileBase implements ICrafter { if (currentRecipe == null) return null; - if (currentRecipe.getRecipeOutput() != null) - return currentRecipe.getRecipeOutput().copy(); + if (currentRecipe.getRecipeOutput(worldObj) != null) + return currentRecipe.getRecipeOutput(worldObj).copy(); return null; } diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index 59dd3ff3c..36248e8b5 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -22,6 +22,7 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import org.lwjgl.opengl.GL11; public class GuiWorktable extends GuiForestryTitled { @@ -29,14 +30,16 @@ public class GuiWorktable extends GuiForestryTitled { private class MemorizedSlot extends Widget { private final int slotNumber; + private final World world; - public MemorizedSlot(WidgetManager manager, int xPos, int yPos, int slot) { + public MemorizedSlot(World world, WidgetManager manager, int xPos, int yPos, int slot) { super(manager, xPos, yPos); this.slotNumber = slot; + this.world = world; } private ItemStack getOutputStack() { - return worktable.getMemory().getRecipeOutput(slotNumber); + return worktable.getMemory().getRecipeOutput(world, slotNumber); } @Override @@ -111,7 +114,7 @@ public class GuiWorktable extends GuiForestryTitled { int yPos = 20 + (y * spacing); for (int x = 0; x < 3; x++) { int xPos = 110 + (x * spacing); - widgetManager.add(new MemorizedSlot(widgetManager, xPos, yPos, slot)); + widgetManager.add(new MemorizedSlot(player.getEntityWorld(), widgetManager, xPos, yPos, slot)); slot += 1; } } diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java new file mode 100644 index 000000000..b027b3769 --- /dev/null +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -0,0 +1,229 @@ +/******************************************************************************* + * 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.factory.recipes; + +import forestry.api.core.INBTTagable; +import forestry.core.gui.ContainerDummy; +import forestry.core.utils.InventoryAdapter; +import forestry.core.utils.PlainInventory; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; + +import java.util.LinkedList; + +public class RecipeMemory implements INBTTagable { + + private final static Container DUMMY_CONTAINER = new ContainerDummy(); + + public static final class Recipe implements INBTTagable { + + private InventoryAdapter matrix; + private long lastUsed; + private boolean locked; + private ItemStack cachedRecipeOutput; + + public Recipe(InventoryCrafting crafting) { + this.matrix = new InventoryAdapter(new PlainInventory(crafting)); + } + + public Recipe(NBTTagCompound nbttagcompound) { + readFromNBT(nbttagcompound); + } + + public void updateLastUse(long lastUsed) { + this.lastUsed = lastUsed; + } + + public void toggleLock() { + locked = !locked; + } + + public InventoryAdapter getMatrix() { + return matrix; + } + + public ItemStack getRecipeOutput(World world) { + if (cachedRecipeOutput == null) { + InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3); + for (int i = 0; i < crafting.getSizeInventory(); i++) { + crafting.setInventorySlotContents(i, matrix.getStackInSlot(i)); + } + + cachedRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world); + } + return cachedRecipeOutput; + } + + public long getLastUsed() { + return this.lastUsed; + } + + public boolean isLocked() { + return this.locked; + } + + public boolean hasSameOutput(InventoryCrafting crafting, World world) { + ItemStack recipeOutput = getRecipeOutput(world); + if (recipeOutput == null) + return false; + + ItemStack matchingRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world); + return ItemStack.areItemStacksEqual(recipeOutput, matchingRecipeOutput); + } + + @Override + public final void readFromNBT(NBTTagCompound nbttagcompound) { + matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3)); + matrix.readFromNBT(nbttagcompound); + sanitizeMatrix(); + lastUsed = nbttagcompound.getLong("LastUsed"); + locked = nbttagcompound.getBoolean("Locked"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + sanitizeMatrix(); + matrix.writeToNBT(nbttagcompound); + nbttagcompound.setLong("LastUsed", lastUsed); + nbttagcompound.setBoolean("Locked", locked); + } + + /** + * This is a nasty hack to hide a bug where the recipe stacks somehow + * get the stackSize set to -1. Which makes the recipe no longer work, + * ever. I've seen the bug, even inspected the NBT data of an afflicted + * worktable, but can't duplicate it, and can't trace it. -CovertJaguar + */ + private void sanitizeMatrix() { + for (int slot = 0; slot < matrix.getSizeInventory(); slot++) { + ItemStack stack = matrix.getStackInSlot(slot); + if (stack != null) + stack.stackSize = 1; + } + } + } + + private LinkedList recipes = new LinkedList(); + private long lastUpdate; + public final int capacity = 9; + + public long getLastUpdate() { + return lastUpdate; + } + + public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) { + + lastUpdate = world.getTotalWorldTime(); + recipe.updateLastUse(lastUpdate); + + Recipe memory = getMemorized(crafting, world); + if (memory != null) { + int index = recipes.indexOf(memory); + recipes.set(index, recipe); + return; + } + + if (recipes.size() < capacity) { + recipes.add(recipe); + return; + } + + Recipe oldest = null; + for (Recipe existing : recipes) { + if (oldest != null && oldest.getLastUsed() < existing.getLastUsed()) + continue; + if (existing.isLocked()) + continue; + + oldest = existing; + } + if (oldest != null) { + recipes.remove(oldest); + recipes.add(recipe); + } + + } + + public Recipe getRecipe(int recipeIndex) { + if (recipes.size() > recipeIndex) + return recipes.get(recipeIndex); + + return null; + } + + public IInventory getRecipeMatrix(int recipeIndex) { + RecipeMemory.Recipe recipe = getRecipe(recipeIndex); + recipe.sanitizeMatrix(); + return recipe.getMatrix(); + } + + public ItemStack getRecipeOutput(World world, int recipeIndex) { + if (recipes.size() > recipeIndex) + return recipes.get(recipeIndex).getRecipeOutput(world); + else + return null; + } + + public boolean isLocked(int recipeIndex) { + if (recipes.size() > recipeIndex) + return recipes.get(recipeIndex).isLocked(); + + return false; + } + + public void toggleLock(World world, int recipeIndex) { + lastUpdate = world.getTotalWorldTime(); + if (recipes.size() > recipeIndex) + recipes.get(recipeIndex).toggleLock(); + } + + private Recipe getMemorized(InventoryCrafting crafting, World world) { + for (Recipe recipe : recipes) { + if (recipe.hasSameOutput(crafting, world)) + return recipe; + } + + return null; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + recipes = new LinkedList(); + if (!nbttagcompound.hasKey("RecipeMemory")) + return; + + NBTTagList nbttaglist = nbttagcompound.getTagList("RecipeMemory", 10); + for (int j = 0; j < nbttaglist.tagCount(); ++j) { + NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j); + recipes.add(new Recipe(nbttagcompound2)); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + NBTTagList nbttaglist = new NBTTagList(); + for (Recipe recipe : recipes) { + if (recipe != null) { + NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + recipe.writeToNBT(nbttagcompound2); + nbttaglist.appendTag(nbttagcompound2); + } + } + nbttagcompound.setTag("RecipeMemory", nbttaglist); + } + +} From c6f205864fe4e2bc2450a97646112b412adc9ac5 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Dec 2014 23:34:30 -0800 Subject: [PATCH 026/175] oops --- src/main/java/forestry/factory/gadgets/TileWorktable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 931537582..d390ec65e 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -128,7 +128,7 @@ public class TileWorktable extends TileBase implements ICrafter { currentRecipe = null; currentCrafting = null; } else { - currentRecipe = new RecipeMemory.Recipe(crafting, worldObj); + currentRecipe = new RecipeMemory.Recipe(crafting); currentCrafting = crafting; } updateCraftResult(); From 029604222c5062f9135571bf7354e7d8e9f53002 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 7 Dec 2014 01:46:15 -0800 Subject: [PATCH 027/175] Support left click drag on Worktable --- .../forestry/core/gui/ContainerForestry.java | 29 ++++++++++++------- .../java/forestry/core/gui/GuiForestry.java | 3 -- .../forestry/core/gui/slots/SlotForestry.java | 9 ++++-- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 15a947fcb..8ce2131b9 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -55,8 +55,6 @@ public class ContainerForestry extends Container { Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex); if (slot instanceof SlotForestry) { - ((SlotForestry) slot).onSlotClick(slotIndex, button, modifier, player); - if (((SlotForestry) slot).isPhantom()) { return slotClickPhantom(slot, button, modifier, player); } @@ -67,29 +65,32 @@ public class ContainerForestry extends Container { private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player) { ItemStack stack = null; + ItemStack stackSlot = slot.getStack(); + if (stackSlot != null) + stack = stackSlot.copy(); + if (mouseButton == 2) { - if (((SlotForestry) slot).canAdjustPhantom()) - slot.putStack(null); + fillPhantomSlot(slot, null, mouseButton, modifier); } else if (mouseButton == 0 || mouseButton == 1) { InventoryPlayer playerInv = player.inventory; - slot.onSlotChanged(); - ItemStack stackSlot = slot.getStack(); - ItemStack stackHeld = playerInv.getItemStack(); - if (stackSlot != null) - stack = stackSlot.copy(); + ItemStack stackHeld = playerInv.getItemStack(); if (stackSlot == null) { if (stackHeld != null && slot.isItemValid(stackHeld)) fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } else if (stackHeld == null) { - adjustPhantomSlot(slot, mouseButton, modifier); - slot.onPickupFromSlot(player, playerInv.getItemStack()); + fillPhantomSlot(slot, null, mouseButton, modifier); } else if (slot.isItemValid(stackHeld)) if (StackUtils.isIdenticalItem(stackSlot, stackHeld)) adjustPhantomSlot(slot, mouseButton, modifier); else fillPhantomSlot(slot, stackHeld, mouseButton, modifier); + } else if (mouseButton == 5) { + InventoryPlayer playerInv = player.inventory; + ItemStack stackHeld = playerInv.getItemStack(); + if (!slot.getHasStack()) + fillPhantomSlot(slot, stackHeld, mouseButton, modifier); } return stack; } @@ -116,6 +117,12 @@ public class ContainerForestry extends Container { protected void fillPhantomSlot(Slot slot, ItemStack stackHeld, int mouseButton, int modifier) { if (!((SlotForestry) slot).canAdjustPhantom()) return; + + if (stackHeld == null) { + slot.putStack(null); + return; + } + int stackSize = mouseButton == 0 ? stackHeld.stackSize : 1; if (stackSize > slot.getSlotStackLimit()) stackSize = slot.getSlotStackLimit(); diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index d52dea0ff..dd55ed8ac 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -214,9 +214,6 @@ public abstract class GuiForestry extends GuiContainer i widgetManager.handleMouseMove(mouseX, mouseY, mouseButton, time); - Slot slot = getSlotAtPosition(mouseX, mouseY); - if (mouseButton == 1 && slot instanceof SlotForestry && ((SlotForestry) slot).isPhantom()) - return; super.mouseClickMove(mouseX, mouseY, mouseButton, time); } diff --git a/src/main/java/forestry/core/gui/slots/SlotForestry.java b/src/main/java/forestry/core/gui/slots/SlotForestry.java index f888a9d15..1171bda30 100755 --- a/src/main/java/forestry/core/gui/slots/SlotForestry.java +++ b/src/main/java/forestry/core/gui/slots/SlotForestry.java @@ -51,6 +51,12 @@ public class SlotForestry extends Slot implements IToolTipProvider{ return this; } + @Override + public void putStack(ItemStack itemStack) { + if (!isPhantom() || canAdjustPhantom()) + super.putStack(itemStack); + } + public SlotForestry setCanAdjustPhantom(boolean canAdjust) { this.canAdjustPhantom = canAdjust; return this; @@ -105,9 +111,6 @@ public class SlotForestry extends Slot implements IToolTipProvider{ return result; } - public void onSlotClick(int slotIndex, int button, int modifier, EntityPlayer player) { - } - /** * @param toolTips the tooltips to set */ From 7ffb9d5c1d2a7ebc2dbd0e05e7f23caf6386a845 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 7 Dec 2014 12:45:21 -0800 Subject: [PATCH 028/175] Fix #362 Missing Analyzer Crafting recipe --- src/main/java/forestry/plugins/PluginApiculture.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 545c959da..3c6e02d18 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -315,11 +315,6 @@ public class PluginApiculture extends ForestryPlugin { registerTemplates(); - definitionAnalyzer.register(); - definitionApiary.register(); - definitionBeehouse.register(); - definitionChest.register(); - GameRegistry.registerTileEntity(TileAlvearyPlain.class, "forestry.Alveary"); GameRegistry.registerTileEntity(TileSwarm.class, "forestry.Swarm"); GameRegistry.registerTileEntity(TileAlvearySwarmer.class, "forestry.AlvearySwarmer"); @@ -716,6 +711,11 @@ public class PluginApiculture extends ForestryPlugin { // ANALYZER definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META); + + definitionAnalyzer.register(); + definitionApiary.register(); + definitionBeehouse.register(); + definitionChest.register(); } public IRecipe[] createAlyzerRecipes(Block block, int meta) { From 2cb19594212a80f3a4b6bf018ca83bb1b3401733 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 7 Dec 2014 16:15:40 -0800 Subject: [PATCH 029/175] Add blacklist to worktable memory, blacklist non-empty maps --- .../factory/gadgets/TileWorktable.java | 6 ++++ .../factory/recipes/RecipeMemory.java | 29 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index d390ec65e..213f917a1 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -98,6 +98,12 @@ public class TileWorktable extends TileBase implements ICrafter { Proxies.net.sendToPlayer(new PacketTileNBT(PacketIds.TILE_NBT, this), player); } + @Override + public void validate() { + super.validate(); + memorized.validate(worldObj); + } + /* RECIPE SELECTION */ public RecipeMemory getMemory() { return memorized; diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index b027b3769..1afccfd46 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -17,18 +17,20 @@ import forestry.core.utils.PlainInventory; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; public class RecipeMemory implements INBTTagable { - private final static Container DUMMY_CONTAINER = new ContainerDummy(); - public static final class Recipe implements INBTTagable { private InventoryAdapter matrix; @@ -117,16 +119,39 @@ public class RecipeMemory implements INBTTagable { } } + private static final Container DUMMY_CONTAINER = new ContainerDummy(); + private static final List> memoryBlacklist = new ArrayList>(); + static { + memoryBlacklist.add(ItemMap.class); // almost every ItemMap is unique + } + private LinkedList recipes = new LinkedList(); private long lastUpdate; public final int capacity = 9; + private static boolean isValid(World world, Recipe recipe) { + Item item = recipe.getRecipeOutput(world).getItem(); + return item != null && !memoryBlacklist.contains(item.getClass()); + } + + public void validate(World world) { + LinkedList validRecipes = new LinkedList(); + for (Recipe recipe : recipes) { + if (isValid(world, recipe)) + validRecipes.add(recipe); + } + this.recipes = validRecipes; + } + public long getLastUpdate() { return lastUpdate; } public void memorizeRecipe(World world, Recipe recipe, InventoryCrafting crafting) { + if (!isValid(world, recipe)) + return; + lastUpdate = world.getTotalWorldTime(); recipe.updateLastUse(lastUpdate); From 23ffb78ab34a987fce43372a66d2efa73a25df68 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 7 Dec 2014 16:23:03 -0800 Subject: [PATCH 030/175] Improve null safety of memorized recipe isValid check --- src/main/java/forestry/factory/recipes/RecipeMemory.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index 1afccfd46..02524f5e3 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -130,7 +130,12 @@ public class RecipeMemory implements INBTTagable { public final int capacity = 9; private static boolean isValid(World world, Recipe recipe) { - Item item = recipe.getRecipeOutput(world).getItem(); + if (recipe == null) + return false; + ItemStack recipeOutput = recipe.getRecipeOutput(world); + if (recipeOutput == null) + return false; + Item item = recipeOutput.getItem(); return item != null && !memoryBlacklist.contains(item.getClass()); } From 99f09b4037d6cf91d8ddc41182e4d7cf595f9cc0 Mon Sep 17 00:00:00 2001 From: MysteriousAges Date: Mon, 8 Dec 2014 21:41:08 -0800 Subject: [PATCH 031/175] Fertile effect should now respect housing territory modifiers. --- .../java/forestry/apiculture/genetics/AlleleEffectFertile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java index be009ac43..b95979e9e 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java @@ -23,7 +23,7 @@ public class AlleleEffectFertile extends AlleleEffectThrottled { } World world = housing.getWorld(); - int territorySize[] = genome.getTerritory(); + int territorySize[] = getModifiedArea(genome, housing); int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]); int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); From e281cb45919c5a1cd6284e66fa6b07771c1a8982 Mon Sep 17 00:00:00 2001 From: MysteriousAges Date: Mon, 8 Dec 2014 21:42:22 -0800 Subject: [PATCH 032/175] Welcoming Miry and Boggy bees! Marshy bees are no longer in a branch all on their lonesome. --- lang | 2 +- .../genetics/AlleleEffectFungification.java | 129 ++++++++++++++++++ .../apiculture/genetics/BeeTemplates.java | 19 +++ .../java/forestry/core/genetics/Allele.java | 5 +- .../forestry/plugins/PluginApiculture.java | 63 +++++---- 5 files changed, 188 insertions(+), 30 deletions(-) create mode 100644 src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java diff --git a/lang b/lang index cc09174a2..52f779303 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit cc09174a2503a4e2df1aad1cc2b662cb607e9f27 +Subproject commit 52f779303aa0ae1aed0f6e97b3f5510e2e4b158c diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java new file mode 100644 index 000000000..cea2123d5 --- /dev/null +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -0,0 +1,129 @@ +package forestry.apiculture.genetics; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenBigMushroom; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.core.genetics.EffectData; + +public class AlleleEffectFungification extends AlleleEffectThrottled { + + public static final int MAX_BLOCK_FIND_TRIES = 10; + public static final int ENTITY_THROTTLE = 6; + + public AlleleEffectFungification(String uid) { + super(uid, "mycophilic", true, 10, false, false); + } + + @Override + public IEffectData validateStorage(IEffectData storedData) { + if (storedData instanceof EffectData && ((EffectData) storedData).getIntSize() == 2) { + return storedData; + } + + return new EffectData(2, 0); + } + + @Override + public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { + if (isHalted(storedData, housing)) { + return storedData; + } + + doBlockEffect(genome, housing); + + int entityThrottle = storedData.getInteger(1); + if (entityThrottle >= ENTITY_THROTTLE) { + doEntityEffect(genome, housing); + entityThrottle = 0; + } else { + ++entityThrottle; + } + storedData.setInteger(1, entityThrottle); + + return storedData; + } + + private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) { + World world = housing.getWorld(); + int territorySize[] = getModifiedArea(genome, housing); + + int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]); + int blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]); + int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); + + for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) { + Block block = world.getBlock(blockX, blockY, blockZ); + if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) { + world.setBlock(blockX, blockY, blockZ, Blocks.mycelium); + break; + } else if (isSuitableForGrowth(block)) { + doMushroomGrowth(block, world, blockX, blockY, blockZ); + break; + } + blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]); + blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]); + blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]); + } + + } + + private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) { + AxisAlignedBB aabb = this.getBounding(genome, housing, 1f); + World world = housing.getWorld(); + @SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities. + List entities = (List)world.getEntitiesWithinAABB(EntityCow.class, aabb); + for (Entity entity : entities) { + if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) { + convertCowToMooshroom((EntityCow)entity); + break; + } + } + } + + private int getRandomOffset(Random random, int centrePos, int offset) { + return centrePos + random.nextInt(offset) - (offset / 2); + } + + private boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) { + return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ)); + } + + private boolean isSuitableForGrowth(Block block) { + return block == Blocks.red_mushroom || block == Blocks.brown_mushroom; + } + + private static void convertCowToMooshroom(EntityCow cow) { + World worldObj = cow.worldObj; + cow.setDead(); + EntityMooshroom mooshroom = new EntityMooshroom(worldObj); + mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch); + mooshroom.setHealth(cow.getHealth()); + mooshroom.renderYawOffset = cow.renderYawOffset; + worldObj.spawnEntityInWorld(mooshroom); + worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D); + } + + private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) { + WorldGenBigMushroom giantMushroomGenerator = null; + + if (block == Blocks.brown_mushroom) { + giantMushroomGenerator = new WorldGenBigMushroom(0); + } else { + giantMushroomGenerator = new WorldGenBigMushroom(1); + } + + world.setBlockToAir(blockX, blockY, blockZ); + giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ); + } +} diff --git a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java index 0021abb01..55aa04097 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java +++ b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java @@ -582,6 +582,25 @@ public class BeeTemplates { alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy; return alleles; } + + public static IAllele[] getMiryTemplate() { + IAllele[] alleles = getBoggyBranchTemplate(); + alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry; + alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum; + alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue; + alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue; + return alleles; + } + + public static IAllele[] getBoggyTemplate() { + IAllele[] alleles = getBoggyBranchTemplate(); + alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy; + alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue; + alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue; + alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic; + alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger; + return alleles; + } /* MONASTIC BRANCH */ public static IAllele[] getMonasticBranchTemplate() { diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index a90fdb1a9..e36f76e85 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -123,8 +123,8 @@ public class Allele implements IAllele { // Boggy branch public static AlleleSpecies speciesMarshy; - // 44 speciesMiry - // 45 speciesBoggy + public static AlleleSpecies speciesMiry; + public static AlleleSpecies speciesBoggy; // Monastic branch public static AlleleSpecies speciesMonastic; @@ -392,6 +392,7 @@ public class Allele implements IAllele { public static Allele effectResurrection; public static Allele effectRepulsion; public static Allele effectFertile; + public static Allele effectMycophilic; // / TREES // EFFECTS public static Allele leavesNone; diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 3c6e02d18..b2dc4fbd1 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -10,6 +10,26 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.IIcon; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -37,7 +57,6 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IClassification; import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.recipes.RecipeManagers; -import forestry.apiculture.commands.CommandBeekeeping; import forestry.apiculture.FlowerProviderCacti; import forestry.apiculture.FlowerProviderEnd; import forestry.apiculture.FlowerProviderGourd; @@ -50,6 +69,7 @@ import forestry.apiculture.GuiHandlerApiculture; import forestry.apiculture.PacketHandlerApiculture; import forestry.apiculture.SaveEventHandlerApiculture; import forestry.apiculture.VillageHandlerApiculture; +import forestry.apiculture.commands.CommandBeekeeping; import forestry.apiculture.gadgets.BlockAlveary; import forestry.apiculture.gadgets.BlockBeehives; import forestry.apiculture.gadgets.BlockCandle; @@ -71,6 +91,8 @@ import forestry.apiculture.genetics.AlleleBeeSpecies; import forestry.apiculture.genetics.AlleleEffectAggressive; import forestry.apiculture.genetics.AlleleEffectCreeper; import forestry.apiculture.genetics.AlleleEffectExploration; +import forestry.apiculture.genetics.AlleleEffectFertile; +import forestry.apiculture.genetics.AlleleEffectFungification; import forestry.apiculture.genetics.AlleleEffectGlacial; import forestry.apiculture.genetics.AlleleEffectHeroic; import forestry.apiculture.genetics.AlleleEffectIgnition; @@ -82,7 +104,6 @@ import forestry.apiculture.genetics.AlleleEffectRadioactive; import forestry.apiculture.genetics.AlleleEffectRepulsion; import forestry.apiculture.genetics.AlleleEffectResurrection; import forestry.apiculture.genetics.AlleleEffectSnowing; -import forestry.apiculture.genetics.AlleleEffectFertile; import forestry.apiculture.genetics.AlleleFlowers; import forestry.apiculture.genetics.Bee; import forestry.apiculture.genetics.BeeHelper; @@ -105,7 +126,6 @@ import forestry.apiculture.items.ItemImprinter; import forestry.apiculture.items.ItemWaxCast; import forestry.apiculture.proxy.ProxyApiculture; import forestry.apiculture.trigger.ApicultureTriggers; -import forestry.apiculture.trigger.TriggerNoFrames; import forestry.apiculture.worldgen.HiveDecorator; import forestry.apiculture.worldgen.HiveEnd; import forestry.apiculture.worldgen.HiveForest; @@ -136,30 +156,8 @@ import forestry.core.items.ItemOverlay.OverlayInfo; import forestry.core.items.ItemScoop; import forestry.core.proxy.Proxies; import forestry.core.render.EntitySnowFX; -import forestry.core.triggers.Trigger; import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.util.IIcon; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; @Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description") public class PluginApiculture extends ForestryPlugin { @@ -1037,8 +1035,10 @@ public class PluginApiculture extends ForestryPlugin { // Boggy branch Allele.speciesMarshy = new AlleleBeeSpecies("speciesMarshy", true, "bees.species.marshy", boggy, "adorasti", 0x546626, 0xffdc16).addProduct( ForestryItem.beeComb.getItemStack(1, 15), 30).setHumidity(EnumHumidity.DAMP); - // 44 speciesMiry - // 45 speciesBoggy + Allele.speciesMiry = new AlleleBeeSpecies("speciesMiry", true, "bees.species.miry", boggy, "humidium", 0x92AF42, 0xffdc16).addProduct( + ForestryItem.beeComb.getItemStack(1, 15), 36).setHumidity(EnumHumidity.DAMP).setIsSecret(); + Allele.speciesBoggy = new AlleleBeeSpecies("speciesBoggy", true, "bees.species.boggy", boggy, "paluster", 0x698948, 0xffdc16).addProduct( + ForestryItem.beeComb.getItemStack(1, 15), 39).addSpecialty(ForestryItem.peat.getItemStack(1), 8).setHumidity(EnumHumidity.DAMP).setIsSecret(); // Monastic branch Allele.speciesMonastic = new AlleleBeeSpecies("speciesMonastic", false, "bees.species.monastic", monastic, "monachus", 0x42371c, 0xfff7b6) @@ -1079,6 +1079,7 @@ public class PluginApiculture extends ForestryPlugin { Allele.effectResurrection = new AlleleEffectResurrection("effectResurrection", "resurrection", AlleleEffectResurrection.getResurrectionList()); Allele.effectRepulsion = new AlleleEffectRepulsion("effectRepulsion"); Allele.effectFertile = new AlleleEffectFertile("effectFertile"); + Allele.effectMycophilic = new AlleleEffectFungification("effectMycophilic"); } @@ -1168,6 +1169,12 @@ public class PluginApiculture extends ForestryPlugin { .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianTemplate(), 6) .restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck(); + + // Boggy branch + new BeeMutation(Allele.speciesMarshy, Allele.speciesNoble, BeeTemplates.getMiryTemplate(), 15) + .setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f); + new BeeMutation(Allele.speciesMarshy, Allele.speciesMiry, BeeTemplates.getBoggyTemplate(), 9) + .setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f); // Monastic branch BeeTemplates.secludedA = new BeeMutation(Allele.speciesMonastic, Allele.speciesAustere, BeeTemplates.getSecludedTemplate(), 12); @@ -1225,6 +1232,8 @@ public class PluginApiculture extends ForestryPlugin { beeInterface.registerTemplate(BeeTemplates.getTipsyTemplate()); beeInterface.registerTemplate(BeeTemplates.getTrickyTemplate()); beeInterface.registerTemplate(BeeTemplates.getMarshyTemplate()); + beeInterface.registerTemplate(BeeTemplates.getMiryTemplate()); + beeInterface.registerTemplate(BeeTemplates.getBoggyTemplate()); beeInterface.registerTemplate(BeeTemplates.getMonasticTemplate()); beeInterface.registerTemplate(BeeTemplates.getSecludedTemplate()); beeInterface.registerTemplate(BeeTemplates.getHermiticTemplate()); From 099f33549b4d423004e09c7f05a4a2c38a6cfacf Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 8 Dec 2014 20:26:51 -0800 Subject: [PATCH 033/175] Refactor out worktable canCraftRecipe logic to RecipeUtil --- .../java/forestry/core/utils/RecipeUtil.java | 56 ++++++++++++++++++ .../factory/gadgets/TileWorktable.java | 58 ++----------------- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index f223be14a..89dd8f684 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -12,12 +12,19 @@ package forestry.core.utils; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Defaults; +import forestry.core.gui.ContainerDummy; import forestry.core.interfaces.IDescriptiveRecipe; import forestry.core.proxy.Proxies; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; public class RecipeUtil { + private static final Container DUMMY_CONTAINER = new ContainerDummy(); + public static void injectLeveledRecipe(ItemStack resource, int fermentationValue, String output) { if (RecipeManagers.fermenterManager == null) return; @@ -67,4 +74,53 @@ public class RecipeUtil { result[9] = output; return result; } + + public static boolean canCraftRecipe(World world, ItemStack[] recipeItems, ItemStack recipeOutput, ItemStack[] availableItems) { + // Need at least one matched set + if (StackUtils.containsSets(recipeItems, availableItems, true, true) == 0) + return false; + + // Check that it doesn't make a different recipe. + // For example: + // Wood Logs are all ore dictionary equivalent with each other, + // but an Oak Log shouldn't be able to make Ebony Wood Planks + // because it makes Oak Wood Planks using the same recipe. + // Strategy: + // Create a fake crafting inventory using items we have in availableItems + // in place of the ones in the saved crafting inventory. + // Check that the recipe it makes is the same as the currentRecipe. + InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3); + ItemStack[] stockCopy = StackUtils.condenseStacks(availableItems); + + for (int slot = 0; slot < recipeItems.length; slot++) { + ItemStack recipeStack = recipeItems[slot]; + if (recipeStack == null) + continue; + + // Use crafting equivalent (not oredict) items first + for (ItemStack stockStack : stockCopy) { + if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) { + ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); + stockStack.stackSize--; + crafting.setInventorySlotContents(slot, stack); + break; + } + } + + // Use oredict items if crafting equivalent items aren't available + if (crafting.getStackInSlot(slot) == null) { + for (ItemStack stockStack : stockCopy) { + if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) { + ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); + stockStack.stackSize--; + crafting.setInventorySlotContents(slot, stack); + break; + } + } + } + } + ItemStack output = CraftingManager.getInstance().findMatchingRecipe(crafting, world); + + return ItemStack.areItemStacksEqual(output, recipeOutput); + } } diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index 213f917a1..aef345581 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -12,7 +12,6 @@ package forestry.factory.gadgets; import forestry.api.core.ForestryAPI; import forestry.core.gadgets.TileBase; -import forestry.core.gui.ContainerDummy; import forestry.core.interfaces.ICrafter; import forestry.core.network.ForestryPacket; import forestry.core.network.GuiId; @@ -21,11 +20,10 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.StackUtils; +import forestry.core.utils.RecipeUtil; import forestry.core.utils.TileInventoryAdapter; import forestry.factory.recipes.RecipeMemory; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -40,7 +38,6 @@ public class TileWorktable extends TileBase implements ICrafter { public final static int SLOT_CRAFTING_RESULT = 9; public final static short SLOT_INVENTORY_1 = 0; public final static short SLOT_INVENTORY_COUNT = 18; - private final static Container DUMMY_CONTAINER = new ContainerDummy(); /* MEMBERS */ private RecipeMemory.Recipe currentRecipe; @@ -156,56 +153,11 @@ public class TileWorktable extends TileBase implements ICrafter { if (currentRecipe == null) return false; - // Need at least one matched set - ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - ItemStack[] stock = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); - if (StackUtils.containsSets(set, stock, true, true) == 0) - return false; + ItemStack[] recipeItems = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + ItemStack[] inventory = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ItemStack recipeOutput = currentRecipe.getRecipeOutput(worldObj); - // Check that it doesn't make a different recipe. - // For example: - // Wood Logs are all ore dictionary equivalent with each other, - // but an Oak Log shouldn't be able to make Ebony Wood Planks - // because it makes Oak Wood Planks using the same recipe. - // Strategy: - // Create a fake crafting inventory using items we have in stock - // in place of the ones in the saved crafting inventory. - // Check that the recipe it makes is the same as the currentRecipe. - InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3); - ItemStack[] stockCopy = StackUtils.condenseStacks(stock); - - for (int slot = 0; slot < currentCrafting.getSizeInventory(); slot++) { - ItemStack recipeStack = currentCrafting.getStackInSlot(slot); - if (recipeStack == null) - continue; - - // Use crafting equivalent (not oredict) items first - for (ItemStack stockStack : stockCopy) { - if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) { - ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); - stockStack.stackSize--; - crafting.setInventorySlotContents(slot, stack); - break; - } - } - - // Use oredict items if crafting equivalent items aren't available - if (crafting.getStackInSlot(slot) == null) { - for (ItemStack stockStack : stockCopy) { - if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) { - ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); - stockStack.stackSize--; - crafting.setInventorySlotContents(slot, stack); - break; - } - } - } - } - ItemStack recipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, worldObj); - if (recipeOutput == null) - return false; - - return ItemStack.areItemStacksEqual(recipeOutput, currentRecipe.getRecipeOutput(worldObj)); + return RecipeUtil.canCraftRecipe(worldObj, recipeItems, recipeOutput, inventory); } private boolean removeResources(EntityPlayer player) { From 76fe2b1c90df5a2d8ed9496f8cb936c8b2b4799c Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 8 Dec 2014 22:39:53 -0800 Subject: [PATCH 034/175] cleanup --- src/main/java/forestry/core/utils/ShapedRecipeCustom.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index b81c79518..0534f79a5 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -33,12 +33,12 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { private final int width; private final int height; - private final Object ingredients[]; + private final Object[] ingredients; private final ItemStack product; private boolean preserveNBT = false; - public ShapedRecipeCustom(int width, int height, Object ingredients[], ItemStack product) { + public ShapedRecipeCustom(int width, int height, Object[] ingredients, ItemStack product) { this.width = width; this.height = height; this.ingredients = ingredients; From a300e97aa0e289995751f4a2d3022360e03aeb20 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 8 Dec 2014 22:41:09 -0800 Subject: [PATCH 035/175] Cleanup MachineFabricator --- .../factory/gadgets/MachineFabricator.java | 124 ++++++------------ 1 file changed, 39 insertions(+), 85 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index f591b17db..b44302666 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -10,28 +10,14 @@ ******************************************************************************/ package forestry.factory.gadgets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import forestry.api.core.EnumErrorCode; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -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 forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IFabricatorManager; import forestry.core.config.Defaults; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FilteredTank; +import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ICrafter; @@ -39,20 +25,31 @@ 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.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +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 net.minecraftforge.fluids.FluidTankInfo; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + public class MachineFabricator extends TilePowered implements ICrafter, ISpecialInventory, ILiquidTankContainer { /* RECIPE MANAGMENT */ public static class Recipe { private final ItemStack plan; - private final FluidStack molten; private final ShapedRecipeCustom internal; @@ -62,20 +59,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial this.internal = internal; } - public boolean matches(ItemStack plan) { - if (this.plan == null) - return true; - else if (plan == null) - return false; - - if (this.plan.getItemDamage() == Defaults.WILDCARD) - return plan.getItem() == this.plan.getItem(); - else - return plan.isItemEqual(this.plan); - } - public boolean matches(ItemStack plan, ItemStack[][] resources) { - if (!this.matches(plan)) + if (this.plan != null && !StackUtils.isCraftingEquivalent(this.plan, plan)) return false; return internal.matches(resources); @@ -106,9 +91,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } public static class Smelting { - ItemStack resource; - FluidStack product; - int meltingPoint; + private final ItemStack resource; + private final FluidStack product; + private final int meltingPoint; public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) { if(resource == null) @@ -121,10 +106,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial this.meltingPoint = meltingPoint; } - public boolean matches(ItemStack resource) { - return this.resource.isItemEqual(resource); - } - public boolean matches(FluidStack product) { return this.product.isFluidEqual(product); } @@ -156,30 +137,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial smeltings.add(new Smelting(resource, molten, meltingPoint)); } - public static Recipe findMatchingRecipe(ItemStack plan) { - for (Recipe recipe : recipes) - if (recipe.matches(plan)) - return recipe; - - return null; - } - - public static Recipe findMatchingRecipeIfSmelted(ItemStack plan, FluidStack liquid, ItemStack itemToMelt, ItemStack[] resources) { - Smelting smelting = findMatchingSmelting(itemToMelt); - if (smelting == null || (liquid != null && !smelting.matches(liquid))) - return findMatchingRecipe(plan, liquid, resources); - - FluidStack liquidIfSmelted; - if (liquid != null) { - liquidIfSmelted = liquid.copy(); - liquidIfSmelted.amount += smelting.getProduct().amount * itemToMelt.stackSize; - } else { - liquidIfSmelted = smelting.getProduct().copy(); - liquidIfSmelted.amount *= itemToMelt.stackSize; - } - return findMatchingRecipe(plan, liquidIfSmelted, resources); - } - public static Recipe findMatchingRecipe(ItemStack plan, FluidStack liquid, ItemStack[] resources) { ItemStack[][] gridResources = new ItemStack[3][3]; for (int i = 0; i < 3; i++) @@ -207,7 +164,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial return null; for (Smelting smelting : smeltings) - if (smelting.matches(resource)) + if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) return smelting; return null; @@ -233,7 +190,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial return recipeList; } - } /* CONSTANTS */ @@ -243,6 +199,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public static final short SLOT_PLAN = 1; public static final short SLOT_RESULT = 2; public static final short SLOT_CRAFTING_1 = 3; + public static final short SLOT_CRAFTING_COUNT = 9; public static final short SLOT_INVENTORY_1 = 12; public static final short SLOT_INVENTORY_COUNT = 18; @@ -372,20 +329,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial this.heat--; } - public Object[] getPlan() { - if (inventory.getStackInSlot(SLOT_PLAN) == null) - return null; - - Recipe myRecipe = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_PLAN)); - if (myRecipe == null) - return null; - - return myRecipe.internal.getIngredients(); - } - private Recipe getRecipe() { - return RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_PLAN), moltenTank.getFluid(), - inventory.getStacks(SLOT_CRAFTING_1, 9)); + ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); + ItemStack[] crafting = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), crafting); } /* ICRAFTER */ @@ -416,8 +363,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial FluidStack liquid = myRecipe.molten; // Remove resources - if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, 9), player, false)) { - removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, 9), player, true); + if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, false)) { + removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, true); moltenTank.drain(liquid.amount, true); } else if (consumeRecipe) { removeFromCraftMatrix(myRecipe); @@ -463,9 +410,16 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial @Override public boolean hasWork() { - Recipe recipe = RecipeManager.findMatchingRecipeIfSmelted(inventory.getStackInSlot(SLOT_PLAN), moltenTank.getFluid(), inventory.getStackInSlot(SLOT_METAL), - inventory.getStacks(SLOT_CRAFTING_1, 9)); - return recipe != null; + ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL); + Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt); + FluidStack liquid = smelting.getProduct(); + if (moltenTank.fill(liquid, false) > 0) + return true; + + ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); + ItemStack[] resources = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + + return RecipeManager.findMatchingRecipe(plan, liquid, resources) != null; } public int getHeatScaled(int i) { From 1d2266a524752bce8601f610e9e231ffe9f58fa5 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 9 Dec 2014 00:58:59 -0800 Subject: [PATCH 036/175] update lang --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 52f779303..3c34adcc5 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 52f779303aa0ae1aed0f6e97b3f5510e2e4b158c +Subproject commit 3c34adcc54f2e1dc0d06b6720261fcd77c4e2f24 From dbf6202a9076acd1d80cf3061bff4db0517551c7 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 9 Dec 2014 00:59:15 -0800 Subject: [PATCH 037/175] Fix Alveary Swarmer and Swarm Hive --- .../apiculture/gadgets/BlockBeehives.java | 6 +- .../gadgets/TileAlvearySwarmer.java | 152 ++++++++++-------- .../apiculture/worldgen/HiveDecorator.java | 21 ++- .../forestry/apiculture/worldgen/HiveEnd.java | 2 - .../apiculture/worldgen/HiveForest.java | 1 - .../apiculture/worldgen/HiveJungle.java | 1 - .../apiculture/worldgen/HiveMeadows.java | 1 - .../apiculture/worldgen/HiveSnow.java | 2 - .../apiculture/worldgen/HiveSwamp.java | 1 - ...rldGenHiveSwamer.java => HiveSwarmer.java} | 34 ++-- .../apiculture/worldgen/WorldGenHive.java | 43 ----- 11 files changed, 110 insertions(+), 154 deletions(-) rename src/main/java/forestry/apiculture/worldgen/{WorldGenHiveSwamer.java => HiveSwarmer.java} (61%) mode change 100755 => 100644 delete mode 100755 src/main/java/forestry/apiculture/worldgen/WorldGenHive.java diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index 98426097f..d4ac8c93d 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -12,7 +12,6 @@ package forestry.apiculture.gadgets; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IHiveDrop; import forestry.api.apiculture.hives.HiveManager; import forestry.api.core.Tabs; @@ -123,9 +122,6 @@ public class BlockBeehives extends BlockContainer { } private List getDropsForHive(int meta) { - if (meta == 8) //TODO: make a real hive for swarm - return BeeManager.hiveDrops[meta]; - String hiveName = getHiveNameForMeta(meta); if (hiveName == null) return Collections.emptyList(); @@ -177,7 +173,7 @@ public class BlockBeehives extends BlockContainer { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int j) { - if (j == 0 || j >= 8) + if (j == 0 || j > 8) return null; if (i == 0 || i == 1) { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index a4f1983e6..4ea11717a 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -10,17 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import java.util.Map.Entry; -import java.util.Stack; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlvearyComponent; @@ -28,12 +17,23 @@ import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; -import forestry.apiculture.worldgen.WorldGenHive; -import forestry.apiculture.worldgen.WorldGenHiveSwamer; +import forestry.apiculture.worldgen.HiveDecorator; +import forestry.apiculture.worldgen.HiveSwarmer; import forestry.core.network.GuiId; +import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; import forestry.core.utils.TileInventoryAdapter; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.Map.Entry; +import java.util.Stack; public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory { @@ -42,6 +42,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory TileInventoryAdapter swarmerInventory; private final Stack pendingSpawns = new Stack(); + private boolean isActive; public TileAlvearySwarmer() { super(BLOCK_META); @@ -64,86 +65,103 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory protected void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 100 != 0) - if (pendingSpawns.size() > 0) + if (pendingSpawns.size() > 0) { + setIsActive(true); + if (worldObj.getTotalWorldTime() % 1000 == 0) trySpawnSwarm(); + } else { + setIsActive(false); + } if (worldObj.getTotalWorldTime() % 500 != 0) return; - if (!this.hasMaster()) + ItemStack princessStack = getPrincessStack(); + if (princessStack == null) return; - IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE(); - if (!(master instanceof IBeeHousing)) + int chance = consumeInducerAndGetChance(); + if (chance == 0) return; - IBeeHousing housing = (IBeeHousing) master; - ItemStack queenstack = housing.getQueen(); - if (queenstack == null) - return; - if (!PluginApiculture.beeInterface.isMated(queenstack)) - return; - - // Calculate chance - int slot = getInducerSlot(); - if (slot < 0) - return; - int chance = getChanceFor(swarmerInventory.getStackInSlot(slot)); - - // Remove resource - swarmerInventory.decrStackSize(slot, 1); - // Try to spawn princess if (worldObj.rand.nextInt(1000) >= chance) return; // Queue swarm spawn - IBee spawn = PluginApiculture.beeInterface.getMember(queenstack); - spawn.setIsNatural(false); - pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(spawn, EnumBeeType.PRINCESS.ordinal())); - + IBee princess = PluginApiculture.beeInterface.getMember(princessStack); + princess.setIsNatural(false); + pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal())); } - private int getChanceFor(ItemStack stack) { - for (Entry entry : BeeManager.inducers.entrySet()) { - if (entry.getKey().isItemEqual(stack)) - return entry.getValue(); + private ItemStack getPrincessStack() { + if (!this.hasMaster()) + return null; + + IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE(); + if (!(master instanceof IBeeHousing)) + return null; + + IBeeHousing housing = (IBeeHousing) master; + ItemStack princessStack = housing.getQueen(); + if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) + return null; + + return princessStack; + } + + private int consumeInducerAndGetChance() { + if (swarmerInventory == null) + return 0; + + for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) { + ItemStack stack = swarmerInventory.getStackInSlot(i); + for (Entry entry : BeeManager.inducers.entrySet()) { + if (StackUtils.isIdenticalItem(entry.getKey(), stack)) { + swarmerInventory.decrStackSize(i, 1); + return entry.getValue(); + } + } } return 0; } - private int getInducerSlot() { - for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) { - if (swarmerInventory.getStackInSlot(i) == null) - continue; - for (Entry entry : BeeManager.inducers.entrySet()) { - if (entry.getKey().isItemEqual(swarmerInventory.getStackInSlot(i))) - return i; - } - } - - return -1; - } - private void trySpawnSwarm() { ItemStack toSpawn = pendingSpawns.peek(); - WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[] { toSpawn }); + HiveSwarmer hive = new HiveSwarmer(128, toSpawn); - int i = 0; - while (i < 10) { - i++; - int spawnX = xCoord + worldObj.rand.nextInt(40 * 2) - 40; - int spawnY = yCoord + worldObj.rand.nextInt(40); - int spawnZ = zCoord + worldObj.rand.nextInt(40 * 2) - 40; - if (generator.generate(worldObj, worldObj.rand, spawnX, spawnY, spawnZ)) { - pendingSpawns.pop(); - break; - } + int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; + int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; + + if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) { + pendingSpawns.pop(); } + } + private void setIsActive(boolean isActive) { + if (this.isActive != isActive) { + this.isActive = isActive; + sendNetworkUpdate(); + } + } + + /* NETWORK */ + @Override + public void fromPacketPayload(PacketPayload payload) { + boolean isActive = payload.shortPayload[0] > 0; + if (this.isActive != isActive) { + this.isActive = isActive; + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } + } + + @Override + public PacketPayload getPacketPayload() { + PacketPayload payload = new PacketPayload(0, 1); + payload.shortPayload[0] = (short) (isActive ? 1 : 0); + return payload; } @Override @@ -157,7 +175,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory if(side == 0 || side == 1) return BlockAlveary.BOTTOM; - if (pendingSpawns.size() > 0) + if (isActive) return BlockAlveary.ALVEARY_SWARMER_ON; else return BlockAlveary.ALVEARY_SWARMER_OFF; diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 80c50a72d..65ea83051 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -52,34 +52,39 @@ public class HiveDecorator { if (!TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) { return; } - decorateHives(event.world, event.rand, event.chunkX * 16, event.chunkZ * 16); + decorateHives(event.world, event.rand, event.chunkX, event.chunkZ); } - private void decorateHives(World world, Random rand, int worldX, int worldZ) { + private void decorateHives(World world, Random rand, int chunkX, int chunkZ) { for (IHive hive : HiveManager.getHives()) if (Config.generateBeehivesDebug) - genHiveDebug(world, worldX, worldZ, hive); + genHiveDebug(world, chunkX, chunkZ, hive); else - genHive(world, rand, worldX, worldZ, hive); + genHive(world, rand, chunkX, chunkZ, hive); } - private void genHive(World world, Random rand, int worldX, int worldZ, IHive hive) { + public boolean genHive(World world, Random rand, int chunkX, int chunkZ, IHive hive) { if (hive.genChance() < rand.nextFloat() * 128.0f) - return; + return false; + + int worldX = chunkX * 16; + int worldZ = chunkZ * 16; BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) - return; + return false; for (int tries = 0; tries < 4; tries ++) { int x = worldX + rand.nextInt(16); int z = worldZ + rand.nextInt(16); if (tryGenHive(world, x, z, hive)) - return; + return true; } + + return false; } private void genHiveDebug(World world, int worldX, int worldZ, IHive hive) { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveEnd.java b/src/main/java/forestry/apiculture/worldgen/HiveEnd.java index b61d63b84..1a675700a 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveEnd.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveEnd.java @@ -11,8 +11,6 @@ package forestry.apiculture.worldgen; import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; import net.minecraft.init.Blocks; import net.minecraft.world.biome.BiomeGenBase; diff --git a/src/main/java/forestry/apiculture/worldgen/HiveForest.java b/src/main/java/forestry/apiculture/worldgen/HiveForest.java index 934efb26f..fdc25a5d7 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveForest.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveForest.java @@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; -import net.minecraft.world.biome.BiomeGenBase; public class HiveForest extends HiveTree { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveJungle.java b/src/main/java/forestry/apiculture/worldgen/HiveJungle.java index 471680714..59e1b341d 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveJungle.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveJungle.java @@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; -import net.minecraft.world.biome.BiomeGenBase; public class HiveJungle extends HiveTree { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java b/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java index 2dec548aa..4917582cc 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java @@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; import net.minecraft.init.Blocks; -import net.minecraft.world.biome.BiomeGenBase; public class HiveMeadows extends HiveGround { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveSnow.java b/src/main/java/forestry/apiculture/worldgen/HiveSnow.java index 5b9a37a63..deafc8802 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveSnow.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveSnow.java @@ -11,12 +11,10 @@ package forestry.apiculture.worldgen; import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; import net.minecraft.init.Blocks; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class HiveSnow extends HiveGround { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java b/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java index e8c434b07..efa47f548 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java @@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.ForestryBlock; import net.minecraft.init.Blocks; -import net.minecraft.world.biome.BiomeGenBase; public class HiveSwamp extends HiveGround { diff --git a/src/main/java/forestry/apiculture/worldgen/WorldGenHiveSwamer.java b/src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java old mode 100755 new mode 100644 similarity index 61% rename from src/main/java/forestry/apiculture/worldgen/WorldGenHiveSwamer.java rename to src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java index d5998d4e8..e06dca4bb --- a/src/main/java/forestry/apiculture/worldgen/WorldGenHiveSwamer.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java @@ -4,46 +4,34 @@ * 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.apiculture.worldgen; -import java.util.Random; - +import forestry.api.apiculture.hives.HiveGround; +import forestry.apiculture.gadgets.TileSwarm; +import forestry.core.config.ForestryBlock; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import forestry.apiculture.gadgets.TileSwarm; +public class HiveSwarmer extends HiveGround { -/** - * - * @author CovertJaguar - */ -public class WorldGenHiveSwamer extends WorldGenHive { + private final ItemStack[] bees; - private ItemStack[] bees; - - public WorldGenHiveSwamer(ItemStack[] bees) { + public HiveSwarmer(float genChance, ItemStack... bees) { + super(ForestryBlock.beehives.block(), 8, genChance, Blocks.dirt, Blocks.grass); this.bees = bees; } @Override - public boolean generate(World world, Random random, int x, int y, int z) { - if (world.blockExists(x, y, z) && world.isAirBlock(x, y, z) && (!world.isAirBlock(x, y - 1, z) || !world.isAirBlock(x, y + 1, z))) { - setHive(world, x, y, z, 8); - return true; - } - - return false; - } - - @Override - protected void postGen(World world, int x, int y, int z, int meta) { + public void postGen(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileSwarm) ((TileSwarm) tile).setContained(bees); } + } diff --git a/src/main/java/forestry/apiculture/worldgen/WorldGenHive.java b/src/main/java/forestry/apiculture/worldgen/WorldGenHive.java deleted file mode 100755 index 91b8ee9a1..000000000 --- a/src/main/java/forestry/apiculture/worldgen/WorldGenHive.java +++ /dev/null @@ -1,43 +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.apiculture.worldgen; - -import java.util.Random; - -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; - -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; - -public abstract class WorldGenHive extends WorldGenerator { - - @Override - public abstract boolean generate(World world, Random random, int x, int y, int z); - - protected void setHive(World world, int x, int y, int z, int meta) { - boolean placed = world.setBlock(x, y, z, ForestryBlock.beehives.block(), meta, Defaults.FLAG_BLOCK_SYNCH); - if (!placed) - return; - - if (!ForestryBlock.beehives.isBlockEqual(world, x, y, z)) - return; - - ForestryBlock.beehives.block().onBlockAdded(world, x, y, z); - world.markBlockForUpdate(x, y, z); - - postGen(world, x, y, z, meta); - } - - protected void postGen(World world, int x, int y, int z, int meta) { - ForestryBlock.beehives.block().onBlockPlaced(world, x, y, z, 0, 0.0f, 0.0f, 0.0f, meta); - } -} From e26da52d214db753832f40a1407dc18c0f641203 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 11 Dec 2014 22:00:03 -0800 Subject: [PATCH 038/175] Closes #363. Ore dictionary support for IC2's Rubberized Electron Tubes --- .../java/forestry/core/utils/RecipeUtil.java | 22 +++++++++++++++++++ src/main/java/forestry/plugins/PluginIC2.java | 9 +++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 89dd8f684..6a51922c9 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -20,6 +20,11 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class RecipeUtil { @@ -38,6 +43,23 @@ public class RecipeUtil { RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 1)); } + /** + * Returns a list of the ore dictionary names if they exist. + * Returns a list containing itemStack if there are no ore dictionary names. + * Used for creating recipes that should accept equivalent itemStacks, based on the ore dictionary. + */ + public static List getOreDictRecipeEquivalents(ItemStack itemStack) { + int[] oreDictIds = OreDictionary.getOreIDs(itemStack); + List oreDictNames = new ArrayList(oreDictIds.length); + for (int oreId : oreDictIds) { + String oreDictName = OreDictionary.getOreName(oreId); + oreDictNames.add(oreDictName); + } + if (oreDictNames.isEmpty()) + return Collections.singletonList(itemStack); + return oreDictNames; + } + public static Object[] getCraftingRecipeAsArray(Object rec) { try { diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 227192bcc..ab30f2500 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -263,9 +263,12 @@ public class PluginIC2 extends ForestryPlugin { @Optional.Method(modid = "IC2") protected void registerRecipes() { - if (rubber != null) - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8), - new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', PluginIC2.rubber}); + if (rubber != null) { + for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { + RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8), + new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', rubberOreDict}); + } + } if (plantBall != null && compressedPlantBall != null) { RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Defaults.LIQUID_BIOMASS); From 2242dfdfb99bf8c37743635dfa94bc2f39e22c29 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 12 Dec 2014 00:34:44 -0800 Subject: [PATCH 039/175] Cleanup --- src/main/java/forestry/core/gadgets/StructureLogic.java | 3 +-- src/main/java/forestry/core/gui/widgets/TankWidget.java | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/StructureLogic.java b/src/main/java/forestry/core/gadgets/StructureLogic.java index 2dcc57c02..4180424e7 100755 --- a/src/main/java/forestry/core/gadgets/StructureLogic.java +++ b/src/main/java/forestry/core/gadgets/StructureLogic.java @@ -70,7 +70,7 @@ public abstract class StructureLogic implements IStructureLogic { EnumStructureState state = EnumStructureState.INDETERMINATE; - boolean rotate = false; + boolean rotate; for (int i = 0; i < schematas.length; i++) { if (!schematas[i].isEnabled()) continue; @@ -87,7 +87,6 @@ public abstract class StructureLogic implements IStructureLogic { isRotated = rotate; break; } - } // Structure state is indeterminate, possibly caused by chunkloading. Remain calm, do nothing. diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index a4fe7d66e..67ea39a73 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -61,10 +61,11 @@ public class TankWidget extends Widget { @Override public void draw(int startX, int startY) { - if (getTank() == null) + StandardTank tank = getTank(); + if (tank == null) return; - FluidStack contents = getTank().getFluid(); + FluidStack contents = tank.getFluid(); if (contents == null || contents.amount <= 0 || contents.getFluid() == null) return; IIcon liquidIcon = contents.getFluid().getIcon(contents); From 5c4bd5307c1efb85481fe425cff01b3f73767093 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 12 Dec 2014 01:30:51 -0800 Subject: [PATCH 040/175] Fix #365 Fluid pipe connected to farmblock --- .../forestry/core/fluids/TankManager.java | 39 ++++--- .../forestry/farming/gadgets/TileControl.java | 4 - .../forestry/farming/gadgets/TileFarm.java | 32 +++--- .../farming/gadgets/TileFarmPlain.java | 101 +++++------------- .../forestry/farming/gadgets/TileGearbox.java | 4 - .../forestry/farming/gadgets/TileHatch.java | 4 - .../forestry/farming/gadgets/TileValve.java | 4 - .../forestry/farming/gui/ContainerFarm.java | 4 - 8 files changed, 65 insertions(+), 127 deletions(-) diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index dbef0aeab..65b8c7357 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -11,13 +11,7 @@ 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; import java.io.DataOutputStream; import java.io.IOException; @@ -26,19 +20,26 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import net.minecraftforge.fluids.IFluidTank; + +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; /** * @@ -287,14 +288,18 @@ public class TankManager extends ForwardingList implements IFluidH return tank.drain(maxDrain, doDrain); } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + public FluidStack drain(FluidStack resource, boolean doDrain) { for (StandardTank tank : tanks) if (tankCanDrainFluid(tank, resource)) return tank.drain(resource.amount, doDrain); return null; } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return drain(resource, doDrain); + } + @Override public boolean canFill(ForgeDirection from, Fluid fluid) { return true; @@ -345,6 +350,14 @@ public class TankManager extends ForwardingList implements IFluidH return tank; } + public boolean accepts(Fluid fluid) { + for (StandardTank tank : tanks) + if (tank.accepts(fluid)) + return true; + + return false; + } + private boolean tankAcceptsFluid(StandardTank tank, FluidStack fluidStack) { if (fluidStack == null) return false; diff --git a/src/main/java/forestry/farming/gadgets/TileControl.java b/src/main/java/forestry/farming/gadgets/TileControl.java index 848168371..c0493fe78 100755 --- a/src/main/java/forestry/farming/gadgets/TileControl.java +++ b/src/main/java/forestry/farming/gadgets/TileControl.java @@ -62,10 +62,6 @@ public class TileControl extends TileFarm implements IFarmListener { return true; } - @Override - protected void createInventory() { - } - /* IFARMLISTENER */ @Override public boolean cancelTask(IFarmLogic logic, ForgeDirection direction) { diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 15e94981e..19d9dff59 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -228,19 +228,21 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { /* INVENTORY MANAGMENT */ protected TileInventoryAdapter inventory; - protected abstract void createInventory(); - /* TILEFORESTRY */ @Override public PacketPayload getPacketPayload() { - PacketPayload payload = new PacketPayload(0, 1); + PacketPayload payload = new PacketPayload(0, 2); payload.shortPayload[0] = (short) farmBlock.ordinal(); + payload.shortPayload[1] = (short) (isMaster() ? 1 : 0); return payload; } @Override public void fromPacketPayload(PacketPayload payload) { EnumFarmBlock farmType = EnumFarmBlock.values()[payload.shortPayload[0]]; + if (payload.shortPayload[1] > 0) + makeMaster(); + if (this.farmBlock != farmType) { this.farmBlock = farmType; worldObj.func_147479_m(xCoord, yCoord, zCoord); @@ -267,9 +269,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { public void makeMaster() { setCentralTE(null); this.isMaster = true; - - if (inventory == null) - createInventory(); } @Override @@ -284,22 +283,19 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public ITileStructure getCentralTE() { - if (!isIntegratedIntoStructure() || !hasMaster()) + if (!isIntegratedIntoStructure()) return null; - if (!isMaster) { - TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ); - if (tile instanceof ITileStructure) { - ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ); - if (master.isMaster()) - return master; - else - return null; - } else - return null; - } else + if (isMaster) return this; + TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ); + if (tile instanceof ITileStructure) { + ITileStructure master = (ITileStructure)tile; + if (master.isMaster()) + return master; + } + return null; } private boolean isSameTile(TileEntity tile) { diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 0638c4766..5aefa40f8 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -19,8 +19,6 @@ import java.util.Set; import java.util.Stack; import java.util.TreeMap; -import forestry.api.core.BiomeHelper; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -31,14 +29,14 @@ 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; +import forestry.api.core.BiomeHelper; +import forestry.api.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.farming.ICrop; @@ -47,29 +45,28 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; -import forestry.api.core.EnumErrorCode; import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FilteredTank; +import forestry.core.fluids.tanks.StandardTank; 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; import forestry.core.utils.TileInventoryAdapter; +import forestry.core.utils.Utils; import forestry.core.utils.Vect; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; -public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource, ILiquidTankContainer { +public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource { public static final int SLOT_RESOURCES_1 = 0; public static final int SLOT_GERMLINGS_1 = 6; @@ -82,9 +79,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public static final int SLOT_COUNT = 22; - public static final int DELAY_HYDRATION = 100; - public static final float RAINFALL_MODIFIER_CAP = 15f; - public static final int BUFFER_FERTILIZER = 200; + private static final int DELAY_HYDRATION = 100; + private static final float RAINFALL_MODIFIER_CAP = 15f; + private static final int BUFFER_FERTILIZER = 200; private IFarmLogic[] farmLogics = new IFarmLogic[4]; @@ -94,8 +91,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); - private final FilteredTank liquidTank; - private final TankManager tankManager; + private TankManager tankManager; private IFarmLogic harvestProvider; // The farm logic which supplied the pending crops. private final Stack pendingCrops = new Stack(); @@ -112,8 +108,6 @@ 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); } @Override @@ -134,7 +128,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable refreshFarmLogics(); - tankManager.readTanksFromNBT(nbttagcompound); + if (tankManager != null) + tankManager.readTanksFromNBT(nbttagcompound); } @Override @@ -146,15 +141,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable nbttagcompound.setInteger("HydrationDelay", hydrationDelay); nbttagcompound.setInteger("TicksSinceRainfall", ticksSinceRainfall); - tankManager.writeTanksToNBT(nbttagcompound); + if (tankManager != null) + tankManager.writeTanksToNBT(nbttagcompound); } /* UPDATING */ - @Override - public void initialize() { - setBiomeInformation(); - } - @Override protected void updateServerSide() { super.updateServerSide(); @@ -179,8 +170,8 @@ 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 && liquidTank.accepts(container.fluid.getFluid())) { - + if (container != null && tankManager.accepts(container.fluid.getFluid())) { + StandardTank liquidTank = tankManager.get(0); inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, liquidTank)); if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0) inventory.setInventorySlotContents(SLOT_CAN, null); @@ -366,16 +357,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } } - @Override protected void createInventory() { inventory = new TileInventoryAdapter(this, SLOT_COUNT, "Items"); + FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); + tankManager = new TankManager(liquidTank); } @Override public boolean doWork() { - - setBiomeInformation(); - // System.out.println("Starting doWork()"); if (targets == null) { createTargets(); @@ -681,18 +670,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public void makeMaster() { super.makeMaster(); refreshFarmLogics(); + createInventory(); } - @Override - public void onStructureReset() { - super.onStructureReset(); - } - - public StandardTank[] getTanks() { - return new StandardTank[] {liquidTank}; - } - - @Override public TankManager getTankManager() { return tankManager; } @@ -792,12 +772,12 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public boolean hasLiquid(FluidStack liquid) { - return liquidTank.getFluidAmount() >= liquid.amount; + return tankManager.get(0).getFluidAmount() >= liquid.amount; } @Override public void removeLiquid(FluidStack liquid) { - liquidTank.drain(liquid.amount, true); + tankManager.drain(liquid, true); } public boolean hasGermlings(ItemStack[] germlings) { @@ -877,9 +857,9 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return StackUtils.isIdenticalItem(PluginFarming.farmFertilizer, itemstack); } - int[] coords; - int[] offset; - int[] area; + private int[] coords; + private int[] offset; + private int[] area; @Override public int[] getCoords() { @@ -989,35 +969,4 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable public boolean isOwnable() { 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); - } } diff --git a/src/main/java/forestry/farming/gadgets/TileGearbox.java b/src/main/java/forestry/farming/gadgets/TileGearbox.java index b7bd656ef..059268bf1 100644 --- a/src/main/java/forestry/farming/gadgets/TileGearbox.java +++ b/src/main/java/forestry/farming/gadgets/TileGearbox.java @@ -33,10 +33,6 @@ public class TileGearbox extends TileFarm implements IPowerHandler { fixedType = TYPE_GEARS; } - @Override - protected void createInventory() { - } - @Override public boolean hasFunction() { return true; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index f80f814f0..a10c769e7 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -42,10 +42,6 @@ public class TileHatch extends TileFarm implements ISidedInventory { return true; } - @Override - protected void createInventory() { - } - @Override protected void updateServerSide() { if (worldObj.getTotalWorldTime() % 40 == 0) diff --git a/src/main/java/forestry/farming/gadgets/TileValve.java b/src/main/java/forestry/farming/gadgets/TileValve.java index d39fb84b1..d51fce0a1 100755 --- a/src/main/java/forestry/farming/gadgets/TileValve.java +++ b/src/main/java/forestry/farming/gadgets/TileValve.java @@ -33,10 +33,6 @@ public class TileValve extends TileFarm implements ILiquidTankContainer { return true; } - @Override - protected void createInventory() { - } - /* ILIQUIDTANKCONTAINER */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index b2e55fa4d..7066cf4b7 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -24,7 +24,6 @@ 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.utils.TileInventoryAdapter; import forestry.farming.gadgets.TileFarmPlain; import forestry.plugins.PluginFarming; @@ -38,9 +37,6 @@ public class ContainerFarm extends ContainerSocketed { this.tile = tile; IInventory inventory = tile.getInventory(); - // Tile will not have an inventory client side. - if (inventory == null) - inventory = new TileInventoryAdapter(tile, TileFarmPlain.SLOT_COUNT, "Items"); // Resources for (int i = 0; i < 3; i++) { From 5ea4770a2d5fef57cf52fb7c81f33671f8086740 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 01:42:52 -0800 Subject: [PATCH 041/175] Fix #364. Cleanup of Liquid/Fluid handling, handle IFluidContainerItem --- .../gadgets/TileAlvearyHygroregulator.java | 18 +- src/main/java/forestry/core/ForestryCore.java | 21 +- .../forestry/core/fluids/FluidHelper.java | 221 ++++++++++++------ .../java/forestry/core/gadgets/BlockBase.java | 12 +- .../forestry/core/gadgets/TilePowered.java | 26 --- .../core/items/ItemLiquidContainer.java | 10 +- .../forestry/core/utils/FluidStackMap.java | 5 +- src/main/java/forestry/core/utils/Fluids.java | 4 +- .../forestry/core/utils/LiquidHelper.java | 182 +-------------- .../java/forestry/core/utils/RecipeUtil.java | 29 +-- .../java/forestry/core/utils/StackUtils.java | 21 -- .../forestry/energy/gadgets/EngineBronze.java | 34 +-- .../energy/gadgets/MachineGenerator.java | 19 +- .../factory/gadgets/MachineBottler.java | 13 +- .../factory/gadgets/MachineCarpenter.java | 75 +++--- .../factory/gadgets/MachineFermenter.java | 92 ++++---- .../factory/gadgets/MachineMoistener.java | 15 +- .../factory/gadgets/MachineRaintank.java | 40 ++-- .../factory/gadgets/MachineSqueezer.java | 24 +- .../factory/gadgets/MachineStill.java | 73 +++--- .../farming/gadgets/TileFarmPlain.java | 16 +- .../farming/logic/FarmLogicWatered.java | 3 +- .../forestry/plugins/PluginApiculture.java | 25 +- .../forestry/plugins/PluginArboriculture.java | 57 ++--- .../plugins/PluginBuildCraftFuels.java | 12 +- .../plugins/PluginBuildCraftRecipes.java | 13 +- .../java/forestry/plugins/PluginFactory.java | 101 ++++---- src/main/java/forestry/plugins/PluginIC2.java | 23 +- .../plugins/PluginLepidopterology.java | 9 +- .../java/forestry/plugins/PluginMail.java | 9 +- .../java/forestry/plugins/PluginNatura.java | 9 +- .../java/forestry/plugins/PluginStorage.java | 22 +- 32 files changed, 518 insertions(+), 715 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 823693d88..e95542055 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -27,6 +27,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ForestryAPI; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.interfaces.ILiquidTankContainer; @@ -69,9 +70,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory public TileAlvearyHygroregulator() { super(BLOCK_META); - Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER); - Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA); - Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE); + Fluid water = FluidRegistry.getFluid(Defaults.LIQUID_WATER); + Fluid lava = FluidRegistry.getFluid(Defaults.LIQUID_LAVA); + Fluid liquidIce = FluidRegistry.getFluid(Defaults.LIQUID_ICE); liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce); tankManager = new TankManager(liquidTank); @@ -133,14 +134,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory // Check if we have suitable items waiting in the item slot if (canInventory.getStackInSlot(0) != null) { - FluidContainerData container = LiquidHelper.getLiquidContainer(canInventory.getStackInSlot(0)); - if (container != null && - (container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) { - - canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank)); - if (canInventory.getStackInSlot(0).stackSize <= 0) - canInventory.setInventorySlotContents(0, null); - } + FluidHelper.drainContainers(tankManager, canInventory, 0); } } @@ -276,7 +270,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { if (slotIndex == 0) { - FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack); + FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack); if (fluid == null || fluid.amount <= 0) return false; return liquidTank.accepts(fluid.getFluid()); diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 45156812c..0905e75b4 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core; +import com.google.common.collect.ImmutableList; + import java.io.File; import net.minecraft.init.Blocks; @@ -17,15 +19,14 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidRegistry; + import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraftforge.common.MinecraftForge; - -import com.google.common.collect.ImmutableList; - import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; @@ -89,17 +90,17 @@ public class ForestryCore { Defaults.ENGINE_COPPER_FUEL_VALUE_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_PEAT)); FuelManager.copperEngineFuel.put(ForestryItem.bituminousPeat.getItemStack(), new EngineCopperFuel(ForestryItem.bituminousPeat.getItemStack(), Defaults.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_BIOMASS), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_BIOMASS), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS), Defaults.ENGINE_FUEL_VALUE_BIOMASS, (int) (Defaults.ENGINE_CYCLE_DURATION_BIOMASS * GameMode.getGameMode().getFloatSetting("fuel.biomass.biogas")), 1)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_WATER), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_WATER), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_WATER), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_WATER), Defaults.ENGINE_FUEL_VALUE_WATER, Defaults.ENGINE_CYCLE_DURATION_WATER, 3)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_MILK), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_MILK), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_MILK), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_MILK), Defaults.ENGINE_FUEL_VALUE_MILK, Defaults.ENGINE_CYCLE_DURATION_MILK, 3)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_SEEDOIL), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_SEEDOIL), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL), Defaults.ENGINE_FUEL_VALUE_SEED_OIL, Defaults.ENGINE_CYCLE_DURATION_SEED_OIL, 1)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_HONEY), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_HONEY), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_HONEY), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_HONEY), Defaults.ENGINE_FUEL_VALUE_HONEY, Defaults.ENGINE_CYCLE_DURATION_HONEY, 1)); - FuelManager.bronzeEngineFuel.put(LiquidHelper.getFluid(Defaults.LIQUID_JUICE), new EngineBronzeFuel(LiquidHelper.getFluid(Defaults.LIQUID_JUICE), + FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_JUICE), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_JUICE), Defaults.ENGINE_FUEL_VALUE_JUICE, Defaults.ENGINE_CYCLE_DURATION_JUICE, 1)); // Set rain substrates diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 9d7f65071..2eac3fb34 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -10,22 +10,28 @@ ******************************************************************************/ package forestry.core.fluids; -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.inventory.InvTools; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.fluids.*; + +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.IFluidBlock; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; + +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.InvTools; +import forestry.core.utils.StackUtils; /** * @@ -63,7 +69,7 @@ public final class FluidHelper { FluidStack available = tank.drain(side, Integer.MAX_VALUE, false); if (available != null) { - ItemStack filled = fillContainer(available, current); + ItemStack filled = getFilledContainer(available, current); liquid = getFluidStackInContainer(filled); if (liquid != null) { @@ -116,6 +122,10 @@ public final class FluidHelper { } public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { + return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true); + } + + public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) { ItemStack input = inv.getStackInSlot(inputSlot); ItemStack output = inv.getStackInSlot(outputSlot); ItemStack filled = getFilledContainer(fluidToFill, input); @@ -123,12 +133,14 @@ public final class FluidHelper { FluidStack fluidInContainer = getFluidStackInContainer(filled); FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false); if (drain != null && drain.amount == fluidInContainer.amount) { - fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (output == null) - inv.setInventorySlotContents(outputSlot, filled); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); + if (doFill) { + fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); + if (output == null) + inv.setInventorySlotContents(outputSlot, filled); + else + output.stackSize++; + inv.decrStackSize(inputSlot, 1); + } return true; } } @@ -143,30 +155,37 @@ public final class FluidHelper { ItemStack input = inv.getStackInSlot(inputSlot); ItemStack output = inv.getStackInSlot(outputSlot); - if (input != null) { - FluidStack fluidInContainer = getFluidStackInContainer(input); - ItemStack emptyItem = input.getItem().getContainerItem(input); - if (fluidInContainer != null && (emptyItem == null || output == null - || (inputSlot == outputSlot && input.stackSize == 1) - || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) { - int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (used >= fluidInContainer.amount) { - fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (emptyItem != null) - if (output == null) - inv.setInventorySlotContents(outputSlot, emptyItem); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); - return true; - } - } - } - return false; - } + if (input == null) + return false; - public static boolean isBucket(ItemStack stack) { - return FluidContainerRegistry.isBucket(stack); + FluidStack fluidInContainer = getFluidStackInContainer(input); + if (fluidInContainer == null) + return false; + + int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); + if (used < fluidInContainer.amount) + return false; + + fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); + + ItemStack emptyItem = getEmptyContainer(input); + + // unstackable containers like buckets are not consumed + if (outputSlot == inputSlot && input.getMaxStackSize() == 1) { + inv.setInventorySlotContents(outputSlot, emptyItem); + return true; + } + + if (emptyItem != null) { + if (output == null) { + inv.setInventorySlotContents(outputSlot, emptyItem); + } else if (StackUtils.isIdenticalItem(output, emptyItem) && (output.stackSize < output.getMaxStackSize())) { + output.stackSize++; + } + // else output item is consumed + } + inv.decrStackSize(inputSlot, 1); + return true; } public static boolean isContainer(ItemStack stack) { @@ -176,48 +195,116 @@ public final class FluidHelper { } public static boolean isFilledContainer(ItemStack stack) { - return FluidContainerRegistry.isFilledContainer(stack); + if (FluidContainerRegistry.isFilledContainer(stack)) + return true; + + Item item = stack.getItem(); + if (item instanceof IFluidContainerItem) { + IFluidContainerItem containerItem = (IFluidContainerItem)item; + FluidStack fluidStack = containerItem.getFluid(stack); + return fluidStack != null && fluidStack.amount > 0; + } + + return false; } - public static boolean isEmptyContainer(ItemStack stack) { - return FluidContainerRegistry.isEmptyContainer(stack); + public static boolean isFillableContainer(ItemStack empty, FluidStack liquid) { + Item item = empty.getItem(); + if (item instanceof IFluidContainerItem) { + IFluidContainerItem containerItem = (IFluidContainerItem)item; + return containerItem.fill(empty, liquid, false) > 0; + } + + for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty))) + return true; + } + + return false; + } + + public static boolean isEmptyContainer(ItemStack empty) { + + if (FluidContainerRegistry.isEmptyContainer(empty)) + return true; + + Item item = empty.getItem(); + if (item instanceof IFluidContainerItem) { + IFluidContainerItem containerItem = (IFluidContainerItem)item; + FluidStack fluid = containerItem.getFluid(empty); + return fluid == null || fluid.amount == 0; + } + + return false; + } + + public static ItemStack getEmptyContainer(ItemStack container) { + + Item item = container.getItem(); + if (item instanceof IFluidContainerItem) { + ItemStack empty = container.copy(); + empty.stackSize = 1; + IFluidContainerItem containerItem = (IFluidContainerItem) item; + containerItem.drain(empty, Integer.MAX_VALUE, true); + return empty; + } + + return FluidContainerRegistry.drainFluidContainer(container); } public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { - if (fluid == null || empty == null) + if (fluid == null) return null; - return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty); + + FluidStack fluidToFill = new FluidStack(fluid, Integer.MAX_VALUE); + + return getFilledContainer(fluidToFill, empty); } - public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) { - if (fluid == null || empty == null) - return null; - fluid = fluid.copy(); - fluid.amount = Integer.MAX_VALUE; - return FluidContainerRegistry.fillFluidContainer(fluid, empty); - } - - public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) { + public static ItemStack getFilledContainer(FluidStack liquid, ItemStack empty) { if (liquid == null || empty == null) return null; + + Item item = empty.getItem(); + if (item instanceof IFluidContainerItem) { + ItemStack full = empty.copy(); + full.stackSize = 1; + IFluidContainerItem containerItem = (IFluidContainerItem) item; + containerItem.fill(full, liquid, true); + return full; + } + return FluidContainerRegistry.fillFluidContainer(liquid, empty); } public static FluidStack getFluidStackInContainer(ItemStack stack) { + Item item = stack.getItem(); + if (item instanceof IFluidContainerItem) { + IFluidContainerItem containerItem = (IFluidContainerItem) item; + return containerItem.getFluid(stack); + } + return FluidContainerRegistry.getFluidForFilledItem(stack); } - public static Fluid getFluidInContianer(ItemStack stack) { - FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); + public static Fluid getFluidInContainer(ItemStack stack) { + FluidStack fluidStack = getFluidStackInContainer(stack); return fluidStack != null ? fluidStack.getFluid() : null; } public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) { + Item item = stack.getItem(); + if (item instanceof IFluidContainerItem) { + IFluidContainerItem containerItem = (IFluidContainerItem) item; + FluidStack contained = containerItem.getFluid(stack); + return contained != null && contained.containsFluid(fluidStack); + } + return FluidContainerRegistry.containsFluid(stack, fluidStack); } public static boolean containsFluid(ItemStack stack, Fluid fluid) { - return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1)); + return containsFluidStack(stack, new FluidStack(fluid, 1)); } public static boolean isFluidEqual(FluidStack L1, FluidStack L2) { @@ -226,24 +313,6 @@ public final class FluidHelper { return L1.isFluidEqual(L2); } - public static Collection getContainersFilledWith(FluidStack fluidStack) { - List containers = new ArrayList(); - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { - FluidStack inContainer = getFluidStackInContainer(data.filledContainer); - if (inContainer != null && inContainer.containsFluid(fluidStack)) - containers.add(data.filledContainer.copy()); - } - return containers; - } - - public static void nerfWaterBottle() { - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) - if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) { - data.fluid.amount = 333; - return; - } - } - public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) { return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain); } diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 404db46d6..7f4fe43be 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -22,20 +22,22 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.fluids.FluidHelper; import forestry.core.interfaces.IOwnable; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.StringUtil; public class BlockBase extends BlockForestry { @@ -167,7 +169,7 @@ public class BlockBase extends BlockForestry { ItemStack current = player.getCurrentEquippedItem(); if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler) { if (Proxies.common.isSimulating(world)) { - if (LiquidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { + if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { return true; } } else { diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index 41fea59e5..895539cb1 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -118,32 +118,6 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine energyManager.readFromNBT(nbt); } - /* LIQUID CONTAINER HANDLING */ - /** - @deprecated Use FluidHelper - */ - @Deprecated - protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) { - if (tank.getFluidAmount() < container.fluid.amount) - return outputStack; - if (canStack.stackSize <= 0) - return outputStack; - if (outputStack != null && !outputStack.isItemEqual(container.filledContainer)) - return outputStack; - if (outputStack != null && outputStack.stackSize >= outputStack.getMaxStackSize()) - return outputStack; - - tank.drain(container.fluid.amount, true); - canStack.stackSize--; - - if (outputStack == null) - outputStack = container.filledContainer.copy(); - else - outputStack.stackSize++; - - return outputStack; - } - // / ADDITIONAL LIQUID HANDLING @Override public EnumTankLevel getPrimaryLevel() { diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 96c71883e..61254b4a9 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -33,6 +33,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import forestry.core.CreativeTabForestry; +import forestry.core.fluids.FluidHelper; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.LiquidHelper; @@ -149,19 +150,18 @@ public class ItemLiquidContainer extends Item { if (fluid == null || fluid.amount <= 0) return itemstack; - // Check whether there is valid container for the liquid. - FluidContainerData container = LiquidHelper.getEmptyContainer(itemstack, fluid); - if (container == null) + ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemstack); + if (filledContainer == null) return itemstack; // Search for a slot to stow a filled container in player's // inventory - int slot = getMatchingSlot(entityplayer, container.filledContainer); + int slot = getMatchingSlot(entityplayer, filledContainer); if (slot < 0) return itemstack; if (entityplayer.inventory.getStackInSlot(slot) == null) - entityplayer.inventory.setInventorySlotContents(slot, container.filledContainer.copy()); + entityplayer.inventory.setInventorySlotContents(slot, filledContainer.copy()); else entityplayer.inventory.getStackInSlot(slot).stackSize++; diff --git a/src/main/java/forestry/core/utils/FluidStackMap.java b/src/main/java/forestry/core/utils/FluidStackMap.java index 757c2b466..a4a46e677 100755 --- a/src/main/java/forestry/core/utils/FluidStackMap.java +++ b/src/main/java/forestry/core/utils/FluidStackMap.java @@ -11,6 +11,7 @@ package forestry.core.utils; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class FluidStackMap extends StackMap { @@ -38,9 +39,9 @@ public class FluidStackMap extends StackMap { if (key instanceof FluidStack) return (FluidStack) key; if (key instanceof Fluid) - return LiquidHelper.getLiquid(((Fluid) key).getName(), 1); + return FluidRegistry.getFluidStack(((Fluid) key).getName(), 1); if (key instanceof String) - return LiquidHelper.getLiquid((String) key, 1); + return FluidRegistry.getFluidStack((String) key, 1); return null; } diff --git a/src/main/java/forestry/core/utils/Fluids.java b/src/main/java/forestry/core/utils/Fluids.java index 681b8632f..0a011b318 100755 --- a/src/main/java/forestry/core/utils/Fluids.java +++ b/src/main/java/forestry/core/utils/Fluids.java @@ -18,6 +18,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import forestry.core.fluids.FluidHelper; + /** * @author CovertJaguar */ @@ -46,7 +48,7 @@ public enum Fluids { } public boolean isContained(ItemStack containerStack) { - return containerStack != null && LiquidHelper.containsFluid(containerStack, Fluids.WATER.get()); + return containerStack != null && FluidHelper.containsFluid(containerStack, Fluids.WATER.get()); } public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index ac019db20..157ff030f 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -10,83 +10,36 @@ ******************************************************************************/ package forestry.core.utils; -import java.util.HashMap; import java.util.LinkedList; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.common.registry.LanguageRegistry; - -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.IFluidHandler; import forestry.api.recipes.RecipeManagers; -import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.render.TextureManager; public class LiquidHelper { private static final LinkedList myLiquids = new LinkedList(); - private static final HashMap liquidMap = new HashMap(); public static boolean isEmptyLiquidData() { return FluidContainerRegistry.getRegisteredFluidContainerData().length <= 0; } - public static boolean isEmptyContainer(ItemStack empty) { - return FluidContainerRegistry.isEmptyContainer(empty); - } - - public static FluidContainerData getEmptyContainer(ItemStack empty, FluidStack liquid) { - for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (cont.fluid.isFluidEqual(liquid) && (cont.emptyContainer != null && cont.emptyContainer.isItemEqual(empty))) - return cont; - } - - return null; - } - - public static FluidContainerData getLiquidContainer(ItemStack container) { - for (FluidContainerData cont : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (cont.filledContainer.isItemEqual(container)) - return cont; - } - return null; - } - - public static FluidContainerData createLiquidData(String ident, FluidStack stillLiquid, ItemStack filled, ItemStack container) { - return new FluidContainerData(new FluidStack(getOrCreateLiquid(ident), Defaults.BUCKET_VOLUME), filled, container); - } - - public static boolean isLiquid(String ident, FluidStack stack) { - return FluidRegistry.getFluidID(ident) == stack.fluidID; - } - - public static boolean exists(String ident) { - return FluidRegistry.isFluidRegistered(ident); - } - - public static Fluid getFluid(String ident) { - return FluidRegistry.getFluid(ident); - } - public static Fluid getOrCreateLiquid(String ident) { if (!FluidRegistry.isFluidRegistered(ident)) { Fluid fluid = new Fluid(ident); FluidRegistry.registerFluid(fluid); myLiquids.add(ident); } - liquidMap.put(ident, FluidRegistry.getFluid(ident)); return FluidRegistry.getFluid(ident); } @@ -111,7 +64,7 @@ public class LiquidHelper { } public static void injectLiquidContainer(String name, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) { - FluidStack contained = getLiquid(name, volume); + FluidStack contained = FluidRegistry.getFluidStack(name, volume); if (contained == null) throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", name)); @@ -128,140 +81,9 @@ public class LiquidHelper { public static void resetLiquidIcons(IIconRegister register) { for (String fluidString : myLiquids) { - Fluid fluid = getFluid(fluidString); + Fluid fluid = FluidRegistry.getFluid(fluidString); IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName()); fluid.setIcons(icon); - } } - - public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) { - if (player == null) { - return false; - } - ItemStack current = player.inventory.getCurrentItem(); - if (current != null) { - - FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); - - if (fill && liquid != null) { - int used = tank.fill(side, liquid, true); - - if (used > 0) { - if (!player.capabilities.isCreativeMode) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current)); - player.inventory.markDirty(); - } - return true; - } - - } else if (drain) { - - FluidStack available = tank.drain(side, Integer.MAX_VALUE, false); - if (available != null) { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); - - liquid = FluidContainerRegistry.getFluidForFilledItem(filled); - if (liquid != null) { - - if (current.stackSize > 1) { - if (!player.inventory.addItemStackToInventory(filled)) - return false; - player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current)); - player.inventory.markDirty(); - } else { - player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.consumeItem(current)); - player.inventory.setInventorySlotContents(player.inventory.currentItem, filled); - player.inventory.markDirty(); - } - - tank.drain(side, liquid.amount, true); - return true; - } - } - } - } - return false; - } - - public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) { - ItemStack input = inv.getStackInSlot(inputSlot); - - if (input == null) - return; - - if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot)) - return; - - if (processEmpty && fluidToFill != null) - fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill); - } - - public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { - return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true); - } - - public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) { - ItemStack input = inv.getStackInSlot(inputSlot); - ItemStack output = inv.getStackInSlot(outputSlot); - ItemStack filled = getFilledContainer(fluidToFill, input); - if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && StackUtils.isIdenticalItem(filled, output)))) { - FluidStack fluidInContainer = getFluidStackInContainer(filled); - FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (drain != null && drain.amount == fluidInContainer.amount) { - if (doFill) { - fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (output == null) - inv.setInventorySlotContents(outputSlot, filled); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); - } - return true; - } - } - return false; - } - - public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) { - ItemStack input = inv.getStackInSlot(inputSlot); - ItemStack output = inv.getStackInSlot(outputSlot); - - if (input != null) { - FluidStack fluidInContainer = getFluidStackInContainer(input); - ItemStack emptyItem = input.getItem().getContainerItem(input); - if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && StackUtils.isIdenticalItem(output, emptyItem)))) { - int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (used >= fluidInContainer.amount) { - fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (emptyItem != null) - if (output == null) - inv.setInventorySlotContents(outputSlot, emptyItem); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); - return true; - } - } - } - return false; - } - - public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { - if (fluid == null || empty == null) - return null; - return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty); - } - - public static FluidStack getFluidStackInContainer(ItemStack stack) { - return FluidContainerRegistry.getFluidForFilledItem(stack); - } - - public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) { - return FluidContainerRegistry.containsFluid(stack, fluidStack); - } - - public static boolean containsFluid(ItemStack stack, Fluid fluid) { - return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1)); - } } diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 6a51922c9..37341c907 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -10,21 +10,24 @@ ******************************************************************************/ package forestry.core.utils; -import forestry.api.recipes.RecipeManagers; -import forestry.core.config.Defaults; -import forestry.core.gui.ContainerDummy; -import forestry.core.interfaces.IDescriptiveRecipe; -import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import forestry.api.recipes.RecipeManagers; +import forestry.core.config.Defaults; +import forestry.core.gui.ContainerDummy; +import forestry.core.interfaces.IDescriptiveRecipe; +import forestry.core.proxy.Proxies; public class RecipeUtil { @@ -34,13 +37,13 @@ public class RecipeUtil { if (RecipeManagers.fermenterManager == null) return; - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1)); + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1)); - if (LiquidHelper.exists(Defaults.LIQUID_JUICE)) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, 1)); + if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_JUICE)) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, 1)); - if (LiquidHelper.exists(Defaults.LIQUID_HONEY)) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, LiquidHelper.getLiquid(output, 1), LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 1)); + if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_HONEY)) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1)); } /** diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 14ea1fbaf..d4fe11fac 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -396,27 +396,6 @@ public class StackUtils { } - public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, StandardTank tank) { - FluidContainerData container = LiquidHelper.getLiquidContainer(inventoryStack); - replenishByContainer(tile, inventoryStack, container, tank); - } - - public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, 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--; - tile.sendNetworkUpdate(); - } - - return inventoryStack; - } - public static ItemStack copyWithRandomSize(ItemStack template, int max, Random rand) { int size = rand.nextInt(max); ItemStack created = template.copy(); diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index a07753998..28b2cd9d6 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -16,6 +16,7 @@ import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -26,6 +27,8 @@ import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.utils.LiquidHelper; import forestry.core.utils.TileInventoryAdapter; + +import static forestry.factory.gadgets.MachineBottler.SLOT_CAN; import static forestry.factory.gadgets.MachineBottler.SLOT_PRODUCT; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -107,30 +110,14 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank super.updateServerSide(); - // 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) { - - StandardTank tank = null; - - if (heatingTank.accepts(container.fluid.getFluid())) - tank = heatingTank; - else if (fuelTank.accepts(container.fluid.getFluid())) - tank = fuelTank; - - if (tank != null) { - inventory.setInventorySlotContents(SLOT_CAN, replenishByContainer(inventory.getStackInSlot(SLOT_CAN), container, tank)); - if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0) - inventory.setInventorySlotContents(0, null); - } - } - } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; + // Check if we have suitable items waiting in the item slot + if (inventory.getStackInSlot(SLOT_CAN) != null) { + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } + if (getHeatLevel() <= 0.2 && heatingTank.getFluidAmount() <= 0) setErrorState(EnumErrorCode.NOHEAT); else if (burnTime <= 0 && fuelTank.getFluidAmount() <= 0) @@ -451,7 +438,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { if (slotIndex == SLOT_CAN) { - FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack); + FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack); if (fluid == null || fluid.amount <= 0) return false; return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid()); @@ -471,8 +458,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank if (!super.canTakeStackFromSide(slotIndex, stack, side)) return false; - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - return container != null; + return FluidHelper.isContainer(stack); } /** diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index bcec54700..c34933a55 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -18,7 +18,6 @@ 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; import ic2.api.energy.prefab.BasicSource; @@ -30,6 +29,7 @@ import forestry.api.fuels.GeneratorFuel; import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.TankManager; import forestry.core.gadgets.TileBase; @@ -39,8 +39,6 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; import net.minecraftforge.fluids.FluidTankInfo; @@ -119,14 +117,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi // Check inventory slots for fuel // 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) - - 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); - } + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); } // No work to be done if IC2 is unavailable. @@ -236,11 +227,9 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi @Override public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - if (container == null) - return 0; + Fluid fluid = FluidHelper.getFluidInContainer(stack); - if (container.fluid == null || !FuelManager.generatorFuel.containsKey(container.fluid.getFluid())) + if (fluid == null || !FuelManager.generatorFuel.containsKey(fluid)) return 0; if (inventory.getStackInSlot(SLOT_CAN) == null) { diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 0e9d01fcd..0a35a8f9f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -17,6 +17,7 @@ import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICraftingProvider; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; @@ -222,13 +223,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq // 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 && RecipeManager.isInput(container.fluid)) { - - 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); - } + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); } checkRecipe(); @@ -461,8 +456,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq return FluidContainerRegistry.isEmptyContainer(itemstack); if(slotIndex == SLOT_CAN) { - FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); - return container != null && RecipeManager.isInput(container.fluid); + FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); + return RecipeManager.isInput(fluidStack); } return false; diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 3ce691173..5e4b99397 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -10,28 +10,11 @@ ******************************************************************************/ package forestry.factory.gadgets; -import forestry.api.core.ForestryAPI; -import forestry.api.recipes.ICarpenterManager; -import forestry.api.core.EnumErrorCode; -import forestry.core.config.Config; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryItem; -import forestry.core.fluids.TankManager; -import forestry.core.fluids.tanks.FilteredTank; -import forestry.core.gadgets.TileBase; -import forestry.core.gadgets.TilePowered; -import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.ShapedRecipeCustom; -import forestry.core.utils.StackUtils; -import forestry.core.utils.TileInventoryAdapter; -import forestry.core.utils.Utils; -import forestry.factory.gui.ContainerCarpenter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -42,17 +25,36 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; 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.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; +import forestry.api.core.EnumErrorCode; +import forestry.api.core.ForestryAPI; +import forestry.api.recipes.ICarpenterManager; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FilteredTank; +import forestry.core.gadgets.TileBase; +import forestry.core.gadgets.TilePowered; +import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.network.EntityNetData; +import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; +import forestry.core.utils.EnumTankLevel; +import forestry.core.utils.InventoryAdapter; +import forestry.core.utils.ShapedRecipeCustom; +import forestry.core.utils.StackUtils; +import forestry.core.utils.TileInventoryAdapter; +import forestry.core.utils.Utils; +import forestry.factory.gui.ContainerCarpenter; public class MachineCarpenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -144,14 +146,14 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void addCrating(ItemStack itemStack) { ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated }); - addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", Character.valueOf('#'), itemStack }); + addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack }); } @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate }); addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated }); } @@ -322,22 +324,15 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) return; // Check if we have suitable items waiting in the item slot if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT) != null) { - FluidContainerData container = LiquidHelper.getLiquidContainer(accessibleInventory.getStackInSlot(SLOT_CAN_INPUT)); - if (container != null && RecipeManager.isResourceLiquid(container.fluid)) { - - accessibleInventory.setInventorySlotContents(SLOT_CAN_INPUT, - StackUtils.replenishByContainer(this, accessibleInventory.getStackInSlot(SLOT_CAN_INPUT), container, resourceTank)); - if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0) - accessibleInventory.setInventorySlotContents(SLOT_CAN_INPUT, null); - } + FluidHelper.drainContainers(tankManager, accessibleInventory, SLOT_CAN_INPUT); } - if (worldObj.getTotalWorldTime() % 40 * 10 != 0) + if (worldObj.getTotalWorldTime() % 40 != 0) return; if (currentRecipe == null) { diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 3b1925a95..a64926b2e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -10,8 +10,29 @@ ******************************************************************************/ package forestry.factory.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import cpw.mods.fml.common.Optional; + import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; @@ -19,6 +40,7 @@ import forestry.api.recipes.IFermenterManager; import forestry.api.recipes.IVariableFermentable; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -29,29 +51,10 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Map; +import buildcraft.api.statements.ITriggerExternal; public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -135,7 +138,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output) { - addRecipe(resource, fermentationValue, modifier, output, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000)); + addRecipe(resource, fermentationValue, modifier, output, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000)); } public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { @@ -161,6 +164,8 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } public static boolean isLiquidResource(FluidStack liquid) { + if (liquid == null) + return false; return recipeFluidInputs.contains(liquid.getFluid()); } @@ -247,33 +252,20 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void updateServerSide() { - // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_INPUT) != null) { - - FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_INPUT)); - if (container != null && RecipeManager.isLiquidResource(container.fluid)) { - - inventory.setInventorySlotContents(SLOT_INPUT, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_INPUT), container, resourceTank)); - if (inventory.getStackInSlot(SLOT_INPUT).stackSize <= 0) - inventory.setInventorySlotContents(SLOT_INPUT, null); - - } - } - // Can/capsule input/output needs to be handled here. - if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { - FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), productTank.getFluid()); - - if (container != null) { - inventory.setInventorySlotContents(SLOT_CAN_OUTPUT, bottleIntoContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), inventory.getStackInSlot(SLOT_CAN_OUTPUT), container, - productTank)); - if (inventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0) - inventory.setInventorySlotContents(SLOT_CAN_INPUT, null); - } - } - - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) return; + // Check if we have suitable items waiting in the item slot + if (inventory.getStackInSlot(SLOT_INPUT) != null) { + FluidHelper.drainContainers(tankManager, inventory, SLOT_INPUT); + } + + // Can/capsule input/output needs to be handled here. + if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { + FluidStack fluidStack = productTank.getFluid(); + if (fluidStack != null) + FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid()); + } if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) { if (resourceTank.getFluidAmount() < fuelCurrentFerment) @@ -550,11 +542,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL if (slotIndex == SLOT_INPUT) { - FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); - return container != null && RecipeManager.isLiquidResource(container.fluid); + FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); + return RecipeManager.isLiquidResource(fluidStack); } - if (slotIndex == SLOT_CAN_INPUT && LiquidHelper.isEmptyContainer(itemstack)) { + if (slotIndex == SLOT_CAN_INPUT && FluidHelper.isEmptyContainer(itemstack)) { return true; } if (slotIndex == SLOT_FUEL && FuelManager.fermenterFuel.containsKey(itemstack)) diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index c3970bdec..10d635ced 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -18,6 +18,7 @@ import forestry.api.fuels.MoistenerFuel; import forestry.api.recipes.IMoistenerManager; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; @@ -27,7 +28,6 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; @@ -38,7 +38,6 @@ 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; @@ -204,13 +203,7 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi // 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 && 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) - inventory.setInventorySlotContents(SLOT_PRODUCT, null); - } + FluidHelper.drainContainers(tankManager, inventory, SLOT_PRODUCT); } // Let's get to work @@ -620,8 +613,8 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi @Override public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - if (container != null && resourceTank.accepts(container.fluid.getFluid())) { + Fluid fluid = FluidHelper.getFluidInContainer(stack); + if (fluid != null && resourceTank.accepts(fluid)) { return inventory.addStack(stack, SLOT_PRODUCT, 1, false, doAdd); } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 64d5ae494..939587e67 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -10,21 +10,6 @@ ******************************************************************************/ package forestry.factory.gadgets; -import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumErrorCode; -import forestry.api.core.ForestryAPI; -import forestry.core.config.Config; -import forestry.core.config.Defaults; -import forestry.core.fluids.TankManager; -import forestry.core.fluids.tanks.FilteredTank; -import forestry.core.gadgets.TileBase; -import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.GuiId; -import forestry.core.utils.Fluids; -import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -32,18 +17,35 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; 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 net.minecraftforge.fluids.FluidTankInfo; +import forestry.api.core.BiomeHelper; +import forestry.api.core.EnumErrorCode; +import forestry.api.core.ForestryAPI; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FilteredTank; +import forestry.core.gadgets.TileBase; +import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.network.GuiId; +import forestry.core.utils.Fluids; +import forestry.core.utils.InventoryAdapter; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; + public class MachineRaintank extends TileBase implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ public static final short SLOT_RESOURCE = 0; public static final short SLOT_PRODUCT = 1; - private static final FluidStack STACK_WATER = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE); + private static final FluidStack STACK_WATER = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ public FilteredTank resourceTank; @@ -132,7 +134,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui tryToStartFillling(); else { fillingTime--; - if (fillingTime <= 0 && LiquidHelper.fillContainers(this, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get())) + if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get())) fillingTime = 0; } } @@ -143,7 +145,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private void tryToStartFillling() { // Nothing to do if no empty cans are available - if (!LiquidHelper.fillContainers(this, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false)) + if (!FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false)) return; fillingTime = Defaults.RAINTANK_FILLING_TIME; @@ -262,7 +264,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui if (slotIndex != SLOT_RESOURCE) return false; - return LiquidHelper.getEmptyContainer(itemstack, STACK_WATER) != null; + return FluidHelper.isFillableContainer(itemstack, STACK_WATER); } /* SMP GUI */ diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index b51346295..62b618155 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -16,6 +16,7 @@ import forestry.api.recipes.ISqueezerManager; import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -230,21 +231,16 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I @Override public void updateServerSide() { + if (worldObj.getTotalWorldTime() % 20 != 0) + return; + // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { - - FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), productTank.getFluid()); - if (container != null) { - inventory.setInventorySlotContents(SLOT_CAN_OUTPUT, bottleIntoContainer(inventory.getStackInSlot(SLOT_CAN_INPUT), inventory.getStackInSlot(SLOT_CAN_OUTPUT), container, productTank)); - if (inventory.getStackInSlot(SLOT_CAN_INPUT).stackSize <= 0) - inventory.setInventorySlotContents(SLOT_CAN_INPUT, null); - } - + FluidStack fluidStack = productTank.getFluid(); + if (fluidStack != null) + FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid()); } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) - return; - checkRecipe(); if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) setErrorState(EnumErrorCode.OK); @@ -436,11 +432,11 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { if(slotIndex == SLOT_CAN_INPUT) { - return LiquidHelper.isEmptyContainer(itemstack); + return FluidHelper.isEmptyContainer(itemstack); } if(slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { - if (LiquidHelper.isEmptyContainer(itemstack)) + if (FluidHelper.isEmptyContainer(itemstack)) return false; if (RecipeManager.canUse(itemstack)) @@ -504,7 +500,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { // Try to add to can slot if input is from top or bottom. - if (LiquidHelper.isEmptyContainer(stack)) { + if (FluidHelper.isEmptyContainer(stack)) { return inventory.addStack(stack, SLOT_CAN_INPUT, 1, false, doAdd); } else { return inventory.addStack(stack, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, false, doAdd); diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index bf5ded4ea..132f242fb 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -10,12 +10,30 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IStillManager; -import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -26,25 +44,8 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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; -import net.minecraftforge.fluids.FluidTankInfo; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; public class MachineStill extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer { @@ -177,32 +178,22 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid @Override public void updateServerSide() { + if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + return; + // 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 && 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); - - } + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); } // Can product liquid if possible if (inventory.getStackInSlot(SLOT_RESOURCE) != null) { - FluidContainerData container = LiquidHelper.getEmptyContainer(inventory.getStackInSlot(SLOT_RESOURCE), productTank.getFluid()); - if (container != null) { - inventory.setInventorySlotContents(SLOT_PRODUCT, bottleIntoContainer(inventory.getStackInSlot(SLOT_RESOURCE), inventory.getStackInSlot(SLOT_PRODUCT), container, productTank)); - if (inventory.getStackInSlot(SLOT_RESOURCE).stackSize <= 0) - inventory.setInventorySlotContents(SLOT_RESOURCE, null); + FluidStack fluidStack = productTank.getFluid(); + if (fluidStack != null) { + FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, fluidStack.getFluid()); } } - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) - return; - checkRecipe(); if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) setErrorState(EnumErrorCode.OK); @@ -335,10 +326,10 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { int inventorySlot; - FluidContainerData container = LiquidHelper.getLiquidContainer(stack); - if (container != null && resourceTank.accepts(container.fluid.getFluid())) + Fluid fluid = FluidHelper.getFluidInContainer(stack); + if (fluid != null && resourceTank.accepts(fluid)) inventorySlot = SLOT_CAN; - else if (LiquidHelper.isEmptyContainer(stack)) + else if (FluidHelper.isEmptyContainer(stack)) inventorySlot = SLOT_RESOURCE; else return 0; @@ -447,11 +438,11 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid return false; if(slotIndex == SLOT_RESOURCE) - return LiquidHelper.isEmptyContainer(itemstack); + return FluidHelper.isEmptyContainer(itemstack); if(slotIndex == SLOT_CAN) { - FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); - return container != null && resourceTank.accepts(container.fluid.getFluid()); + Fluid fluid = FluidHelper.getFluidInContainer(itemstack); + return fluid != null && resourceTank.accepts(fluid); } return false; diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 5aefa40f8..b0014ebd1 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -29,7 +29,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -48,16 +47,15 @@ import forestry.api.farming.IFarmable; import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Defaults; +import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; -import forestry.core.fluids.tanks.StandardTank; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IHintSource; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.core.utils.DelayTimer; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.TileInventoryAdapter; import forestry.core.utils.Utils; @@ -169,13 +167,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 && tankManager.accepts(container.fluid.getFluid())) { - StandardTank liquidTank = tankManager.get(0); - inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, liquidTank)); - if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0) - inventory.setInventorySlotContents(SLOT_CAN, null); - } + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); } } @@ -442,7 +434,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable else hasFertilizer = true; - FluidStack liquid = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) continue; else @@ -565,7 +557,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } // Check water - FluidStack liquid = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, provider.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, provider.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) { setErrorState(EnumErrorCode.NOLIQUID); return false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 5a0281b50..a2b50cdea 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -23,6 +23,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -33,7 +34,7 @@ public abstract class FarmLogicWatered extends FarmLogic { protected ItemStack ground; private final ItemStack[] resource; - private static final FluidStack STACK_WATER = new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_WATER), 1000); + private static final FluidStack STACK_WATER = new FluidStack(FluidRegistry.getFluid(Defaults.LIQUID_WATER), 1000); ArrayList produce = new ArrayList(); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index b2dc4fbd1..4ab0a92be 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -25,11 +25,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.util.IIcon; import net.minecraft.util.WeightedRandomChestContent; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -40,6 +43,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -156,7 +160,6 @@ import forestry.core.items.ItemOverlay.OverlayInfo; import forestry.core.items.ItemScoop; import forestry.core.proxy.Proxies; import forestry.core.render.EntitySnowFX; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; @Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description") @@ -560,13 +563,13 @@ public class PluginApiculture extends ForestryPlugin { '#', ForestryItem.propolis.getItemStack(1, 2)); // / CANDLES - RecipeManagers.carpenterManager.addRecipe(30, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 600), null, ForestryBlock.candle.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(30, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 600), null, ForestryBlock.candle.getItemStack(24), " X ", "###", "###", '#', ForestryItem.beeswax, 'X', Items.string); - RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 200), null, ForestryBlock.candle.getItemStack(6), + RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 200), null, ForestryBlock.candle.getItemStack(6), "#X#", '#', ForestryItem.beeswax, 'X', ForestryItem.craftingMaterial.getItemStack(1, 2)); @@ -636,20 +639,20 @@ public class PluginApiculture extends ForestryPlugin { 'W', ForestryItem.craftingMaterial.getItemStack(1, 3)); // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP), + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP), ForestryItem.propolis.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 2000)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 2000)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600)); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.beealyzer.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.beealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotTin", 'R', Items.redstone, 'D', Items.diamond); - RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), + RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), " J ", "###", "WPW", '#', "plankWood", 'J', ForestryItem.royalJelly, @@ -704,8 +707,8 @@ public class PluginApiculture extends ForestryPlugin { ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10}); // / FERMENTER - RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, LiquidHelper.getLiquid(Defaults.LIQUID_MEAD, 1), - LiquidHelper.getLiquid(Defaults.LIQUID_HONEY, 1)); + RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, FluidRegistry.getFluidStack(Defaults.LIQUID_MEAD, 1), + FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1)); // ANALYZER definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index e507bde93..2f33f7e73 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -10,6 +10,24 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.command.ICommand; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; + +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -17,6 +35,7 @@ import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeRoot; @@ -122,24 +141,8 @@ import forestry.core.interfaces.IPacketHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemFruit.EnumFruit; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.RecipeUtil; import forestry.core.utils.ShapedRecipeCustom; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; @Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description") public class PluginArboriculture extends ForestryPlugin { @@ -409,7 +412,7 @@ public class PluginArboriculture extends ForestryPlugin { ItemStack logStack = forestryBlock.getItemStack(1, i); ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofLogStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofLogStack, new Object[]{ " # ", "#X#", " # ", @@ -424,7 +427,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -436,7 +439,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -474,20 +477,20 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i)); // Treealyzer - RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", + RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotCopper", 'R', Items.redstone, 'D', Items.diamond); // SQUEEZER RECIPES - RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 18 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 22 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 2); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.5f)), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 3); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.DATES.ordinal())}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.25)), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"))); + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 18 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 22 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 2); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.5f)), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 3); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.DATES.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.25)), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"))); RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index 79ce9b58f..002241592 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -10,14 +10,18 @@ ******************************************************************************/ package forestry.plugins; -import buildcraft.api.fuels.BuildcraftFuelRegistry; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + import cpw.mods.fml.common.Optional; + import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; -import net.minecraftforge.fluids.Fluid; + +import buildcraft.api.fuels.BuildcraftFuelRegistry; @Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends ForestryPlugin { @@ -35,9 +39,9 @@ public class PluginBuildCraftFuels extends ForestryPlugin { @Optional.Method(modid = "BuildCraftAPI|fuels") @Override public void doInit() { - BuildcraftFuelRegistry.coolant.addCoolant(LiquidHelper.getFluid(Defaults.LIQUID_ICE), 10.0f); + BuildcraftFuelRegistry.coolant.addCoolant(FluidRegistry.getFluid(Defaults.LIQUID_ICE), 10.0f); - Fluid ethanol = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1).getFluid(); + Fluid ethanol = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1).getFluid(); int ethanolPower = 40; int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 632880e42..9224ffe1c 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -10,12 +10,15 @@ ******************************************************************************/ package forestry.plugins; -import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import cpw.mods.fml.common.Optional; + import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; -import net.minecraftforge.fluids.FluidStack; + +import buildcraft.api.recipes.BuildcraftRecipeRegistry; @Plugin(pluginID = "BC6|Recipes", name = "BuildCraft 6 Recipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftRecipes extends ForestryPlugin { @@ -34,8 +37,8 @@ public class PluginBuildCraftRecipes extends ForestryPlugin { @Override protected void registerRecipes() { // Add recipe for ethanol - FluidStack input = LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, 4); - FluidStack output = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1); + FluidStack input = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 4); + FluidStack output = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1); BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", input, output, 100, 1); } } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index 05eec8e43..ccf9e261f 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -10,7 +10,17 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; + +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.FluidRegistry; + import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.recipes.ICraftingProvider; import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; @@ -25,7 +35,6 @@ import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.RecipeUtil; import forestry.core.utils.ShapedRecipeCustom; import forestry.factory.GuiHandlerFactory; @@ -42,12 +51,6 @@ import forestry.factory.gadgets.MillRainmaker; import forestry.factory.gadgets.TileWorktable; import forestry.factory.recipes.CraftGuideIntegration; import forestry.factory.triggers.FactoryTriggers; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; @Plugin(pluginID = "Factory", name = "Factory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.factory.description") public class PluginFactory extends ForestryPlugin { @@ -250,27 +253,27 @@ public class PluginFactory extends ForestryPlugin { protected void registerRecipes() { // / FABRICATOR - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 10), + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 10), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"}); - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 11), + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 11), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", @@ -278,28 +281,28 @@ public class PluginFactory extends ForestryPlugin { if (PluginManager.Module.APICULTURE.isEnabled()) for (int i = 0; i < 16; i++) - RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, + RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, Defaults.BUCKET_VOLUME), ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i], 'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)}); // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple")), + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple")), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple")); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, GameMode + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)}, - LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1600)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 500)); + FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500)); RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)}, - LiquidHelper.getLiquid(Defaults.LIQUID_ICE, 4000)); + FluidRegistry.getFluidStack(Defaults.LIQUID_ICE, 4000)); // STILL - RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, LiquidHelper.getLiquid(Defaults.LIQUID_BIOMASS, - Defaults.STILL_DESTILLATION_INPUT), LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, Defaults.STILL_DESTILLATION_OUTPUT)); + RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, + Defaults.STILL_DESTILLATION_INPUT), FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, Defaults.STILL_DESTILLATION_OUTPUT)); // MOISTENER RecipeManagers.moistenerManager.addRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Blocks.mycelium), 5000); @@ -319,17 +322,17 @@ public class PluginFactory extends ForestryPlugin { RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.red_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Defaults.LIQUID_BIOMASS); // FABRICATOR - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 1000), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 375), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 1000), 3000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 375), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 3000); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 250), null, ForestryItem.impregnatedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 250), null, ForestryItem.impregnatedCasing.getItemStack(), "###", "# #", "###", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(50, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 500), null, + RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 500), null, ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META), "# ", "###", @@ -337,35 +340,35 @@ public class PluginFactory extends ForestryPlugin { '#', "plankWood"); // RESOURCES - RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 100), null, + RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 100), null, ForestryItem.stickImpregnated.getItemStack(2), "#", "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null, + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, ForestryItem.woodPulp.getItemStack(4), "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null, + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, new ItemStack(Items.paper, 1), "#", "#", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryBlock.soil.getItemStack(9), "###", "#X#", "###", '#', Blocks.dirt, 'X', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryBlock.soil.getItemStack(8, 1), "#X#", "XYX", "#X#", '#', Blocks.dirt, 'X', Blocks.sand, 'Y', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(75, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 5000), null, ForestryItem.hardenedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(75, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 5000), null, ForestryItem.hardenedCasing.getItemStack(), "# #", " Y ", "# #", @@ -373,21 +376,21 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.sturdyCasing); // / CHIPSETS - RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0), + RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0), "R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1), + RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1), "R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2), + RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2), "R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3), "R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(), " # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze"); // ForestryCore.oreHandler.registerCarpenterRecipe(solderingIron); // RAIN SUBSTRATES if (PluginManager.Module.APICULTURE.isEnabled()) { - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.iodineCharge.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.iodineCharge.getItemStack(), "Z#Z", "#Y#", "X#X", @@ -396,7 +399,7 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.canEmpty, 'Z', ForestryItem.honeyDrop); // ForestryCore.oreHandler.registerCarpenterRecipe(iodineCapsule); - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), "Z#Z", "#Y#", "X#X", @@ -411,13 +414,13 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), " # ", "###", " # ", '#', ForestryItem.craftingMaterial.getItemStack(1, 1)); // Woven Silk - RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), "###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2)); // Boxes - RecipeManagers.carpenterManager.addRecipe(5, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2), + RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2), " # ", "# #", " # ", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(20, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24), " # ", "# #", " # ", '#', "logWood"); // Assembly Kits diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index ab30f2500..1360c94f1 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -10,9 +10,19 @@ ******************************************************************************/ package forestry.plugins; +import java.util.EnumSet; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitLayout; import forestry.api.fuels.FuelManager; @@ -45,15 +55,10 @@ import forestry.energy.gadgets.EngineTin; import forestry.energy.gadgets.MachineGenerator; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicRubber; + import ic2.api.item.IC2Items; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.Recipes; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import java.util.EnumSet; @Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends ForestryPlugin { @@ -195,11 +200,11 @@ public class PluginIC2 extends ForestryPlugin { definitionEngineTin.register(); definitionGenerator.register(); - FluidStack ethanol = LiquidHelper.getLiquid(Defaults.LIQUID_ETHANOL, 1); + FluidStack ethanol = FluidRegistry.getFluidStack(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); + FluidStack biomass = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 1); GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1); FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel); @@ -265,7 +270,7 @@ public class PluginIC2 extends ForestryPlugin { if (rubber != null) { for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { - RecipeManagers.fabricatorManager.addRecipe(null, LiquidHelper.getLiquid(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8), + RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', rubberOreDict}); } } diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index 1630ac097..b2ad5d5bd 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -17,6 +17,8 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.crafting.CraftingManager; + +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.RecipeSorter; import cpw.mods.fml.common.SidedProxy; @@ -42,7 +44,6 @@ import forestry.core.gadgets.MachineDefinition; import forestry.core.genetics.Allele; import forestry.core.genetics.Branch; import forestry.core.items.ItemForestryBlock; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.Utils; import forestry.lepidopterology.ButterflySpawner; @@ -148,9 +149,9 @@ public class PluginLepidopterology extends ForestryPlugin { protected void registerRecipes() { CraftingManager.getInstance().getRecipeList().add(new MatingRecipe()); - RecipeManagers.carpenterManager.addRecipe(100, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(), - "X#X", "X#X", "RDR", Character.valueOf('#'), Blocks.glass_pane, Character.valueOf('X'), "ingotBronze", Character.valueOf('R'), - Items.redstone, Character.valueOf('D'), Items.diamond); + RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(), + "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotBronze", 'R', + Items.redstone, 'D', Items.diamond); } private void createAlleles() { diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index b98c89c30..d3ac0b401 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -16,9 +16,12 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; + import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; +import forestry.api.mail.EnumAddressee; import forestry.api.mail.EnumPostage; import forestry.api.mail.PostManager; import forestry.api.recipes.RecipeManagers; @@ -34,9 +37,7 @@ import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.triggers.Trigger; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; -import forestry.api.mail.EnumAddressee; import forestry.mail.GuiHandlerMail; import forestry.mail.PacketHandlerMail; import forestry.mail.PostRegistry; @@ -201,7 +202,7 @@ public class PluginMail extends ForestryPlugin { 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper, 'Z', stampGlue); - RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, 300), null, ForestryItem.stamps.getItemStack(9, i), + RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 300), null, ForestryItem.stamps.getItemStack(9, i), "XXX", "###", 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper); @@ -211,7 +212,7 @@ public class PluginMail extends ForestryPlugin { Proxies.common.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, Defaults.WILDCARD)); // Carpenter - RecipeManagers.carpenterManager.addRecipe(10, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); + RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); Proxies.common.addShapelessRecipe(ForestryItem.catalogue.getItemStack(), ForestryItem.stamps.getItemStack(1, Defaults.WILDCARD), new ItemStack(Items.book)); } diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 8611c3700..0e5a07b95 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -12,19 +12,20 @@ package forestry.plugins; import java.util.ArrayList; -import cpw.mods.fml.common.registry.GameData; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; + import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; @Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description") public class PluginNatura extends ForestryPlugin { @@ -86,7 +87,7 @@ public class PluginNatura extends ForestryPlugin { int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); for (ItemStack aSeedList : seedList) RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, - LiquidHelper.getLiquid(Defaults.LIQUID_SEEDOIL, amount)); + FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, amount)); ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); @@ -119,7 +120,7 @@ public class PluginNatura extends ForestryPlugin { amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. for (ItemStack berry : berries) RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, - LiquidHelper.getLiquid(Defaults.LIQUID_JUICE, amount)); + FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, amount)); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index c8bfb475d..94708ad26 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -41,14 +41,15 @@ import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.IShearable; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.IShearable; -import net.minecraftforge.oredict.OreDictionary; - import forestry.api.core.Tabs; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; @@ -66,7 +67,6 @@ import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.storage.BackpackDefinition; import forestry.storage.BackpackHelper; import forestry.storage.GuiHandlerStorage; @@ -504,22 +504,22 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl // / CARPENTER // / BACKPACKS T2 - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, LiquidHelper.getLiquid(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack); From 792ab77a488b9954ed35b236da922a67716139bd Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 13 Dec 2014 18:20:52 -0800 Subject: [PATCH 042/175] More Inventory rewrite stuff. --- .../forestry/core/fluids/FluidHelper.java | 4 + .../forestry/core/inventory/InvTools.java | 34 +- .../manipulators/InventoryManipulator.java | 3 - .../manipulators/SpecialManipulator.java | 101 ----- .../wrappers/SpecialInventoryMapper.java | 47 -- .../java/forestry/core/utils/StackUtils.java | 3 - .../factory/gadgets/MachineBottler.java | 9 - .../factory/gadgets/MachineCentrifuge.java | 5 - .../factory/gadgets/MachineFabricator.java | 161 ++++--- .../factory/gadgets/MachineFermenter.java | 154 +++---- .../factory/gadgets/MachineMoistener.java | 422 ++++++++---------- .../factory/gadgets/MachineRaintank.java | 107 ++--- .../factory/gadgets/MachineSqueezer.java | 186 +++----- .../factory/gadgets/MachineStill.java | 203 ++++----- .../factory/gadgets/MillRainmaker.java | 167 ++++--- .../factory/gadgets/TileWorktable.java | 27 +- .../forestry/farming/gadgets/TileFarm.java | 11 +- .../farming/gadgets/TileFarmPlain.java | 29 +- .../forestry/farming/gadgets/TileHatch.java | 118 ++--- .../forestry/mail/gadgets/MachineMailbox.java | 234 +++++----- .../mail/gadgets/MachinePhilatelist.java | 55 +-- .../forestry/mail/gadgets/MachineTrader.java | 61 +-- .../forestry/mail/gui/ContainerMailbox.java | 10 +- 23 files changed, 805 insertions(+), 1346 deletions(-) delete mode 100755 src/main/java/forestry/core/inventory/manipulators/SpecialManipulator.java delete mode 100755 src/main/java/forestry/core/inventory/wrappers/SpecialInventoryMapper.java diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 2eac3fb34..b4450bb81 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -251,6 +251,10 @@ public final class FluidHelper { return FluidContainerRegistry.drainFluidContainer(container); } + + public static ItemStack getFullyDrainedContainer(ItemStack container) { + return container.getItem().getContainerItem(container); + } public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { if (fluid == null) diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index b4b973c1c..d0c13abf2 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -33,7 +33,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; import buildcraft.api.transport.PipeManager; - import forestry.api.core.ISpecialInventory; import forestry.core.inventory.filters.ArrayStackFilter; import forestry.core.inventory.filters.IStackFilter; @@ -45,7 +44,6 @@ import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; -import forestry.core.inventory.wrappers.SpecialInventoryMapper; import forestry.core.utils.PlainInventory; public abstract class InvTools { @@ -130,9 +128,7 @@ public abstract class InvTools { public boolean matches(TileEntity tile) { if (type != null && !type.isAssignableFrom(tile.getClass())) return false; - if (exclude != null && exclude.isAssignableFrom(tile.getClass())) - return false; - return true; + return !(exclude != null && exclude.isAssignableFrom(tile.getClass())); } }); } @@ -161,10 +157,7 @@ public abstract class InvTools { public static IInventory getInventory(IInventory inv, ForgeDirection side) { if (inv == null) return null; - - if (inv instanceof ISpecialInventory) - inv = new SpecialInventoryMapper((ISpecialInventory) inv, side); - else if (inv instanceof ISidedInventory) + if (inv instanceof ISidedInventory) inv = new SidedInventoryMapper((ISidedInventory) inv, side); return inv; } @@ -318,9 +311,8 @@ public abstract class InvTools { return countItems(inv); int count = 0; - ItemStack stack = null; - for (int slot = 0; slot < inv.getSizeInventory(); slot++) { - stack = inv.getStackInSlot(slot); + for (IInvSlot slot : InventoryIterator.getIterable(inv)) { + ItemStack stack = slot.getStackInSlot(); if (stack != null) for (ItemStack filter : filters) { if (filter != null && isItemEqual(stack, filter)) { @@ -392,7 +384,7 @@ public abstract class InvTools { * * @param source * @param dest - * @param filer an ItemStack[] to match against + * @param filters an ItemStack[] to match against * @return null if nothing was moved, the stack moved otherwise */ public static ItemStack moveOneItem(IInventory source, IInventory dest, ItemStack... filters) { @@ -404,7 +396,7 @@ public abstract class InvTools { * * @param source * @param dest - * @param filer an IItemType to match against + * @param filter an IItemType to match against * @return null if nothing was moved, the stack moved otherwise */ public static ItemStack moveOneItem(IInventory source, IInventory dest, IStackFilter filter) { @@ -434,7 +426,7 @@ public abstract class InvTools { * * @param sources * @param dest - * @param filters + * @param filter * @return */ public static ItemStack moveOneItem(Collection sources, IInventory dest, IStackFilter filter) { @@ -449,8 +441,8 @@ public abstract class InvTools { /** * Attempts to move one item to a collection of inventories. * - * @param sources - * @param dest + * @param source + * @param destinations * @param filters * @return */ @@ -470,7 +462,7 @@ public abstract class InvTools { * * @param source * @param dest - * @param filer an ItemStack[] to exclude + * @param filters an ItemStack[] to exclude * @return null if nothing was moved, the stack moved otherwise */ public static ItemStack moveOneItemExcept(IInventory source, IInventory dest, ItemStack... filters) { @@ -497,8 +489,8 @@ public abstract class InvTools { /** * Attempts to move one item to a collection of inventories. * - * @param sources - * @param dest + * @param source + * @param destinations * @param filters * @return */ @@ -750,7 +742,7 @@ public abstract class InvTools { * Removes and returns a single item from the inventory that matches the * filter. * - * @param inv The inventory + * @param invs The inventory * @param filter EnumItemType to match against * @return An ItemStack */ diff --git a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java index 8d1a6fcfd..0b175bfd1 100755 --- a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java +++ b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java @@ -30,9 +30,6 @@ public class InventoryManipulator { private final IInventory inv; public static InventoryManipulator get(IInventory inv) { - if (inv instanceof ISpecialInventory) { - return new SpecialManipulator((ISpecialInventory) inv); - } return new InventoryManipulator(inv); } diff --git a/src/main/java/forestry/core/inventory/manipulators/SpecialManipulator.java b/src/main/java/forestry/core/inventory/manipulators/SpecialManipulator.java deleted file mode 100755 index e9547b537..000000000 --- a/src/main/java/forestry/core/inventory/manipulators/SpecialManipulator.java +++ /dev/null @@ -1,101 +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.inventory.manipulators; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.common.util.ForgeDirection; - -import forestry.api.core.ISpecialInventory; -import forestry.core.inventory.filters.IStackFilter; - -/** - * - * @author CovertJaguar - */ -public class SpecialManipulator extends InventoryManipulator { - - private final ISpecialInventory inv; - protected ForgeDirection side = ForgeDirection.UNKNOWN; - - protected SpecialManipulator(ISpecialInventory inv) { - super(inv); - this.inv = inv; - } - - public void setSide(ForgeDirection side) { - this.side = side; - } - - @Override - public ItemStack tryAddStack(ItemStack stack) { - return addStackInternal(stack, false); - } - - @Override - public ItemStack addStack(ItemStack stack) { - return addStackInternal(stack, true); - } - - private ItemStack addStackInternal(ItemStack stack, boolean doAdd) { - if (stack == null) { - return null; - } - stack = stack.copy(); - int used = inv.addItem(stack.copy(), doAdd, side); - if (used >= stack.stackSize) { - return null; - } - stack.stackSize -= used; - return stack; - } - - @Override - public boolean canRemoveItem(IStackFilter filter) { - return tryRemoveItem(filter) == null; - } - - @Override - public ItemStack tryRemoveItem(IStackFilter filter) { - return removeStackInternal(filter, false); - } - - @Override - public ItemStack removeItem(IStackFilter filter) { - return removeStackInternal(filter, true); - } - - protected ItemStack removeStackInternal(IStackFilter filter, boolean doRemove) { - ItemStack[] extracted = inv.extractItem(false, side, 1); - if (extracted != null && extracted.length > 0 && filter.matches(extracted[0])) { - if (doRemove) { - inv.extractItem(true, side, 1); - } - return extracted[0]; - } - return null; - } - - @Override - public ItemStack moveItem(IInventory dest, IStackFilter filter) { - InventoryManipulator imDest = InventoryManipulator.get(dest); - ItemStack stack = tryRemoveItem(filter); - if (stack != null) { - ItemStack result = imDest.addStack(stack); - if (result == null) { - return removeItem(filter); - } - } - return null; - } - -} diff --git a/src/main/java/forestry/core/inventory/wrappers/SpecialInventoryMapper.java b/src/main/java/forestry/core/inventory/wrappers/SpecialInventoryMapper.java deleted file mode 100755 index e84c74e98..000000000 --- a/src/main/java/forestry/core/inventory/wrappers/SpecialInventoryMapper.java +++ /dev/null @@ -1,47 +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.inventory.wrappers; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.common.util.ForgeDirection; - -import forestry.api.core.ISpecialInventory; - -/** - * - * @author CovertJaguar - */ -public class SpecialInventoryMapper extends InventoryMapper implements ISpecialInventory -{ - - private final ISpecialInventory inv; - protected final ForgeDirection side; - - public SpecialInventoryMapper(ISpecialInventory inv, ForgeDirection side) - { - super(inv, side); - this.inv = inv; - this.side = side; - } - - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) - { - return inv.addItem(stack, doAdd, side); - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) - { - return inv.extractItem(doRemove, side, maxItemCount); - } -} diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 7f0b17cb8..e6d04335b 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -26,12 +26,9 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.oredict.OreDictionary; import forestry.core.config.Defaults; -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.gadgets.TileForestry; public class StackUtils { diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index e6fc6f40d..4d327eb7d 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -27,8 +27,6 @@ import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; import net.minecraft.entity.player.EntityPlayer; @@ -42,7 +40,6 @@ import net.minecraft.tileentity.TileEntity; 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; @@ -439,15 +436,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq if (slotIndex == SLOT_RESOURCE) return FluidContainerRegistry.isEmptyContainer(itemstack); -<<<<<<< HEAD - if (slotIndex == SLOT_CAN) { - FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack); - return container != null && RecipeManager.isInput(container.fluid); -======= if(slotIndex == SLOT_CAN) { FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); return RecipeManager.isInput(fluidStack); ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 } return false; diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index e54ea176d..7a85f4af7 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -338,11 +338,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } /* IINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - @Override protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 5779f7a90..7f31286ed 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -12,7 +12,6 @@ package forestry.factory.gadgets; import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IFabricatorManager; import forestry.core.config.Defaults; import forestry.core.fluids.TankManager; @@ -23,18 +22,15 @@ import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.ICraftingPlan; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.inventory.wrappers.IInvSlot; +import forestry.core.inventory.wrappers.InventoryIterator; +import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -<<<<<<< HEAD -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.fluids.TankManager; -import forestry.core.fluids.tanks.FilteredTank; -import forestry.core.inventory.InventoryAdapter; -======= -import forestry.core.utils.InventoryAdapter; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -51,11 +47,13 @@ import net.minecraftforge.fluids.FluidTankInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import net.minecraft.inventory.ISidedInventory; -public class MachineFabricator extends TilePowered implements ICrafter, ISpecialInventory, ILiquidTankContainer { +public class MachineFabricator extends TilePowered implements ICrafter, ILiquidTankContainer, ISidedInventory { /* RECIPE MANAGMENT */ public static class Recipe { + private final ItemStack plan; private final FluidStack molten; private final ShapedRecipeCustom internal; @@ -74,7 +72,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } public boolean hasLiquid(FluidStack resource) { - if(resource == null) + if (resource == null) return molten == null; if (!resource.isFluidEqual(molten)) @@ -98,14 +96,15 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } public static class Smelting { + private final ItemStack resource; private final FluidStack product; private final int meltingPoint; public Smelting(ItemStack resource, FluidStack molten, int meltingPoint) { - if(resource == null) + if (resource == null) throw new IllegalArgumentException("Resource cannot be null"); - if(molten == null) + if (molten == null) throw new IllegalArgumentException("Molten cannot be null"); this.resource = resource; @@ -131,6 +130,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } public static class RecipeManager implements IFabricatorManager { + public static final ArrayList recipes = new ArrayList(); public static final ArrayList smeltings = new ArrayList(); @@ -146,22 +146,26 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public static Recipe findMatchingRecipe(ItemStack plan, FluidStack liquid, ItemStack[] resources) { ItemStack[][] gridResources = new ItemStack[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { gridResources[j][i] = resources[i * 3 + j]; + } + } - for (Recipe recipe : recipes) + for (Recipe recipe : recipes) { if (recipe.matches(plan, gridResources)) if (recipe.hasLiquid(liquid)) return recipe; + } return null; } public static boolean isResourceLiquid(FluidStack liquid) { - for (Recipe recipe : recipes) + for (Recipe recipe : recipes) { if (recipe.hasLiquid(liquid)) return true; + } return false; } @@ -170,9 +174,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial if (resource == null) return null; - for (Smelting smelting : smeltings) + for (Smelting smelting : smeltings) { if (StackUtils.isCraftingEquivalent(smelting.resource, resource)) return smelting; + } return null; } @@ -181,9 +186,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial if (product == null) return null; - for (Smelting smelting : smeltings) + for (Smelting smelting : smeltings) { if (smelting.matches(product)) return smelting; + } return null; } @@ -192,8 +198,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public Map getRecipes() { HashMap recipeList = new HashMap(); - for (Recipe recipe : recipes) - recipeList.put(recipe.internal.getIngredients(), new Object[] { recipe.internal.getRecipeOutput() }); + for (Recipe recipe : recipes) { + recipeList.put(recipe.internal.getIngredients(), new Object[]{recipe.internal.getRecipeOutput()}); + } return recipeList; } @@ -211,9 +218,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public static final short SLOT_INVENTORY_COUNT = 18; /* MEMBER */ + private final InventoryMapper invCrafting; private final TankManager tankManager; - private FilteredTank moltenTank; - private final InventoryAdapter inventory = new InventoryAdapter(30, "Items"); + private final FilteredTank moltenTank; private int heat = 0; private int guiMeltingPoint = 0; @@ -221,6 +228,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public MachineFabricator() { super(1100, 50, 3300); + setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); + invCrafting = new InventoryMapper(getInternalInventory(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); Fluid liquidGlass = FluidRegistry.getFluid(Defaults.LIQUID_GLASS); moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, liquidGlass); moltenTank.tankMode = StandardTank.TankMode.INTERNAL; @@ -253,9 +262,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial pendingSmelt.writeToNBT(smelt); nbttagcompound.setTag("PendingSmelt", smelt); } - - // / Inventory - inventory.writeToNBT(nbttagcompound); } @Override @@ -273,14 +279,12 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial pendingSmelt = FluidStack.loadFluidStackFromNBT(smelt); } - // / Inventory - inventory.readFromNBT(nbttagcompound); - } /* UPDATING */ @Override public void updateServerSide() { + TileInventoryAdapter inventory = getInternalInventory(); // Add pending smelt if (pendingSmelt != null) { @@ -306,11 +310,10 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial this.dissipateHeat(); - if (energyManager.getTotalEnergyStored() == 0 && heat == 0) { + if (energyManager.getTotalEnergyStored() == 0 && heat == 0) setErrorState(EnumErrorCode.NOPOWER); - } else if (getErrorState() == EnumErrorCode.NOPOWER) { + else if (getErrorState() == EnumErrorCode.NOPOWER) setErrorState(EnumErrorCode.OK); - } } @Override @@ -337,6 +340,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } private Recipe getRecipe() { + TileInventoryAdapter inventory = getInternalInventory(); ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); ItemStack[] crafting = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), crafting); @@ -360,7 +364,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - if(slotIndex != SLOT_RESULT) + if (slotIndex != SLOT_RESULT) return null; Recipe myRecipe = getRecipe(); @@ -369,6 +373,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial FluidStack liquid = myRecipe.molten; + TileInventoryAdapter inventory = getInternalInventory(); // Remove resources if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, false)) { removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, true); @@ -392,19 +397,19 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial } private void removeFromCraftMatrix(Recipe recipe) { - - for (int i = 0; i < 9; i++) { - if (inventory.getStackInSlot(SLOT_CRAFTING_1 + i) == null) + for (IInvSlot slot : InventoryIterator.getIterable(invCrafting)) { + if (slot.getStackInSlot() == null) continue; - inventory.decrStackSize(SLOT_CRAFTING_1 + i, 1); + slot.decreaseStackInSlot(); } } private boolean removeFromInventory(int count, ItemStack[] set, EntityPlayer player, boolean doRemove) { - if (doRemove) { + TileInventoryAdapter inventory = getInternalInventory(); + if (doRemove) return inventory.removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); - } else { + else { ItemStack[] stock = inventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); return StackUtils.containsSets(set, stock) >= count; } @@ -417,6 +422,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial @Override public boolean hasWork() { + TileInventoryAdapter inventory = getInternalInventory(); ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL); Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt); FluidStack liquid = smelting.getProduct(); @@ -476,59 +482,35 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial iCrafting.sendProgressBarUpdate(container, messageId + 1, getMeltingPoint()); } - // / ISPECIALINVENTORY - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (from == ForgeDirection.UP && RecipeManager.findMatchingSmelting(stack) != null) - return inventory.addStack(stack, SLOT_METAL, 1, false, doAdd); - return inventory.addStack(stack, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, false, doAdd); - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - ItemStack taken; - if (doRemove) { - EntityPlayer player = Proxies.common.getPlayer(worldObj, owner); - taken = this.takenFromSlot(SLOT_RESULT, false, player); - } else { - taken = this.getResult(); - } - - if (taken != null) - return new ItemStack[] { taken }; - else - return new ItemStack[0]; - } - - // / IINVENTORY + /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override @@ -539,28 +521,41 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { + if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) + return false; + if (slotIndex == SLOT_METAL && RecipeManager.findMatchingSmelting(stack) == null) + return false; + return slotIndex >= SLOT_INVENTORY_1 && slotIndex < SLOT_INVENTORY_1 + SLOT_INVENTORY_COUNT; + } + + /* ISIDEDINVENTORY */ + @Override + public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { + return isItemValidForSlot(slotIndex, stack); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, stack, side)) + return false; + return slotIndex == SLOT_RESULT; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILIQUIDCONTAINER */ diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 7dc11227a..c7ce0c685 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -50,17 +50,11 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -<<<<<<< HEAD -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; -======= -import forestry.core.utils.InventoryAdapter; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; import buildcraft.api.statements.ITriggerExternal; +import forestry.core.inventory.TileInventoryAdapter; public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -160,11 +154,10 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL for (int i = 0; i < recipes.size(); i++) { Recipe recipe = recipes.get(i); if (recipe.resource.getItemDamage() == Defaults.WILDCARD - && recipe.resource.getItem() == resource.getItem()) { + && recipe.resource.getItem() == resource.getItem()) return true; - } else if (recipe.resource.isItemEqual(resource)) { + else if (recipe.resource.isItemEqual(resource)) return true; - } } return false; } @@ -184,7 +177,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL HashMap recipeList = new HashMap(); for (Recipe recipe : recipes) { - recipeList.put(new Object[] { recipe.resource, recipe.liquid }, new Object[] { recipe.output }); + recipeList.put(new Object[]{recipe.resource, recipe.liquid}, new Object[]{recipe.output}); } return recipeList; @@ -197,7 +190,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL private final TankManager tankManager; - private final InventoryAdapter inventory = new InventoryAdapter(5, "Items"); private Recipe currentRecipe; private float currentResourceModifier; public int fermentationTime = 0; @@ -208,6 +200,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public MachineFermenter() { super(2000, 150, 8000); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items")); setHints(Config.hints.get("fermenter")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs); resourceTank.tankMode = StandardTank.TankMode.INPUT; @@ -237,7 +230,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL nbttagcompound.setInteger("FuelCurrentFerment", fuelCurrentFerment); tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); } @@ -252,7 +244,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL fuelCurrentFerment = nbttagcompound.getInteger("FuelCurrentFerment"); tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); } @Override @@ -261,10 +252,10 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL if (worldObj.getTotalWorldTime() % 20 != 0) return; + TileInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_INPUT) != null) { + if (inventory.getStackInSlot(SLOT_INPUT) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_INPUT); - } // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { @@ -273,12 +264,12 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid()); } - if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) { + if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) if (resourceTank.getFluidAmount() < fuelCurrentFerment) setErrorState(EnumErrorCode.NORESOURCE); else setErrorState(EnumErrorCode.OK); - } else if (inventory.getStackInSlot(SLOT_FUEL) == null && fuelBurnTime <= 0) + else if (inventory.getStackInSlot(SLOT_FUEL) == null && fuelBurnTime <= 0) setErrorState(EnumErrorCode.NOFUEL); else if (energyManager.getTotalEnergyStored() == 0) setErrorState(EnumErrorCode.NOPOWER); @@ -293,6 +284,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL checkRecipe(); resetRecipe(); + TileInventoryAdapter inventory = getInternalInventory(); if (currentRecipe != null) { currentResourceModifier = determineResourceMod(inventory.getStackInSlot(SLOT_RESOURCE)); decrStackSize(SLOT_RESOURCE, 1); @@ -313,9 +305,8 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL // input are checked, add output if possible if (!addProduct(new FluidStack(currentRecipe.output, - Math.round(fermented * currentRecipe.modifier * currentResourceModifier)))) { + Math.round(fermented * currentRecipe.modifier * currentResourceModifier)))) return false; // the output tank is too full, TODO: check/add error code? - } fuelBurnTime--; resourceTank.drain(fuelCurrentFerment, true); @@ -350,12 +341,12 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL productTank.fill(output, true); return true; - } else { + } else return false; - } } private void checkRecipe() { + TileInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()); if (currentRecipe != sameRec) @@ -408,13 +399,14 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean isWorking() { + TileInventoryAdapter inventory = getInternalInventory(); if (currentRecipe == null && RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) return false; if (fuelBurnTime > 0) return resourceTank.getFluidAmount() > 0 && productTank.getFluidAmount() < Defaults.PROCESSOR_TANK_CAPACITY; - else - return determineFuelValue(getFuelStack()) > 0; + else + return determineFuelValue(getFuelStack()) > 0; } @Override @@ -435,6 +427,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean hasWork() { + TileInventoryAdapter inventory = getInternalInventory(); if (this.getFuelStack() == null && fuelBurnTime <= 0) return false; else if (fuelBurnTime <= 0) @@ -489,14 +482,15 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } public ItemStack getFermentationStack() { - return inventory.getStackInSlot(SLOT_RESOURCE); + return getInternalInventory().getStackInSlot(SLOT_RESOURCE); } public ItemStack getFuelStack() { - return inventory.getStackInSlot(SLOT_FUEL); + return getInternalInventory().getStackInSlot(SLOT_FUEL); } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { int firstMessageId = tankManager.maxMessageId() + 1; @@ -506,10 +500,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL fuelTotalTime = j; else if (i == firstMessageId + 2) fermentationTime = j; - else if (i == firstMessageId + 3) + else if (i == firstMessageId + 3) fermentationTotalTime = j; } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int firstMessageId = tankManager.maxMessageId() + 1; @@ -520,75 +515,34 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } /* INVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_CAN_OUTPUT) - return true; - - return false; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_RESOURCE && RecipeManager.isResource(itemstack)) - return true; - - - if (slotIndex == SLOT_INPUT) { - FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); - return RecipeManager.isLiquidResource(fluidStack); - } - - if (slotIndex == SLOT_CAN_INPUT && FluidHelper.isEmptyContainer(itemstack)) { - return true; - } - if (slotIndex == SLOT_FUEL && FuelManager.fermenterFuel.containsKey(itemstack)) - return true; - - return false; - } - @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -599,52 +553,51 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + if (slotIndex == SLOT_RESOURCE && RecipeManager.isResource(itemstack)) + return true; + + if (slotIndex == SLOT_INPUT) { + FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); + return RecipeManager.isLiquidResource(fluidStack); + } + + if (slotIndex == SLOT_CAN_INPUT && FluidHelper.isEmptyContainer(itemstack)) + return true; + return slotIndex == SLOT_FUEL && FuelManager.fermenterFuel.containsKey(itemstack); } - /** - * TODO: just a specialsource workaround - */ + /* ISIDEDINVENTORY */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex == SLOT_CAN_OUTPUT; } - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILiquidTankContainer */ @@ -678,6 +631,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL return tankManager; } + @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { return tankManager.getTankInfo(from); } diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 7b714adc4..ebf8a9ad6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -10,9 +10,9 @@ ******************************************************************************/ package forestry.factory.gadgets; +import static cpw.mods.fml.relauncher.FMLLaunchHandler.side; import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.api.fuels.FuelManager; import forestry.api.fuels.MoistenerFuel; import forestry.api.recipes.IMoistenerManager; @@ -24,15 +24,10 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -<<<<<<< HEAD -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -======= -import forestry.core.utils.InventoryAdapter; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; @@ -51,7 +46,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -public class MachineMoistener extends TileBase implements ISpecialInventory, ISidedInventory, ILiquidTankContainer, IRenderableMachine { +public class MachineMoistener extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine { /* CONSTANTS */ private static final short SLOT_STASH_1 = 0; @@ -64,16 +59,17 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi /* RECIPE MANAGMENT */ public static class Recipe { + public final int timePerItem; public final ItemStack resource; public final ItemStack product; - + public Recipe(ItemStack resource, ItemStack product, int timePerItem) { this.timePerItem = timePerItem; this.resource = resource; this.product = product; } - + public boolean matches(ItemStack res) { if (res == null && resource == null) return true; @@ -83,27 +79,28 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi return resource.isItemEqual(res); } } - + public static class RecipeManager implements IMoistenerManager { + public static final ArrayList recipes = new ArrayList(); - + @Override public void addRecipe(ItemStack resource, ItemStack product, int timePerItem) { recipes.add(new MachineMoistener.Recipe(resource, product, timePerItem)); } - + public static boolean isResource(ItemStack resource) { - if(resource == null) + if (resource == null) return false; - - for(Recipe rec : recipes) { - if(StackUtils.isIdenticalItem(resource, rec.resource)) + + for (Recipe rec : recipes) { + if (StackUtils.isIdenticalItem(resource, rec.resource)) return true; } - + return false; } - + public static Recipe findMatchingRecipe(ItemStack item) { for (int i = 0; i < recipes.size(); i++) { Recipe recipe = recipes.get(i); @@ -112,43 +109,44 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi } return null; } - + @Override public Map getRecipes() { HashMap recipeList = new HashMap(); - - for (Recipe recipe : recipes) - recipeList.put(new ItemStack[] { recipe.resource }, new ItemStack[] { recipe.product }); - + + for (Recipe recipe : recipes) { + recipeList.put(new ItemStack[]{recipe.resource}, new ItemStack[]{recipe.product}); + } + return recipeList; } } - + @EntityNetData public final FilteredTank resourceTank; private final TankManager tankManager; - private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); //private ItemStack[] inventoryStacks = new ItemStack[12]; public MachineMoistener.Recipe currentRecipe; - + public int burnTime = 0; public int totalTime = 0; public int productionTime = 0; private int timePerItem = 0; private ItemStack currentProduct; private ItemStack pendingProduct; - + public MachineMoistener() { + setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); setHints(Config.hints.get("moistener")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); tankManager = new TankManager(resourceTank); } - + @Override public String getInventoryName() { return getUnlocalizedName(); } - + @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.MoistenerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -158,13 +156,12 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - + nbttagcompound.setInteger("BurnTime", burnTime); nbttagcompound.setInteger("TotalTime", totalTime); nbttagcompound.setInteger("ProductionTime", productionTime); - + tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); // Write pending product if (pendingProduct != null) { @@ -178,17 +175,16 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi nbttagcompound.setTag("CurrentProduct", nbttagcompoundP); } } - + @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - + burnTime = nbttagcompound.getInteger("BurnTime"); totalTime = nbttagcompound.getInteger("TotalTime"); productionTime = nbttagcompound.getInteger("ProductionTime"); - + tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); // Load pending product if (nbttagcompound.hasKey("PendingProduct")) { @@ -199,17 +195,17 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi NBTTagCompound nbttagcompoundP = nbttagcompound.getCompoundTag("CurrentProduct"); currentProduct = ItemStack.loadItemStackFromNBT(nbttagcompoundP); } - + checkRecipe(); } - + @Override public void updateServerSide() { + TileInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable water container waiting in the item slot - if (inventory.getStackInSlot(SLOT_PRODUCT) != null) { + if (inventory.getStackInSlot(SLOT_PRODUCT) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_PRODUCT); - } // Let's get to work int lightvalue = worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord); @@ -236,67 +232,68 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi // Not working if there is no water available. if (resourceTank.getFluidAmount() <= 0) return; - + checkRecipe(); - + if (currentRecipe == null) return; - + resourceTank.drain(1, true); burnTime -= speed; productionTime -= speed; - + if (productionTime <= 0) { pendingProduct = currentProduct; decrStackSize(SLOT_RESOURCE, 1); resetRecipe(); tryAddPending(); } - + } else if (pendingProduct != null) tryAddPending(); // Try to start process else // Make sure we have a new item in the working slot. - if (rotateWorkingSlot()) { - checkRecipe(); - - // Let's see if we have a valid resource in the working slot - if (inventory.getStackInSlot(SLOT_WORKING) == null) - return; - - if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) { - MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING)); - burnTime = totalTime = res.moistenerValue; - } - } else - rotateReservoir(); + if (rotateWorkingSlot()) { + checkRecipe(); + // Let's see if we have a valid resource in the working slot + if (inventory.getStackInSlot(SLOT_WORKING) == null) + return; + + if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(SLOT_WORKING))) { + MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(SLOT_WORKING)); + burnTime = totalTime = res.moistenerValue; + } + } else + rotateReservoir(); + if (currentRecipe != null) setErrorState(EnumErrorCode.OK); else setErrorState(EnumErrorCode.NORECIPE); } - + private boolean tryAddPending() { if (pendingProduct == null) return false; - - if(inventory.tryAddStack(pendingProduct, SLOT_PRODUCT, 1, true)) { + + TileInventoryAdapter inventory = getInternalInventory(); + if (inventory.tryAddStack(pendingProduct, SLOT_PRODUCT, 1, true)) { pendingProduct = null; return true; } - + return false; } - + public void checkRecipe() { - Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE)); + Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE)); if (currentRecipe != sameRec) { currentRecipe = sameRec; resetRecipe(); } } - + private void resetRecipe() { if (currentRecipe == null) { currentProduct = null; @@ -305,15 +302,16 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi setErrorState(EnumErrorCode.NORECIPE); return; } - + currentProduct = currentRecipe.product; productionTime = currentRecipe.timePerItem; timePerItem = currentRecipe.timePerItem; } - + private int getFreeSlot(ItemStack deposit, int startSlot, int endSlot, boolean emptyOnly) { int slot = -1; - + + TileInventoryAdapter inventory = getInternalInventory(); for (int i = startSlot; i < endSlot; i++) { ItemStack slotStack = inventory.getStackInSlot(i); // Empty slots are okay. @@ -322,53 +320,55 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi slot = i; continue; } - + if (emptyOnly) continue; // Wrong item or full if (!slotStack.isItemEqual(deposit) || slotStack.stackSize >= slotStack.getMaxStackSize()) continue; - + slot = i; } - + return slot; } - + private int getFreeStashSlot(ItemStack deposit, boolean emptyOnly) { return getFreeSlot(deposit, 0, SLOT_RESERVOIR_1, emptyOnly); } - + private int getFreeReservoirSlot(ItemStack deposit) { return getFreeSlot(deposit, SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOTS_COUNT_RESERVOIR, false); - + } - + private int getNextResourceSlot(int startSlot, int endSlot) { // Let's look for a new resource to put into the working slot. int stage = -1; int resourceSlot = -1; - + + TileInventoryAdapter inventory = getInternalInventory(); for (int i = startSlot; i < endSlot; i++) { ItemStack slotStack = inventory.getStackInSlot(i); if (slotStack == null) continue; - + if (!FuelManager.moistenerResource.containsKey(slotStack)) continue; - + MoistenerFuel res = FuelManager.moistenerResource.get(slotStack); if (stage < 0 || res.stage < stage) { stage = res.stage; resourceSlot = i; } } - + return resourceSlot; } - - private boolean rotateWorkingSlot() { + + private boolean rotateWorkingSlot() { + TileInventoryAdapter inventory = getInternalInventory(); // Put working slot contents into inventory if space is available if (inventory.getStackInSlot(SLOT_WORKING) != null) { // Get the result of the consumed item in the working slot @@ -378,20 +378,20 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi deposit = res.product.copy(); } else deposit = inventory.getStackInSlot(SLOT_WORKING).copy(); - + int targetSlot = getFreeReservoirSlot(deposit); // We stop the whole thing, if we don't have any room anymore. if (targetSlot < 0) return false; - + if (inventory.getStackInSlot(targetSlot) == null) inventory.setInventorySlotContents(targetSlot, deposit); else inventory.getStackInSlot(targetSlot).stackSize++; - + decrStackSize(SLOT_WORKING, 1); } - + if (inventory.getStackInSlot(SLOT_WORKING) != null) return true; @@ -400,18 +400,20 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi // Nothing found, stop. if (resourceSlot < 0) return false; - + inventory.setInventorySlotContents(SLOT_WORKING, inventory.decrStackSize(resourceSlot, 1)); return true; } - + private void rotateReservoir() { ArrayList slotsToShift = new ArrayList(); - + + TileInventoryAdapter inventory = getInternalInventory(); + for (int i = SLOT_RESERVOIR_1; i < SLOT_RESERVOIR_1 + SLOTS_COUNT_RESERVOIR; i++) { if (inventory.getStackInSlot(i) == null) continue; - + if (!FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) slotsToShift.add(i); } @@ -423,7 +425,7 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi int targetSlot = getFreeStashSlot(slotStack, true); if (targetSlot < 0) continue; - + inventory.setInventorySlotContents(targetSlot, slotStack); inventory.setInventorySlotContents(slot, null); shiftedSlots++; @@ -450,15 +452,16 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi } } } - + public boolean isWorking() { return burnTime > 0 && resourceTank.getFluidAmount() > 0; } - + public boolean hasFuelMin(float percentage) { int max = 0; int avail = 0; - + TileInventoryAdapter inventory = getInternalInventory(); + for (int i = SLOT_STASH_1; i < SLOT_RESERVOIR_1; i++) { if (inventory.getStackInSlot(i) == null) { max += 64; @@ -472,37 +475,38 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi } } } - + return ((float) avail / (float) max) > percentage; } - + public boolean hasResourcesMin(float percentage) { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; - + return ((float) inventory.getStackInSlot(SLOT_RESOURCE).stackSize / (float) inventory.getStackInSlot(SLOT_RESOURCE).getMaxStackSize()) > percentage; } - + public boolean isProducing() { return productionTime > 0; } - + public int getProductionProgressScaled(int i) { if (timePerItem == 0) return 0; - + return (productionTime * i) / timePerItem; - + } - + public int getConsumptionProgressScaled(int i) { if (totalTime == 0) return 0; - + return (burnTime * i) / totalTime; - + } - + public int getResourceScaled(int i) { return (resourceTank.getFluidAmount() * i) / Defaults.PROCESSOR_TANK_CAPACITY; } @@ -512,153 +516,100 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi public EnumTankLevel getPrimaryLevel() { return Utils.rateTankLevel(getResourceScaled(100)); } - + @Override public EnumTankLevel getSecondaryLevel() { return EnumTankLevel.EMPTY; } /* IINVENTORY */ - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} - - /** - * TODO: just a specialsource workaround - */ + @Override + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInternalInventory().getStackInSlot(i); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + return getInternalInventory().decrStackSize(i, j); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(i, itemstack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - - /** - * TODO: just a specialsource workaround - */ + @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - - /** - * TODO: just a specialsource workaround - */ + @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + if (slotIndex == SLOT_RESOURCE) + return RecipeManager.isResource(itemstack); + + if (slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH - 2) + return FuelManager.moistenerResource.containsKey(itemstack); + + return false; } - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } /* ISIDEDINVENTORY */ @Override - public InventoryAdapter getInternalInventory() { - return inventory; + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } - + @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) return false; - - if(slotIndex == SLOT_PRODUCT) + + if (slotIndex == SLOT_PRODUCT) return true; - - if(slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH) { + + if (slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH) return !FuelManager.moistenerResource.containsKey(itemstack); - } - + return false; } - + @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if(slotIndex == SLOT_RESOURCE) - return RecipeManager.isResource(itemstack); - - if(slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH - 2) { - return FuelManager.moistenerResource.containsKey(itemstack); - } - - return false; - } - - /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - - Fluid fluid = FluidHelper.getFluidInContainer(stack); - if (fluid != null && resourceTank.accepts(fluid)) { - return inventory.addStack(stack, SLOT_PRODUCT, 1, false, doAdd); - } - - // Try to add to resource slot if input is from top or bottom. - if (from == ForgeDirection.UP || from == ForgeDirection.DOWN) { - return inventory.addStack(stack, SLOT_RESOURCE, 1, false, doAdd); - } - - return inventory.addStack(stack, SLOT_STASH_1, SLOTS_COUNT_STASH - 2, false, doAdd); - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - ItemStack product; - - ItemStack slotStack = inventory.getStackInSlot(SLOT_PRODUCT); - if (slotStack != null && slotStack.stackSize > 0) { - - product = new ItemStack(slotStack.getItem(), 1, slotStack.getItemDamage()); - if (doRemove) { - inventory.decrStackSize(SLOT_PRODUCT, 1); - } - return new ItemStack[] { product }; - } else - for (int i = 0; i < SLOT_RESERVOIR_1; i++) { - slotStack = inventory.getStackInSlot(i); - if (slotStack == null) - continue; - - if (!FuelManager.moistenerResource.containsKey(slotStack)) { - product = new ItemStack(slotStack.getItem(), 1, slotStack.getItemDamage()); - if (doRemove) { - inventory.decrStackSize(i, 1); - } - return new ItemStack[] { product }; - } - } - - return StackUtils.EMPTY_STACK_ARRAY; + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILiquidTankContainer */ @@ -666,40 +617,42 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return tankManager.fill(from, resource, doFill); } - + @Override public TankManager getTankManager() { return tankManager; } - + + @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); } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; - + switch (i) { case 0: burnTime = j; @@ -715,7 +668,8 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi break; } } - + + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int i = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, i, burnTime); @@ -723,5 +677,5 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi iCrafting.sendProgressBarUpdate(container, i + 2, productionTime); iCrafting.sendProgressBarUpdate(container, i + 3, timePerItem); } - + } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index db704b489..55003b1bb 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -34,14 +34,10 @@ 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.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.Fluids; -<<<<<<< HEAD -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -======= -import forestry.core.utils.InventoryAdapter; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; @@ -55,12 +51,12 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui /* MEMBER */ public FilteredTank resourceTank; private final TankManager tankManager; - private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); private boolean isValidBiome = true; private int fillingTime; private ItemStack usedEmpty; public MachineRaintank() { + setInternalInventory(new TileInventoryAdapter(this, 3, "Items")); setHints(Config.hints.get("raintank")); resourceTank = new FilteredTank(Defaults.RAINTANK_TANK_CAPACITY, FluidRegistry.WATER); @@ -98,7 +94,6 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui nbttagcompound.setBoolean("IsValidBiome", isValidBiome); tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); } @Override @@ -108,7 +103,6 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui isValidBiome = nbttagcompound.getBoolean("IsValidBiome"); tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); } @Override @@ -127,6 +121,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui if (worldObj.getTotalWorldTime() % 16 != 0) return; + TileInventoryAdapter inventory = getInternalInventory(); if (!StackUtils.isIdenticalItem(usedEmpty, inventory.getStackInSlot(SLOT_RESOURCE))) { fillingTime = 0; usedEmpty = null; @@ -150,7 +145,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private void tryToStartFillling() { // Nothing to do if no empty cans are available - if (!FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false)) + if (!FluidHelper.fillContainers(tankManager, getInternalInventory(), SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false)) return; fillingTime = Defaults.RAINTANK_FILLING_TIME; @@ -163,32 +158,32 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -199,71 +194,19 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - - /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_PRODUCT; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - if (!super.canPutStackFromSide(slotIndex, itemstack, side)) + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) return false; if (slotIndex != SLOT_RESOURCE) @@ -272,7 +215,27 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui return FluidHelper.isFillableContainer(itemstack, STACK_WATER); } + /* ISIDEDINVENTORY */ + @Override + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex == SLOT_PRODUCT; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); + } + /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { @@ -282,6 +245,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui } } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int i = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, i, fillingTime); @@ -318,6 +282,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui return tankManager; } + @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { return tankManager.getTankInfo(from); } diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index f83e1b64c..1cb6b6c4e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -28,7 +28,7 @@ import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.LiquidHelper; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; @@ -40,7 +40,6 @@ 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; import net.minecraftforge.fluids.FluidTankInfo; @@ -51,7 +50,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Stack; -public class MachineSqueezer extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer { +public class MachineSqueezer extends TilePowered implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ private static final short SLOT_RESOURCE_1 = 0; @@ -62,6 +61,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I /* RECIPE MANAGMENT */ public static class Recipe { + public final int timePerItem; public final ItemStack[] resources; public final FluidStack liquid; @@ -82,6 +82,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } public static class RecipeManager implements ISqueezerManager { + public static final ArrayList recipes = new ArrayList(); public static final HashSet recipeFluids = new HashSet(); public static final HashSet recipeInputs = new HashSet(); @@ -112,9 +113,10 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I public static boolean canUse(ItemStack itemStack) { if (recipeInputs.contains(itemStack)) return true; - for (ItemStack recipeInput : recipeInputs) + for (ItemStack recipeInput : recipeInputs) { if (StackUtils.isCraftingEquivalent(recipeInput, itemStack)) return true; + } return false; } @@ -122,8 +124,9 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I public Map getRecipes() { HashMap recipeList = new HashMap(); - for (Recipe recipe : recipes) - recipeList.put(recipe.resources, new Object[] { recipe.remnants, recipe.liquid }); + for (Recipe recipe : recipes) { + recipeList.put(recipe.resources, new Object[]{recipe.remnants, recipe.liquid}); + } return recipeList; } @@ -134,7 +137,6 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I @EntityNetData public final FilteredTank productTank; - private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); private Recipe currentRecipe; private final Stack pendingLiquids = new Stack(); @@ -144,6 +146,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I public MachineSqueezer() { super(1100, 50, 4000); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); setHints(Config.hints.get("squeezer")); productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids); productTank.tankMode = StandardTank.TankMode.OUTPUT; @@ -168,31 +171,30 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I nbttagcompound.setInteger("ProductionTime", productionTime); nbttagcompound.setInteger("TimePerItem", timePerItem); - // Inventory - inventory.writeToNBT(nbttagcompound); - // Pending remnants NBTTagList nbttaglist = new NBTTagList(); ItemStack[] remnants = pendingRemnants.toArray(new ItemStack[pendingRemnants.size()]); - for (int i = 0; i < remnants.length; i++) + for (int i = 0; i < remnants.length; i++) { if (remnants[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); remnants[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingRemnants", nbttaglist); // Pending liquids nbttaglist = new NBTTagList(); FluidStack[] liquids = pendingLiquids.toArray(new FluidStack[pendingLiquids.size()]); - for (int i = 0; i < liquids.length; i++) + for (int i = 0; i < liquids.length; i++) { if (liquids[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); liquids[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingLiquids", nbttaglist); tankManager.writeTanksToNBT(nbttagcompound); @@ -205,9 +207,6 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I productionTime = nbttagcompound.getInteger("ProductionTime"); timePerItem = nbttagcompound.getInteger("TimePerItem"); - // Inventory - inventory.readFromNBT(nbttagcompound); - // Pending remnants NBTTagList nbttaglist = nbttagcompound.getTagList("PendingRemnants", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { @@ -234,6 +233,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I if (worldObj.getTotalWorldTime() % 20 != 0) return; + TileInventoryAdapter inventory = getInternalInventory(); // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidStack fluidStack = productTank.getFluid(); @@ -294,7 +294,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } private void checkRecipe() { - Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStacks(SLOT_RESOURCE_1, 9)); + Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStacks(SLOT_RESOURCE_1, 9)); if (sameRec == null) setErrorState(EnumErrorCode.NORECIPE); @@ -349,12 +349,12 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } private boolean addRemnant(ItemStack stack) { - return inventory.tryAddStack(stack, SLOT_REMNANT, 1, true); + return getInternalInventory().tryAddStack(stack, SLOT_REMNANT, 1, true); } private boolean removeResources(ItemStack[] stacks) { - EntityPlayer player = Proxies.common.getPlayer(worldObj, owner); - return inventory.removeSets(1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true); + EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); + return getInternalInventory().removeSets(1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true); } @Override @@ -384,6 +384,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { @@ -396,6 +397,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int i = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, i, productionTime); @@ -403,39 +405,63 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I } /* IINVENTORY */ - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} - - /** - * TODO: just a specialsource workaround - */ @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int i) { + return getInternalInventory().getStackInSlot(i); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + return getInternalInventory().decrStackSize(i, j); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(i, itemstack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { + if(!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; - if(slotIndex == SLOT_CAN_INPUT) { + if (slotIndex == SLOT_CAN_INPUT) return FluidHelper.isEmptyContainer(itemstack); - } - if(slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { + if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { if (FluidHelper.isEmptyContainer(itemstack)) return false; @@ -446,90 +472,23 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I return false; } - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - /* ISIDEDINVENTORY */ @Override - public InventoryAdapter getInternalInventory() { - return inventory; + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) return false; return slotIndex == SLOT_REMNANT || slotIndex == SLOT_CAN_OUTPUT; } - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - 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) { - - // Try to add to can slot if input is from top or bottom. - if (FluidHelper.isEmptyContainer(stack)) { - return inventory.addStack(stack, SLOT_CAN_INPUT, 1, false, doAdd); - } else { - return inventory.addStack(stack, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, false, doAdd); - } - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - ItemStack product; - - if (inventory.getStackInSlot(SLOT_CAN_OUTPUT) != null) { - - product = new ItemStack(inventory.getStackInSlot(SLOT_CAN_OUTPUT).getItem(), 1, inventory.getStackInSlot(SLOT_CAN_OUTPUT).getItemDamage()); - if (doRemove) { - inventory.decrStackSize(SLOT_CAN_OUTPUT, 1); - } - return new ItemStack[] { product }; - } else { - - if (inventory.getStackInSlot(SLOT_REMNANT) == null) - return StackUtils.EMPTY_STACK_ARRAY; - - product = new ItemStack(inventory.getStackInSlot(SLOT_REMNANT).getItem(), 1, inventory.getStackInSlot(SLOT_REMNANT).getItemDamage()); - if (doRemove) { - inventory.decrStackSize(SLOT_REMNANT, 1); - } - return new ItemStack[] { product }; - } - + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ILIQUIDCONTAINER IMPLEMENTATION */ @@ -543,6 +502,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I return tankManager.fill(from, resource, doFill); } + @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return tankManager.drain(from, resource, doDrain); } diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 8aca97814..d8822fbbb 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -26,10 +26,8 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; - import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IStillManager; import forestry.core.config.Config; import forestry.core.config.Defaults; @@ -40,19 +38,13 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; -<<<<<<< HEAD -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -======= -import forestry.core.utils.InventoryAdapter; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 -import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -public class MachineStill extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer { +public class MachineStill extends TilePowered implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ public static final short SLOT_PRODUCT = 0; @@ -60,15 +52,16 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid public static final short SLOT_CAN = 2; public static class Recipe { + public final int timePerUnit; public final FluidStack input; public final FluidStack output; public Recipe(int timePerUnit, FluidStack input, FluidStack output) { this.timePerUnit = timePerUnit; - if(input == null) + if (input == null) throw new IllegalArgumentException("Still recipes need an input. Input was null."); - if(output == null) + if (output == null) throw new IllegalArgumentException("Still recipes need an output. Output was null."); this.input = input; this.output = output; @@ -85,6 +78,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid } public static class RecipeManager implements IStillManager { + public static final ArrayList recipes = new ArrayList(); public static final HashSet recipeFluidInputs = new HashSet(); public static final HashSet recipeFluidOutputs = new HashSet(); @@ -115,8 +109,9 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid public Map getRecipes() { HashMap recipeList = new HashMap(); - for (Recipe recipe : recipes) - recipeList.put(new Object[] { recipe.input }, new Object[] { recipe.output }); + for (Recipe recipe : recipes) { + recipeList.put(new Object[]{recipe.input}, new Object[]{recipe.output}); + } return recipeList; } @@ -129,8 +124,6 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid public final FilteredTank productTank; private final TankManager tankManager; - private final InventoryAdapter inventory = new InventoryAdapter(3, "Items"); - private Recipe currentRecipe; private FluidStack bufferedLiquid; public int distillationTime = 0; @@ -138,6 +131,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid public MachineStill() { super(1100, 50, 8000); + setInternalInventory(new TileInventoryAdapter(this,3, "Items")); setHints(Config.hints.get("still")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs); resourceTank.tankMode = StandardTank.TankMode.INPUT; @@ -164,7 +158,6 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid nbttagcompound.setInteger("DistillationTotalTime", distillationTotalTime); tankManager.writeTanksToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); } @Override @@ -175,7 +168,6 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid distillationTotalTime = nbttagcompound.getInteger("DistillationTotalTime"); tankManager.readTanksFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); checkRecipe(); } @@ -186,17 +178,16 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; + TileInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_CAN) != null) { + if (inventory.getStackInSlot(SLOT_CAN) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); - } // Can product liquid if possible if (inventory.getStackInSlot(SLOT_RESOURCE) != null) { FluidStack fluidStack = productTank.getFluid(); - if (fluidStack != null) { + if (fluidStack != null) FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, fluidStack.getFluid()); - } } checkRecipe(); @@ -326,134 +317,91 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid iCrafting.sendProgressBarUpdate(container, i + 1, distillationTotalTime); } - /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - int inventorySlot; - - Fluid fluid = FluidHelper.getFluidInContainer(stack); - if (fluid != null && resourceTank.accepts(fluid)) - inventorySlot = SLOT_CAN; - else if (FluidHelper.isEmptyContainer(stack)) - inventorySlot = SLOT_RESOURCE; - else - return 0; - - return inventory.addStack(stack, inventorySlot, 1, false, doAdd); - } - - /** - * Transport pipes cannot extract items from the still. - */ - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - ItemStack product = null; - - if (inventory.getStackInSlot(SLOT_PRODUCT) != null) { - - product = new ItemStack(inventory.getStackInSlot(SLOT_PRODUCT).getItem(), 1, inventory.getStackInSlot(SLOT_PRODUCT).getItemDamage()); - if (doRemove) { - inventory.decrStackSize(SLOT_PRODUCT, 1); - } - } - - if (product != null) - return new ItemStack[] { product }; - else - return StackUtils.EMPTY_STACK_ARRAY; - } - /* IINVENTORY */ - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return getInternalInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(int slot, int value) { + return getInternalInventory().decrStackSize(slot, value); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(slot, itemstack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - - /* ISIDEDINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return inventory; - } - - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) return false; - return slotIndex == SLOT_PRODUCT; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if(slotIndex == SLOT_RESOURCE) + if (slotIndex == SLOT_RESOURCE) return FluidHelper.isEmptyContainer(itemstack); - if(slotIndex == SLOT_CAN) { + if (slotIndex == SLOT_CAN) { Fluid fluid = FluidHelper.getFluidInContainer(itemstack); return fluid != null && resourceTank.accepts(fluid); } return false; } + + /* ISIDEDINVENTORY */ + @Override + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); + } - /* ILiquidTankContainer */ + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex == SLOT_PRODUCT; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getInternalInventory().getAccessibleSlotsFromSide(side); + } + + /* IFluidHandler */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return tankManager.fill(from, resource, doFill); @@ -484,6 +432,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid return tankManager; } + @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { return tankManager.getTankInfo(from); } diff --git a/src/main/java/forestry/factory/gadgets/MillRainmaker.java b/src/main/java/forestry/factory/gadgets/MillRainmaker.java index 438d95216..436b3156e 100755 --- a/src/main/java/forestry/factory/gadgets/MillRainmaker.java +++ b/src/main/java/forestry/factory/gadgets/MillRainmaker.java @@ -11,19 +11,15 @@ package forestry.factory.gadgets; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import forestry.api.core.ISpecialInventory; import forestry.api.fuels.FuelManager; import forestry.api.fuels.RainSubstrate; import forestry.core.gadgets.Mill; import forestry.core.gadgets.TileBase; import forestry.core.proxy.Proxies; -public class MillRainmaker extends Mill implements ISpecialInventory { +public class MillRainmaker extends Mill { private int duration; private boolean reverse; @@ -32,11 +28,6 @@ public class MillRainmaker extends Mill implements ISpecialInventory { speed = 0.01f; } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { if (!Proxies.common.isSimulating(player.worldObj)) @@ -117,86 +108,78 @@ public class MillRainmaker extends Mill implements ISpecialInventory { } } - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (charge != 0) - return 0; - - if (!FuelManager.rainSubstrate.containsKey(stack)) - return 0; - - RainSubstrate substrate = FuelManager.rainSubstrate.get(stack); - if (!substrate.item.isItemEqual(stack)) - return 0; - - if (doAdd) - addCharge(substrate); - return 1; - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - return null; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(int var1) { - return null; - } - - @Override - public ItemStack decrStackSize(int var1, int var2) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int var1) { - return null; - } - - @Override - public void setInventorySlotContents(int var1, ItemStack var2) { - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } + // TODO: Give Rainmaker a real inventory and a GUI with slots +// @Override +// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { +// if (charge != 0) +// return 0; +// +// if (!FuelManager.rainSubstrate.containsKey(stack)) +// return 0; +// +// RainSubstrate substrate = FuelManager.rainSubstrate.get(stack); +// if (!substrate.item.isItemEqual(stack)) +// return 0; +// +// if (doAdd) +// addCharge(substrate); +// return 1; +// } +// +// @Override +// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { +// return null; +// } +// +// @Override +// public int getSizeInventory() { +// return 0; +// } +// +// @Override +// public ItemStack getStackInSlot(int var1) { +// return null; +// } +// +// @Override +// public ItemStack decrStackSize(int var1, int var2) { +// return null; +// } +// +// @Override +// public ItemStack getStackInSlotOnClosing(int var1) { +// return null; +// } +// +// @Override +// public void setInventorySlotContents(int var1, ItemStack var2) { +// } +// +// @Override +// public int getInventoryStackLimit() { +// return 0; +// } +// +// @Override +// public void openInventory() { +// } +// +// @Override +// public void closeInventory() { +// } +// +// @Override +// public boolean isUseableByPlayer(EntityPlayer player) { +// return Utils.isUseableByPlayer(player, this); +// } +// +// @Override +// public boolean hasCustomInventoryName() { +// return false; +// } +// +// @Override +// public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { +// return false; +// } } diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index c50059dd6..cbe34cfa1 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -13,21 +13,15 @@ package forestry.factory.gadgets; import forestry.api.core.ForestryAPI; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ICrafter; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.ForestryPacket; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; -<<<<<<< HEAD -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.PlainInventory; -import forestry.core.utils.StackUtils; -import forestry.core.inventory.TileInventoryAdapter; -======= -import forestry.core.utils.InventoryAdapter; import forestry.core.utils.RecipeUtil; -import forestry.core.utils.TileInventoryAdapter; import forestry.factory.recipes.RecipeMemory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -35,7 +29,7 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; ->>>>>>> 5ea4770a2d5fef57cf52fb7c81f33671f8086740 + public class TileWorktable extends TileBase implements ICrafter { @@ -51,11 +45,10 @@ public class TileWorktable extends TileBase implements ICrafter { private InventoryCrafting currentCrafting; private final RecipeMemory memorized; private final TileInventoryAdapter craftingInventory; - private final TileInventoryAdapter accessibleInventory; public TileWorktable() { craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems"); - accessibleInventory = new TileInventoryAdapter(this, 18, "Items"); + setInternalInventory(new TileInventoryAdapter(this, 18, "Items")); memorized = new RecipeMemory(); } @@ -71,7 +64,6 @@ public class TileWorktable extends TileBase implements ICrafter { super.writeToNBT(nbttagcompound); craftingInventory.writeToNBT(nbttagcompound); - accessibleInventory.writeToNBT(nbttagcompound); memorized.writeToNBT(nbttagcompound); } @@ -81,7 +73,6 @@ public class TileWorktable extends TileBase implements ICrafter { super.readFromNBT(nbttagcompound); craftingInventory.readFromNBT(nbttagcompound); - accessibleInventory.readFromNBT(nbttagcompound); memorized.readFromNBT(nbttagcompound); } @@ -161,7 +152,7 @@ public class TileWorktable extends TileBase implements ICrafter { return false; ItemStack[] recipeItems = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - ItemStack[] inventory = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ItemStack[] inventory = getInternalInventory().getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); ItemStack recipeOutput = currentRecipe.getRecipeOutput(worldObj); return RecipeUtil.canCraftRecipe(worldObj, recipeItems, recipeOutput, inventory); @@ -169,7 +160,7 @@ public class TileWorktable extends TileBase implements ICrafter { private boolean removeResources(EntityPlayer player) { ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, 9); - return accessibleInventory.removeSets(1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); + return getInternalInventory().removeSets(1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); } @Override @@ -201,12 +192,6 @@ public class TileWorktable extends TileBase implements ICrafter { return null; } - /* INVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return accessibleInventory; - } - /** * @return Inaccessible crafting inventory for the craft grid. */ diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 2ac282257..8f9dedaaf 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -144,9 +144,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { if (isMaster) makeMaster(); - if (inventory != null) - inventory.readFromNBT(nbttagcompound); - structureLogic.readFromNBT(nbttagcompound); } @@ -161,9 +158,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { farmBlock.saveToCompound(nbttagcompound); - if (inventory != null) - inventory.writeToNBT(nbttagcompound); - structureLogic.writeToNBT(nbttagcompound); } @@ -225,9 +219,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { return null; } - /* INVENTORY MANAGMENT */ - protected TileInventoryAdapter inventory; - /* TILEFORESTRY */ @Override public PacketPayload getPacketPayload() { @@ -329,7 +320,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { @Override public IInventory getInventory() { - return inventory; + return getInternalInventory(); } @Override diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index cc4adb051..8b0a899c1 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -166,8 +166,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return; // Check if we have suitable items waiting in the item slot - if (inventory.getStackInSlot(SLOT_CAN) != null) { - FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + if (getInternalInventory().getStackInSlot(SLOT_CAN) != null) { + FluidHelper.drainContainers(tankManager, getInternalInventory(), SLOT_CAN); } } @@ -350,7 +350,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } protected void createInventory() { - inventory = new TileInventoryAdapter(this, SLOT_COUNT, "Items"); + setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items")); FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); tankManager = new TankManager(liquidTank); } @@ -364,7 +364,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } else if (checkTimer.delayPassed(worldObj, 400)) setExtents(); - if (inventory == null) + if (getInternalInventory() == null) createInventory(); // System.out.println("Targets set"); @@ -526,7 +526,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private void addProduceToInventory(ItemStack produce) { - + TileInventoryAdapter inventory = getInternalInventory(); for (IFarmLogic logic : getFarmLogics()) { // Germlings try to go into germling slots first. if (logic.isAcceptedGermling(produce)) @@ -576,6 +576,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable // Let event handlers handle the harvest first. for (IFarmListener listener : eventHandlers) listener.afterCropHarvest(harvested, crop); + + TileInventoryAdapter inventory = getInternalInventory(); // Stow harvest. for (ItemStack harvest : harvested) { @@ -606,7 +608,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return false; ItemStack next = pendingProduce.peek(); - if (inventory.tryAddStack(next, SLOT_PRODUCTION_1, SLOT_COUNT_PRODUCTION, true, true)) { + if (getInternalInventory().tryAddStack(next, SLOT_PRODUCTION_1, SLOT_COUNT_PRODUCTION, true, true)) { pendingProduce.pop(); return true; } @@ -622,6 +624,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return; } + TileInventoryAdapter inventory = getInternalInventory(); ItemStack fertilizer = inventory.getStackInSlot(SLOT_FERTILIZER); if (fertilizer == null || fertilizer.stackSize <= 0) return; @@ -741,25 +744,25 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public boolean hasResources(ItemStack[] resources) { - return inventory.contains(resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); + return getInternalInventory().contains(resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); } public boolean hasResourcesAmount(int amount) { - return inventory.containsAmount(amount, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); + return getInternalInventory().containsAmount(amount, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); } public boolean hasGermlingsPercent(float percent) { - return inventory.containsPercent(percent, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); + return getInternalInventory().containsPercent(percent, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); } public boolean hasFertilizerPercent(float percent) { - return inventory.containsPercent(percent, SLOT_FERTILIZER, 1); + return getInternalInventory().containsPercent(percent, SLOT_FERTILIZER, 1); } @Override public void removeResources(ItemStack[] resources) { EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); - inventory.removeSets(1, resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS, player, false, true, true); + getInternalInventory().removeSets(1, resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS, player, false, true, true); } @Override @@ -773,12 +776,12 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } public boolean hasGermlings(ItemStack[] germlings) { - return inventory.contains(germlings, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); + return getInternalInventory().contains(germlings, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); } @Override public boolean plantGermling(IFarmable germling, World world, int x, int y, int z) { - + TileInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_GERMLINGS_1; i < SLOT_GERMLINGS_1 + SLOT_COUNT_RESERVOIRS; i++) { if (inventory.getStackInSlot(i) == null) continue; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 2c263fc07..eb94e4fab 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -14,7 +14,6 @@ import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import forestry.api.core.ITileStructure; import forestry.core.utils.BlockUtil; -import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.farming.triggers.FarmingTriggers; @@ -69,9 +68,11 @@ public class TileHatch extends TileFarm implements ISidedInventory { private void dumpToPipe(ArrayList pipes) { ItemStack[] products = extractItem(true, ForgeDirection.DOWN, 1); - for (ItemStack product : products) - while (product.stackSize > 0) + for (ItemStack product : products) { + while (product.stackSize > 0) { BlockUtil.putFromStackIntoPipe(this, pipes, product); + } + } } @@ -118,17 +119,11 @@ public class TileHatch extends TileFarm implements ISidedInventory { } /* IINVENTORY */ - @Override - public InventoryAdapter getInternalInventory() { - return (InventoryAdapter)getStructureInventory(); - } - - private IInventory getStructureInventory() { - + private ISidedInventory getStructureInventory() { if (hasMaster()) { ITileStructure central = getCentralTE(); if (central != null) - return central.getInventory(); + return (ISidedInventory) central.getInventory(); } return null; @@ -186,46 +181,6 @@ public class TileHatch extends TileFarm implements ISidedInventory { return 0; } - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - if(slotIndex >= TileFarmPlain.SLOT_PRODUCTION_1 && slotIndex < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION) - return true; - - return false; - } - - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if (!hasMaster()) - return false; - - ITileStructure struct = getCentralTE(); - if (!(struct instanceof TileFarmPlain)) - return false; - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - TileFarmPlain housing = (TileFarmPlain) struct; - if (slotIndex == TileFarmPlain.SLOT_FERTILIZER && housing.acceptsAsFertilizer(itemstack)) - return true; - if (slotIndex >= TileFarmPlain.SLOT_RESOURCES_1 && slotIndex < TileFarmPlain.SLOT_RESOURCES_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS - && housing.acceptsAsResource(itemstack)) - return true; - if (slotIndex >= TileFarmPlain.SLOT_GERMLINGS_1 && slotIndex < TileFarmPlain.SLOT_GERMLINGS_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS - && housing.acceptsAsGermling(itemstack)) - return true; - if(slotIndex == TileFarmPlain.SLOT_CAN) - return FluidContainerRegistry.isFilledContainer(itemstack); - - return false; - } - @Override public void openInventory() { } @@ -239,52 +194,59 @@ public class TileHatch extends TileFarm implements ISidedInventory { return getUnlocalizedName(); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + if (!hasMaster()) + return false; + + ITileStructure struct = getCentralTE(); + if (!(struct instanceof TileFarmPlain)) + return false; + + if (!getStructureInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + + TileFarmPlain housing = (TileFarmPlain) struct; + if (slotIndex == TileFarmPlain.SLOT_FERTILIZER && housing.acceptsAsFertilizer(itemstack)) + return true; + if (slotIndex >= TileFarmPlain.SLOT_RESOURCES_1 && slotIndex < TileFarmPlain.SLOT_RESOURCES_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS + && housing.acceptsAsResource(itemstack)) + return true; + if (slotIndex >= TileFarmPlain.SLOT_GERMLINGS_1 && slotIndex < TileFarmPlain.SLOT_GERMLINGS_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS + && housing.acceptsAsGermling(itemstack)) + return true; + if (slotIndex == TileFarmPlain.SLOT_CAN) + return FluidContainerRegistry.isFilledContainer(itemstack); + + return false; } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(xCoord, itemstack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getStructureInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + + return slotIndex >= TileFarmPlain.SLOT_PRODUCTION_1 && slotIndex < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; } - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); + return getStructureInventory().getAccessibleSlotsFromSide(side); } public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { @@ -316,7 +278,7 @@ public class TileHatch extends TileFarm implements ISidedInventory { } if (product != null) - return new ItemStack[] { product }; + return new ItemStack[]{product}; else return StackUtils.EMPTY_STACK_ARRAY; } diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index b4e5facfe..6a34a372d 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -14,7 +14,6 @@ import buildcraft.api.statements.ITriggerExternal; import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.Optional; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostalState; @@ -31,7 +30,6 @@ import forestry.mail.PostRegistry; import forestry.plugins.PluginMail; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentTranslation; @@ -41,7 +39,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.Collection; import java.util.LinkedList; -public class MachineMailbox extends TileBase implements IMailContainer, ISpecialInventory, ISidedInventory { +public class MachineMailbox extends TileBase implements IMailContainer { private boolean isLinked = false; @@ -49,11 +47,6 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial setHints(Config.hints.get("mailbox")); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - /* GUI */ @Override public void openGui(EntityPlayer player, TileBase tile) { @@ -84,7 +77,6 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial } /* MAIL HANDLING */ - public IInventory getOrCreateMailInventory(World world, GameProfile playerProfile) { if (!Proxies.common.isSimulating(world)) return new InventoryAdapter(POBox.SLOT_SIZE, "Letters"); @@ -110,9 +102,10 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial public boolean hasMail() { IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile()); - for (int i = 0; i < mailInventory.getSizeInventory(); i++) + for (int i = 0; i < mailInventory.getSizeInventory(); i++) { if (mailInventory.getStackInSlot(i) != null) return true; + } return false; } @@ -127,124 +120,107 @@ public class MachineMailbox extends TileBase implements IMailContainer, ISpecial } /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - if (!PostManager.postRegistry.isLetter(stack)) - return 0; +// @Override +// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { +// if (!PostManager.postRegistry.isLetter(stack)) +// return 0; +// +// IPostalState result = tryDispatchLetter(stack, doAdd); +// +// if (!result.isOk()) +// return 0; +// else +// return 1; +// } +// +// @Override +// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { +// +// ItemStack product = null; +// IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile()); +// +// for (int i = 0; i < mailInventory.getSizeInventory(); i++) { +// ItemStack slotStack = mailInventory.getStackInSlot(i); +// if (slotStack == null) +// continue; +// +// product = slotStack; +// if (doRemove) +// mailInventory.setInventorySlotContents(i, null); +// break; +// } +// +// if (product != null) +// return new ItemStack[]{product}; +// else +// return new ItemStack[0]; +// } - IPostalState result = tryDispatchLetter(stack, doAdd); - - if (!result.isOk()) - return 0; - else - return 1; - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - - ItemStack product = null; - IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile()); - - for (int i = 0; i < mailInventory.getSizeInventory(); i++) { - ItemStack slotStack = mailInventory.getStackInSlot(i); - if (slotStack == null) - continue; - - product = slotStack; - if (doRemove) - mailInventory.setInventorySlotContents(i, null); - break; - } - - if (product != null) - return new ItemStack[] { product }; - else - return new ItemStack[0]; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(int var1) { - return null; - } - - @Override - public ItemStack decrStackSize(int var1, int var2) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int var1) { - return null; - } - - @Override - public void setInventorySlotContents(int var1, ItemStack var2) { - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } +// @Override +// public int getSizeInventory() { +// return 0; +// } +// +// @Override +// public ItemStack getStackInSlot(int var1) { +// return null; +// } +// +// @Override +// public ItemStack decrStackSize(int var1, int var2) { +// return null; +// } +// +// @Override +// public ItemStack getStackInSlotOnClosing(int var1) { +// return null; +// } +// +// @Override +// public void setInventorySlotContents(int var1, ItemStack var2) { +// } +// +// @Override +// public int getInventoryStackLimit() { +// return 0; +// } +// +// @Override +// public boolean isUseableByPlayer(EntityPlayer player) { +// return Utils.isUseableByPlayer(player, this); +// } +// +// @Override +// public boolean hasCustomInventoryName() { +// return false; +// } +// +// // TODO: This is broken mezz, I don't know how to fix -CovertJaguar +// @Override +// public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { +// return super.isItemValidForSlot(slotIndex, itemstack); +// } +// +// @Override +// public boolean canInsertItem(int i, ItemStack itemstack, int j) { +// return super.canInsertItem(i, itemstack, j); +// } +// +// @Override +// public boolean canExtractItem(int i, ItemStack itemstack, int j) { +// return super.canExtractItem(i, itemstack, j); +// } +// +// @Override +// public int[] getAccessibleSlotsFromSide(int side) { +// return super.getAccessibleSlotsFromSide(side); +// } +// +// @Override +// public void openInventory() { +// } +// +// @Override +// public void closeInventory() { +// } } diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 14f03818e..6d45de2ff 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -13,15 +13,15 @@ package forestry.mail.gadgets; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import forestry.api.core.ForestryAPI; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.core.gadgets.TileBase; import forestry.core.network.GuiId; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; public class MachinePhilatelist extends TileBase implements IInventory { @@ -30,9 +30,8 @@ public class MachinePhilatelist extends TileBase implements IInventory { public static final short SLOT_BUFFER_1 = 1; public static final short SLOT_BUFFER_COUNT = 27; - private final InventoryAdapter inventory = new InventoryAdapter(28, "INV"); - public MachinePhilatelist() { + setInternalInventory(new TileInventoryAdapter(this, 28, "INV")); } @Override @@ -45,21 +44,6 @@ public class MachinePhilatelist extends TileBase implements IInventory { player.openGui(ForestryAPI.instance, GuiId.PhilatelistGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); } - /* SAVING & LOADING */ - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - inventory.writeToNBT(nbttagcompound); - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - inventory.readFromNBT(nbttagcompound); - } - // / UPDATING @Override public void updateServerSide() { @@ -68,6 +52,7 @@ public class MachinePhilatelist extends TileBase implements IInventory { ItemStack stamp = null; + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_FILTER) == null) stamp = PostManager.postRegistry.getPostOffice(worldObj).getAnyStamp(1); else { @@ -86,37 +71,32 @@ public class MachinePhilatelist extends TileBase implements IInventory { /* IINVENTORY */ @Override public int getSizeInventory() { - return inventory.getSizeInventory(); + return getInternalInventory().getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - return inventory.getStackInSlot(i); + return getInternalInventory().getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - return inventory.decrStackSize(i, j); + return getInternalInventory().decrStackSize(i, j); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - inventory.setInventorySlotContents(i, itemstack); + getInternalInventory().setInventorySlotContents(i, itemstack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); - } - - @Override - public void markDirty() { - inventory.markDirty(); + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); + return getInternalInventory().getInventoryStackLimit(); } @Override @@ -127,28 +107,19 @@ public class MachinePhilatelist extends TileBase implements IInventory { public void closeInventory() { } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); } } diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 7b813ef3a..c74c2d818 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -17,6 +17,7 @@ import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.api.core.EnumErrorCode; +import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; @@ -24,6 +25,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import forestry.mail.MailAddress; import forestry.mail.TradeStation; import forestry.plugins.PluginMail; @@ -63,9 +65,8 @@ public class MachineTrader extends TileBase implements ISidedInventory { @Override public void onRemoval() { - if (isLinked()) { + if (isLinked()) PostManager.postRegistry.deleteTradeStation(worldObj, address); - } } /* SAVING & LOADING */ @@ -84,13 +85,11 @@ public class MachineTrader extends TileBase implements ISidedInventory { public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("address")) { + if (nbttagcompound.hasKey("address")) address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address")); - } } /* UPDATING */ - /** * The trade station should show errors for missing stamps and paper first. * Once it is able to send letters, it should display other error states. @@ -106,12 +105,11 @@ public class MachineTrader extends TileBase implements ISidedInventory { if (!hasPostageMin(3)) errorCode = EnumErrorCode.NOSTAMPS; - if (!hasPaperMin(2)) { + if (!hasPaperMin(2)) if (errorCode == EnumErrorCode.NOSTAMPS) errorCode = EnumErrorCode.NOSTAMPSNOPAPER; else errorCode = EnumErrorCode.NOPAPER; - } if (errorCode != EnumErrorCode.OK) { setErrorState(errorCode); @@ -133,23 +131,21 @@ public class MachineTrader extends TileBase implements ISidedInventory { } boolean hasSupplies = hasItemCount(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood, tradeGood.stackSize); - if(!hasSupplies) { + if (!hasSupplies) { setErrorState(EnumErrorCode.NOSUPPLIES); return; } - if (inventory instanceof TradeStation) { - if (!((TradeStation)inventory).canReceivePayment()) { + if (inventory instanceof TradeStation) + if (!((TradeStation) inventory).canReceivePayment()) { setErrorState(EnumErrorCode.NOSPACE); return; } - } setErrorState(EnumErrorCode.OK); } /* STATE INFORMATION */ - public boolean isLinked() { return address.isValid(); } @@ -186,16 +182,16 @@ public class MachineTrader extends TileBase implements ISidedInventory { IInventory tradeInventory = this.getOrCreateTradeInventory(); for (int i = startSlot; i < startSlot + countSlots; i++) { ItemStack itemInSlot = tradeInventory.getStackInSlot(i); - if (itemInSlot == null) { + if (itemInSlot == null) total += 64; - } else { + else { total += itemInSlot.getMaxStackSize(); if (item == null || StackUtils.isIdenticalItem(itemInSlot, item)) count += itemInSlot.stackSize; } } - return ((float)count / (float)total); + return ((float) count / (float) total); } public boolean hasPaperMin(int count) { @@ -277,23 +273,6 @@ public class MachineTrader extends TileBase implements ISidedInventory { return PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); } - /* ISIDEDINVENTORY */ - - /** - * TODO: just a specialsource workaround - */ - @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - return super.canTakeStackFromSide(slotIndex, itemstack, side); - } - - /** - * TODO: just a specialsource workaround - */ - @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - return super.canPutStackFromSide(slotIndex, itemstack, side); - } /* ISIDEDINVENTORY */ @Override @@ -349,12 +328,18 @@ public class MachineTrader extends TileBase implements ISidedInventory { return getOrCreateTradeInventory().isItemValidForSlot(slotIndex, itemstack); } + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return Utils.isUseableByPlayer(player, this); + } + + /* ISIDEDINVENTORY */ @Override public boolean canInsertItem(int i, ItemStack itemstack, int j) { IInventory inventory = getOrCreateTradeInventory(); if (inventory instanceof TradeStation) - return ((TradeStation)getOrCreateTradeInventory()).canInsertItem(i, itemstack, j); - return super.canInsertItem(i, itemstack, j); + return ((TradeStation) inventory).canInsertItem(i, itemstack, j); + return false; } @Override @@ -362,9 +347,9 @@ public class MachineTrader extends TileBase implements ISidedInventory { IInventory inventory = getOrCreateTradeInventory(); if (inventory instanceof TradeStation) { boolean permission = (getAccess() == EnumAccess.SHARED); - return ((TradeStation) getOrCreateTradeInventory()).canExtractItem(i, itemstack, j, permission); + return ((TradeStation) inventory).canExtractItem(i, itemstack, j, permission); } - return super.canExtractItem(i, itemstack, j); + return false; } @Override @@ -372,9 +357,9 @@ public class MachineTrader extends TileBase implements ISidedInventory { IInventory inventory = getOrCreateTradeInventory(); if (inventory instanceof TradeStation) { boolean permission = (getAccess() == EnumAccess.SHARED); - return ((TradeStation) getOrCreateTradeInventory()).getAccessibleSlotsFromSide(side, permission); + return ((TradeStation) inventory).getAccessibleSlotsFromSide(side, permission); } - return super.getAccessibleSlotsFromSide(side); + return Defaults.FACINGS_NONE; } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index b9d30631d..c8c443360 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -20,7 +20,6 @@ import forestry.mail.gadgets.MachineMailbox; import forestry.plugins.PluginMail; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -33,20 +32,19 @@ public class ContainerMailbox extends ContainerForestry { private final POBox mailInventory; public ContainerMailbox(InventoryPlayer player, MachineMailbox tile) { - super(tile); + super(tile.getOrCreateMailInventory(player.player.worldObj, player.player.getGameProfile())); // Mailbox contents this.mailbox = tile; - IInventory inv = mailbox.getOrCreateMailInventory(player.player.worldObj, player.player.getGameProfile()); - if (inv instanceof POBox) - this.mailInventory = (POBox) inv; + if (inventory instanceof POBox) + this.mailInventory = (POBox) inventory; else this.mailInventory = null; for (int i = 0; i < 7; i++) for (int j = 0; j < 12; j++) - addSlot(new SlotClosed(inv, j + i * 9, 8 + j * 18, 8 + i * 18)); + addSlot(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) From c4b3f7e9f1c8116d39c5943786d9612692c7c111 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 18:56:31 -0800 Subject: [PATCH 043/175] Only consume fluid containers with null getContainerItem --- .../forestry/core/fluids/FluidHelper.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 2eac3fb34..adad32f67 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -166,23 +166,32 @@ public final class FluidHelper { if (used < fluidInContainer.amount) return false; - fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); - ItemStack emptyItem = getEmptyContainer(input); - // unstackable containers like buckets are not consumed - if (outputSlot == inputSlot && input.getMaxStackSize() == 1) { - inv.setInventorySlotContents(outputSlot, emptyItem); - return true; + if (output != null && emptyItem != null) { + if (outputSlot == inputSlot) { + if (input.stackSize > 1) + return false; + } else if (!StackUtils.isIdenticalItem(output, emptyItem)) { + return false; + } else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) { + return false; + } } + fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); + if (emptyItem != null) { + if (outputSlot == inputSlot) { + inv.setInventorySlotContents(outputSlot, emptyItem); + return true; + } + if (output == null) { inv.setInventorySlotContents(outputSlot, emptyItem); - } else if (StackUtils.isIdenticalItem(output, emptyItem) && (output.stackSize < output.getMaxStackSize())) { + } else { output.stackSize++; } - // else output item is consumed } inv.decrStackSize(inputSlot, 1); return true; @@ -239,17 +248,11 @@ public final class FluidHelper { } public static ItemStack getEmptyContainer(ItemStack container) { - Item item = container.getItem(); - if (item instanceof IFluidContainerItem) { - ItemStack empty = container.copy(); - empty.stackSize = 1; - IFluidContainerItem containerItem = (IFluidContainerItem) item; - containerItem.drain(empty, Integer.MAX_VALUE, true); - return empty; - } + if (item == null) + return null; - return FluidContainerRegistry.drainFluidContainer(container); + return item.getContainerItem(container); } public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { From 9cbb6e390b0580913261c71a9cbf99b6b7842326 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 18:58:49 -0800 Subject: [PATCH 044/175] Cleanup, use Fluids enum --- .../gadgets/TileAlvearyHygroregulator.java | 11 +- .../java/forestry/core/EventHandlerCore.java | 27 ++-- src/main/java/forestry/core/ForestryCore.java | 91 +++++++------ .../java/forestry/core/config/Defaults.java | 14 -- .../java/forestry/core/fluids/Fluids.java | 47 ++++--- .../java/forestry/core/items/ItemFruit.java | 13 +- src/main/java/forestry/core/utils/Fluids.java | 59 --------- .../forestry/core/utils/LiquidHelper.java | 52 ++------ .../java/forestry/core/utils/RecipeUtil.java | 14 +- .../forestry/energy/gadgets/EngineBronze.java | 34 ++--- .../factory/gadgets/MachineBottler.java | 7 +- .../factory/gadgets/MachineCarpenter.java | 5 +- .../factory/gadgets/MachineFabricator.java | 4 +- .../factory/gadgets/MachineFermenter.java | 3 +- .../factory/gadgets/MachineRaintank.java | 4 +- .../farming/gadgets/TileFarmPlain.java | 5 +- .../farming/logic/FarmLogicWatered.java | 23 ++-- .../forestry/plugins/PluginApiculture.java | 20 +-- .../forestry/plugins/PluginArboriculture.java | 42 +++--- .../plugins/PluginBuildCraftFuels.java | 18 +-- .../plugins/PluginBuildCraftRecipes.java | 8 +- .../java/forestry/plugins/PluginFactory.java | 123 +++++++++--------- .../java/forestry/plugins/PluginFood.java | 5 +- src/main/java/forestry/plugins/PluginIC2.java | 17 +-- .../plugins/PluginLepidopterology.java | 4 +- .../java/forestry/plugins/PluginMail.java | 7 +- .../java/forestry/plugins/PluginNatura.java | 9 +- .../java/forestry/plugins/PluginStorage.java | 14 +- 28 files changed, 302 insertions(+), 378 deletions(-) delete mode 100755 src/main/java/forestry/core/utils/Fluids.java diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index e95542055..87d8603a2 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -19,8 +19,6 @@ 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; @@ -28,14 +26,13 @@ import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ForestryAPI; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; 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; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer { @@ -70,9 +67,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory public TileAlvearyHygroregulator() { super(BLOCK_META); - Fluid water = FluidRegistry.getFluid(Defaults.LIQUID_WATER); - Fluid lava = FluidRegistry.getFluid(Defaults.LIQUID_LAVA); - Fluid liquidIce = FluidRegistry.getFluid(Defaults.LIQUID_ICE); + Fluid water = Fluids.WATER.get(); + Fluid lava = Fluids.LAVA.get(); + Fluid liquidIce = Fluids.ICE.get(); liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce); tankManager = new TankManager(liquidTank); diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index 4be006a84..c3b3df08c 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -10,23 +10,26 @@ ******************************************************************************/ package forestry.core; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.EnumErrorCode; -import forestry.core.interfaces.IOreDictionaryHandler; -import forestry.core.interfaces.IPickupHandler; -import forestry.core.interfaces.ISaveEventHandler; -import forestry.core.render.TextureManager; -import forestry.core.utils.LiquidHelper; -import forestry.plugins.PluginManager; import net.minecraft.item.ItemStack; + import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.EnumErrorCode; +import forestry.core.fluids.Fluids; +import forestry.core.interfaces.IOreDictionaryHandler; +import forestry.core.interfaces.IPickupHandler; +import forestry.core.interfaces.ISaveEventHandler; +import forestry.core.render.TextureManager; +import forestry.plugins.PluginManager; + public class EventHandlerCore { public EventHandlerCore() { @@ -87,7 +90,7 @@ public class EventHandlerCore { EnumErrorCode.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); } else if(event.map.getTextureType() == 0) - LiquidHelper.resetLiquidIcons(event.map); + Fluids.resetFluidIcons(event.map); } @SubscribeEvent diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 0905e75b4..29f61b83a 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -20,7 +20,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -39,6 +38,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.config.Version; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.TileEngine; import forestry.core.gadgets.TileMachine; import forestry.core.gadgets.TileMill; @@ -90,17 +90,18 @@ public class ForestryCore { Defaults.ENGINE_COPPER_FUEL_VALUE_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_PEAT)); FuelManager.copperEngineFuel.put(ForestryItem.bituminousPeat.getItemStack(), new EngineCopperFuel(ForestryItem.bituminousPeat.getItemStack(), Defaults.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_BIOMASS), + + FuelManager.bronzeEngineFuel.put(Fluids.BIOMASS.get(), new EngineBronzeFuel(Fluids.BIOMASS.get(), Defaults.ENGINE_FUEL_VALUE_BIOMASS, (int) (Defaults.ENGINE_CYCLE_DURATION_BIOMASS * GameMode.getGameMode().getFloatSetting("fuel.biomass.biogas")), 1)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_WATER), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_WATER), + FuelManager.bronzeEngineFuel.put(Fluids.WATER.get(), new EngineBronzeFuel(Fluids.WATER.get(), Defaults.ENGINE_FUEL_VALUE_WATER, Defaults.ENGINE_CYCLE_DURATION_WATER, 3)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_MILK), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_MILK), + FuelManager.bronzeEngineFuel.put(Fluids.MILK.get(), new EngineBronzeFuel(Fluids.MILK.get(), Defaults.ENGINE_FUEL_VALUE_MILK, Defaults.ENGINE_CYCLE_DURATION_MILK, 3)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_SEEDOIL), + FuelManager.bronzeEngineFuel.put(Fluids.SEEDOIL.get(), new EngineBronzeFuel(Fluids.SEEDOIL.get(), Defaults.ENGINE_FUEL_VALUE_SEED_OIL, Defaults.ENGINE_CYCLE_DURATION_SEED_OIL, 1)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_HONEY), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_HONEY), + FuelManager.bronzeEngineFuel.put(Fluids.HONEY.get(), new EngineBronzeFuel(Fluids.HONEY.get(), Defaults.ENGINE_FUEL_VALUE_HONEY, Defaults.ENGINE_CYCLE_DURATION_HONEY, 1)); - FuelManager.bronzeEngineFuel.put(FluidRegistry.getFluid(Defaults.LIQUID_JUICE), new EngineBronzeFuel(FluidRegistry.getFluid(Defaults.LIQUID_JUICE), + FuelManager.bronzeEngineFuel.put(Fluids.JUICE.get(), new EngineBronzeFuel(Fluids.JUICE.get(), Defaults.ENGINE_FUEL_VALUE_JUICE, Defaults.ENGINE_CYCLE_DURATION_JUICE, 1)); // Set rain substrates @@ -149,60 +150,58 @@ public class ForestryCore { private void registerLiquidContainers() { // Add lava and water buckets to the API in case this has not been done yet. if (LiquidHelper.isEmptyLiquidData()) { - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, new ItemStack(Items.lava_bucket), new ItemStack(Items.bucket)); - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.water_bucket), new ItemStack(Items.bucket)); + LiquidHelper.injectLiquidContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, new ItemStack(Items.lava_bucket), new ItemStack(Items.bucket)); + LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.water_bucket), new ItemStack(Items.bucket)); } // Glass - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_GLASS); + Fluids.GLASS.register(); // Set default lava, water and biofuel buckets - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_MILK); - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_MILK, Defaults.BUCKET_VOLUME, new ItemStack(Items.milk_bucket), new ItemStack(Items.bucket)); + Fluids.MILK.register(); + LiquidHelper.injectLiquidContainer(Fluids.MILK, Defaults.BUCKET_VOLUME, new ItemStack(Items.milk_bucket), new ItemStack(Items.bucket)); // Lava - LiquidHelper.injectTinContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, ForestryItem.canLava.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, ForestryItem.refractoryLava.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectTinContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.canLava.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.refractoryLava.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); // Water - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem, 1, 0), - new ItemStack(Items.glass_bottle)); - LiquidHelper.injectTinContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, ForestryItem.canWater.getItemStack(), - ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleWater.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, ForestryItem.refractoryWater.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.glass_bottle)); + LiquidHelper.injectTinContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.canWater.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleWater.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.refractoryWater.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_BIOMASS); - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiomass.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Defaults.LIQUID_BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.canBiomass.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiomass.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiomass.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.BIOMASS.register(); + LiquidHelper.injectLiquidContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiomass.getItemStack(), new ItemStack(Items.bucket)); + LiquidHelper.injectTinContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.canBiomass.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiomass.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiomass.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_ETHANOL); - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_ETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiofuel.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Defaults.LIQUID_ETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.canBiofuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_ETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiofuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_ETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiofuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.BIOETHANOL.register(); + LiquidHelper.injectLiquidContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiofuel.getItemStack(), new ItemStack(Items.bucket)); + LiquidHelper.injectTinContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.canBiofuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiofuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiofuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_SEEDOIL); - LiquidHelper.injectTinContainer(Defaults.LIQUID_SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.canSeedOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleSeedOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.refractorySeedOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.SEEDOIL.register(); + LiquidHelper.injectTinContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.canSeedOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleSeedOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.refractorySeedOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_HONEY); - LiquidHelper.injectTinContainer(Defaults.LIQUID_HONEY, Defaults.BUCKET_VOLUME, ForestryItem.canHoney.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_HONEY, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleHoney.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_HONEY, Defaults.BUCKET_VOLUME, ForestryItem.refractoryHoney.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.HONEY.register(); + LiquidHelper.injectTinContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.canHoney.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleHoney.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.refractoryHoney.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_JUICE); - LiquidHelper.injectTinContainer(Defaults.LIQUID_JUICE, Defaults.BUCKET_VOLUME, ForestryItem.canJuice.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_JUICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleJuice.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_JUICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryJuice.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.JUICE.register(); + LiquidHelper.injectTinContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.canJuice.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleJuice.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryJuice.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_ICE); - LiquidHelper.injectTinContainer(Defaults.LIQUID_ICE, Defaults.BUCKET_VOLUME, ForestryItem.canIce.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_ICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleIce.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_ICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryIce.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + Fluids.ICE.register(); + LiquidHelper.injectTinContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.canIce.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleIce.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryIce.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); } } diff --git a/src/main/java/forestry/core/config/Defaults.java b/src/main/java/forestry/core/config/Defaults.java index 104eff1e5..4cf2e08e5 100755 --- a/src/main/java/forestry/core/config/Defaults.java +++ b/src/main/java/forestry/core/config/Defaults.java @@ -45,20 +45,6 @@ public class Defaults { public static final int[] FACING_WESTEAST = { FACING_WEST, FACING_EAST }; public static final int[] FACINGS_NONE = new int[0]; - public static final String LIQUID_WATER = "water"; - public static final String LIQUID_LAVA = "lava"; - public static final String LIQUID_MILK = "milk"; - public static final String LIQUID_BIOMASS = "biomass"; - public static final String LIQUID_ETHANOL = "bioethanol"; - public static final String LIQUID_SEEDOIL = "seedoil"; - public static final String LIQUID_HONEY = "honey"; - public static final String LIQUID_JUICE = "juice"; - public static final String LIQUID_ICE = "ice"; - public static final String LIQUID_MEAD = "short.mead"; - public static final String LIQUID_GLASS = "glass"; - public static final String LIQUID_OIL = "oil"; - public static final String LIQUID_FUEL = "fuel"; - // Textures public static final String TEXTURE_PATH_GUI = "textures/gui"; public static final String TEXTURE_PATH_BLOCKS = "textures/blocks"; diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index f148112d9..46e294f8f 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -10,14 +10,20 @@ ******************************************************************************/ package forestry.core.fluids; -import forestry.core.config.Defaults; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; + +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import forestry.core.render.TextureManager; + /** * * @author CovertJaguar @@ -25,7 +31,10 @@ import net.minecraftforge.fluids.FluidStack; public enum Fluids { WATER, LAVA, FUEL, BIOMASS, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, - COAL, PYROTHEUM, HONEY, MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD(Defaults.LIQUID_MEAD); + COAL, PYROTHEUM, HONEY, MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); + + private static final List myLiquids = new ArrayList(values().length); + private final String tag; private Fluids() { @@ -44,24 +53,20 @@ public enum Fluids { return FluidRegistry.getFluid(tag); } - /** - * Gets a FluidStack filled with qty milliBuckets worth of Fluid. - * - * @param qty - * @return - */ - public FluidStack get(int qty) { - return FluidRegistry.getFluidStack(tag, qty); + public void register() { + Fluid fluid = get(); + if (fluid == null) { + fluid = new Fluid(tag); + FluidRegistry.registerFluid(fluid); + myLiquids.add(tag); + } } /** - * Gets a FluidStack filled with n buckets worth of Fluid. - * - * @param n - * @return + * Gets a FluidStack filled with mb milliBuckets worth of Fluid. */ - public FluidStack getB(int n) { - return FluidRegistry.getFluidStack(tag, n * FluidContainerRegistry.BUCKET_VOLUME); + public FluidStack get(int mb) { + return FluidRegistry.getFluidStack(tag, mb); } public boolean is(Fluid fluid) { @@ -82,4 +87,12 @@ public enum Fluids { return fluid == null && fluidStack == null; } + public static void resetFluidIcons(IIconRegister register) { + for (String fluidString : myLiquids) { + Fluid fluid = FluidRegistry.getFluid(fluidString); + IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName()); + fluid.setIcons(icon); + } + } + } diff --git a/src/main/java/forestry/core/items/ItemFruit.java b/src/main/java/forestry/core/items/ItemFruit.java index 6948c9c1f..15591a8a5 100755 --- a/src/main/java/forestry/core/items/ItemFruit.java +++ b/src/main/java/forestry/core/items/ItemFruit.java @@ -19,11 +19,12 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; - +import forestry.core.config.ForestryItem; import forestry.core.render.TextureManager; public class ItemFruit extends ItemForestryFood { @@ -49,6 +50,14 @@ public class ItemFruit extends ItemForestryFood { public IIcon getIcon() { return icons[ordinal()]; } + + public ItemStack getStack() { + return getStack(1); + } + + public ItemStack getStack(int qty) { + return ForestryItem.fruits.getItemStack(qty, ordinal()); + } } public ItemFruit() { diff --git a/src/main/java/forestry/core/utils/Fluids.java b/src/main/java/forestry/core/utils/Fluids.java deleted file mode 100755 index 0a011b318..000000000 --- a/src/main/java/forestry/core/utils/Fluids.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.utils; - -import java.util.Locale; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import forestry.core.fluids.FluidHelper; - -/** - * @author CovertJaguar - */ -public enum Fluids { - - WATER, LAVA, FUEL, BIOFUEL, CREOSOTE, STEAM; - - public String getTag() { - return name().toLowerCase(Locale.ENGLISH); - } - - public Fluid get() { - return FluidRegistry.getFluid(getTag()); - } - - public FluidStack get(int qty) { - return FluidRegistry.getFluidStack(getTag(), qty); - } - - public boolean is(Fluid fluid) { - return get() == fluid; - } - - public boolean is(FluidStack fluidStack) { - return fluidStack != null && get() == fluidStack.getFluid(); - } - - public boolean isContained(ItemStack containerStack) { - return containerStack != null && FluidHelper.containsFluid(containerStack, Fluids.WATER.get()); - } - - public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { - if (fluidStack != null && fluid == fluidStack.getFluid()) - return true; - return fluid == null && fluidStack == null; - } -} diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index 157ff030f..e6ec5a3a7 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -10,63 +10,42 @@ ******************************************************************************/ package forestry.core.utils; -import java.util.LinkedList; - -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -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 forestry.api.recipes.RecipeManagers; import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; +import forestry.core.fluids.Fluids; public class LiquidHelper { - private static final LinkedList myLiquids = new LinkedList(); - public static boolean isEmptyLiquidData() { return FluidContainerRegistry.getRegisteredFluidContainerData().length <= 0; } - public static Fluid getOrCreateLiquid(String ident) { - if (!FluidRegistry.isFluidRegistered(ident)) { - Fluid fluid = new Fluid(ident); - FluidRegistry.registerFluid(fluid); - myLiquids.add(ident); - } - return FluidRegistry.getFluid(ident); + public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { + injectLiquidContainer(fluid, volume, filled, empty, null, 0); } - public static FluidStack getLiquid(String name, int amount) { - return FluidRegistry.getFluidStack(name, amount); + public static void injectWaxContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { + injectLiquidContainer(fluid, volume, filled, empty, ForestryItem.beeswax.getItemStack(), 10); } - public static void injectLiquidContainer(String name, int volume, ItemStack filled, ItemStack empty) { - injectLiquidContainer(name, volume, filled, empty, null, 0); + public static void injectRefractoryContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { + injectLiquidContainer(fluid, volume, filled, empty, ForestryItem.refractoryWax.getItemStack(), 10); } - public static void injectWaxContainer(String name, int volume, ItemStack filled, ItemStack empty) { - injectLiquidContainer(name, volume, filled, empty, ForestryItem.beeswax.getItemStack(), 10); + public static void injectTinContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { + injectLiquidContainer(fluid, volume, filled, empty, ForestryItem.ingotTin.getItemStack(), 5); } - public static void injectRefractoryContainer(String name, int volume, ItemStack filled, ItemStack empty) { - injectLiquidContainer(name, volume, filled, empty, ForestryItem.refractoryWax.getItemStack(), 10); - } - - public static void injectTinContainer(String name, int volume, ItemStack filled, ItemStack empty) { - injectLiquidContainer(name, volume, filled, empty, ForestryItem.ingotTin.getItemStack(), 5); - } - - public static void injectLiquidContainer(String name, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) { - FluidStack contained = FluidRegistry.getFluidStack(name, volume); + public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) { + FluidStack contained = fluid.get(volume); if (contained == null) - throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", name)); + throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", fluid)); FluidContainerData container = new FluidContainerData(contained, filled, empty); FluidContainerRegistry.registerFluidContainer(container); @@ -79,11 +58,4 @@ public class LiquidHelper { RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { container.filledContainer }, container.fluid); } - public static void resetLiquidIcons(IIconRegister register) { - for (String fluidString : myLiquids) { - Fluid fluid = FluidRegistry.getFluid(fluidString); - IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName()); - fluid.setIcons(icon); - } - } } diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 37341c907..fe1fb3d63 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -21,10 +21,12 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; import forestry.core.gui.ContainerDummy; import forestry.core.interfaces.IDescriptiveRecipe; import forestry.core.proxy.Proxies; @@ -33,17 +35,17 @@ public class RecipeUtil { private static final Container DUMMY_CONTAINER = new ContainerDummy(); - public static void injectLeveledRecipe(ItemStack resource, int fermentationValue, String output) { + public static void injectLeveledRecipe(ItemStack resource, int fermentationValue, Fluids output) { if (RecipeManagers.fermenterManager == null) return; - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1)); + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, output.get(1), Fluids.WATER.get(1)); - if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_JUICE)) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, 1)); + if (FluidRegistry.isFluidRegistered(Fluids.JUICE.get())) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.get(1), Fluids.JUICE.get(1)); - if (FluidRegistry.isFluidRegistered(Defaults.LIQUID_HONEY)) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1)); + if (FluidRegistry.isFluidRegistered(Fluids.HONEY.get())) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.get(1), Fluids.HONEY.get(1)); } /** diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 28b2cd9d6..b26ba5d61 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -10,6 +10,20 @@ ******************************************************************************/ package forestry.energy.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; @@ -17,6 +31,7 @@ import forestry.api.fuels.FuelManager; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -25,24 +40,8 @@ import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.TileInventoryAdapter; -import static forestry.factory.gadgets.MachineBottler.SLOT_CAN; -import static forestry.factory.gadgets.MachineBottler.SLOT_PRODUCT; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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; - public class EngineBronze extends Engine implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ @@ -143,7 +142,8 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank if (heatStage > 0.25 && shutdown) shutdown(false); else if (shutdown) - if (heatingTank.getFluidAmount() > 0 && heatingTank.getFluid().getFluid().getName().equals(Defaults.LIQUID_LAVA)) { + + if (heatingTank.getFluidAmount() > 0 && Fluids.LAVA.is(heatingTank.getFluid())) { addHeat(Defaults.ENGINE_HEAT_VALUE_LAVA); heatingTank.drain(1, true); } diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 0a35a8f9f..e9228a06e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -106,11 +106,10 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } // No recipe matched. See if the liquid dictionary has anything. - if(FluidContainerRegistry.isEmptyContainer(empty)) { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(res, empty); + if(FluidHelper.isEmptyContainer(empty)) { + ItemStack filled = FluidHelper.getFilledContainer(res, empty); if(filled != null) { - FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(filled); - Recipe recipe = new Recipe(CYCLES_FILLING_DEFAULT, fluidStack, empty, filled); + Recipe recipe = new Recipe(CYCLES_FILLING_DEFAULT, res, empty, filled); recipes.add(recipe); return recipe; } diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 5e4b99397..cef212e38 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -40,6 +40,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; @@ -146,14 +147,14 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void addCrating(ItemStack itemStack) { ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.get(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated }); addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack }); } @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.get(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate }); addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated }); } diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index b44302666..8e10ad22e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -15,6 +15,7 @@ import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IFabricatorManager; import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -214,8 +215,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public MachineFabricator() { super(1100, 50, 3300); - Fluid liquidGlass = FluidRegistry.getFluid(Defaults.LIQUID_GLASS); - moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, liquidGlass); + moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.get()); moltenTank.tankMode = StandardTank.TankMode.INTERNAL; tankManager = new TankManager(moltenTank); } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index a64926b2e..d70e068a1 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -41,6 +41,7 @@ import forestry.api.recipes.IVariableFermentable; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.tanks.StandardTank; @@ -138,7 +139,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output) { - addRecipe(resource, fermentationValue, modifier, output, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000)); + addRecipe(resource, fermentationValue, modifier, output, Fluids.WATER.get(1000)); } public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 939587e67..b9ddcf208 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -30,12 +30,12 @@ import forestry.api.core.ForestryAPI; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.GuiId; -import forestry.core.utils.Fluids; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; @@ -45,7 +45,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui /* CONSTANTS */ public static final short SLOT_RESOURCE = 0; public static final short SLOT_PRODUCT = 1; - private static final FluidStack STACK_WATER = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, Defaults.RAINTANK_AMOUNT_PER_UPDATE); + private static final FluidStack STACK_WATER = Fluids.WATER.get(Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ public FilteredTank resourceTank; diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index b0014ebd1..31543a143 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -48,6 +48,7 @@ import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.interfaces.IClimatised; @@ -434,7 +435,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable else hasFertilizer = true; - FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = Fluids.WATER.get(logic.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) continue; else @@ -557,7 +558,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } // Check water - FluidStack liquid = FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, provider.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = Fluids.WATER.get(provider.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) { setErrorState(EnumErrorCode.NOLIQUID); return false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index a2b50cdea..9899b59fb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -10,31 +10,30 @@ ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.IFarmHousing; -import forestry.core.config.Defaults; -import forestry.core.proxy.Proxies; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.Collection; +import forestry.api.farming.IFarmHousing; +import forestry.core.fluids.Fluids; +import forestry.core.utils.BlockUtil; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; +import forestry.core.utils.Vect; public abstract class FarmLogicWatered extends FarmLogic { protected ItemStack ground; private final ItemStack[] resource; - private static final FluidStack STACK_WATER = new FluidStack(FluidRegistry.getFluid(Defaults.LIQUID_WATER), 1000); + private static final FluidStack STACK_WATER = Fluids.WATER.get(1000); ArrayList produce = new ArrayList(); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 4ab0a92be..b3a009d30 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -145,6 +145,7 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.config.Property; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.gadgets.TileAnalyzer; @@ -563,13 +564,13 @@ public class PluginApiculture extends ForestryPlugin { '#', ForestryItem.propolis.getItemStack(1, 2)); // / CANDLES - RecipeManagers.carpenterManager.addRecipe(30, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 600), null, ForestryBlock.candle.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.get(600), null, ForestryBlock.candle.getItemStack(24), " X ", "###", "###", '#', ForestryItem.beeswax, 'X', Items.string); - RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 200), null, ForestryBlock.candle.getItemStack(6), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(200), null, ForestryBlock.candle.getItemStack(6), "#X#", '#', ForestryItem.beeswax, 'X', ForestryItem.craftingMaterial.getItemStack(1, 2)); @@ -639,20 +640,20 @@ public class PluginApiculture extends ForestryPlugin { 'W', ForestryItem.craftingMaterial.getItemStack(1, 3)); // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP), + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), ForestryItem.propolis.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, Defaults.FLUID_PER_HONEY_DROP)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 2000)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, Fluids.LAVA.get(2000)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, Fluids.LAVA.get(1600)); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.beealyzer.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.beealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotTin", 'R', Items.redstone, 'D', Items.diamond); - RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), + RecipeManagers.carpenterManager.addRecipe(50, Fluids.HONEY.get(500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), " J ", "###", "WPW", '#', "plankWood", 'J', ForestryItem.royalJelly, @@ -707,8 +708,7 @@ public class PluginApiculture extends ForestryPlugin { ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10}); // / FERMENTER - RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, FluidRegistry.getFluidStack(Defaults.LIQUID_MEAD, 1), - FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, 1)); + RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.get(1), Fluids.HONEY.get(1)); // ANALYZER definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 2f33f7e73..58b0f989c 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -133,6 +133,7 @@ import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.genetics.Allele; @@ -412,7 +413,7 @@ public class PluginArboriculture extends ForestryPlugin { ItemStack logStack = forestryBlock.getItemStack(1, i); ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofLogStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofLogStack, new Object[]{ " # ", "#X#", " # ", @@ -427,7 +428,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -439,7 +440,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -477,22 +478,25 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i)); // Treealyzer - RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotCopper", 'R', Items.redstone, 'D', Items.diamond); // SQUEEZER RECIPES - RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 5 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 18 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 22 * GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed")), ForestryItem.mulch.getItemStack(), 2); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.5f)), ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 3); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple") * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.fruits.getItemStack(1, EnumFruit.DATES.ordinal())}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") * 0.25)), ForestryItem.mulch.getItemStack(), (int) Math.floor(GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"))); + int seedOilMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + int juiceMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + int mulchMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{EnumFruit.CHERRY.getStack()}, Fluids.SEEDOIL.get(5 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{EnumFruit.WALNUT.getStack()}, Fluids.SEEDOIL.get(18 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{EnumFruit.CHESTNUT.getStack()}, Fluids.SEEDOIL.get(22 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 2); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.LEMON.getStack()}, Fluids.JUICE.get(juiceMultiplier * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PLUM.getStack()}, Fluids.JUICE.get((int) Math.floor(juiceMultiplier * 0.5f)), ForestryItem.mulch.getItemStack(), mulchMultiplier * 3); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PAPAYA.getStack()}, Fluids.JUICE.get(juiceMultiplier * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.DATES.getStack()}, Fluids.JUICE.get((int) Math.floor(juiceMultiplier * 0.25)), ForestryItem.mulch.getItemStack(), mulchMultiplier); - RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); + RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); // Stairs for (int i = 0; i < 16; i++) { @@ -918,17 +922,17 @@ public class PluginArboriculture extends ForestryPlugin { Allele.fruitApple = new AlleleFruit("fruitApple", new FruitProviderRandom("apple", pomes, new ItemStack(Items.apple), 1.0f).setColour(0xff2e2e).setOverlay("pomes")); Allele.fruitCocoa = new AlleleFruit("fruitCocoa", new FruitProviderPod("cocoa", jungle, EnumPodType.COCOA)); // .setColours(0xecdca5, 0xc4d24a), true); - Allele.fruitChestnut = new AlleleFruit("fruitChestnut", new FruitProviderRipening("chestnut", nux, ForestryItem.fruits.getItemStack(1, EnumFruit.CHESTNUT.ordinal()), 1.0f).setRipeningPeriod(6).setColours(0x7f333d, 0xc4d24a).setOverlay("nuts"), true); - Allele.fruitWalnut = new AlleleFruit("fruitWalnut", new FruitProviderRipening("walnut", nux, ForestryItem.fruits.getItemStack(1, EnumFruit.WALNUT.ordinal()), 1.0f).setRipeningPeriod(8).setColours(0xfba248, 0xc4d24a).setOverlay("nuts"), true); - Allele.fruitCherry = new AlleleFruit("fruitCherry", new FruitProviderRipening("cherry", prunes, ForestryItem.fruits.getItemStack(1, EnumFruit.CHERRY.ordinal()), 1.0f).setColours(0xff2e2e, 0xc4d24a).setOverlay("berries"), true); - Allele.fruitDates = new AlleleFruit("fruitDates", new FruitProviderPod("dates", jungle, EnumPodType.DATES, ForestryItem.fruits.getItemStack(4, EnumFruit.DATES.ordinal()))); - Allele.fruitPapaya = new AlleleFruit("fruitPapaya", new FruitProviderPod("papaya", jungle, EnumPodType.PAPAYA, ForestryItem.fruits.getItemStack(1, EnumFruit.PAPAYA.ordinal()))); + Allele.fruitChestnut = new AlleleFruit("fruitChestnut", new FruitProviderRipening("chestnut", nux, EnumFruit.CHESTNUT.getStack(), 1.0f).setRipeningPeriod(6).setColours(0x7f333d, 0xc4d24a).setOverlay("nuts"), true); + Allele.fruitWalnut = new AlleleFruit("fruitWalnut", new FruitProviderRipening("walnut", nux, EnumFruit.WALNUT.getStack(), 1.0f).setRipeningPeriod(8).setColours(0xfba248, 0xc4d24a).setOverlay("nuts"), true); + Allele.fruitCherry = new AlleleFruit("fruitCherry", new FruitProviderRipening("cherry", prunes, EnumFruit.CHERRY.getStack(), 1.0f).setColours(0xff2e2e, 0xc4d24a).setOverlay("berries"), true); + Allele.fruitDates = new AlleleFruit("fruitDates", new FruitProviderPod("dates", jungle, EnumPodType.DATES, EnumFruit.DATES.getStack(4))); + Allele.fruitPapaya = new AlleleFruit("fruitPapaya", new FruitProviderPod("papaya", jungle, EnumPodType.PAPAYA, EnumFruit.PAPAYA.getStack())); // Allele.fruitCoconut = new AlleleFruit("fruitCoconut", new // FruitProviderPod("coconut", jungle, EnumPodType.COCONUT, new // ItemStack[] { new ItemStack( // ForestryItem.fruits, 1, EnumFruit.COCONUT.ordinal()) })); - Allele.fruitLemon = new AlleleFruit("fruitLemon", new FruitProviderRipening("lemon", prunes, ForestryItem.fruits.getItemStack(1, EnumFruit.LEMON.ordinal()), 1.0f).setColours(0xeeee00, 0x99ff00).setOverlay("citrus"), true); - Allele.fruitPlum = new AlleleFruit("fruitPlum", new FruitProviderRipening("plum", prunes, ForestryItem.fruits.getItemStack(1, EnumFruit.PLUM.ordinal()), 1.0f).setColours(0x663446, 0xeeff1a).setOverlay("plums"), true); + Allele.fruitLemon = new AlleleFruit("fruitLemon", new FruitProviderRipening("lemon", prunes, EnumFruit.LEMON.getStack(), 1.0f).setColours(0xeeee00, 0x99ff00).setOverlay("citrus"), true); + Allele.fruitPlum = new AlleleFruit("fruitPlum", new FruitProviderRipening("plum", prunes, EnumFruit.PLUM.getStack(), 1.0f).setColours(0x663446, 0xeeff1a).setOverlay("plums"), true); // / TREES // GROWTH PROVIDER 1350 - 1399 Allele.growthLightlevel = new AlleleGrowth("growthLightlevel", new GrowthProvider()); diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index 002241592..0e38ec085 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -11,13 +11,13 @@ package forestry.plugins; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.common.Optional; import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; @@ -39,19 +39,19 @@ public class PluginBuildCraftFuels extends ForestryPlugin { @Optional.Method(modid = "BuildCraftAPI|fuels") @Override public void doInit() { - BuildcraftFuelRegistry.coolant.addCoolant(FluidRegistry.getFluid(Defaults.LIQUID_ICE), 10.0f); + BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.get(), 10.0f); - Fluid ethanol = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1).getFluid(); + Fluid ethanol = Fluids.BIOETHANOL.get(); int ethanolPower = 40; int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_OIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectWaxContainer(Defaults.LIQUID_FUEL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleFuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_OIL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Defaults.LIQUID_FUEL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryFuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Defaults.LIQUID_OIL, Defaults.BUCKET_VOLUME, ForestryItem.canOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Defaults.LIQUID_FUEL, Defaults.BUCKET_VOLUME, ForestryItem.canFuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectWaxContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleFuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectRefractoryContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryFuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectTinContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.canOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); + LiquidHelper.injectTinContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.canFuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); } } diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 9224ffe1c..2f1ad1cb5 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -10,12 +10,10 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - import cpw.mods.fml.common.Optional; import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import buildcraft.api.recipes.BuildcraftRecipeRegistry; @@ -37,8 +35,6 @@ public class PluginBuildCraftRecipes extends ForestryPlugin { @Override protected void registerRecipes() { // Add recipe for ethanol - FluidStack input = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 4); - FluidStack output = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1); - BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", input, output, 100, 1); + BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.get(4), Fluids.BIOETHANOL.get(1), 100, 1); } } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index ccf9e261f..d8306553d 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -18,6 +18,7 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.network.IGuiHandler; @@ -27,6 +28,7 @@ import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.gadgets.MachineNBTDefinition; @@ -253,56 +255,58 @@ public class PluginFactory extends ForestryPlugin { protected void registerRecipes() { // / FABRICATOR - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ + + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 10), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 10), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"}); - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 11), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 11), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; - if (PluginManager.Module.APICULTURE.isEnabled()) + if (PluginManager.Module.APICULTURE.isEnabled()) { + FluidStack liquidGlass = Fluids.GLASS.get(Defaults.BUCKET_VOLUME); for (int i = 0; i < 16; i++) - RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, - Defaults.BUCKET_VOLUME), ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i], - 'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)}); + RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), liquidGlass, ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i], + 'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)}); + } // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple")), - ForestryItem.mulch.getItemStack(), GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple")); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode - .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode - .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, GameMode - .getGameMode().getIntegerSetting("squeezer.liquid.seed"))); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)}, - FluidRegistry.getFluidStack(Defaults.LIQUID_LAVA, 1600)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)}, - FluidRegistry.getFluidStack(Defaults.LIQUID_ICE, 4000)); + int appleMulchAmount = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); + int appleJuiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, Fluids.JUICE.get(appleJuiceAmount), + ForestryItem.mulch.getItemStack(), appleMulchAmount); + + int seedOilAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + FluidStack seedOil = Fluids.SEEDOIL.get(seedOilAmount); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, seedOil); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, seedOil); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, seedOil); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)}, Fluids.LAVA.get(1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, Fluids.WATER.get(500)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)}, Fluids.ICE.get(4000)); // STILL - RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, - Defaults.STILL_DESTILLATION_INPUT), FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, Defaults.STILL_DESTILLATION_OUTPUT)); + RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.get(Defaults.STILL_DESTILLATION_INPUT), + Fluids.BIOETHANOL.get(Defaults.STILL_DESTILLATION_OUTPUT)); // MOISTENER RecipeManagers.moistenerManager.addRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Blocks.mycelium), 5000); @@ -310,29 +314,28 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.moistenerManager.addRecipe(new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stonebrick, 1, 1), 20000); // FERMENTER - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, 0), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, 1), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, 2), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, 3), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); + for (int i = 0; i < 4; i++) + RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.sapling, 1, i), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.cactus), GameMode.getGameMode().getIntegerSetting("fermenter.yield.cactus"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Items.wheat), GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Items.reeds), GameMode.getGameMode().getIntegerSetting("fermenter.yield.cane"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.brown_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.red_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Defaults.LIQUID_BIOMASS); + RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.cactus), GameMode.getGameMode().getIntegerSetting("fermenter.yield.cactus"), Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(new ItemStack(Items.wheat), GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(new ItemStack(Items.reeds), GameMode.getGameMode().getIntegerSetting("fermenter.yield.cane"), Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.brown_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(new ItemStack(Blocks.red_mushroom), GameMode.getGameMode().getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS); // FABRICATOR - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 375), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 1000), 3000); + + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), Fluids.GLASS.get(1000), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), Fluids.GLASS.get(375), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), Fluids.GLASS.get(1000), 3000); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 250), null, ForestryItem.impregnatedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.get(250), null, ForestryItem.impregnatedCasing.getItemStack(), "###", "# #", "###", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(50, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 500), null, + RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.get(500), null, ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META), "# ", "###", @@ -340,35 +343,35 @@ public class PluginFactory extends ForestryPlugin { '#', "plankWood"); // RESOURCES - RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 100), null, + RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.get(100), null, ForestryItem.stickImpregnated.getItemStack(2), "#", "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(250), null, ForestryItem.woodPulp.getItemStack(4), "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(250), null, new ItemStack(Items.paper, 1), "#", "#", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryBlock.soil.getItemStack(9), "###", "#X#", "###", '#', Blocks.dirt, 'X', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryBlock.soil.getItemStack(8, 1), "#X#", "XYX", "#X#", '#', Blocks.dirt, 'X', Blocks.sand, 'Y', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(75, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 5000), null, ForestryItem.hardenedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(75, Fluids.WATER.get(5000), null, ForestryItem.hardenedCasing.getItemStack(), "# #", " Y ", "# #", @@ -376,21 +379,21 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.sturdyCasing); // / CHIPSETS - RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 0), + RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 0), "R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 1), + RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 1), "R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 2), + RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 2), "R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.circuitboards.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 3), "R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.solderingIron.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.get(1000), null, ForestryItem.solderingIron.getItemStack(), " # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze"); // ForestryCore.oreHandler.registerCarpenterRecipe(solderingIron); // RAIN SUBSTRATES if (PluginManager.Module.APICULTURE.isEnabled()) { - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.iodineCharge.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.iodineCharge.getItemStack(), "Z#Z", "#Y#", "X#X", @@ -399,7 +402,7 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.canEmpty, 'Z', ForestryItem.honeyDrop); // ForestryCore.oreHandler.registerCarpenterRecipe(iodineCapsule); - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), "Z#Z", "#Y#", "X#X", @@ -414,13 +417,13 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), " # ", "###", " # ", '#', ForestryItem.craftingMaterial.getItemStack(1, 1)); // Woven Silk - RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), "###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2)); // Boxes - RecipeManagers.carpenterManager.addRecipe(5, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.carton.getItemStack(2), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.carton.getItemStack(2), " # ", "# #", " # ", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(20, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.crate.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.get(1000), null, ForestryItem.crate.getItemStack(24), " # ", "# #", " # ", '#', "logWood"); // Assembly Kits diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index 3e68bed5d..47426ea22 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -20,6 +20,7 @@ import forestry.api.food.IBeverageEffect; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryFood; @@ -69,8 +70,8 @@ public class PluginFood extends ForestryPlugin { ItemStack meadBottle = ForestryItem.beverage.getItemStack(); ((ItemBeverage) ForestryItem.beverage.item()).beverages[0].saveEffects(meadBottle, new IBeverageEffect[] { BeverageEffect.weakAlcoholic }); - LiquidHelper.getOrCreateLiquid(Defaults.LIQUID_MEAD); - LiquidHelper.injectLiquidContainer(Defaults.LIQUID_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); + Fluids.SHORT_MEAD.register(); + LiquidHelper.injectLiquidContainer(Fluids.SHORT_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); } @Override diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 1360c94f1..a0c9c382a 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -38,6 +38,7 @@ import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.items.ItemCrated; @@ -200,11 +201,11 @@ public class PluginIC2 extends ForestryPlugin { definitionEngineTin.register(); definitionGenerator.register(); - FluidStack ethanol = FluidRegistry.getFluidStack(Defaults.LIQUID_ETHANOL, 1); + FluidStack ethanol = Fluids.BIOETHANOL.get(1); GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4); FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel); - FluidStack biomass = FluidRegistry.getFluidStack(Defaults.LIQUID_BIOMASS, 1); + FluidStack biomass = Fluids.BIOMASS.get(1); GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1); FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel); @@ -270,14 +271,14 @@ public class PluginIC2 extends ForestryPlugin { if (rubber != null) { for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { - RecipeManagers.fabricatorManager.addRecipe(null, FluidRegistry.getFluidStack(Defaults.LIQUID_GLASS, 500), ForestryItem.tubes.getItemStack(4, 8), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 8), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', rubberOreDict}); } } if (plantBall != null && compressedPlantBall != null) { - RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Defaults.LIQUID_BIOMASS); - RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 5, Defaults.LIQUID_BIOMASS); + RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 5, Fluids.BIOMASS); } else { Proxies.log.fine("No IC2 plantballs found."); } @@ -288,7 +289,7 @@ public class PluginIC2 extends ForestryPlugin { Proxies.log.fine("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); if (rubbersapling != null) { - RecipeUtil.injectLeveledRecipe(rubbersapling, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Defaults.LIQUID_BIOMASS); + RecipeUtil.injectLeveledRecipe(rubbersapling, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); } else Proxies.log.fine("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); @@ -303,10 +304,10 @@ public class PluginIC2 extends ForestryPlugin { } if (lavaCell != null) - LiquidHelper.injectTinContainer(Defaults.LIQUID_LAVA, Defaults.BUCKET_VOLUME, lavaCell, emptyCell); + LiquidHelper.injectTinContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, lavaCell, emptyCell); if (waterCell != null) { - LiquidHelper.injectTinContainer(Defaults.LIQUID_WATER, Defaults.BUCKET_VOLUME, waterCell, emptyCell); + LiquidHelper.injectTinContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, waterCell, emptyCell); ItemStack bogEarthCan = GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can"); if (bogEarthCan.stackSize > 0) diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index b2ad5d5bd..9f7eff777 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -18,7 +18,6 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.crafting.CraftingManager; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.RecipeSorter; import cpw.mods.fml.common.SidedProxy; @@ -39,6 +38,7 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.config.Property; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.genetics.Allele; @@ -149,7 +149,7 @@ public class PluginLepidopterology extends ForestryPlugin { protected void registerRecipes() { CraftingManager.getInstance().getRecipeList().add(new MatingRecipe()); - RecipeManagers.carpenterManager.addRecipe(100, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 2000), null, ForestryItem.flutterlyzer.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.flutterlyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotBronze", 'R', Items.redstone, 'D', Items.diamond); } diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index d3ac0b401..0a81a1899 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -16,8 +16,6 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; - import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; @@ -29,6 +27,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.interfaces.IOreDictionaryHandler; @@ -202,7 +201,7 @@ public class PluginMail extends ForestryPlugin { 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper, 'Z', stampGlue); - RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, 300), null, ForestryItem.stamps.getItemStack(9, i), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.get(300), null, ForestryItem.stamps.getItemStack(9, i), "XXX", "###", 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper); @@ -212,7 +211,7 @@ public class PluginMail extends ForestryPlugin { Proxies.common.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, Defaults.WILDCARD)); // Carpenter - RecipeManagers.carpenterManager.addRecipe(10, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); Proxies.common.addShapelessRecipe(ForestryItem.catalogue.getItemStack(), ForestryItem.stamps.getItemStack(1, Defaults.WILDCARD), new ItemStack(Items.book)); } diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 0e5a07b95..5d2270cae 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -16,8 +16,6 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; - import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; @@ -25,6 +23,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; import forestry.core.config.Defaults; +import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; @Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description") @@ -86,8 +85,7 @@ public class PluginNatura extends ForestryPlugin { int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); for (ItemStack aSeedList : seedList) - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, - FluidRegistry.getFluidStack(Defaults.LIQUID_SEEDOIL, amount)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.get(amount)); ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); @@ -119,8 +117,7 @@ public class PluginNatura extends ForestryPlugin { amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25; amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. for (ItemStack berry : berries) - RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, - FluidRegistry.getFluidStack(Defaults.LIQUID_JUICE, amount)); + RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.get(amount)); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 94708ad26..0888e78c4 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -43,7 +43,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IShearable; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -60,6 +59,7 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.config.Property; +import forestry.core.fluids.Fluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.IResupplyHandler; @@ -504,22 +504,22 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl // / CARPENTER // / BACKPACKS T2 - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.minerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.minerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.diggerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.diggerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.foresterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.foresterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.hunterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.hunterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, FluidRegistry.getFluidStack(Defaults.LIQUID_WATER, 1000), null, ForestryItem.builderBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.builderBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack); From 1b741eaac5ba4a82d26192b48a1d17d5da93fddd Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 19:19:49 -0800 Subject: [PATCH 045/175] Remove vialEmpty, vialCatalyst --- lang | 2 +- .../forestry/core/config/ForestryItem.java | 2 -- .../forestry/plugins/PluginApiculture.java | 30 ------------------- .../java/forestry/plugins/PluginCore.java | 11 ------- 4 files changed, 1 insertion(+), 44 deletions(-) diff --git a/lang b/lang index 3c34adcc5..78a42965d 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 3c34adcc54f2e1dc0d06b6720261fcd77c4e2f24 +Subproject commit 78a42965de89d39804cccdaeed51ac2cf98f2919 diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 6d586e14e..eb8838dae 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -43,8 +43,6 @@ public enum ForestryItem { wrench, pipette, bucketBiomass, - vialEmpty, - vialCatalyst, bucketBiofuel, // Crafting impregnatedCasing, diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index b3a009d30..3b66f571c 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -472,36 +472,6 @@ public class PluginApiculture extends ForestryPlugin { // / HABITAT LOCATOR //Proxies.common.addRecipe(ForestryItem.biomeFinder.getItemStack(), // new Object[] { " X ", "X#X", " X ", '#', Items.redstone, 'X', "ingotBronze" }); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(3), - "###", "YXY", - '#', ForestryItem.waxCapsule, - 'X', Items.bone, - 'Y', ForestryItem.pollenCluster); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(3), - "###", "YXY", - '#', ForestryItem.canEmpty, - 'X', Items.bone, - 'Y', ForestryItem.pollenCluster); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(), - "###", "YXY", "###", - '#', ForestryItem.honeyDrop, - 'Y', ForestryItem.fertilizerCompound, - 'X', ForestryItem.waxCapsule); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(), - "###", "YXY", "###", - '#', ForestryItem.honeyDrop, - 'Y', ForestryItem.fertilizerCompound, - 'X', ForestryItem.canEmpty); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(), - "###", "YXY", "###", - '#', ForestryItem.honeyDrop, - 'Y', ForestryItem.pollenCluster, - 'X', ForestryItem.waxCapsule); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(), - "###", "YXY", "###", - '#', ForestryItem.honeyDrop, - 'Y', ForestryItem.pollenCluster, - 'X', ForestryItem.canEmpty); // Bees Proxies.common.addRecipe(ForestryItem.scoop.getItemStack(1), diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index 411514819..f904f8b00 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -193,13 +193,6 @@ public class PluginCore extends ForestryPlugin { /* ARMOR */ ForestryItem.naturalistHat.registerItem(new ItemArmorNaturalist(0), "naturalistHelmet"); - // / DISCONTINUED - // ForestryItem.vialEmpty = (new - // ItemForestry(Config.getOrCreateIntProperty("vialEmpty", - // Config.CATEGORY_ITEM, Defaults.ID_ITEM_VIAL_EMPTY))) - // .setItemName("vialEmpty").setIconIndex(10); - ForestryItem.vialCatalyst.registerItem((new ItemForestry()), "vialCatalyst"); - // / PEAT PRODUCTION ForestryItem.peat.registerItem((new ItemForestry()), "peat"); OreDictionary.registerOre("brickPeat", ForestryItem.peat.getItemStack()); @@ -432,10 +425,6 @@ public class PluginCore extends ForestryPlugin { Proxies.common.addRecipe(GameMode.getGameMode().getStackSetting("recipe.output.bogearth.can"), "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', ForestryItem.refractoryWater, 'Y', Blocks.sand); } - // Vials and catalyst - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(3), "###", "YXY", '#', ForestryItem.waxCapsule.item(), 'X', Items.bone, 'Y', ForestryItem.fertilizerCompound); - Proxies.common.addRecipe(ForestryItem.vialCatalyst.getItemStack(3), "###", "YXY", '#', ForestryItem.canEmpty.item(), 'X', Items.bone, 'Y', ForestryItem.fertilizerCompound); - // Crafting Material Proxies.common.addRecipe(new ItemStack(Items.string), "#", "#", "#", '#', ForestryItem.craftingMaterial.getItemStack(1, 2)); From a8b7098f391155f7808450db0c55e65ce3ff7077 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 21:29:55 -0800 Subject: [PATCH 046/175] Implement spawn tree and spawn forest commands --- lang | 2 +- .../commands/CommandBeekeeping.java | 4 +- .../commands/CommandBeekeepingGiveBee.java | 19 +-- .../arboriculture/CommandSpawnForest.java | 49 ------ .../arboriculture/CommandSpawnTree.java | 52 ------- .../arboriculture/commands/CommandTrees.java | 23 +++ .../commands/CommandTreesSpawn.java | 141 ++++++++++++++++++ .../commands/CommandTreesSpawnForest.java | 44 ++++++ .../commands/CommandTreesSpawnTree.java | 31 ++++ .../worldgen/WorldGenArboriculture.java | 6 +- .../commands}/SpeciesNotFoundException.java | 4 +- .../commands}/TemplateNotFoundException.java | 2 +- .../forestry/core/worldgen/WorldGenBase.java | 8 +- .../forestry/plugins/PluginArboriculture.java | 9 +- 14 files changed, 268 insertions(+), 126 deletions(-) delete mode 100755 src/main/java/forestry/arboriculture/CommandSpawnForest.java delete mode 100755 src/main/java/forestry/arboriculture/CommandSpawnTree.java create mode 100644 src/main/java/forestry/arboriculture/commands/CommandTrees.java create mode 100644 src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java create mode 100644 src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java create mode 100644 src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java rename src/main/java/forestry/{apiculture => core/commands}/SpeciesNotFoundException.java (89%) mode change 100755 => 100644 rename src/main/java/forestry/{apiculture => core/commands}/TemplateNotFoundException.java (96%) mode change 100755 => 100644 diff --git a/lang b/lang index 78a42965d..76846d9c7 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 78a42965de89d39804cccdaeed51ac2cf98f2919 +Subproject commit 76846d9c7646a02c8ac28e673579f065d499b3b9 diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java b/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java index f39dccc23..ceeb66d33 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java @@ -15,8 +15,8 @@ import forestry.core.commands.SubCommand; public class CommandBeekeeping extends SubCommand { public CommandBeekeeping() { - super("beekeeping"); - addAlias("bee"); + super("bee"); + addAlias("beekeeping"); addChildCommand(new CommandBeekeepingMode()); addChildCommand(new CommandBeekeepingSave()); addChildCommand(new CommandBeekeepingGiveBee()); diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java b/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java index b82f4d9b5..4134d27ca 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java @@ -10,24 +10,25 @@ ******************************************************************************/ package forestry.apiculture.commands; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; -import forestry.apiculture.SpeciesNotFoundException; -import forestry.apiculture.TemplateNotFoundException; import forestry.core.commands.CommandHelpers; +import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.SubCommand; +import forestry.core.commands.TemplateNotFoundException; import forestry.plugins.PluginApiculture; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; public class CommandBeekeepingGiveBee extends SubCommand { diff --git a/src/main/java/forestry/arboriculture/CommandSpawnForest.java b/src/main/java/forestry/arboriculture/CommandSpawnForest.java deleted file mode 100755 index 2cb959d0b..000000000 --- a/src/main/java/forestry/arboriculture/CommandSpawnForest.java +++ /dev/null @@ -1,49 +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.arboriculture; - -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.gen.feature.WorldGenerator; - -import forestry.api.world.ITreeGenData; -import forestry.arboriculture.genetics.TreeTemplates; -import forestry.arboriculture.worldgen.WorldGenBalsa; -import forestry.core.utils.CommandMC; -import forestry.plugins.PluginArboriculture; - -public class CommandSpawnForest extends CommandMC { - - @Override - public String getCommandName() { - return "spawnforest"; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "/" + getCommandName() + " "; - } - - @Override - public void processCommand(ICommandSender sender, String[] arguments) { - EntityPlayer player = getCommandSenderAsPlayer(sender); - - int x = (int) player.posX - 16; - int y = (int) (player.posY); - int z = (int) player.posZ - 16; - - WorldGenerator gen = new WorldGenBalsa((ITreeGenData) PluginArboriculture.treeInterface.getTree(player.worldObj, - TreeTemplates.templateAsGenome(PluginArboriculture.treeInterface.getTemplate("treeBalsa")))); - - for (int i = 0; i < 16; i++) - gen.generate(player.worldObj, player.worldObj.rand, x + player.worldObj.rand.nextInt(32), y, z + player.worldObj.rand.nextInt(32)); - } -} diff --git a/src/main/java/forestry/arboriculture/CommandSpawnTree.java b/src/main/java/forestry/arboriculture/CommandSpawnTree.java deleted file mode 100755 index 9ad8e744a..000000000 --- a/src/main/java/forestry/arboriculture/CommandSpawnTree.java +++ /dev/null @@ -1,52 +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.arboriculture; - -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.gen.feature.WorldGenerator; - -import forestry.api.world.ITreeGenData; -import forestry.arboriculture.genetics.TreeTemplates; -import forestry.arboriculture.worldgen.WorldGenBalsa; -import forestry.core.utils.CommandMC; -import forestry.plugins.PluginArboriculture; - -public class CommandSpawnTree extends CommandMC { - - public CommandSpawnTree() { - } - - @Override - public String getCommandName() { - return "spawntree"; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "/" + getCommandName() + " "; - } - - @Override - public void processCommand(ICommandSender sender, String[] arguments) { - EntityPlayer player = getCommandSenderAsPlayer(sender); - - int x = (int) player.posX; - int y = (int) (player.posY); - int z = (int) player.posZ; - - WorldGenerator gen = new WorldGenBalsa((ITreeGenData) PluginArboriculture.treeInterface.getTree(player.worldObj, - TreeTemplates.templateAsGenome(PluginArboriculture.treeInterface.getTemplate("treeBalsa")))); - - gen.generate(player.worldObj, player.worldObj.rand, x, y, z); - - } -} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTrees.java b/src/main/java/forestry/arboriculture/commands/CommandTrees.java new file mode 100644 index 000000000..dc6da946e --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/CommandTrees.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import forestry.core.commands.SubCommand; + +public class CommandTrees extends SubCommand { + + public CommandTrees() { + super("tree"); + addChildCommand(new CommandTreesSpawnTree()); + addChildCommand(new CommandTreesSpawnForest()); + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java new file mode 100644 index 000000000..7a05b7964 --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.gen.feature.WorldGenerator; + +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.core.commands.CommandHelpers; +import forestry.core.commands.SpeciesNotFoundException; +import forestry.core.commands.SubCommand; +import forestry.core.commands.TemplateNotFoundException; +import forestry.core.worldgen.WorldGenBase; +import forestry.plugins.PluginArboriculture; + +import org.apache.commons.lang3.StringUtils; + +public abstract class CommandTreesSpawn extends SubCommand { + + public CommandTreesSpawn(String name) { + super(name); + setPermLevel(PermLevel.ADMIN); + } + + @Override + public final void processSubCommand(ICommandSender sender, String[] arguments) { + if (arguments.length < 1 || arguments.length > 2) { + printHelp(sender); + return; + } + + EntityPlayer player; + String treeName; + try { + player = CommandHelpers.getPlayer(sender, arguments[arguments.length - 1]); + String[] argumentsWithoutPlayer = new String[arguments.length - 1]; + System.arraycopy(arguments, 0, argumentsWithoutPlayer, 0, arguments.length - 1); + treeName = StringUtils.join(argumentsWithoutPlayer, " "); + } catch (PlayerNotFoundException e) { + player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName()); + treeName = StringUtils.join(arguments, " "); + } + + processSubCommand(sender, treeName, player); + } + + protected abstract void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player); + + protected final WorldGenerator getWorldGen(String treeName, EntityPlayer player, int x, int y, int z) { + ITreeGenome treeGenome = getTreeGenome(treeName); + if (treeGenome == null) { + return null; + } + + ITree tree = PluginArboriculture.treeInterface.getTree(player.worldObj, treeGenome); + return tree.getTreeGenerator(player.worldObj, x, y, z, true); + } + + protected final void generateTree(WorldGenerator gen, EntityPlayer player, int x, int y, int z) { + if (gen instanceof WorldGenBase) { + ((WorldGenBase) gen).generate(player.worldObj, player.worldObj.rand, x, y, z, true); + } else { + gen.generate(player.worldObj, player.worldObj.rand, x, y, z); + } + } + + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] parameters) { + if (parameters.length == 1) { + List tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies()); + tabCompletion.add("help"); + return tabCompletion; + } else if (parameters.length == 2) { + return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers()); + } + return null; + } + + private static String[] getSpecies() { + List species = new ArrayList(); + + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) + if (allele instanceof IAlleleTreeSpecies) + species.add(allele.getName().replaceAll("\\s", "")); + + return species.toArray(new String[species.size()]); + } + + private static ITreeGenome getTreeGenome(String speciesName) { + IAlleleTreeSpecies species = null; + + for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { + + if (!uid.equals(speciesName)) + continue; + + IAllele allele = AlleleManager.alleleRegistry.getAllele(uid); + if (allele instanceof IAlleleTreeSpecies) { + species = (IAlleleTreeSpecies) allele; + break; + } + } + + if (species == null) { + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleTreeSpecies && allele.getName().replaceAll("\\s", "").equals(speciesName)) { + species = (IAlleleTreeSpecies) allele; + break; + } + } + } + + if (species == null) + throw new SpeciesNotFoundException(speciesName); + + IAllele[] template = PluginArboriculture.treeInterface.getTemplate(species.getUID()); + + if (template == null) + throw new TemplateNotFoundException(species); + + return PluginArboriculture.treeInterface.templateAsGenome(template); + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java new file mode 100644 index 000000000..450b3956a --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class CommandTreesSpawnForest extends CommandTreesSpawn { + + public CommandTreesSpawnForest() { + super("spawnForest"); + } + + protected void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player) { + Vec3 look = player.getLookVec(); + + int x = (int)Math.round(player.posX + (16 * look.xCoord)); + int y = (int)Math.round(player.posY); + int z = (int)Math.round(player.posZ + (16 * look.zCoord)); + + for (int i = 0; i < 16; i++) { + int spawnX = x + player.worldObj.rand.nextInt(32) - 16; + int spawnZ = z + player.worldObj.rand.nextInt(32) - 16; + + WorldGenerator gen = getWorldGen(treeName, player, spawnX, y, spawnZ); + if (gen == null) { + printHelp(sender); + return; + } + generateTree(gen, player, spawnX, y, spawnZ); + } + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java new file mode 100644 index 000000000..54daa8061 --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java @@ -0,0 +1,31 @@ +package forestry.arboriculture.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class CommandTreesSpawnTree extends CommandTreesSpawn { + + public CommandTreesSpawnTree() { + super("spawnTree"); + } + + @Override + protected void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player) { + Vec3 look = player.getLookVec(); + + int x = (int)Math.round(player.posX + (3 * look.xCoord)); + int y = (int)Math.round(player.posY); + int z = (int)Math.round(player.posZ + (3 * look.zCoord)); + + WorldGenerator gen = getWorldGen(treeName, player, x, y, z); + if (gen == null) { + printHelp(sender); + return; + } + + generateTree(gen, player, x, y, z); + } + +} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 8d4f87a4a..f93b72d7d 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -43,7 +43,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } @Override - public boolean subGenerate(int x, int y, int z) { + public boolean subGenerate(int x, int y, int z, boolean forced) { this.startX = x; this.startY = y; this.startZ = z; @@ -53,9 +53,9 @@ public abstract class WorldGenArboriculture extends WorldGenBase { this.wood = getWood(); preGenerate(); - if (!canGrow()) + if (!forced && !canGrow()) { return false; - else { + } else { generate(); return true; } diff --git a/src/main/java/forestry/apiculture/SpeciesNotFoundException.java b/src/main/java/forestry/core/commands/SpeciesNotFoundException.java old mode 100755 new mode 100644 similarity index 89% rename from src/main/java/forestry/apiculture/SpeciesNotFoundException.java rename to src/main/java/forestry/core/commands/SpeciesNotFoundException.java index 9e4308a12..c84501bf5 --- a/src/main/java/forestry/apiculture/SpeciesNotFoundException.java +++ b/src/main/java/forestry/core/commands/SpeciesNotFoundException.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture; +package forestry.core.commands; import net.minecraft.command.CommandException; @@ -17,7 +17,7 @@ public class SpeciesNotFoundException extends CommandException { private static final long serialVersionUID = 1L; public SpeciesNotFoundException(String title) { - super("Could not find bee species with Name or UID %s", title); + super("Could not find species with Name or UID %s", title); } } diff --git a/src/main/java/forestry/apiculture/TemplateNotFoundException.java b/src/main/java/forestry/core/commands/TemplateNotFoundException.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/forestry/apiculture/TemplateNotFoundException.java rename to src/main/java/forestry/core/commands/TemplateNotFoundException.java index 16a157084..06da28fc5 --- a/src/main/java/forestry/apiculture/TemplateNotFoundException.java +++ b/src/main/java/forestry/core/commands/TemplateNotFoundException.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture; +package forestry.core.commands; import net.minecraft.command.CommandException; diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index 488863351..332e46770 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -42,15 +42,19 @@ public abstract class WorldGenBase extends WorldGenerator { @Override public final boolean generate(World world, Random random, int x, int y, int z) { + return generate(world, random, x, y, z, false); + } + + public final boolean generate(World world, Random random, int x, int y, int z, boolean forced) { this.world = world; this.rand = random; - boolean result = subGenerate(x, y, z); + boolean result = subGenerate(x, y, z, forced); this.world = null; this.rand = null; return result; } - public boolean subGenerate(int x, int y, int z) { + public boolean subGenerate(int x, int y, int z, boolean forced) { return false; } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 58b0f989c..304e55b37 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -25,7 +25,6 @@ import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.IFuelHandler; @@ -47,8 +46,6 @@ import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.genetics.IFruitFamily; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; -import forestry.arboriculture.CommandSpawnForest; -import forestry.arboriculture.CommandSpawnTree; import forestry.arboriculture.CommandTreekeepingMode; import forestry.arboriculture.EventHandlerArboriculture; import forestry.arboriculture.FruitProviderNone; @@ -60,6 +57,7 @@ import forestry.arboriculture.GuiHandlerArboriculture; import forestry.arboriculture.PacketHandlerArboriculture; import forestry.arboriculture.VillageHandlerArboriculture; import forestry.arboriculture.WoodType; +import forestry.arboriculture.commands.CommandTrees; import forestry.arboriculture.gadgets.BlockArbFence; import forestry.arboriculture.gadgets.BlockArbFence.FenceCat; import forestry.arboriculture.gadgets.BlockArbStairs; @@ -297,6 +295,8 @@ public class PluginArboriculture extends ForestryPlugin { validFences.add(Blocks.fence_gate); validFences.add(Blocks.nether_brick_fence); + // Commands + PluginCore.rootCommand.addChildCommand(new CommandTrees()); } @Override @@ -1104,8 +1104,7 @@ public class PluginArboriculture extends ForestryPlugin { @Override public ICommand[] getConsoleCommands() { - return new ICommand[]{new CommandSpawnTree(), new CommandSpawnForest(), - new CommandTreekeepingMode()}; + return new ICommand[]{new CommandTreekeepingMode()}; } @Override From a68cbc54e79368dfbd1288aeabf29cf3f5803947 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 13 Dec 2014 23:38:36 -0800 Subject: [PATCH 047/175] Fix and migrate Tree commands to new format. Remove CommandMC --- lang | 2 +- .../apiculture/commands/BeeModeHelper.java | 59 +++++ .../commands/BeeStatsSaveHelper.java | 78 ++++++ .../apiculture/commands/CommandBee.java | 32 +++ ...eepingGiveBee.java => CommandBeeGive.java} | 6 +- .../arboriculture/CommandTreekeepingMode.java | 247 ------------------ .../arboriculture/commands/CommandTree.java | 33 +++ ...dTreesSpawn.java => CommandTreeSpawn.java} | 73 +----- .../commands/CommandTreesSpawnTree.java | 31 --- ...eesSpawnForest.java => ForestSpawner.java} | 16 +- .../{CommandTrees.java => ITreeSpawner.java} | 11 +- .../arboriculture/commands/TreeGenHelper.java | 80 ++++++ .../commands/TreeModeHelper.java | 59 +++++ .../arboriculture/commands/TreeSpawner.java | 37 +++ .../commands/TreeStatsSaveHelper.java | 63 +++++ .../commands/CommandMode.java} | 14 +- .../commands/CommandModeInfo.java} | 62 ++--- .../commands/CommandModeSet.java} | 34 +-- .../commands/CommandSaveStats.java} | 113 ++++---- .../commands/ICommandModeHelper.java} | 22 +- .../core/commands/IStatsSaveHelper.java | 35 +++ .../java/forestry/core/utils/CommandMC.java | 53 ---- .../java/forestry/core/utils/StringUtil.java | 8 + .../forestry/plugins/PluginApiculture.java | 18 +- .../forestry/plugins/PluginArboriculture.java | 24 +- 25 files changed, 621 insertions(+), 589 deletions(-) create mode 100644 src/main/java/forestry/apiculture/commands/BeeModeHelper.java create mode 100644 src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java create mode 100644 src/main/java/forestry/apiculture/commands/CommandBee.java rename src/main/java/forestry/apiculture/commands/{CommandBeekeepingGiveBee.java => CommandBeeGive.java} (95%) delete mode 100755 src/main/java/forestry/arboriculture/CommandTreekeepingMode.java create mode 100644 src/main/java/forestry/arboriculture/commands/CommandTree.java rename src/main/java/forestry/arboriculture/commands/{CommandTreesSpawn.java => CommandTreeSpawn.java} (53%) delete mode 100644 src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java rename src/main/java/forestry/arboriculture/commands/{CommandTreesSpawnForest.java => ForestSpawner.java} (75%) rename src/main/java/forestry/arboriculture/commands/{CommandTrees.java => ITreeSpawner.java} (72%) create mode 100644 src/main/java/forestry/arboriculture/commands/TreeGenHelper.java create mode 100644 src/main/java/forestry/arboriculture/commands/TreeModeHelper.java create mode 100644 src/main/java/forestry/arboriculture/commands/TreeSpawner.java create mode 100644 src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java rename src/main/java/forestry/{apiculture/commands/CommandBeekeepingMode.java => core/commands/CommandMode.java} (68%) rename src/main/java/forestry/{apiculture/commands/CommandBeekeepingModeInfo.java => core/commands/CommandModeInfo.java} (53%) rename src/main/java/forestry/{apiculture/commands/CommandBeekeepingModeSet.java => core/commands/CommandModeSet.java} (60%) rename src/main/java/forestry/{apiculture/commands/CommandBeekeepingSave.java => core/commands/CommandSaveStats.java} (63%) rename src/main/java/forestry/{apiculture/commands/CommandBeekeeping.java => core/commands/ICommandModeHelper.java} (62%) create mode 100644 src/main/java/forestry/core/commands/IStatsSaveHelper.java delete mode 100755 src/main/java/forestry/core/utils/CommandMC.java diff --git a/lang b/lang index 76846d9c7..71f517c5a 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 76846d9c7646a02c8ac28e673579f065d499b3b9 +Subproject commit 71f517c5a6d4bb564b3996822b84da91bff791f3 diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java new file mode 100644 index 000000000..396ed7229 --- /dev/null +++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.apiculture.commands; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.world.World; + +import forestry.api.apiculture.IBeekeepingMode; +import forestry.core.commands.ICommandModeHelper; +import forestry.plugins.PluginApiculture; + +public class BeeModeHelper implements ICommandModeHelper { + + @Override + public String[] getModeNames() { + ArrayList beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes(); + int modeStringCount = beekeepingModes.size(); + List modeStrings = new ArrayList(modeStringCount); + for (IBeekeepingMode mode : beekeepingModes) + modeStrings.add(mode.getName()); + + return modeStrings.toArray(new String[modeStringCount]); + } + + @Override + public String getModeNameMatching(String desired) { + IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired); + if (mode == null) + return null; + return mode.getName(); + } + + @Override + public String getModeName(World world) { + return PluginApiculture.beeInterface.getBeekeepingMode(world).getName(); + } + + @Override + public void setMode(World world, String modeName) { + PluginApiculture.beeInterface.setBeekeepingMode(world, modeName); + } + + @Override + public ArrayList getDescription(String modeName) { + IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName); + return mode.getDescription(); + } + +} diff --git a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java new file mode 100644 index 000000000..6e69bd27f --- /dev/null +++ b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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.apiculture.commands; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import forestry.api.apiculture.IAlleleBeeSpecies; +import forestry.api.apiculture.IApiaristTracker; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.core.commands.IStatsSaveHelper; +import forestry.core.utils.StringUtil; +import forestry.plugins.PluginApiculture; + +import com.mojang.authlib.GameProfile; + +public class BeeStatsSaveHelper implements IStatsSaveHelper { + + @Override + public String getUnlocalizedSaveStatsString() { + return "for.chat.command.forestry.bee.save.stats"; + } + + @Override + public void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker) { + IApiaristTracker tracker = (IApiaristTracker)breedingTracker; + String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered") + ":"; + statistics.add(discoveredLine); + statistics.add(StringUtil.line(discoveredLine.length())); + + String queen = StatCollector.translateToLocal("for.bees.grammar.queen.type"); + String princess = StatCollector.translateToLocal("for.bees.grammar.princess.type"); + String drone = StatCollector.translateToLocal("for.bees.grammar.drone.type"); + statistics.add(queen + ":\t\t" + tracker.getQueenCount()); + statistics.add(princess + ":\t" + tracker.getPrincessCount()); + statistics.add(drone + ":\t\t" + tracker.getDroneCount()); + statistics.add(""); + } + + @Override + public String getModeName(World world) { + return PluginApiculture.beeInterface.getBeekeepingMode(world).getName(); + } + + @Override + public Collection getSpecies() { + Collection species = new ArrayList(); + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) + if (allele instanceof IAlleleBeeSpecies) + species.add((IAlleleBeeSpecies) allele); + return species; + } + + @Override + public String getFileSuffix() { + return "bees"; + } + + @Override + public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) { + return PluginApiculture.beeInterface.getBreedingTracker(world, gameProfile); + } + +} diff --git a/src/main/java/forestry/apiculture/commands/CommandBee.java b/src/main/java/forestry/apiculture/commands/CommandBee.java new file mode 100644 index 000000000..baf36df83 --- /dev/null +++ b/src/main/java/forestry/apiculture/commands/CommandBee.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.apiculture.commands; + +import forestry.core.commands.CommandMode; +import forestry.core.commands.CommandSaveStats; +import forestry.core.commands.ICommandModeHelper; +import forestry.core.commands.IStatsSaveHelper; +import forestry.core.commands.SubCommand; + +public class CommandBee extends SubCommand { + + public CommandBee() { + super("bee"); + addAlias("beekeeping"); + + IStatsSaveHelper saveHelper = new BeeStatsSaveHelper(); + ICommandModeHelper modeHelper = new BeeModeHelper(); + + addChildCommand(new CommandMode(modeHelper)); + addChildCommand(new CommandSaveStats(saveHelper)); + addChildCommand(new CommandBeeGive()); + } +} diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java similarity index 95% rename from src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java rename to src/main/java/forestry/apiculture/commands/CommandBeeGive.java index 4134d27ca..b8a72b595 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingGiveBee.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java @@ -30,12 +30,12 @@ import forestry.core.commands.SubCommand; import forestry.core.commands.TemplateNotFoundException; import forestry.plugins.PluginApiculture; -public class CommandBeekeepingGiveBee extends SubCommand { +public class CommandBeeGive extends SubCommand { private final String beeTypeHelpString; private final String[] beeTypeArr; - public CommandBeekeepingGiveBee() { + public CommandBeeGive() { super("give"); setPermLevel(PermLevel.ADMIN); @@ -93,7 +93,7 @@ public class CommandBeekeepingGiveBee extends SubCommand { ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal()); player.dropPlayerItemWithRandomChoice(beeStack, true); - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName()); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName()); } private static IBeeGenome getBeeGenome(String speciesName) { diff --git a/src/main/java/forestry/arboriculture/CommandTreekeepingMode.java b/src/main/java/forestry/arboriculture/CommandTreekeepingMode.java deleted file mode 100755 index d21ca6daa..000000000 --- a/src/main/java/forestry/arboriculture/CommandTreekeepingMode.java +++ /dev/null @@ -1,247 +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.arboriculture; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; - -import com.mojang.authlib.GameProfile; - -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.api.arboriculture.IArboristTracker; -import forestry.api.arboriculture.ITreekeepingMode; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.core.config.Defaults; -import forestry.core.config.Version; -import forestry.core.proxy.Proxies; -import forestry.core.utils.CommandMC; -import forestry.core.utils.StringUtil; -import forestry.plugins.PluginArboriculture; - -public class CommandTreekeepingMode extends CommandMC { - - private final String[] modeStrings; - - public CommandTreekeepingMode() { - modeStrings = new String[PluginArboriculture.treeInterface.getTreekeepingModes().size()]; - for (int i = 0; i < PluginArboriculture.treeInterface.getTreekeepingModes().size(); i++) - modeStrings[i] = PluginArboriculture.treeInterface.getTreekeepingModes().get(i).getName(); - } - - @Override - public int compareTo(Object arg0) { - return this.getCommandName().compareTo(((ICommand) arg0).getCommandName()); - } - - @Override - public String getCommandName() { - return "treekeeping"; - } - - @Override - public String getCommandUsage(ICommandSender var1) { - return "/" + this.getCommandName() + " help"; - } - - @SuppressWarnings("rawtypes") - @Override - public List getCommandAliases() { - return null; - } - - @Override - public void processCommand(ICommandSender sender, String[] arguments) { - - if (arguments.length <= 0) - throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender))); - - if (arguments[0].matches("list")) - listModes(sender, arguments); - else if (arguments[0].matches("info")) - listModeInfo(sender, arguments); - else if (arguments[0].matches("set")) { - if (arguments.length <= 1) - throw new WrongUsageException("/" + this.getCommandName() + " set [] "); - - World world = getWorld(sender, arguments); - String desired = arguments[arguments.length - 1]; - - ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(desired); - if (mode == null) - throw new CommandException(StringUtil.localize("chat.trees.command.treekeeping.error"), desired); - - PluginArboriculture.treeInterface.setTreekeepingMode(world, mode.getName()); - func_152373_a(sender, this, StringUtil.localize("chat.trees.command.treekeeping.set"), mode.getName()); - - } else if (arguments[0].matches("save")) { - if (arguments.length <= 1) - throw new WrongUsageException("/" + this.getCommandName() + " save "); - - saveStatistics(sender, arguments); - } else if (arguments[0].matches("help")) { - sendChatMessage(sender, StringUtil.localizeAndFormat("chat.trees.command.help.0", this.getCommandName())); - sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.1")); - sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.2")); - sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.3")); - sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.4")); - sendChatMessage(sender, StringUtil.localize("chat.trees.command.help.5")); - } - } - - private void saveStatistics(ICommandSender sender, String[] arguments) { - - String newLine = System.getProperty("line.separator"); - World world = getWorld(sender, arguments); - - String player = arguments[1]; - Collection statistics = new ArrayList(); - - statistics.add(String.format("Treekeeping statistics for %s on %s:", player, DateFormat.getInstance().format(new Date()))); - statistics.add(""); - statistics.add("MODE: " + PluginArboriculture.treeInterface.getTreekeepingMode(world).getName()); - statistics.add(""); - - GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player); - IArboristTracker tracker = PluginArboriculture.treeInterface.getBreedingTracker(world, profile); - if (tracker == null) - statistics.add("No statistics found."); - else { - statistics.add("BRED:"); - statistics.add("-----"); - statistics.add(""); - - Collection species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleTreeSpecies) - species.add((IAlleleTreeSpecies) allele); - - statistics.add(String.format("SPECIES (%s):", species.size())); - statistics.add("-------------"); - statistics.add(""); - - for (IAlleleTreeSpecies allele : species) - statistics.add(generateSpeciesListEntry(allele, tracker)); - } - - File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log"); - try { - - if (file.getParentFile() != null) - file.getParentFile().mkdirs(); - - if (!file.exists() && !file.createNewFile()) { - sendChatMessage(sender, "Log file could not be created. Failed to save statistics."); - return; - } - - if (!file.canWrite()) { - sendChatMessage(sender, "Cannot write to log file. Failed to save statistics."); - return; - } - - FileOutputStream fileout = new FileOutputStream(file); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8")); - - writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine); - - for (String line : statistics) - writer.write(line + newLine); - - writer.close(); - - } catch (Exception ex) { - sendChatMessage(sender, "Write operation threw an exception. Failed to save statistics."); - ex.printStackTrace(); - } - - sendChatMessage(sender, "Saved statistics for player " + player); - } - - private String generateSpeciesListEntry(IAlleleTreeSpecies species, IArboristTracker tracker) { - String discovered = "[ ]"; - if (tracker.isDiscovered(species)) - discovered = "[ X ]"; - String blacklisted = "[ ]"; - if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID())) - blacklisted = "[ BL ]"; - String notcounted = "[ ]"; - if (!species.isCounted()) - notcounted = "[ NC ]"; - - return String.format("%s %s %s\t%-40s %-20s %-20s", discovered, blacklisted, notcounted, species.getUID(), species.getName(), species.getAuthority()); - } - - private void listModes(ICommandSender sender, String[] arguments) { - World world = getWorld(sender, arguments); - - sendChatMessage(sender, "Current: " + PluginArboriculture.treeInterface.getTreekeepingMode(world).getName() + " (#" + world.getWorldInfo().getSaveVersion() - + ")"); - - String help = ""; - for (ITreekeepingMode mode : PluginArboriculture.treeInterface.getTreekeepingModes()) { - if (!help.isEmpty()) - help += ", "; - help += mode.getName(); - } - sendChatMessage(sender, "Available modes: " + help); - } - - private void listModeInfo(ICommandSender sender, String[] arguments) { - if (arguments.length <= 1) - throw new WrongUsageException("/" + this.getCommandName() + " info "); - - ITreekeepingMode found = null; - for (ITreekeepingMode mode : PluginArboriculture.treeInterface.getTreekeepingModes()) - if (mode.getName().equalsIgnoreCase(arguments[1])) { - found = mode; - break; - } - - if (found == null) - throw new CommandException("No treekeeping mode called '%s' is available.", arguments[1]); - - sendChatMessage(sender, "\u00A7aMode: " + found.getName()); - for (String desc : found.getDescription()) - sendChatMessage(sender, StringUtil.localize(desc)); - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - if (sender instanceof EntityPlayer) - return Proxies.common.isOp((EntityPlayer) sender); - else - return sender.canCommandSenderUseCommand(4, getCommandName()); - } - - @SuppressWarnings("rawtypes") - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] incomplete) { - return getListOfStringsMatchingLastWord(incomplete, modeStrings); - } - -} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTree.java b/src/main/java/forestry/arboriculture/commands/CommandTree.java new file mode 100644 index 000000000..88c86d8b3 --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/CommandTree.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import forestry.core.commands.CommandMode; +import forestry.core.commands.CommandSaveStats; +import forestry.core.commands.ICommandModeHelper; +import forestry.core.commands.IStatsSaveHelper; +import forestry.core.commands.SubCommand; + +public class CommandTree extends SubCommand { + + public CommandTree() { + super("tree"); + + IStatsSaveHelper saveHelper = new TreeStatsSaveHelper(); + ICommandModeHelper modeHelper = new TreeModeHelper(); + + addChildCommand(new CommandTreeSpawn("spawnTree", new TreeSpawner())); + addChildCommand(new CommandTreeSpawn("spawnForest", new ForestSpawner())); + addChildCommand(new CommandMode(modeHelper)); + addChildCommand(new CommandSaveStats(saveHelper)); + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java similarity index 53% rename from src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java rename to src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java index 7a05b7964..39341c665 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawn.java +++ b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java @@ -16,27 +16,23 @@ import java.util.List; import net.minecraft.command.ICommandSender; import net.minecraft.command.PlayerNotFoundException; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.gen.feature.WorldGenerator; import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.api.arboriculture.ITree; -import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.SubCommand; -import forestry.core.commands.TemplateNotFoundException; -import forestry.core.worldgen.WorldGenBase; -import forestry.plugins.PluginArboriculture; import org.apache.commons.lang3.StringUtils; -public abstract class CommandTreesSpawn extends SubCommand { +public final class CommandTreeSpawn extends SubCommand { - public CommandTreesSpawn(String name) { + private final ITreeSpawner treeSpawner; + + public CommandTreeSpawn(String name, ITreeSpawner treeSpawner) { super(name); setPermLevel(PermLevel.ADMIN); + this.treeSpawner = treeSpawner; } @Override @@ -58,27 +54,9 @@ public abstract class CommandTreesSpawn extends SubCommand { treeName = StringUtils.join(arguments, " "); } - processSubCommand(sender, treeName, player); - } - - protected abstract void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player); - - protected final WorldGenerator getWorldGen(String treeName, EntityPlayer player, int x, int y, int z) { - ITreeGenome treeGenome = getTreeGenome(treeName); - if (treeGenome == null) { - return null; - } - - ITree tree = PluginArboriculture.treeInterface.getTree(player.worldObj, treeGenome); - return tree.getTreeGenerator(player.worldObj, x, y, z, true); - } - - protected final void generateTree(WorldGenerator gen, EntityPlayer player, int x, int y, int z) { - if (gen instanceof WorldGenBase) { - ((WorldGenBase) gen).generate(player.worldObj, player.worldObj.rand, x, y, z, true); - } else { - gen.generate(player.worldObj, player.worldObj.rand, x, y, z); - } + boolean success = treeSpawner.spawn(sender, treeName, player); + if (!success) + printHelp(sender); } @Override @@ -103,39 +81,4 @@ public abstract class CommandTreesSpawn extends SubCommand { return species.toArray(new String[species.size()]); } - private static ITreeGenome getTreeGenome(String speciesName) { - IAlleleTreeSpecies species = null; - - for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { - - if (!uid.equals(speciesName)) - continue; - - IAllele allele = AlleleManager.alleleRegistry.getAllele(uid); - if (allele instanceof IAlleleTreeSpecies) { - species = (IAlleleTreeSpecies) allele; - break; - } - } - - if (species == null) { - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { - if (allele instanceof IAlleleTreeSpecies && allele.getName().replaceAll("\\s", "").equals(speciesName)) { - species = (IAlleleTreeSpecies) allele; - break; - } - } - } - - if (species == null) - throw new SpeciesNotFoundException(speciesName); - - IAllele[] template = PluginArboriculture.treeInterface.getTemplate(species.getUID()); - - if (template == null) - throw new TemplateNotFoundException(species); - - return PluginArboriculture.treeInterface.templateAsGenome(template); - } - } diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java b/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java deleted file mode 100644 index 54daa8061..000000000 --- a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnTree.java +++ /dev/null @@ -1,31 +0,0 @@ -package forestry.arboriculture.commands; - -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.Vec3; -import net.minecraft.world.gen.feature.WorldGenerator; - -public class CommandTreesSpawnTree extends CommandTreesSpawn { - - public CommandTreesSpawnTree() { - super("spawnTree"); - } - - @Override - protected void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player) { - Vec3 look = player.getLookVec(); - - int x = (int)Math.round(player.posX + (3 * look.xCoord)); - int y = (int)Math.round(player.posY); - int z = (int)Math.round(player.posZ + (3 * look.zCoord)); - - WorldGenerator gen = getWorldGen(treeName, player, x, y, z); - if (gen == null) { - printHelp(sender); - return; - } - - generateTree(gen, player, x, y, z); - } - -} diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java b/src/main/java/forestry/arboriculture/commands/ForestSpawner.java similarity index 75% rename from src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java rename to src/main/java/forestry/arboriculture/commands/ForestSpawner.java index 450b3956a..002f9b962 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTreesSpawnForest.java +++ b/src/main/java/forestry/arboriculture/commands/ForestSpawner.java @@ -15,13 +15,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.Vec3; import net.minecraft.world.gen.feature.WorldGenerator; -public class CommandTreesSpawnForest extends CommandTreesSpawn { +public class ForestSpawner implements ITreeSpawner { - public CommandTreesSpawnForest() { - super("spawnForest"); - } - - protected void processSubCommand(ICommandSender sender, String treeName, EntityPlayer player) { + public boolean spawn(ICommandSender sender, String treeName, EntityPlayer player) { Vec3 look = player.getLookVec(); int x = (int)Math.round(player.posX + (16 * look.xCoord)); @@ -32,13 +28,13 @@ public class CommandTreesSpawnForest extends CommandTreesSpawn { int spawnX = x + player.worldObj.rand.nextInt(32) - 16; int spawnZ = z + player.worldObj.rand.nextInt(32) - 16; - WorldGenerator gen = getWorldGen(treeName, player, spawnX, y, spawnZ); + WorldGenerator gen = TreeGenHelper.getWorldGen(treeName, player, spawnX, y, spawnZ); if (gen == null) { - printHelp(sender); - return; + return false; } - generateTree(gen, player, spawnX, y, spawnZ); + TreeGenHelper.generateTree(gen, player, spawnX, y, spawnZ); } + return true; } } diff --git a/src/main/java/forestry/arboriculture/commands/CommandTrees.java b/src/main/java/forestry/arboriculture/commands/ITreeSpawner.java similarity index 72% rename from src/main/java/forestry/arboriculture/commands/CommandTrees.java rename to src/main/java/forestry/arboriculture/commands/ITreeSpawner.java index dc6da946e..ddeec9b99 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTrees.java +++ b/src/main/java/forestry/arboriculture/commands/ITreeSpawner.java @@ -10,14 +10,11 @@ ******************************************************************************/ package forestry.arboriculture.commands; -import forestry.core.commands.SubCommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; -public class CommandTrees extends SubCommand { +public interface ITreeSpawner { - public CommandTrees() { - super("tree"); - addChildCommand(new CommandTreesSpawnTree()); - addChildCommand(new CommandTreesSpawnForest()); - } + boolean spawn(ICommandSender sender, String treeName, EntityPlayer player); } diff --git a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java new file mode 100644 index 000000000..870b7d1b6 --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.gen.feature.WorldGenerator; + +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.arboriculture.ITree; +import forestry.api.arboriculture.ITreeGenome; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.core.commands.SpeciesNotFoundException; +import forestry.core.commands.TemplateNotFoundException; +import forestry.core.worldgen.WorldGenBase; +import forestry.plugins.PluginArboriculture; + +public final class TreeGenHelper { + + public static WorldGenerator getWorldGen(String treeName, EntityPlayer player, int x, int y, int z) { + ITreeGenome treeGenome = getTreeGenome(treeName); + if (treeGenome == null) { + return null; + } + + ITree tree = PluginArboriculture.treeInterface.getTree(player.worldObj, treeGenome); + return tree.getTreeGenerator(player.worldObj, x, y, z, true); + } + + public static void generateTree(WorldGenerator gen, EntityPlayer player, int x, int y, int z) { + if (gen instanceof WorldGenBase) { + ((WorldGenBase) gen).generate(player.worldObj, player.worldObj.rand, x, y, z, true); + } else { + gen.generate(player.worldObj, player.worldObj.rand, x, y, z); + } + } + + private static ITreeGenome getTreeGenome(String speciesName) { + IAlleleTreeSpecies species = null; + + for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) { + + if (!uid.equals(speciesName)) + continue; + + IAllele allele = AlleleManager.alleleRegistry.getAllele(uid); + if (allele instanceof IAlleleTreeSpecies) { + species = (IAlleleTreeSpecies) allele; + break; + } + } + + if (species == null) { + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) { + if (allele instanceof IAlleleTreeSpecies && allele.getName().replaceAll("\\s", "").equals(speciesName)) { + species = (IAlleleTreeSpecies) allele; + break; + } + } + } + + if (species == null) + throw new SpeciesNotFoundException(speciesName); + + IAllele[] template = PluginArboriculture.treeInterface.getTemplate(species.getUID()); + + if (template == null) + throw new TemplateNotFoundException(species); + + return PluginArboriculture.treeInterface.templateAsGenome(template); + } +} diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java new file mode 100644 index 000000000..c0a13ee1f --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.world.World; + +import forestry.api.arboriculture.ITreekeepingMode; +import forestry.core.commands.ICommandModeHelper; +import forestry.plugins.PluginArboriculture; + +public class TreeModeHelper implements ICommandModeHelper { + + @Override + public String[] getModeNames() { + ArrayList treekeepingModes = PluginArboriculture.treeInterface.getTreekeepingModes(); + int modeStringCount = treekeepingModes.size(); + List modeStrings = new ArrayList(modeStringCount); + for (ITreekeepingMode mode : treekeepingModes) + modeStrings.add(mode.getName()); + + return modeStrings.toArray(new String[modeStringCount]); + } + + @Override + public String getModeNameMatching(String desired) { + ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(desired); + if (mode == null) + return null; + return mode.getName(); + } + + @Override + public String getModeName(World world) { + return PluginArboriculture.treeInterface.getTreekeepingMode(world).getName(); + } + + @Override + public void setMode(World world, String modeName) { + PluginArboriculture.treeInterface.setTreekeepingMode(world, modeName); + } + + @Override + public ArrayList getDescription(String modeName) { + ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(modeName); + return mode.getDescription(); + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/TreeSpawner.java b/src/main/java/forestry/arboriculture/commands/TreeSpawner.java new file mode 100644 index 000000000..6e47c368a --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/TreeSpawner.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.arboriculture.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class TreeSpawner implements ITreeSpawner { + + @Override + public boolean spawn(ICommandSender sender, String treeName, EntityPlayer player) { + Vec3 look = player.getLookVec(); + + int x = (int)Math.round(player.posX + (3 * look.xCoord)); + int y = (int)Math.round(player.posY); + int z = (int)Math.round(player.posZ + (3 * look.zCoord)); + + WorldGenerator gen = TreeGenHelper.getWorldGen(treeName, player, x, y, z); + if (gen == null) { + return false; + } + + TreeGenHelper.generateTree(gen, player, x, y, z); + return true; + } + +} diff --git a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java new file mode 100644 index 000000000..6a1b2e568 --- /dev/null +++ b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java @@ -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.arboriculture.commands; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.world.World; + +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.core.commands.IStatsSaveHelper; +import forestry.plugins.PluginArboriculture; + +import com.mojang.authlib.GameProfile; + +public class TreeStatsSaveHelper implements IStatsSaveHelper { + + @Override + public String getUnlocalizedSaveStatsString() { + return "for.chat.command.forestry.tree.save.stats"; + } + + @Override + public void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker) { + } + + @Override + public String getModeName(World world) { + return PluginArboriculture.treeInterface.getTreekeepingMode(world).getName(); + } + + @Override + public Collection getSpecies() { + Collection species = new ArrayList(); + for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) + if (allele instanceof IAlleleTreeSpecies) + species.add((IAlleleTreeSpecies) allele); + return species; + } + + @Override + public String getFileSuffix() { + return "trees"; + } + + @Override + public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) { + return PluginArboriculture.treeInterface.getBreedingTracker(world, gameProfile); + } + +} diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingMode.java b/src/main/java/forestry/core/commands/CommandMode.java similarity index 68% rename from src/main/java/forestry/apiculture/commands/CommandBeekeepingMode.java rename to src/main/java/forestry/core/commands/CommandMode.java index 0502deb12..ee3c2cc16 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingMode.java +++ b/src/main/java/forestry/core/commands/CommandMode.java @@ -4,19 +4,17 @@ * 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.apiculture.commands; +package forestry.core.commands; -import forestry.core.commands.SubCommand; +public class CommandMode extends SubCommand { -public class CommandBeekeepingMode extends SubCommand { - - public CommandBeekeepingMode() { + public CommandMode(ICommandModeHelper modeHelper) { super("mode"); - addChildCommand(new CommandBeekeepingModeInfo()); - addChildCommand(new CommandBeekeepingModeSet()); + addChildCommand(new CommandModeInfo(modeHelper)); + addChildCommand(new CommandModeSet(modeHelper)); } } diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingModeInfo.java b/src/main/java/forestry/core/commands/CommandModeInfo.java similarity index 53% rename from src/main/java/forestry/apiculture/commands/CommandBeekeepingModeInfo.java rename to src/main/java/forestry/core/commands/CommandModeInfo.java index dce83b61b..419e5cd09 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingModeInfo.java +++ b/src/main/java/forestry/core/commands/CommandModeInfo.java @@ -8,45 +8,28 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture.commands; +package forestry.core.commands; + +import java.util.List; -import forestry.api.apiculture.IBeekeepingMode; -import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SubCommand; -import forestry.plugins.PluginApiculture; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class CommandBeekeepingModeInfo extends SubCommand { +import org.apache.commons.lang3.StringUtils; +public class CommandModeInfo extends SubCommand { private final String[] modeStringArr; private final String helpString; + private final ICommandModeHelper modeHelper; - public CommandBeekeepingModeInfo() { + public CommandModeInfo(ICommandModeHelper modeHelper) { super("info"); - List modeStrings = new ArrayList(); - for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) - modeStrings.add(mode.getName()); - - modeStringArr = modeStrings.toArray(new String[modeStrings.size()]); - - StringBuilder help = new StringBuilder(); - String separator = ", "; - - Iterator iter = modeStrings.iterator(); - while (iter.hasNext()) { - help.append(iter.next()); - if (iter.hasNext()) - help.append(separator); - } - helpString = help.toString(); + this.modeHelper = modeHelper; + modeStringArr = modeHelper.getModeNames(); + helpString = StringUtils.join(modeStringArr, ", "); } @Override @@ -56,42 +39,33 @@ public class CommandBeekeepingModeInfo extends SubCommand { return; } - String modeName = args[0]; + String modeName = modeHelper.getModeNameMatching(args[0]); - IBeekeepingMode found = findModeWithName(modeName); - if (found == null) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.error", modeName); + if (modeName == null) { + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.info.error", args[0]); printHelp(sender); return; } ChatStyle green = new ChatStyle(); green.setColor(EnumChatFormatting.GREEN); - CommandHelpers.sendLocalizedChatMessage(sender, green, found.getName()); + CommandHelpers.sendLocalizedChatMessage(sender, green, modeName); - for (String desc : found.getDescription()) + for (String desc : modeHelper.getDescription(modeName)) CommandHelpers.sendLocalizedChatMessage(sender, "for." + desc); } - private IBeekeepingMode findModeWithName(String name) { - for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) { - if (mode.getName().equalsIgnoreCase(name)) - return mode; - } - return null; - } - @Override public void printHelp(ICommandSender sender) { super.printHelp(sender); World world = CommandHelpers.getWorld(sender, this); - String modeName = PluginApiculture.beeInterface.getBeekeepingMode(world).getName(); + String modeName = modeHelper.getModeName(world); String worldName = String.valueOf(world.getWorldInfo().getSaveVersion()); - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.current", modeName, worldName); - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.available", helpString); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.info.current", modeName, worldName); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.info.available", helpString); } @Override diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingModeSet.java b/src/main/java/forestry/core/commands/CommandModeSet.java similarity index 60% rename from src/main/java/forestry/apiculture/commands/CommandBeekeepingModeSet.java rename to src/main/java/forestry/core/commands/CommandModeSet.java index 13aa6bb34..1fd50ba9d 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingModeSet.java +++ b/src/main/java/forestry/core/commands/CommandModeSet.java @@ -8,30 +8,24 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture.commands; +package forestry.core.commands; + +import java.util.List; -import forestry.api.apiculture.IBeekeepingMode; -import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SubCommand; -import forestry.plugins.PluginApiculture; import net.minecraft.command.ICommandSender; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.List; - -public class CommandBeekeepingModeSet extends SubCommand { +public final class CommandModeSet extends SubCommand { private final String[] modeStringArr; + private final ICommandModeHelper modeSetter; - public CommandBeekeepingModeSet() { + public CommandModeSet(ICommandModeHelper modeSetter) { super("set"); setPermLevel(PermLevel.ADMIN); - int modeStringCount = PluginApiculture.beeInterface.getBeekeepingModes().size(); - List modeStrings = new ArrayList(modeStringCount); - for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) - modeStrings.add(mode.getName()); - modeStringArr = modeStrings.toArray(new String[modeStringCount]); + this.modeSetter = modeSetter; + modeStringArr = modeSetter.getModeNames(); + } @Override @@ -49,15 +43,15 @@ public class CommandBeekeepingModeSet extends SubCommand { String desired = args[args.length - 1]; - IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired); - if (mode == null) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.set.error", desired); + String modeName = modeSetter.getModeNameMatching(desired); + if (modeName == null) { + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.error", desired); printHelp(sender); return; } - PluginApiculture.beeInterface.setBeekeepingMode(world, mode.getName()); - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.set.success", mode.getName()); + modeSetter.setMode(world, modeName); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.success", modeName); } @Override diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeepingSave.java b/src/main/java/forestry/core/commands/CommandSaveStats.java similarity index 63% rename from src/main/java/forestry/apiculture/commands/CommandBeekeepingSave.java rename to src/main/java/forestry/core/commands/CommandSaveStats.java index 60423d3c8..18f3ea606 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeepingSave.java +++ b/src/main/java/forestry/core/commands/CommandSaveStats.java @@ -8,23 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture.commands; - -import com.mojang.authlib.GameProfile; -import forestry.api.apiculture.IAlleleBeeSpecies; -import forestry.api.apiculture.IApiaristTracker; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.core.commands.CommandHelpers; -import forestry.core.commands.SubCommand; -import forestry.core.config.Defaults; -import forestry.core.config.Version; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginApiculture; -import net.minecraft.command.ICommandSender; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; +package forestry.core.commands; import java.io.BufferedWriter; import java.io.File; @@ -38,17 +22,32 @@ import java.util.Date; import java.util.List; import java.util.Locale; -public class CommandBeekeepingSave extends SubCommand { +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.core.config.Defaults; +import forestry.core.config.Version; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + +public final class CommandSaveStats extends SubCommand { private final String discoveredSymbol; private final String blacklistedSymbol; private final String notCountedSymbol; + private final IStatsSaveHelper saveHelper; - public CommandBeekeepingSave() { + public CommandSaveStats(IStatsSaveHelper saveHelper) { super("save"); - discoveredSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered.symbol"); - blacklistedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.blacklisted.symbol"); - notCountedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.notCounted.symbol"); + discoveredSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered.symbol"); + blacklistedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.blacklisted.symbol"); + notCountedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.notCounted.symbol"); + this.saveHelper = saveHelper; } @Override @@ -58,7 +57,7 @@ public class CommandBeekeepingSave extends SubCommand { @Override public void processSubCommand(ICommandSender sender, String[] args) { - if (args.length != 1) { + if (args.length > 1) { printHelp(sender); return; } @@ -66,76 +65,66 @@ public class CommandBeekeepingSave extends SubCommand { String newLine = System.getProperty("line.separator"); World world = CommandHelpers.getWorld(sender, this); - String player = args[0]; + EntityPlayerMP player; + if (args.length > 0) + player = CommandHelpers.getPlayer(sender, args[0]); + else + player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName()); + Collection statistics = new ArrayList(); String date = DateFormat.getInstance().format(new Date()); - statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.beekeeping.save.stats", player, date)); + statistics.add(StatCollector.translateToLocalFormatted(saveHelper.getUnlocalizedSaveStatsString(), player.getDisplayName(), date)); statistics.add(""); - String modeName = PluginApiculture.beeInterface.getBeekeepingMode(world).getName(); - statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.beekeeping.save.mode", modeName)); + statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.stats.save.mode", saveHelper.getModeName(world))); statistics.add(""); - GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player); - IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(world, profile); + IBreedingTracker tracker = saveHelper.getBreedingTracker(world, player.getGameProfile()); if (tracker == null) - statistics.add(StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.error4")); + statistics.add(StatCollector.translateToLocal("for.chat.command.forestry.stats.save.error4")); else { - String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered") + ":"; - statistics.add(discoveredLine); - statistics.add(line(discoveredLine.length())); + saveHelper.addExtraInfo(statistics, tracker); - String queen = StatCollector.translateToLocal("for.bees.grammar.queen.type"); - String princess = StatCollector.translateToLocal("for.bees.grammar.princess.type"); - String drone = StatCollector.translateToLocal("for.bees.grammar.drone.type"); - statistics.add(queen + ":\t\t" + tracker.getQueenCount()); - statistics.add(princess + ":\t" + tracker.getPrincessCount()); - statistics.add(drone + ":\t\t" + tracker.getDroneCount()); - statistics.add(""); - - Collection species = new ArrayList(); - for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) - if (allele instanceof IAlleleBeeSpecies) - species.add((IAlleleBeeSpecies) allele); + Collection species = saveHelper.getSpecies(); String speciesCount = StatCollector.translateToLocal("for.gui.speciescount"); String speciesCountLine = String.format("%s (%s):", speciesCount, species.size()); statistics.add(speciesCountLine); - statistics.add(line(speciesCountLine.length())); + statistics.add(StringUtil.line(speciesCountLine.length())); - statistics.add(discoveredSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered")); - statistics.add(blacklistedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.blacklisted")); - statistics.add(notCountedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.notCounted")); + statistics.add(discoveredSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered")); + statistics.add(blacklistedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.blacklisted")); + statistics.add(notCountedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.notCounted")); statistics.add(""); String header = generateSpeciesListHeader(); statistics.add(header); - statistics.add(line(header.length())); + statistics.add(StringUtil.line(header.length())); statistics.add(""); - for (IAlleleBeeSpecies allele : species) + for (IAlleleSpecies allele : species) statistics.add(generateSpeciesListEntry(allele, tracker)); } - File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log"); + File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player.getDisplayName() + "-" + saveHelper.getFileSuffix() + ".log"); try { File folder = file.getParentFile(); if (folder != null && !folder.exists()) { boolean success = file.getParentFile().mkdirs(); if (!success) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error1"); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error1"); return; } } if (!file.exists() && !file.createNewFile()) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error1"); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error1"); return; } if (!file.canWrite()) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error2"); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error2"); return; } @@ -151,20 +140,12 @@ public class CommandBeekeepingSave extends SubCommand { } catch (IOException ex) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error3"); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.error3"); ex.printStackTrace(); return; } - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.saved", player); - } - - private String line(int length) { - StringBuilder line = new StringBuilder(); - for (int i = 0; i < length; i++) - line.append("-"); - - return line.toString(); + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.stats.save.saved", player.getDisplayName()); } private String generateSpeciesListHeader() { @@ -173,7 +154,7 @@ public class CommandBeekeepingSave extends SubCommand { return speciesListEntry(discoveredSymbol, blacklistedSymbol, notCountedSymbol, "UID", species, authority); } - private String generateSpeciesListEntry(IAlleleBeeSpecies species, IApiaristTracker tracker) { + private String generateSpeciesListEntry(IAlleleSpecies species, IBreedingTracker tracker) { String discovered = ""; if (tracker.isDiscovered(species)) discovered = discoveredSymbol; diff --git a/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java b/src/main/java/forestry/core/commands/ICommandModeHelper.java similarity index 62% rename from src/main/java/forestry/apiculture/commands/CommandBeekeeping.java rename to src/main/java/forestry/core/commands/ICommandModeHelper.java index ceeb66d33..3e57fa387 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeekeeping.java +++ b/src/main/java/forestry/core/commands/ICommandModeHelper.java @@ -8,17 +8,19 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.apiculture.commands; +package forestry.core.commands; -import forestry.core.commands.SubCommand; +import java.util.ArrayList; -public class CommandBeekeeping extends SubCommand { +import net.minecraft.world.World; - public CommandBeekeeping() { - super("bee"); - addAlias("beekeeping"); - addChildCommand(new CommandBeekeepingMode()); - addChildCommand(new CommandBeekeepingSave()); - addChildCommand(new CommandBeekeepingGiveBee()); - } +public interface ICommandModeHelper { + String[] getModeNames(); + + String getModeNameMatching(String desired); + + String getModeName(World world); + void setMode(World world, String modeName); + + ArrayList getDescription(String modeName); } diff --git a/src/main/java/forestry/core/commands/IStatsSaveHelper.java b/src/main/java/forestry/core/commands/IStatsSaveHelper.java new file mode 100644 index 000000000..3cc6092fc --- /dev/null +++ b/src/main/java/forestry/core/commands/IStatsSaveHelper.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.commands; + +import java.util.Collection; + +import net.minecraft.world.World; + +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; + +import com.mojang.authlib.GameProfile; + +public interface IStatsSaveHelper { + + String getUnlocalizedSaveStatsString(); + + void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker); + + String getModeName(World world); + + Collection getSpecies(); + + String getFileSuffix(); + + IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile); +} diff --git a/src/main/java/forestry/core/utils/CommandMC.java b/src/main/java/forestry/core/utils/CommandMC.java deleted file mode 100755 index 138fb83c0..000000000 --- a/src/main/java/forestry/core/utils/CommandMC.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.utils; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; -import net.minecraft.world.World; - -@Deprecated -public abstract class CommandMC extends CommandBase { - - protected World getWorld(ICommandSender sender, String[] arguments) { - - // Handle passed in world argument - if (arguments.length > 2) { - int dim = 0; - try { - dim = Integer.parseInt(arguments[1]); - } catch (Exception ex) { - throw new WrongUsageException("/" + getCommandName() + " set [] "); - } - - return MinecraftServer.getServer().worldServerForDimension(dim); - } - - if (sender instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) sender; - return player.worldObj; - } else - return MinecraftServer.getServer().worldServerForDimension(0); - - } - - protected String[] getPlayers() { - return MinecraftServer.getServer().getAllUsernames(); - } - - protected void sendChatMessage(ICommandSender sender, String message) { - sender.addChatMessage(new ChatComponentText(message)); - } -} diff --git a/src/main/java/forestry/core/utils/StringUtil.java b/src/main/java/forestry/core/utils/StringUtil.java index cfbd90c70..75698486a 100755 --- a/src/main/java/forestry/core/utils/StringUtil.java +++ b/src/main/java/forestry/core/utils/StringUtil.java @@ -89,4 +89,12 @@ public class StringUtil { public static String floatAsPercent(float val) { return (int) (val * 100) + " %"; } + + public static String line(int length) { + StringBuilder line = new StringBuilder(); + for (int i = 0; i < length; i++) + line.append("-"); + + return line.toString(); + } } diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 3b66f571c..4a6d187a8 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -30,7 +30,6 @@ import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.FMLCommonHandler; @@ -73,7 +72,7 @@ import forestry.apiculture.GuiHandlerApiculture; import forestry.apiculture.PacketHandlerApiculture; import forestry.apiculture.SaveEventHandlerApiculture; import forestry.apiculture.VillageHandlerApiculture; -import forestry.apiculture.commands.CommandBeekeeping; +import forestry.apiculture.commands.CommandBee; import forestry.apiculture.gadgets.BlockAlveary; import forestry.apiculture.gadgets.BlockBeehives; import forestry.apiculture.gadgets.BlockCandle; @@ -269,8 +268,15 @@ public class PluginApiculture extends ForestryPlugin { // Register village components with the Structure registry. VillageHandlerApiculture.registerVillageComponents(); + // Modes + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.easy); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.normal); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hard); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hardcore); + PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.insane); + // Commands - PluginCore.rootCommand.addChildCommand(new CommandBeekeeping()); + PluginCore.rootCommand.addChildCommand(new CommandBee()); } @Override @@ -306,12 +312,6 @@ public class PluginApiculture extends ForestryPlugin { createMutations(); registerBeehiveDrops(); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.easy); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.normal); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hard); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.hardcore); - PluginApiculture.beeInterface.registerBeekeepingMode(BeekeepingMode.insane); - // Inducers for swarmer BeeManager.inducers.put(ForestryItem.royalJelly.getItemStack(), 10); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 304e55b37..1a3ad311b 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -16,7 +16,6 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -46,7 +45,6 @@ import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.genetics.IFruitFamily; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; -import forestry.arboriculture.CommandTreekeepingMode; import forestry.arboriculture.EventHandlerArboriculture; import forestry.arboriculture.FruitProviderNone; import forestry.arboriculture.FruitProviderPod; @@ -57,7 +55,7 @@ import forestry.arboriculture.GuiHandlerArboriculture; import forestry.arboriculture.PacketHandlerArboriculture; import forestry.arboriculture.VillageHandlerArboriculture; import forestry.arboriculture.WoodType; -import forestry.arboriculture.commands.CommandTrees; +import forestry.arboriculture.commands.CommandTree; import forestry.arboriculture.gadgets.BlockArbFence; import forestry.arboriculture.gadgets.BlockArbFence.FenceCat; import forestry.arboriculture.gadgets.BlockArbStairs; @@ -295,8 +293,15 @@ public class PluginArboriculture extends ForestryPlugin { validFences.add(Blocks.fence_gate); validFences.add(Blocks.nether_brick_fence); + // Modes + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.easy); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.normal); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hard); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hardcore); + PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.insane); + // Commands - PluginCore.rootCommand.addChildCommand(new CommandTrees()); + PluginCore.rootCommand.addChildCommand(new CommandTree()); } @Override @@ -313,12 +318,6 @@ public class PluginArboriculture extends ForestryPlugin { registerTemplates(); registerErsatzGenomes(); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.easy); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.normal); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hard); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.hardcore); - PluginArboriculture.treeInterface.registerTreekeepingMode(TreekeepingMode.insane); - MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture()); VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK); @@ -1102,11 +1101,6 @@ public class PluginArboriculture extends ForestryPlugin { return new GuiHandlerArboriculture(); } - @Override - public ICommand[] getConsoleCommands() { - return new ICommand[]{new CommandTreekeepingMode()}; - } - @Override public IFuelHandler getFuelHandler() { return new IFuelHandler() { From d8beaa92b94776d2b476c20fb2547e7cb5ebf692 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 14 Dec 2014 13:54:47 -0800 Subject: [PATCH 048/175] Fix #367 Fix fabricator crash --- .../java/forestry/factory/gadgets/MachineFabricator.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 8e10ad22e..6bf4f9f12 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -412,14 +412,13 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial public boolean hasWork() { ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL); Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt); - FluidStack liquid = smelting.getProduct(); - if (moltenTank.fill(liquid, false) > 0) + if (smelting != null && moltenTank.fill(smelting.getProduct(), false) > 0) return true; ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); ItemStack[] resources = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - return RecipeManager.findMatchingRecipe(plan, liquid, resources) != null; + return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), resources) != null; } public int getHeatScaled(int i) { From 3d4ba157519ab0b93c189b1340b16e54fce8c421 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 14 Dec 2014 14:46:25 -0800 Subject: [PATCH 049/175] Minor Cleanup bee and tree commands --- .../apiculture/commands/BeeModeHelper.java | 2 +- .../commands/BeeStatsSaveHelper.java | 5 ----- .../apiculture/commands/CommandBee.java | 2 +- .../arboriculture/commands/CommandTree.java | 2 +- .../commands/TreeModeHelper.java | 2 +- .../commands/TreeStatsSaveHelper.java | 5 ----- .../core/commands/CommandSaveStats.java | 21 ++++++++++++------- .../core/commands/ICommandModeHelper.java | 4 +--- .../core/commands/IStatsSaveHelper.java | 2 -- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java index 396ed7229..5352e23c5 100644 --- a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java @@ -51,7 +51,7 @@ public class BeeModeHelper implements ICommandModeHelper { } @Override - public ArrayList getDescription(String modeName) { + public Iterable getDescription(String modeName) { IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName); return mode.getDescription(); } diff --git a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java index 6e69bd27f..ed2e020b2 100644 --- a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java @@ -51,11 +51,6 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper { statistics.add(""); } - @Override - public String getModeName(World world) { - return PluginApiculture.beeInterface.getBeekeepingMode(world).getName(); - } - @Override public Collection getSpecies() { Collection species = new ArrayList(); diff --git a/src/main/java/forestry/apiculture/commands/CommandBee.java b/src/main/java/forestry/apiculture/commands/CommandBee.java index baf36df83..9cf050973 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBee.java +++ b/src/main/java/forestry/apiculture/commands/CommandBee.java @@ -26,7 +26,7 @@ public class CommandBee extends SubCommand { ICommandModeHelper modeHelper = new BeeModeHelper(); addChildCommand(new CommandMode(modeHelper)); - addChildCommand(new CommandSaveStats(saveHelper)); + addChildCommand(new CommandSaveStats(saveHelper, modeHelper)); addChildCommand(new CommandBeeGive()); } } diff --git a/src/main/java/forestry/arboriculture/commands/CommandTree.java b/src/main/java/forestry/arboriculture/commands/CommandTree.java index 88c86d8b3..f15d86448 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTree.java +++ b/src/main/java/forestry/arboriculture/commands/CommandTree.java @@ -27,7 +27,7 @@ public class CommandTree extends SubCommand { addChildCommand(new CommandTreeSpawn("spawnTree", new TreeSpawner())); addChildCommand(new CommandTreeSpawn("spawnForest", new ForestSpawner())); addChildCommand(new CommandMode(modeHelper)); - addChildCommand(new CommandSaveStats(saveHelper)); + addChildCommand(new CommandSaveStats(saveHelper, modeHelper)); } } diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java index c0a13ee1f..61c4b5fc1 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -51,7 +51,7 @@ public class TreeModeHelper implements ICommandModeHelper { } @Override - public ArrayList getDescription(String modeName) { + public Iterable getDescription(String modeName) { ITreekeepingMode mode = PluginArboriculture.treeInterface.getTreekeepingMode(modeName); return mode.getDescription(); } diff --git a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java index 6a1b2e568..8eae52876 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java @@ -36,11 +36,6 @@ public class TreeStatsSaveHelper implements IStatsSaveHelper { public void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker) { } - @Override - public String getModeName(World world) { - return PluginArboriculture.treeInterface.getTreekeepingMode(world).getName(); - } - @Override public Collection getSpecies() { Collection species = new ArrayList(); diff --git a/src/main/java/forestry/core/commands/CommandSaveStats.java b/src/main/java/forestry/core/commands/CommandSaveStats.java index 18f3ea606..658d15086 100644 --- a/src/main/java/forestry/core/commands/CommandSaveStats.java +++ b/src/main/java/forestry/core/commands/CommandSaveStats.java @@ -37,17 +37,22 @@ import forestry.core.utils.StringUtil; public final class CommandSaveStats extends SubCommand { - private final String discoveredSymbol; - private final String blacklistedSymbol; - private final String notCountedSymbol; - private final IStatsSaveHelper saveHelper; - - public CommandSaveStats(IStatsSaveHelper saveHelper) { - super("save"); + private static final String discoveredSymbol; + private static final String blacklistedSymbol; + private static final String notCountedSymbol; + static { discoveredSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered.symbol"); blacklistedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.blacklisted.symbol"); notCountedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.notCounted.symbol"); + } + + private final IStatsSaveHelper saveHelper; + private final ICommandModeHelper modeHelper; + + public CommandSaveStats(IStatsSaveHelper saveHelper, ICommandModeHelper modeHelper) { + super("save"); this.saveHelper = saveHelper; + this.modeHelper = modeHelper; } @Override @@ -76,7 +81,7 @@ public final class CommandSaveStats extends SubCommand { String date = DateFormat.getInstance().format(new Date()); statistics.add(StatCollector.translateToLocalFormatted(saveHelper.getUnlocalizedSaveStatsString(), player.getDisplayName(), date)); statistics.add(""); - statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.stats.save.mode", saveHelper.getModeName(world))); + statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.stats.save.mode", modeHelper.getModeName(world))); statistics.add(""); IBreedingTracker tracker = saveHelper.getBreedingTracker(world, player.getGameProfile()); diff --git a/src/main/java/forestry/core/commands/ICommandModeHelper.java b/src/main/java/forestry/core/commands/ICommandModeHelper.java index 3e57fa387..f5670c7d2 100644 --- a/src/main/java/forestry/core/commands/ICommandModeHelper.java +++ b/src/main/java/forestry/core/commands/ICommandModeHelper.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.core.commands; -import java.util.ArrayList; - import net.minecraft.world.World; public interface ICommandModeHelper { @@ -22,5 +20,5 @@ public interface ICommandModeHelper { String getModeName(World world); void setMode(World world, String modeName); - ArrayList getDescription(String modeName); + Iterable getDescription(String modeName); } diff --git a/src/main/java/forestry/core/commands/IStatsSaveHelper.java b/src/main/java/forestry/core/commands/IStatsSaveHelper.java index 3cc6092fc..51ab4d130 100644 --- a/src/main/java/forestry/core/commands/IStatsSaveHelper.java +++ b/src/main/java/forestry/core/commands/IStatsSaveHelper.java @@ -25,8 +25,6 @@ public interface IStatsSaveHelper { void addExtraInfo(Collection statistics, IBreedingTracker breedingTracker); - String getModeName(World world); - Collection getSpecies(); String getFileSuffix(); From 344e842764d03b520cbd42811bb77899de422e76 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 14 Dec 2014 18:07:57 -0800 Subject: [PATCH 050/175] Fix some mail glitches. Check valid addresses for writing letters --- api | 2 +- .../core/proxy/ClientProxyNetwork.java | 6 ++++- src/main/java/forestry/mail/MailAddress.java | 23 ++++++++++--------- src/main/java/forestry/mail/PostRegistry.java | 16 +++++++++++++ .../forestry/mail/gadgets/MachineTrader.java | 1 - .../forestry/mail/gui/ContainerLetter.java | 21 ++++++++++++----- .../forestry/mail/gui/ContainerTradeName.java | 4 ++-- .../java/forestry/mail/gui/GuiLetter.java | 5 +++- 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/api b/api index d6d724bbd..c2f49cd4d 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit d6d724bbd787f432e08a38304ba6bac3cf5bf303 +Subproject commit c2f49cd4d292a7023d2310d81c24c54269b15d14 diff --git a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java index b8c649194..b55ad8e65 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java +++ b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java @@ -10,12 +10,16 @@ ******************************************************************************/ package forestry.core.proxy; +import net.minecraft.client.network.NetHandlerPlayClient; + import forestry.core.network.ForestryPacket; public class ClientProxyNetwork extends ProxyNetwork { @Override public void sendToServer(ForestryPacket packet) { - Proxies.common.getClientInstance().getNetHandler().addToSendQueue(packet.getPacket()); + NetHandlerPlayClient netHandler = Proxies.common.getClientInstance().getNetHandler(); + if (netHandler != null) + netHandler.addToSendQueue(packet.getPacket()); } } diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index d5ea3a8fd..1f2e65e87 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -10,23 +10,24 @@ ******************************************************************************/ package forestry.mail; -import com.mojang.authlib.GameProfile; -import forestry.api.core.INBTTagable; -import forestry.api.mail.EnumAddressee; -import forestry.api.mail.IMailAddress; -import forestry.core.network.EntityNetData; -import forestry.core.utils.PlayerUtil; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; - import java.util.Locale; import java.util.UUID; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; + +import com.mojang.authlib.GameProfile; + +import forestry.api.core.INBTTagable; +import forestry.api.mail.EnumAddressee; +import forestry.api.mail.IMailAddress; +import forestry.core.network.PacketPayload; +import forestry.core.utils.PlayerUtil; + public class MailAddress implements INBTTagable, IMailAddress { private static final GameProfile invalidGameProfile = new GameProfile(new UUID(0, 0), ""); - @EntityNetData + private EnumAddressee type; - @EntityNetData private GameProfile gameProfile; // gameProfile is a fake GameProfile for traders, and real for players public MailAddress() { diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 507f78daf..6199ce05d 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -16,6 +16,7 @@ import java.util.Map; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; @@ -163,11 +164,26 @@ public class PostRegistry implements IPostRegistry { return new MailAddress(gameProfile); } + public IMailAddress getValidMailAddress(World world, GameProfile gameProfile) { + IMailAddress address = new MailAddress(gameProfile);; + if (getPOBox(world, address) != null) + return address; + return null; + } + @Override public IMailAddress getMailAddress(String traderName) { return new MailAddress(traderName); } + @Override + public IMailAddress getValidMailAddress(World world, String traderName) { + IMailAddress address = new MailAddress(traderName); + if (getTradeStation(world, address) != null) + return address; + return null; + } + /* CARRIER */ private final HashMap carriers = new HashMap(); diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 224a2d780..fa0790c47 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -41,7 +41,6 @@ import java.util.LinkedList; public class MachineTrader extends TileBase implements ISidedInventory { - @EntityNetData private MailAddress address; public MachineTrader() { diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index 679ce4f37..16252c599 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -156,14 +156,14 @@ public class ContainerLetter extends ContainerItemInventory { String typeName = packet.payload.stringPayload[1]; EnumAddressee type = EnumAddressee.fromString(typeName); - IMailAddress recipient; + IMailAddress recipient = null; if (type == EnumAddressee.PLAYER) { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); if (gameProfile == null) gameProfile = new GameProfile(new UUID(0, 0), recipientName); - recipient = PostManager.postRegistry.getMailAddress(gameProfile); + recipient = PostManager.postRegistry.getValidMailAddress(player.worldObj, gameProfile); } else if (type == EnumAddressee.TRADER) { - recipient = PostManager.postRegistry.getMailAddress(recipientName); + recipient = PostManager.postRegistry.getValidMailAddress(player.worldObj, recipientName); } else { return; } @@ -171,7 +171,8 @@ public class ContainerLetter extends ContainerItemInventory { getLetter().setRecipient(recipient); // Update the trading info - updateTradeInfo(player.worldObj, recipient); + if (recipient == null || recipient.isTrader()) + updateTradeInfo(player.worldObj, recipient); // Update info on client Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, type, tradeInfo, recipient), player); @@ -210,12 +211,16 @@ public class ContainerLetter extends ContainerItemInventory { if (!Proxies.common.isSimulating(world)) return; - if (address.isPlayer()) + if (address == null) { + setTradeInfo(null); return; + } ITradeStation station = PostManager.postRegistry.getTradeStation(world, address); - if (station == null) + if (station == null) { + setTradeInfo(null); return; + } setTradeInfo(station.getTradeInfo()); } @@ -235,5 +240,9 @@ public class ContainerLetter extends ContainerItemInventory { private void setTradeInfo(TradeStationInfo info) { this.tradeInfo = info; + if (tradeInfo == null) + getLetter().setRecipient(null); + else + getLetter().setRecipient(tradeInfo.address); } } diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index b97913f2e..8dd4a5e57 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -51,13 +51,13 @@ public class ContainerTradeName extends ContainerForestry { PacketUpdate packet = new PacketUpdate(PacketIds.TRADING_ADDRESS_SET, payload); Proxies.net.sendToServer(packet); - IMailAddress address = PostManager.postRegistry.getMailAddress(addressName); + IMailAddress address = PostManager.postRegistry.getValidMailAddress(machine.getWorld(), addressName); machine.setAddress(address); } public void handleSetAddress(PacketUpdate packet) { String addressName = packet.payload.stringPayload[0]; - IMailAddress address = PostManager.postRegistry.getMailAddress(addressName); + IMailAddress address = PostManager.postRegistry.getValidMailAddress(machine.getWorld(), addressName); machine.setAddress(address); } diff --git a/src/main/java/forestry/mail/gui/GuiLetter.java b/src/main/java/forestry/mail/gui/GuiLetter.java index 25fd670d9..f5af7a737 100755 --- a/src/main/java/forestry/mail/gui/GuiLetter.java +++ b/src/main/java/forestry/mail/gui/GuiLetter.java @@ -154,6 +154,9 @@ public class GuiLetter extends GuiForestry { if(!isProcessedLetter && !checkedSessionVars) { checkedSessionVars = true; setFromSessionVars(); + String recipient = this.address.getText(); + EnumAddressee recipientType = container.getCarrierType(); + setRecipient(recipient, recipientType); } // Check for focus changes @@ -247,7 +250,7 @@ public class GuiLetter extends GuiForestry { address.setText(recipient); EnumAddressee type = EnumAddressee.fromString(typeName); - setRecipient(recipient, type); + container.setCarrierType(type); } SessionVars.clearStringVar("mail.letter.recipient"); From 84da3cc9393c2b2026afde0117468b53f4e94361 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 14 Dec 2014 18:28:38 -0800 Subject: [PATCH 051/175] Remove ClassMap and EntityNetData --- src/main/java/forestry/core/gadgets/Mill.java | 23 +- .../forestry/core/gadgets/TileAnalyzer.java | 12 +- .../java/forestry/core/gadgets/TileBase.java | 33 +-- .../forestry/core/gadgets/TilePowered.java | 51 +--- .../java/forestry/core/network/ClassMap.java | 232 ------------------ .../forestry/core/network/EntityNetData.java | 23 -- .../energy/gadgets/MachineGenerator.java | 12 +- .../factory/gadgets/MachineBottler.java | 51 ++-- .../factory/gadgets/MachineCarpenter.java | 3 - .../factory/gadgets/MachineFermenter.java | 4 - .../factory/gadgets/MachineMoistener.java | 34 +-- .../factory/gadgets/MachineSqueezer.java | 44 ++-- .../factory/gadgets/MachineStill.java | 3 - .../forestry/mail/gadgets/MachineTrader.java | 29 ++- 14 files changed, 118 insertions(+), 436 deletions(-) delete mode 100755 src/main/java/forestry/core/network/ClassMap.java delete mode 100755 src/main/java/forestry/core/network/EntityNetData.java diff --git a/src/main/java/forestry/core/gadgets/Mill.java b/src/main/java/forestry/core/gadgets/Mill.java index 67f1291a1..a6f15aa7f 100755 --- a/src/main/java/forestry/core/gadgets/Mill.java +++ b/src/main/java/forestry/core/gadgets/Mill.java @@ -10,15 +10,12 @@ ******************************************************************************/ package forestry.core.gadgets; -import forestry.core.network.EntityNetData; +import forestry.core.network.PacketPayload; public abstract class Mill extends TileBase { - @EntityNetData public int charge = 0; - @EntityNetData public float speed; - @EntityNetData public int stage = 0; public float progress; @@ -36,6 +33,24 @@ public abstract class Mill extends TileBase { update(true); } + @Override + public PacketPayload getPacketPayload() { + PacketPayload payload = new PacketPayload(2, 1, 0); + payload.intPayload[0] = charge; + payload.intPayload[1] = stage; + + payload.floatPayload[0] = speed; + return payload; + } + + @Override + public void fromPacketPayload(PacketPayload payload) { + charge = payload.intPayload[0]; + stage = payload.intPayload[1]; + + speed = payload.floatPayload[0]; + } + private void update(boolean isSimulating) { // Stop gracefully if discharged. diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 22a1c007b..daa496611 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -15,6 +15,7 @@ import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -25,25 +26,23 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; +import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; -import forestry.api.core.EnumErrorCode; -import forestry.core.fluids.TankManager; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.FluidHelper; import forestry.core.fluids.Fluids; -import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; -import forestry.core.network.GuiId; +import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; +import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.InvTools; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; +import forestry.core.network.GuiId; import forestry.core.utils.InventoryAdapter; -import net.minecraft.inventory.IInventory; public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -61,7 +60,6 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui private int analyzeTime; - @EntityNetData public final FilteredTank resourceTank; private final TankManager tankManager; diff --git a/src/main/java/forestry/core/gadgets/TileBase.java b/src/main/java/forestry/core/gadgets/TileBase.java index a88799bae..7ae581a4c 100755 --- a/src/main/java/forestry/core/gadgets/TileBase.java +++ b/src/main/java/forestry/core/gadgets/TileBase.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.core.gadgets; +import net.minecraft.entity.player.EntityPlayer; + import forestry.core.interfaces.IHintSource; -import forestry.core.network.ClassMap; -import forestry.core.network.IndexInPayload; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; public abstract class TileBase extends TileForestry implements IHintSource { @@ -52,37 +51,11 @@ public abstract class TileBase extends TileForestry implements IHintSource { /* NETWORK */ @Override public PacketPayload getPacketPayload() { - if (!ClassMap.classMappers.containsKey(this.getClass())) - ClassMap.classMappers.put(this.getClass(), new ClassMap(this.getClass())); - - ClassMap classmap = ClassMap.classMappers.get(this.getClass()); - PacketPayload payload = new PacketPayload(classmap.intSize, classmap.floatSize, classmap.stringSize); - - try { - classmap.setData(this, payload.intPayload, payload.floatPayload, payload.stringPayload, new IndexInPayload(0, 0, 0)); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return payload; + return null; } @Override public void fromPacketPayload(PacketPayload payload) { - - if (payload.isEmpty()) - return; - - if (!ClassMap.classMappers.containsKey(this.getClass())) - ClassMap.classMappers.put(this.getClass(), new ClassMap(this.getClass())); - - ClassMap classmap = ClassMap.classMappers.get(this.getClass()); - - try { - classmap.fromData(this, payload.intPayload, payload.floatPayload, payload.stringPayload, new IndexInPayload(0, 0, 0)); - } catch (Exception ex) { - ex.printStackTrace(); - } } /* INTERACTION */ diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index 895539cb1..b62b23fb6 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -10,62 +10,25 @@ ******************************************************************************/ package forestry.core.gadgets; -import buildcraft.api.tiles.IHasWork; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; -import forestry.core.fluids.tanks.StandardTank; + import forestry.core.interfaces.IPowerHandler; import forestry.core.interfaces.IRenderableMachine; -import forestry.core.network.ClassMap; -import forestry.core.network.IndexInPayload; -import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.energy.EnergyManager; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; + +import buildcraft.api.tiles.IHasWork; @Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork { public static final int WORK_CYCLES = 4; - @Override - public PacketPayload getPacketPayload() { - if (!ClassMap.classMappers.containsKey(this.getClass())) - ClassMap.classMappers.put(this.getClass(), new ClassMap(this.getClass())); - - ClassMap classmap = ClassMap.classMappers.get(this.getClass()); - PacketPayload payload = new PacketPayload(classmap.intSize, classmap.floatSize, classmap.stringSize); - - try { - classmap.setData(this, payload.intPayload, payload.floatPayload, payload.stringPayload, new IndexInPayload(0, 0, 0)); - } catch (Exception ex) { - ex.printStackTrace(); - } - - return payload; - } - - @Override - public void fromPacketPayload(PacketPayload payload) { - - if (payload.isEmpty()) - return; - - if (!ClassMap.classMappers.containsKey(this.getClass())) - ClassMap.classMappers.put(this.getClass(), new ClassMap(this.getClass())); - - ClassMap classmap = ClassMap.classMappers.get(this.getClass()); - - try { - classmap.fromData(this, payload.intPayload, payload.floatPayload, payload.stringPayload, new IndexInPayload(0, 0, 0)); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - protected final EnergyManager energyManager; public TilePowered(int maxTransfer, int energyPerWork, int capacity) { diff --git a/src/main/java/forestry/core/network/ClassMap.java b/src/main/java/forestry/core/network/ClassMap.java deleted file mode 100755 index 02fb6b930..000000000 --- a/src/main/java/forestry/core/network/ClassMap.java +++ /dev/null @@ -1,232 +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 java.lang.reflect.Field; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.UUID; - -import com.mojang.authlib.GameProfile; - -import forestry.core.gadgets.TileForestry; - -public class ClassMap { - - @SuppressWarnings("rawtypes") - public static final HashMap classMappers = new HashMap(); - - private final LinkedList intMember = new LinkedList(); - private final LinkedList floatMember = new LinkedList(); - private final LinkedList booleanMember = new LinkedList(); - private final LinkedList stringMember = new LinkedList(); - private final LinkedList enumMember = new LinkedList(); - private final LinkedList gameProfileMember = new LinkedList(); - private final LinkedList objectMember = new LinkedList(); - - public int intSize; - public int floatSize; - public int stringSize; - - private Field field; - - /** - * Writes the actual data to the packet payload - * - * @param obj - * {@link TileForestry} to write to packet - * @param intPayload - * @param floatPayload - * @param stringPayload - * @param index - */ - @SuppressWarnings("rawtypes") - public void setData(Object obj, int[] intPayload, float[] floatPayload, String[] stringPayload, IndexInPayload index) throws IllegalAccessException { - for (Field member : intMember) { - intPayload[index.intIndex] = member.getInt(obj); - index.intIndex++; - } - for (Field member : floatMember) { - floatPayload[index.floatIndex] = member.getFloat(obj); - index.floatIndex++; - } - for (Field member : booleanMember) { - if (member.getBoolean(obj)) - floatPayload[index.intIndex] = 1; - else - floatPayload[index.intIndex] = 0; - index.intIndex++; - } - for (Field member : stringMember) { - stringPayload[index.stringIndex] = (String) member.get(obj); - index.stringIndex++; - } - for (Field member : enumMember) { - intPayload[index.intIndex] = ((Enum) member.get(obj)).ordinal(); - index.intIndex++; - } - for (Field member : gameProfileMember) { - GameProfile profile = (GameProfile) member.get(obj); - UUID profileID = profile.getId(); - if (profileID == null) - profileID = new UUID(0,0); - intPayload[index.intIndex] = (int) (profileID.getMostSignificantBits() >>> 32); - intPayload[index.intIndex + 1] = (int) profileID.getMostSignificantBits(); - intPayload[index.intIndex + 2] = (int) (profileID.getLeastSignificantBits() >>> 32); - intPayload[index.intIndex + 3] = (int) profileID.getLeastSignificantBits(); - index.intIndex += 4; - stringPayload[index.stringIndex] = profile.getName(); - index.stringIndex++; - } - - // Handle subobjects - for (ClassMap submap : objectMember) { - Object source = submap.field.get(obj); - - if (source == null) { - intPayload[index.intIndex] = 0; - index.intIndex++; - - index.intIndex += submap.intSize; - index.floatIndex += submap.floatSize; - index.stringIndex += submap.stringSize; - } else { - intPayload[index.intIndex] = 1; - index.intIndex++; - submap.setData(source, intPayload, floatPayload, stringPayload, index); - } - } - } - - /** - * Updates the given object with the data from the passed payload arrays - * - * @param obj - * @param intPayload - * @param floatPayload - * @param stringPayload - * @param index - * @throws IllegalAccessException - */ - @SuppressWarnings("rawtypes") - public void fromData(Object obj, int[] intPayload, float[] floatPayload, String[] stringPayload, IndexInPayload index) throws IllegalAccessException { - - for (Field member : intMember) { - member.setInt(obj, intPayload[index.intIndex]); - index.intIndex++; - } - - for (Field member : booleanMember) { - member.setBoolean(obj, intPayload[index.intIndex] == 1); - index.intIndex++; - } - - for (Field member : enumMember) { - member.set(obj, ((Class) member.getGenericType()).getEnumConstants()[intPayload[index.intIndex]]); - index.intIndex++; - } - - for (Field member : floatMember) { - member.setFloat(obj, floatPayload[index.floatIndex]); - index.floatIndex++; - } - for (Field member : stringMember) { - member.set(obj, stringPayload[index.stringIndex]); - index.stringIndex++; - } - for (Field member : gameProfileMember) { - GameProfile profile = new GameProfile(new UUID((long) intPayload[index.intIndex] << 32 | intPayload[index.intIndex + 1], - (long) intPayload[index.intIndex + 2] << 32 | intPayload[index.intIndex + 3]), - stringPayload[index.stringIndex]); - index.intIndex += 4; - index.stringIndex++; - - member.set(obj, profile); - } - - for (ClassMap map : objectMember) { - boolean isNull = intPayload[index.intIndex] == 0; - index.intIndex++; - - if (isNull) { - index.intIndex += map.intSize; - index.floatIndex += map.floatSize; - index.stringIndex += map.stringSize; - } else { - map.field.get(obj); - map.fromData(map.field.get(obj), intPayload, floatPayload, stringPayload, index); - } - } - } - - @SuppressWarnings("rawtypes") - public ClassMap(final Class targetClass) { - Field[] fields = targetClass.getDeclaredFields(); - - try { - for (Field field : fields) { - // We only handle fields marked with EntityNetData - if (!isNetworkedMember(field)) - continue; - - field.setAccessible(true); - Type type = field.getGenericType(); - - if (type instanceof Class && !((Class) type).isArray()) { - Class memberClass = (Class) type; - if (memberClass.equals(int.class)) { - intSize++; - intMember.add(field); - } else if (memberClass.equals(float.class)) { - floatSize++; - floatMember.add(field); - } else if (memberClass.equals(boolean.class)) { - intSize++; - booleanMember.add(field); - } else if (memberClass.equals(String.class)) { - stringSize++; - stringMember.add(field); - } else if (Enum.class.isAssignableFrom(memberClass)) { - intSize++; - enumMember.add(field); - } else if (GameProfile.class.isAssignableFrom(memberClass)) { - intSize += 4; - stringSize++; - gameProfileMember.add(field); - } else { - // If we are none of the above we assume to be another - // mapable object - // Might not be true and fail! - ClassMap mapper = new ClassMap(memberClass); - mapper.field = field; - - objectMember.add(mapper); - intSize++; - - intSize += mapper.intSize; - floatSize += mapper.floatSize; - stringSize += mapper.stringSize; - } - } else if (type instanceof Class && ((Class) type).isArray()) - // We don't handle arrays currently. Throw exception - throw new RuntimeException("Tried to map class " + targetClass.toString() + " but it requested mapping of an array. Not handled!"); - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - } - - private boolean isNetworkedMember(Field member) { - return member.getAnnotation(EntityNetData.class) != null; - } - -} diff --git a/src/main/java/forestry/core/network/EntityNetData.java b/src/main/java/forestry/core/network/EntityNetData.java deleted file mode 100755 index 311bdc863..000000000 --- a/src/main/java/forestry/core/network/EntityNetData.java +++ /dev/null @@ -1,23 +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 java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Simple annotation to mark a field for synchronization in SMP. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface EntityNetData { - // Needs to be set for arrays - int staticSize() default -1; -} diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index c34933a55..487c65598 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -19,29 +19,28 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; -import ic2.api.energy.prefab.BasicSource; - +import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.fuels.FuelManager; import forestry.api.fuels.GeneratorFuel; -import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; -import forestry.core.fluids.tanks.FilteredTank; import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; -import net.minecraftforge.fluids.FluidTankInfo; + +import ic2.api.energy.prefab.BasicSource; public class MachineGenerator extends TileBase implements ISpecialInventory, ILiquidTankContainer, IRenderableMachine { @@ -49,7 +48,6 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi public static final short SLOT_CAN = 0; public static final int maxEnergy = 30000; - @EntityNetData public final FilteredTank resourceTank; private final TankManager tankManager; private int tickCount = 0; diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index e9228a06e..1b64b721e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -10,8 +10,31 @@ ******************************************************************************/ package forestry.factory.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import cpw.mods.fml.common.Optional; + import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICraftingProvider; @@ -23,36 +46,13 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; -import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -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 java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Stack; +import buildcraft.api.statements.ITriggerExternal; public class MachineBottler extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -140,7 +140,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } } - @EntityNetData public final StandardTank resourceTank; private final TankManager tankManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index cef212e38..e1f88dbf6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -29,7 +29,6 @@ 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.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -46,7 +45,6 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; @@ -211,7 +209,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL } /* MEMBER */ - @EntityNetData public final FilteredTank resourceTank; private final TankManager tankManager; private final TileInventoryAdapter craftingInventory; diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index d70e068a1..6f4061e27 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -27,7 +27,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -48,7 +47,6 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; @@ -185,9 +183,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL return recipeList; } } - @EntityNetData public final FilteredTank resourceTank; - @EntityNetData public final FilteredTank productTank; private final TankManager tankManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 10d635ced..1e70d4b3f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -10,6 +10,23 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; @@ -24,27 +41,11 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; public class MachineMoistener extends TileBase implements ISpecialInventory, ISidedInventory, ILiquidTankContainer, IRenderableMachine { @@ -119,7 +120,6 @@ public class MachineMoistener extends TileBase implements ISpecialInventory, ISi } } - @EntityNetData public final FilteredTank resourceTank; private final TankManager tankManager; private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 62b618155..2760641a6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -10,10 +10,30 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.ISqueezerManager; -import forestry.api.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; @@ -23,33 +43,12 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -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; -import net.minecraftforge.fluids.FluidTankInfo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Stack; public class MachineSqueezer extends TilePowered implements ISpecialInventory, ISidedInventory, ILiquidTankContainer { @@ -131,7 +130,6 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I /* MEMBER */ private final TankManager tankManager; - @EntityNetData public final FilteredTank productTank; private final InventoryAdapter inventory = new InventoryAdapter(12, "Items"); diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 132f242fb..60f9d3ea8 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -40,7 +40,6 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.InventoryAdapter; @@ -118,9 +117,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid } /* MEMBER */ - @EntityNetData public final FilteredTank resourceTank; - @EntityNetData public final FilteredTank productTank; private final TankManager tankManager; diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index fa0790c47..afce32272 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -10,15 +10,27 @@ ******************************************************************************/ package forestry.mail.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + +import forestry.api.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; -import forestry.api.core.EnumErrorCode; import forestry.core.gadgets.TileBase; -import forestry.core.network.EntityNetData; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; @@ -27,17 +39,8 @@ import forestry.core.utils.StackUtils; import forestry.mail.MailAddress; import forestry.mail.TradeStation; import forestry.plugins.PluginMail; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; -import java.util.LinkedList; +import buildcraft.api.statements.ITriggerExternal; public class MachineTrader extends TileBase implements ISidedInventory { From 364ed4cf53ae0711d6395dab69a832ecf57d5092 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 14 Dec 2014 18:35:14 -0800 Subject: [PATCH 052/175] Remove unused defaults --- .../java/forestry/core/config/Defaults.java | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/src/main/java/forestry/core/config/Defaults.java b/src/main/java/forestry/core/config/Defaults.java index 4cf2e08e5..97122bd75 100755 --- a/src/main/java/forestry/core/config/Defaults.java +++ b/src/main/java/forestry/core/config/Defaults.java @@ -29,7 +29,6 @@ public class Defaults { public static final int NET_MAX_UPDATE_DISTANCE = 50; - public static final String DEFAULT_POWER_FRAMEWORK = "forestry.energy.BioPowerFramework"; public static final int BUCKET_VOLUME = 1000; public static final int FLUID_PER_HONEY_DROP = 100; @@ -51,20 +50,12 @@ public class Defaults { public static final String TEXTURE_PATH_ITEMS = "textures/items"; public static final String TEXTURE_PATH_ENTITIES = "textures/entity"; - public static final String TEXTURE_BLOCKS = TEXTURE_PATH_BLOCKS + "/blocks.png"; - public static final String TEXTURE_ARBORICULTURE = TEXTURE_PATH_BLOCKS + "/arboriculture.png"; - public static final String TEXTURE_PODS = TEXTURE_PATH_BLOCKS + "/pods.png"; - public static final String TEXTURE_FARM = TEXTURE_PATH_BLOCKS + "/farm.png"; - public static final String TEXTURE_APIARIST_ARMOR_PRIMARY = TEXTURE_PATH_ITEMS + "/apiarist_armor_1.png"; public static final String TEXTURE_APIARIST_ARMOR_SECONDARY = TEXTURE_PATH_ITEMS + "/apiarist_armor_2.png"; public static final String TEXTURE_NATURALIST_ARMOR_PRIMARY = TEXTURE_PATH_ITEMS + "/naturalist_armor_1.png"; public static final String TEXTURE_SKIN_BEEKPEEPER = TEXTURE_PATH_ENTITIES + "/beekeeper.png"; public static final String TEXTURE_SKIN_LUMBERJACK = TEXTURE_PATH_ENTITIES + "/lumberjack.png"; - public static final String TEXTURE_ICONS_MINECRAFT = "/gui/items.png"; - public static final String TEXTURE_BLOCKS_MINECRAFT = "/terrain.png"; - // Villagers public static final int ID_VILLAGER_BEEKEEPER = 80; public static final int ID_VILLAGER_LUMBERJACK = 81; @@ -146,13 +137,6 @@ public class Defaults { public static final int FOOD_HONEY_HEAL = 2; public static final float FOOD_HONEY_SATURATION = 0.2f; - // IndustrialCraft 2 - public static final int ID_IC2_FUELCAN_DAMAGE = 6480; - - // BuildCraft - public static final int BUILDCRAFT_BLOCKID_ENGINE = 161; - public static final int BUILDCRAFT_BLOCKID_PIPE = 166; - public static final int APIARY_MIN_LEVEL_LIGHT = 11; public static final int APIARY_BREEDING_TIME = 100; @@ -219,32 +203,4 @@ public class Defaults { public static final int CARPENTER_CRATING_CYCLES = 5; public static final int CARPENTER_UNCRATING_CYCLES = 5; public static final int CARPENTER_CRATING_LIQUID_QUANTITY = 100; - - // SMP gui ids - public static final int ID_GUI_ARBORETUM = 90; - public static final int ID_GUI_BOTTLER = 91; - public static final int ID_GUI_ENGINE_BRONZE = 92; - public static final int ID_GUI_FARM = 93; - public static final int ID_GUI_FERMENTER = 94; - public static final int ID_GUI_FORESTER = 95; - public static final int ID_GUI_PLANTATION = 96; - public static final int ID_GUI_PUMPKIN_FARM = 97; - public static final int ID_GUI_PEAT_BOG = 98; - public static final int ID_GUI_STILL = 99; - public static final int ID_GUI_ENGINE_COPPER = 89; - public static final int ID_GUI_RAINTANK = 88; - public static final int ID_GUI_GENERATOR = 87; - public static final int ID_GUI_CARPENTER = 86; - public static final int ID_GUI_MOISTENER = 85; - public static final int ID_GUI_MUSHROOM_FARM = 84; - public static final int ID_GUI_APIARY = 83; - public static final int ID_GUI_CENTRIFUGE = 82; - public static final int ID_GUI_APIARIST_INVENTORY = 81; - public static final int ID_GUI_BACKPACK = 80; - public static final int ID_GUI_SQUEEZER = 79; - public static final int ID_GUI_NETHER_FARM = 78; - public static final int ID_GUI_BEEALYZER = 100; - public static final int ID_GUI_BACKPACK_T2 = 101; - public static final int ID_GUI_BIOME_FINDER = 102; - // ID 100 used by bucket filler. } From ccdcce47cc77eb24102234c55d6d52ec7df89d50 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 15 Dec 2014 07:45:10 -0800 Subject: [PATCH 053/175] Fixes #369 The Solding Iron and other Cicruit stuff should no longer crash if no layouts are defined. The fix kind of grew out of control because I had to add a new EnumErrorCode and didn't want to keep breaking the API every time I did that. So I needed to decouple the ErrorStates from EnumErrorCode. --- api | 2 +- lang | 2 +- .../forestry/apiculture/BeekeepingLogic.java | 7 +- .../apiculture/gadgets/TileAlvearyPlain.java | 7 +- .../apiculture/gadgets/TileBeehouse.java | 4 +- .../genetics/AlleleEffectThrottled.java | 12 +- .../forestry/apiculture/genetics/Bee.java | 2 +- .../apiculture/items/ItemBeealyzer.java | 2 +- .../apiculture/items/ItemBiomefinder.java | 2 +- .../trigger/TriggerMissingDrone.java | 2 +- .../trigger/TriggerMissingQueen.java | 2 +- .../arboriculture/gadgets/TileLeaves.java | 5 +- .../arboriculture/items/ItemTreealyzer.java | 2 +- .../java/forestry/core/EnumErrorCode.java | 105 ++++++++++++++++++ .../java/forestry/core/EventHandlerCore.java | 4 +- src/main/java/forestry/core/ForestryCore.java | 2 + .../core/circuits/CircuitBoardManager.java | 14 --- .../forestry/core/circuits/CircuitLayout.java | 4 +- .../core/circuits/CircuitRegistry.java | 29 +++-- .../core/circuits/ItemSolderingIron.java | 81 ++++++-------- .../forestry/core/gadgets/TileAnalyzer.java | 2 +- .../forestry/core/gadgets/TileForestry.java | 10 +- .../java/forestry/core/gui/ErrorLedger.java | 12 +- .../core/interfaces/IErrorSource.java | 4 +- .../core/network/PacketTileUpdate.java | 23 ++-- .../java/forestry/core/proxy/ProxyLog.java | 31 ++++++ .../forestry/core/utils/RevolvingList.java | 69 ++++++++++++ .../forestry/energy/gadgets/EngineBronze.java | 2 +- .../forestry/energy/gadgets/EngineCopper.java | 2 +- .../forestry/energy/gadgets/EngineTin.java | 2 +- .../energy/gadgets/MachineGenerator.java | 2 +- .../factory/gadgets/MachineBottler.java | 2 +- .../factory/gadgets/MachineCarpenter.java | 2 +- .../factory/gadgets/MachineCentrifuge.java | 2 +- .../factory/gadgets/MachineFabricator.java | 2 +- .../factory/gadgets/MachineFermenter.java | 2 +- .../factory/gadgets/MachineMoistener.java | 2 +- .../factory/gadgets/MachineRaintank.java | 2 +- .../factory/gadgets/MachineSqueezer.java | 2 +- .../factory/gadgets/MachineStill.java | 2 +- .../farming/gadgets/TileFarmPlain.java | 2 +- .../forestry/farming/gadgets/TileGearbox.java | 2 +- .../items/ItemFlutterlyzer.java | 2 +- .../forestry/mail/gadgets/MachineTrader.java | 2 +- .../java/forestry/mail/items/ItemLetter.java | 2 +- .../textures/items/errors/noCircuitLayout.png | Bin 0 -> 370 bytes 46 files changed, 336 insertions(+), 141 deletions(-) create mode 100644 src/main/java/forestry/core/EnumErrorCode.java delete mode 100755 src/main/java/forestry/core/circuits/CircuitBoardManager.java create mode 100644 src/main/java/forestry/core/utils/RevolvingList.java create mode 100644 src/main/resources/assets/forestry/textures/items/errors/noCircuitLayout.png diff --git a/api b/api index c2f49cd4d..89067121c 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit c2f49cd4d292a7023d2310d81c24c54269b15d14 +Subproject commit 89067121c057bda5c535bf7a46c0112e245e311b diff --git a/lang b/lang index 71f517c5a..ab16b1a2e 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 71f517c5a6d4bb564b3996822b84da91bff791f3 +Subproject commit ab16b1a2efc80aa48e70d81c8859fd83e143a98f diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java index fa1c70e86..19ccf272f 100755 --- a/src/main/java/forestry/apiculture/BeekeepingLogic.java +++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java @@ -23,10 +23,12 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingLogic; import forestry.api.genetics.IEffectData; import forestry.api.genetics.IIndividual; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; +import forestry.api.core.IErrorState; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; +import forestry.core.proxy.ProxyLog; import forestry.plugins.PluginApiculture; public class BeekeepingLogic implements IBeekeepingLogic { @@ -261,7 +263,7 @@ public class BeekeepingLogic implements IBeekeepingLogic { try { boolean canWork = true; // Not while raining, at night or without light - EnumErrorCode state = queen.canWork(housing); + IErrorState state = queen.canWork(housing); if (state != EnumErrorCode.OK) { housing.setErrorState(state); canWork = false; @@ -270,6 +272,7 @@ public class BeekeepingLogic implements IBeekeepingLogic { } return canWork; } catch (Error e) { + Proxies.log.logErrorAPI("Forestry", e, IBee.class); return queenCanWorkDeprecated(); } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 13c3ff600..4b1dd4b44 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -18,10 +18,11 @@ import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; import forestry.api.apiculture.IBeekeepingLogic; import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; +import forestry.api.core.IErrorState; import forestry.api.core.ISpecialInventory; import forestry.api.core.ITileStructure; import forestry.api.genetics.IIndividual; @@ -424,7 +425,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public int getErrorOrdinal() { - return getErrorState().ordinal(); + return getErrorState().getID(); } @Override @@ -803,7 +804,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS /* IERRORSOURCE */ @Override - public EnumErrorCode getErrorState() { + public IErrorState getErrorState() { if (hasMaster()) { ITileStructure tile = this.getCentralTE(); if (tile != null) diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index d343f4a03..337d16656 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -15,7 +15,7 @@ import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingLogic; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; @@ -351,7 +351,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { @Override public int getErrorOrdinal() { - return getErrorState().ordinal(); + return getErrorState().getID(); } @Override diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index dfd554053..4fe7543a8 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -16,7 +16,7 @@ import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; import forestry.core.genetics.EffectData; import forestry.core.utils.Vect; @@ -55,14 +55,14 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee public boolean isHalted(IEffectData storedData, IBeeHousing housing) { - if (requiresWorkingQueen && housing.getErrorOrdinal() != EnumErrorCode.OK.ordinal()) + if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) return true; - int throttle = storedData.getInteger(0); - throttle++; - storedData.setInteger(0, throttle); + int throt = storedData.getInteger(0); + throt++; + storedData.setInteger(0, throt); - if (throttle < getThrottle()) + if (throt < getThrottle()) return true; // Reset since we are done throttling. diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 9a774a9bd..ea52b7f6e 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -20,7 +20,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeMutation; import forestry.api.apiculture.IBeekeepingMode; import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index d5a8210d5..fc74aa51b 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -19,7 +19,7 @@ import net.minecraft.world.World; import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java index a77af1765..a7c8b1909 100755 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java @@ -30,7 +30,7 @@ import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.apiculture.render.TextureBiomefinder; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java index 7a8199113..5d3e99c2b 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java @@ -12,7 +12,7 @@ package forestry.apiculture.trigger; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.triggers.Trigger; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java index 12f38c772..89c2005a4 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java @@ -12,7 +12,7 @@ package forestry.apiculture.trigger; import buildcraft.api.statements.IStatementContainer; import buildcraft.api.statements.IStatementParameter; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.triggers.Trigger; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 21c07f8ce..0c474ea9b 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -17,9 +17,10 @@ import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ILeafTickHandler; import forestry.api.arboriculture.ITree; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; +import forestry.api.core.IErrorState; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IEffectData; import forestry.api.genetics.IFruitBearer; @@ -442,7 +443,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru @Override public void setErrorState(int state) {} @Override - public void setErrorState(EnumErrorCode state) { + public void setErrorState(IErrorState state) { } @Override public int getErrorOrdinal() { return 0; } diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index d9156069e..15a63b279 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -19,7 +19,7 @@ import forestry.core.utils.AlyzerInventory; import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java new file mode 100644 index 000000000..6fcaa0fa8 --- /dev/null +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.core; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.ErrorStateRegistry; +import forestry.api.core.IErrorState; + +public enum EnumErrorCode implements IErrorState { + + UNKNOWN("unknown"), + OK("ok"), + INVALIDBIOME("invalidBiome"), + ISRAINING("isRaining"), + NOTRAINING("notRaining"), + NOFUEL("noFuel"), // Biogas & Peat-fired + NOHEAT("noHeat"), // Biogas engine + NODISPOSAL("noDisposal"), + NORESOURCE("noResource"), + NOTGLOOMY("notGloomy"), + NOTLUCID("notLucid"), + NOTDAY("notDay"), + NOTNIGHT("notNight"), + NOFLOWER("noFlower"), + NOQUEEN("noQueen"), + NODRONE("noDrone"), + NOSKY("noSky"), + NOSPACE("noSpace"), + NORECIPE("noRecipe"), + NOENERGYNET("noEnergyNet"), + NOTHINGANALYZE("noSpecimen"), + FORCEDCOOLDOWN("forcedCooldown"), + NOHONEY("noHoney"), + NOTPOSTPAID("notPostpaid", "noStamps"), + NORECIPIENT("noRecipient"), + NOTALPHANUMERIC("notAlphaNumeric"), + NOTUNIQUE("notUnique"), + NOSTAMPS("noStamps"), + NOCIRCUITBOARD("noCircuitBoard"), + NOCIRCUITLAYOUT("noCircuitLayout"), + WRONGSTACKSIZE("wrongStacksize"), + NOFERTILIZER("noFertilizer"), + NOFARMLAND("noFarmland"), + CIRCUITMISMATCH("circuitMismatch"), + NOLIQUID("noLiquid"), + NOPAPER("noPaper"), + NOSTAMPSNOPAPER("noStampsNoPaper", "noStamps"), + NOSUPPLIES("noSupplies", "noResource"), + NOTRADE("noTrade", "noResource"), + NOPOWER("noPower"); + + private String name; + private String iconName; + @SideOnly(Side.CLIENT) + private IIcon icon; + + private EnumErrorCode(String name) { + this(name, name); + } + + private EnumErrorCode(String name, String iconName) { + this.name = name; + this.iconName = iconName; + } + + @Override + public String getDescription() { + return "errors." + name + ".desc"; + } + + @Override + public String getHelp() { + return "errors." + name + ".help"; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister register) { + icon = register.registerIcon("forestry:errors/" + iconName); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon() { + return icon; + } + + @Override + public short getID() { + return (short) ordinal(); + } + + public static void init() { + for (IErrorState code : values()) { + ErrorStateRegistry.registerErrorState(code); + } + } +} diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index c3b3df08c..13c061bac 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -21,8 +21,8 @@ import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.ErrorStateRegistry; -import forestry.api.core.EnumErrorCode; import forestry.core.fluids.Fluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; @@ -87,7 +87,7 @@ public class EventHandlerCore { @SideOnly(Side.CLIENT) public void handleTextureRemap(TextureStitchEvent.Pre event) { if(event.map.getTextureType() == 1) { - EnumErrorCode.initIcons(event.map); + ErrorStateRegistry.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); } else if(event.map.getTextureType() == 0) Fluids.resetFluidIcons(event.map); diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 29f61b83a..2b797d3af 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -58,6 +58,8 @@ public class ForestryCore { Config.load(); if (!Config.disableVersionCheck) Version.versionCheck(); + + EnumErrorCode.init(); PluginManager.runPreInit(); } diff --git a/src/main/java/forestry/core/circuits/CircuitBoardManager.java b/src/main/java/forestry/core/circuits/CircuitBoardManager.java deleted file mode 100755 index 7de2ccfdd..000000000 --- a/src/main/java/forestry/core/circuits/CircuitBoardManager.java +++ /dev/null @@ -1,14 +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.circuits; - -public class CircuitBoardManager { -} diff --git a/src/main/java/forestry/core/circuits/CircuitLayout.java b/src/main/java/forestry/core/circuits/CircuitLayout.java index e649a9017..60cb2d29d 100755 --- a/src/main/java/forestry/core/circuits/CircuitLayout.java +++ b/src/main/java/forestry/core/circuits/CircuitLayout.java @@ -28,11 +28,11 @@ public class CircuitLayout implements ICircuitLayout { @Override public String getName() { - return StringUtil.localize("layout." + this.uid); + return StringUtil.localize("circuit.layout." + this.uid + ".name"); } @Override public String getUsage() { - return StringUtil.localize("usage." + this.uid); + return StringUtil.localize("circuit.layout." + this.uid + ".usage"); } } diff --git a/src/main/java/forestry/core/circuits/CircuitRegistry.java b/src/main/java/forestry/core/circuits/CircuitRegistry.java index bfcac9040..3d316449f 100755 --- a/src/main/java/forestry/core/circuits/CircuitRegistry.java +++ b/src/main/java/forestry/core/circuits/CircuitRegistry.java @@ -23,12 +23,19 @@ import forestry.api.circuits.ICircuitLayout; import forestry.api.circuits.ICircuitLibrary; import forestry.api.circuits.ICircuitRegistry; import forestry.core.config.ForestryItem; +import java.util.Map; public class CircuitRegistry implements ICircuitRegistry { - private final LinkedHashMap layoutMap = new LinkedHashMap(); - private final LinkedHashMap circuitMap = new LinkedHashMap(); - private final HashMap legacyMap = new HashMap(); + public static final ICircuitLayout DUMMY_LAYOUT = new CircuitLayout("dummy"); + public static final Map DUMMY_MAP = new LinkedHashMap(); + private final Map layoutMap = new LinkedHashMap(); + private final Map circuitMap = new LinkedHashMap(); + private final Map legacyMap = new HashMap(); + + static { + DUMMY_MAP.put("dummy", DUMMY_LAYOUT); + } @Override public ICircuitLibrary getCircuitLibrary(World world, String playername) { @@ -47,12 +54,16 @@ public class CircuitRegistry implements ICircuitRegistry { public ICircuitLayout getDefaultLayout() { if (layoutMap.containsKey("forestry.engine.tin")) return layoutMap.get("forestry.engine.tin"); - else + else if (!layoutMap.isEmpty()) return layoutMap.values().iterator().next(); + else + return DUMMY_LAYOUT; } @Override - public LinkedHashMap getRegisteredLayouts() { + public Map getRegisteredLayouts() { + if (layoutMap.isEmpty()) + return DUMMY_MAP; return layoutMap; } @@ -71,7 +82,7 @@ public class CircuitRegistry implements ICircuitRegistry { /* CIRCUITS */ @Override - public HashMap getRegisteredCircuits() { + public Map getRegisteredCircuits() { return circuitMap; } @@ -100,14 +111,12 @@ public class CircuitRegistry implements ICircuitRegistry { public void initialize() { } - - - + @Override public boolean isChipset(ItemStack itemstack) { return ForestryItem.circuitboards.isItemEqual(itemstack); } - + @Override public ICircuitBoard getCircuitboard(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTagCompound(); diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index 0a6e3413e..3c213d4fb 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -12,8 +12,6 @@ package forestry.core.circuits; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; -import java.util.Map.Entry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -25,16 +23,19 @@ import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitLayout; import forestry.api.circuits.ISolderManager; import forestry.api.core.ForestryAPI; -import forestry.api.core.EnumErrorCode; +import forestry.api.core.IErrorState; +import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.ItemInventory; +import forestry.core.utils.RevolvingList; public class ItemSolderingIron extends ItemForestry implements ISolderingIron { public static class CircuitRecipe { + private final ICircuitLayout layout; private final ItemStack resource; public final ICircuit circuit; @@ -54,6 +55,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } public static class SolderManager implements ISolderManager { + public static final ArrayList recipes = new ArrayList(); @Override @@ -71,9 +73,10 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { if (layout == null || resource == null) return null; - for (CircuitRecipe recipe : recipes) + for (CircuitRecipe recipe : recipes) { if (recipe.matches(layout, resource)) return recipe; + } return null; } @@ -82,7 +85,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { // / INVENTORY MANAGMENT public static class SolderingInventory extends ItemInventory implements IErrorSource { - private ICircuitLayout layout; + private final RevolvingList layouts = new RevolvingList(ChipsetManager.circuitRegistry.getRegisteredLayouts().values()); private EnumErrorCode errorState; private final short blankSlot = 0; @@ -91,57 +94,32 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { public SolderingInventory() { super(ItemSolderingIron.class, 6); - layout = ChipsetManager.circuitRegistry.getDefaultLayout(); + init(); } public SolderingInventory(ItemStack itemstack) { super(ItemSolderingIron.class, 6, itemstack); - layout = ChipsetManager.circuitRegistry.getDefaultLayout(); + init(); + } + + private void init() { + layouts.setCurrent(ChipsetManager.circuitRegistry.getDefaultLayout()); } public ICircuitLayout getLayout() { - return this.layout; + return layouts.getCurrent(); } public void setLayout(String uid) { - this.layout = ChipsetManager.circuitRegistry.getLayout(uid); + layouts.setCurrent(ChipsetManager.circuitRegistry.getLayout(uid)); } public void advanceLayout() { - Iterator> it = ChipsetManager.circuitRegistry.getRegisteredLayouts().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - if (entry.getKey().equals(layout.getUID())) { - - if (it.hasNext()) - layout = it.next().getValue(); - else - layout = ChipsetManager.circuitRegistry.getRegisteredLayouts().entrySet().iterator().next().getValue(); - - break; - } - } + layouts.rotateRight(); } public void regressLayout() { - Iterator> it = ChipsetManager.circuitRegistry.getRegisteredLayouts().entrySet().iterator(); - - ICircuitLayout previous = null; - while (it.hasNext()) { - Entry entry = it.next(); - if (entry.getKey().equals(layout.getUID())) { - - if (previous != null) - layout = previous; - else - while (it.hasNext()) - layout = it.next().getValue(); - - break; - } - - previous = entry.getValue(); - } + layouts.rotateLeft(); } private Collection getCircuits(EnumCircuitBoardType type, boolean doConsume) { @@ -153,7 +131,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { if (ingredient == null) continue; - CircuitRecipe recipe = SolderManager.getMatchingRecipe(layout, ingredient); + CircuitRecipe recipe = SolderManager.getMatchingRecipe(layouts.getCurrent(), ingredient); if (recipe == null) continue; @@ -170,16 +148,18 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } public void trySolder() { - - // Requires blank slot - if (inventoryStacks[blankSlot] == null) + if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) return; - if (inventoryStacks[blankSlot].stackSize > 1) + + ItemStack blank = inventoryStacks[blankSlot]; + // Requires blank slot + if (blank == null) + return; + if (blank.stackSize > 1) return; if (inventoryStacks[finishedSlot] != null) return; - ItemStack blank = inventoryStacks[blankSlot]; // Need a chipset item if (!ChipsetManager.circuitRegistry.isChipset(blank)) return; @@ -199,15 +179,16 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } circuits = getCircuits(type, true); - inventoryStacks[finishedSlot] = ItemCircuitBoard.createCircuitboard(type, layout, circuits.toArray(new ICircuit[circuits.size()])); + inventoryStacks[finishedSlot] = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuits.toArray(new ICircuit[circuits.size()])); inventoryStacks[blankSlot] = null; } public int getCount(ICircuit circuit, ArrayList circuits) { int count = 0; - for (ICircuit other : circuits) + for (ICircuit other : circuits) { if (other.getUID().equals(circuit.getUID())) count++; + } return count; } @@ -231,7 +212,9 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { } @Override - public EnumErrorCode getErrorState() { + public IErrorState getErrorState() { + if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) + return EnumErrorCode.NOCIRCUITLAYOUT; if (inventoryStacks[blankSlot] == null) return EnumErrorCode.NOCIRCUITBOARD; if (inventoryStacks[blankSlot].stackSize > 1) diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index daa496611..537fe6a03 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -26,7 +26,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index a6e1aedcd..bc49ad212 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -16,7 +16,8 @@ import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerProvider; import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.Optional; -import forestry.api.core.EnumErrorCode; +import forestry.api.core.IErrorState; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.interfaces.IErrorSource; @@ -186,9 +187,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit this.sendNetworkUpdate(); } // / ERROR HANDLING - public EnumErrorCode errorState = EnumErrorCode.OK; + public IErrorState errorState = EnumErrorCode.OK; - public void setErrorState(EnumErrorCode state) { + public void setErrorState(IErrorState state) { if (this.errorState == state) return; this.errorState = state; @@ -201,7 +202,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } @Override - public EnumErrorCode getErrorState() { + public IErrorState getErrorState() { return errorState; } // / OWNERSHIP @@ -288,6 +289,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit /** * Gets the tile's unlocalized name, based on the block at the location of this entity (client-only). + * @return */ public String getUnlocalizedName() { String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.",""); diff --git a/src/main/java/forestry/core/gui/ErrorLedger.java b/src/main/java/forestry/core/gui/ErrorLedger.java index 7c1ffc88e..7ea4c454b 100755 --- a/src/main/java/forestry/core/gui/ErrorLedger.java +++ b/src/main/java/forestry/core/gui/ErrorLedger.java @@ -10,7 +10,8 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; +import forestry.api.core.IErrorState; import forestry.core.interfaces.IErrorSource; import forestry.core.utils.StringUtil; @@ -30,7 +31,7 @@ public class ErrorLedger extends Ledger { @Override public void draw(int x, int y) { - EnumErrorCode state = tile.getErrorState(); + IErrorState state = tile.getErrorState(); if (state == EnumErrorCode.OK) return; @@ -52,11 +53,8 @@ public class ErrorLedger extends Ledger { @Override public boolean isVisible() { - EnumErrorCode state = tile.getErrorState(); - if (state == EnumErrorCode.OK) - return false; - else - return true; + IErrorState state = tile.getErrorState(); + return state != EnumErrorCode.OK; } @Override diff --git a/src/main/java/forestry/core/interfaces/IErrorSource.java b/src/main/java/forestry/core/interfaces/IErrorSource.java index 342a2ad35..019c03f78 100755 --- a/src/main/java/forestry/core/interfaces/IErrorSource.java +++ b/src/main/java/forestry/core/interfaces/IErrorSource.java @@ -10,12 +10,12 @@ ******************************************************************************/ package forestry.core.interfaces; -import forestry.api.core.EnumErrorCode; +import forestry.api.core.IErrorState; public interface IErrorSource { boolean throwsErrors(); - EnumErrorCode getErrorState(); + IErrorState getErrorState(); } diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index e9443ca13..819d94eb7 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -18,15 +18,17 @@ import java.util.UUID; import net.minecraftforge.common.util.ForgeDirection; import com.mojang.authlib.GameProfile; +import forestry.api.core.ErrorStateRegistry; +import forestry.api.core.IErrorState; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.gadgets.TileForestry; import forestry.core.utils.EnumAccess; public class PacketTileUpdate extends PacketUpdate { private ForgeDirection orientation = ForgeDirection.WEST; - private EnumErrorCode errorState = EnumErrorCode.OK; + private IErrorState errorState = EnumErrorCode.OK; private boolean isOwnable = false; private EnumAccess access = EnumAccess.SHARED; @@ -57,11 +59,14 @@ public class PacketTileUpdate extends PacketUpdate { data.writeInt(posY); data.writeInt(posZ); - data.writeInt(this.orientation.ordinal()); - data.writeInt(this.errorState.ordinal()); + data.writeByte(this.orientation.ordinal()); + data.writeShort(this.errorState.getID()); + // TODO: Should this really be sent to the client? Huge network cost. + // As far as I know, only GUIs need it, and there are better ways to get the information to a GUI. + // -CovertJaguar if (isOwnable) { - data.writeInt(access.ordinal()); + data.writeByte(access.ordinal()); if (owner == null) { data.writeBoolean(false); } else { @@ -83,10 +88,10 @@ public class PacketTileUpdate extends PacketUpdate { posY = data.readInt(); posZ = data.readInt(); - orientation = ForgeDirection.values()[data.readInt()]; - errorState = EnumErrorCode.values()[data.readInt()]; + orientation = ForgeDirection.getOrientation(data.readByte()); + errorState = ErrorStateRegistry.getErrorStateFromCode(data.readShort()); - int ordinal = data.readInt(); + int ordinal = data.readByte(); isOwnable = ordinal >= 0; if (isOwnable) { access = EnumAccess.values()[ordinal]; @@ -105,7 +110,7 @@ public class PacketTileUpdate extends PacketUpdate { return this.orientation; } - public EnumErrorCode getErrorState() { + public IErrorState getErrorState() { return this.errorState; } diff --git a/src/main/java/forestry/core/proxy/ProxyLog.java b/src/main/java/forestry/core/proxy/ProxyLog.java index 4d6d21c1f..7b4e168dc 100755 --- a/src/main/java/forestry/core/proxy/ProxyLog.java +++ b/src/main/java/forestry/core/proxy/ProxyLog.java @@ -101,4 +101,35 @@ public class ProxyLog { LogManager.getLogger(Defaults.MOD).log(logLevel, new MessageFormatMessage(String.format(message, params), params)); } + /* EXCEPTIONS */ + public void logThrowable(String msg, Throwable error, Object... args) { + logThrowable(Level.ERROR, msg, 3, error, args); + } + + public void logThrowable(String msg, int lines, Throwable error, Object... args) { + logThrowable(Level.ERROR, msg, lines, error, args); + } + + public void logThrowable(Level level, String msg, int lines, Throwable error, Object... args) { + StackTraceElement[] oldtrace = error.getStackTrace(); + if (lines < oldtrace.length) { + StackTraceElement[] newtrace = new StackTraceElement[lines]; + System.arraycopy(oldtrace, 0, newtrace, 0, newtrace.length); + error.setStackTrace(newtrace); + } + LogManager.getLogger(Defaults.MOD).log(level, new MessageFormatMessage(msg, args), error); + } + + public void logErrorAPI(String mod, Throwable error, Class classFile) { + StringBuilder msg = new StringBuilder(mod); + msg.append(" API error, please update your mods. Error: ").append(error); + logThrowable(Level.ERROR, msg.toString(), 2, error); + + if (classFile != null) { + msg = new StringBuilder(mod); + msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation()); + log(Level.ERROR, msg.toString()); + } + } + } diff --git a/src/main/java/forestry/core/utils/RevolvingList.java b/src/main/java/forestry/core/utils/RevolvingList.java new file mode 100644 index 000000000..7a5a385f2 --- /dev/null +++ b/src/main/java/forestry/core/utils/RevolvingList.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import com.google.common.collect.ForwardingCollection; +import java.util.*; + +/** + * + * @author CovertJaguar + * @param + */ +public class RevolvingList extends ForwardingCollection { + + private final Deque list = new LinkedList(); + + public RevolvingList() { + } + + public RevolvingList(Collection collection) { + list.addAll(collection); + } + + @Override + protected Collection delegate() { + return list; + } + + public void rotateLeft() { + if (list.isEmpty()) + return; + list.addFirst(list.removeLast()); + } + + public void rotateRight() { + if (list.isEmpty()) + return; + list.addLast(list.removeFirst()); + } + + public T getCurrent() { + if (list.isEmpty()) + return null; + return list.getFirst(); + } + + public void setCurrent(T e) { + if (!contains(e)) + return; + + if (e == null) + while (getCurrent() != null) { + rotateRight(); + } + else + while (getCurrent() == null || !getCurrent().equals(e)) { + rotateRight(); + } + } + +} diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index b26ba5d61..ab9d9b245 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -24,7 +24,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 9e98ee7f9..6bb079f48 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -13,7 +13,7 @@ package forestry.energy.gadgets; import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameData; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.core.TemperatureState; diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index e584daadc..f8bfb5ec7 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -22,7 +22,7 @@ import ic2.api.energy.prefab.BasicSink; import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.ForestryAPI; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.TemperatureState; import forestry.core.config.Config; import forestry.core.config.Defaults; diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index 487c65598..4b45022ae 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -21,7 +21,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.fuels.FuelManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 1b64b721e..f2c7d15ac 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -35,7 +35,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import cpw.mods.fml.common.Optional; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICraftingProvider; import forestry.core.config.Config; diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index e1f88dbf6..43f02f007 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -32,7 +32,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICarpenterManager; import forestry.core.config.Config; diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index cf1b0a6e7..5aeb1a73e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -15,7 +15,7 @@ import cpw.mods.fml.common.Optional; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.ICentrifugeManager; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 6bf4f9f12..4e6388855 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.factory.gadgets; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IFabricatorManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 6f4061e27..146562792 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -32,7 +32,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import cpw.mods.fml.common.Optional; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.recipes.IFermenterManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 1e70d4b3f..d27cec204 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -27,7 +27,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.fuels.FuelManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index b9ddcf208..b909c1ad6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -25,7 +25,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.core.config.Config; import forestry.core.config.Defaults; diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 2760641a6..7408793ea 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -30,7 +30,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.ISqueezerManager; diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 60f9d3ea8..35c136765 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -27,7 +27,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.core.ISpecialInventory; import forestry.api.recipes.IStillManager; diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 31543a143..d5e2eebc8 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -35,7 +35,7 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.farming.ICrop; diff --git a/src/main/java/forestry/farming/gadgets/TileGearbox.java b/src/main/java/forestry/farming/gadgets/TileGearbox.java index 059268bf1..dd5d4ddef 100644 --- a/src/main/java/forestry/farming/gadgets/TileGearbox.java +++ b/src/main/java/forestry/farming/gadgets/TileGearbox.java @@ -12,7 +12,7 @@ package forestry.farming.gadgets; import forestry.api.core.ITileStructure; import forestry.api.farming.IFarmHousing; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.gadgets.TileForestry; import forestry.core.interfaces.IPowerHandler; import forestry.energy.EnergyManager; diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index a7f66e480..8d037ae50 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -19,7 +19,7 @@ import forestry.core.utils.AlyzerInventory; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.api.lepidopterology.IButterfly; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index afce32272..bf69b9644 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index d143399e1..fbdfc755d 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.ForestryAPI; import forestry.api.mail.ILetter; -import forestry.api.core.EnumErrorCode; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; diff --git a/src/main/resources/assets/forestry/textures/items/errors/noCircuitLayout.png b/src/main/resources/assets/forestry/textures/items/errors/noCircuitLayout.png new file mode 100644 index 0000000000000000000000000000000000000000..3c458744ff9222380bf9d81555c02bdeadc3f06f GIT binary patch literal 370 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@p$DS^ZAr}70C$_C`PxkaY`MHV$Aix}X>98Yb9s`Fp1Fy@p z_DnZJh9~wZt|!&G+D6ifRwA@t~BEX;UARK+r21*t@YsH zU=<02&8H_DF;6f(Y!Jw%Gvh(?BF?)8O^qFEB%Vo?I2TAYtkF0W&wZ3ZTR2n1*?`Ak z8cU{wf2Wum%Os;sX(c?TxE0PO^k^F&v{3jjc*tO@z@Pby45o1&R;r$NeSqF&@O1Ta JS?83{1OR0LfFu9_ literal 0 HcmV?d00001 From d4b8c6b5032d1c813f265a5b6797493a25e3c915 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 15 Dec 2014 07:45:25 -0800 Subject: [PATCH 054/175] Bump version --- application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application.properties b/application.properties index 3e5aeb49f..8c91f8142 100644 --- a/application.properties +++ b/application.properties @@ -1,6 +1,6 @@ mcversion=1.7.10 forgeversion=10.13.0.1207 version_major=3 -version_minor=1 -version_patch=1 +version_minor=3 +version_patch=0 From aaa00d01842b7c9be16f7c53d7dccb88cf7d2d8b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 15 Dec 2014 07:46:28 -0800 Subject: [PATCH 055/175] For whatever reason the Potion.isBadEffect() reflection was giving me generics related compile errors. This fixes it. --- .../apiculture/genetics/AlleleEffectPotion.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java index c55961d14..1ca3a1674 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java @@ -51,21 +51,21 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { EntityPlayer player = (EntityPlayer) entity; - int duration = this.duration; + int dur = this.duration; if (isBadEffect) { // Players are not attacked if they wear a full set of apiarist's armor. int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true); if (count >= 4) continue; // Full set, no damage/effect else if (count == 3) - duration = this.duration / 4; + dur = this.duration / 4; else if (count == 2) - duration = this.duration / 2; + dur = this.duration / 2; else if (count == 1) - duration = this.duration * 3 / 4; + dur = this.duration * 3 / 4; } - player.addPotionEffect(new PotionEffect(potion.getId(), duration, 0)); + player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0)); } return storedData; @@ -74,7 +74,7 @@ public class AlleleEffectPotion extends AlleleEffectThrottled { //FIXME: remove when Potion.isBadEffect() is available server-side private static boolean isBadEffect(Potion potion) { try { - return ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect"); + return (Boolean) ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect"); } catch (ReflectionHelper.UnableToFindFieldException e) { Proxies.log.severe("Could not access potion field isBadEffect."); return false; From 344bb7514bce3744ee4ffc675eb3ad2c2c46a07b Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 15 Dec 2014 08:09:46 -0800 Subject: [PATCH 056/175] Finish Inventory cleanup --- .../forestry/energy/gadgets/EngineBronze.java | 22 +-- .../energy/gadgets/MachineGenerator.java | 37 ++-- .../factory/gadgets/MachineCentrifuge.java | 172 ++++++------------ .../factory/gadgets/MachineFabricator.java | 20 +- .../factory/gadgets/MachineStill.java | 2 + 5 files changed, 83 insertions(+), 170 deletions(-) diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 175bc93fa..0a2bc5105 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -10,24 +10,10 @@ ******************************************************************************/ package forestry.energy.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; @@ -41,8 +27,6 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; -<<<<<<< HEAD - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -56,10 +40,6 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -======= -import forestry.core.utils.TileInventoryAdapter; - ->>>>>>> dev public class EngineBronze extends Engine implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index b4542ae95..4c6e7146b 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -10,21 +10,10 @@ ******************************************************************************/ package forestry.energy.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; 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.FluidHelper; @@ -33,24 +22,22 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; -<<<<<<< HEAD import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.network.EntityNetData; -======= ->>>>>>> dev import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; -<<<<<<< HEAD -import net.minecraft.inventory.ISidedInventory; -import net.minecraftforge.fluids.FluidTankInfo; -======= - import ic2.api.energy.prefab.BasicSource; ->>>>>>> dev - - +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; public class MachineGenerator extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine { @@ -187,6 +174,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { int firstMessageId = tankManager.maxMessageId() + 1; if (i == firstMessageId) @@ -194,6 +182,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu ic2EnergySource.setEnergyStored(j); } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int firstMessageId = tankManager.maxMessageId() + 1; if (ic2EnergySource != null) diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index b1355e409..eb3aea99b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -13,7 +13,6 @@ package forestry.factory.gadgets; import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import forestry.api.core.ForestryAPI; -import forestry.api.core.ISpecialInventory; import forestry.api.recipes.ICentrifugeManager; import forestry.core.EnumErrorCode; import forestry.core.config.Config; @@ -22,7 +21,9 @@ import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.network.GuiId; import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -42,7 +43,7 @@ import java.util.Map; import java.util.Set; import java.util.Stack; -public class MachineCentrifuge extends TilePowered implements ISidedInventory, ISpecialInventory { +public class MachineCentrifuge extends TilePowered implements ISidedInventory { /* CONSTANTS */ public static final int SLOT_RESOURCE = 0; @@ -50,6 +51,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I /* RECIPE MANAGMENT */ public static class Recipe { + public final int timePerItem; public final ItemStack resource; public final HashMap products; @@ -76,6 +78,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } public static class RecipeManager implements ICentrifugeManager { + public static final ArrayList recipes = new ArrayList(); @Override @@ -134,7 +137,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } /* MEMBER */ - private final InventoryAdapter inventory = new InventoryAdapter(10, "Items"); public MachineCentrifuge.Recipe currentRecipe; private final Stack pendingProducts = new Stack(); @@ -143,6 +145,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I public MachineCentrifuge() { super(800, 40, Defaults.MACHINE_MAX_ENERGY); + setInternalInventory(new TileInventoryAdapter(this, 10, "Items")); setHints(Config.hints.get("centrifuge")); } @@ -164,17 +167,16 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I nbttagcompound.setInteger("ProductionTime", productionTime); nbttagcompound.setInteger("TimePerItem", timePerItem); - inventory.writeToNBT(nbttagcompound); - NBTTagList nbttaglist = new NBTTagList(); ItemStack[] offspring = pendingProducts.toArray(new ItemStack[pendingProducts.size()]); - for (int i = 0; i < offspring.length; i++) + for (int i = 0; i < offspring.length; i++) { if (offspring[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); offspring[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } + } nbttagcompound.setTag("PendingProducts", nbttaglist); } @@ -185,8 +187,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I productionTime = nbttagcompound.getInteger("ProductionTime"); timePerItem = nbttagcompound.getInteger("TimePerItem"); - inventory.readFromNBT(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10); for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); @@ -240,13 +240,14 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } // We are done, add products to queue - for (Map.Entry entry : currentRecipe.products.entrySet()) + for (Map.Entry entry : currentRecipe.products.entrySet()) { if (entry.getValue() >= 100) pendingProducts.push(entry.getKey().copy()); else if (worldObj.rand.nextInt(100) < entry.getValue()) pendingProducts.push(entry.getKey().copy()); + } - inventory.decrStackSize(SLOT_RESOURCE, 1); + getInternalInventory().decrStackSize(SLOT_RESOURCE, 1); checkRecipe(); resetRecipe(); @@ -255,7 +256,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } public void checkRecipe() { - Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE)); + Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE)); if (sameRec == null) setErrorState(EnumErrorCode.NORECIPE); @@ -292,7 +293,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } private boolean addProduct(ItemStack product, boolean all) { - return inventory.tryAddStack(product, 1, getSizeInventory() - 1, all); + return getInternalInventory().tryAddStack(product, 1, getSizeInventory() - 1, all); } @Override @@ -302,6 +303,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I @Override public boolean hasResourcesMin(float percentage) { + TileInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; @@ -338,134 +340,78 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I } /* IINVENTORY */ + @Override - protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canTakeStackFromSide(slotIndex, itemstack, side)) - return false; - - if(slotIndex >= SLOT_PRODUCT_1 && slotIndex < SLOT_PRODUCT_1 + 9) - return true; - - return false; + public int getSizeInventory() { + return getInternalInventory().getSizeInventory(); } @Override - protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) { - - if(!super.canPutStackFromSide(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemstack) != null) - return true; - - return false; + public ItemStack getStackInSlot(int i) { + return getInternalInventory().getStackInSlot(i); } - @Override public int getSizeInventory() { return inventory.getSizeInventory(); } - @Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); } - @Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); } - @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); } - @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void openInventory() {} - @Override public void closeInventory() {} + @Override + public ItemStack decrStackSize(int i, int j) { + return getInternalInventory().decrStackSize(i, j); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(i, itemstack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int slot) { + return getInternalInventory().getStackInSlotOnClosing(slot); + } + + @Override + public int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isUseableByPlayer(EntityPlayer player) { - return super.isUseableByPlayer(player); + return Utils.isUseableByPlayer(player, this); } - /** - * TODO: just a specialsource workaround - */ @Override public boolean hasCustomInventoryName() { - return super.hasCustomInventoryName(); + return false; } - /** - * TODO: just a specialsource workaround - */ @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return super.isItemValidForSlot(slotIndex, itemstack); + if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) + return false; + return slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemstack) != null; } - /** - * TODO: just a specialsource workaround - */ + /* ISIDEDINVENTORY */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return super.canInsertItem(i, itemstack, j); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(xCoord, itemstack); } - /** - * TODO: just a specialsource workaround - */ @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return super.canExtractItem(i, itemstack, j); + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) + return false; + return slotIndex >= SLOT_PRODUCT_1 && slotIndex < SLOT_PRODUCT_1 + 9; } - /** - * TODO: just a specialsource workaround - */ @Override public int[] getAccessibleSlotsFromSide(int side) { - return super.getAccessibleSlotsFromSide(side); - } - - /* ISPECIALINVENTORY */ - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - - ItemStack product = null; - - for (int i = SLOT_PRODUCT_1; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) - continue; - - product = StackUtils.createSplitStack(stack, 1); - if (doRemove) - decrStackSize(i, 1); - - break; - } - - if (product != null) - return new ItemStack[] { product }; - else - return new ItemStack[0]; - } - - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - ItemStack resource = inventory.getStackInSlot(SLOT_RESOURCE); - if (resource == null) { - if (doAdd) - inventory.setInventorySlotContents(SLOT_RESOURCE, stack.copy()); - return stack.stackSize; - } - - if (!StackUtils.isIdenticalItem(resource, stack)) - return 0; - - int space = resource.getMaxStackSize() - resource.stackSize; - if (space <= 0) - return 0; - - if (doAdd) - if (stack.stackSize <= space) - resource.stackSize += stack.stackSize; - else - resource.stackSize += space; - - return Math.min(stack.stackSize, space); + return getInternalInventory().getAccessibleSlotsFromSide(side); } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index e9b45db80..461b27435 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -10,9 +10,10 @@ ******************************************************************************/ package forestry.factory.gadgets; -import forestry.core.EnumErrorCode; + 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; @@ -28,13 +29,16 @@ import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -45,11 +49,6 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.inventory.ISidedInventory; - public class MachineFabricator extends TilePowered implements ICrafter, ILiquidTankContainer, ISidedInventory { /* RECIPE MANAGMENT */ @@ -229,14 +228,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public MachineFabricator() { super(1100, 50, 3300); -<<<<<<< HEAD setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); invCrafting = new InventoryMapper(getInternalInventory(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - Fluid liquidGlass = FluidRegistry.getFluid(Defaults.LIQUID_GLASS); - moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, liquidGlass); -======= moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.get()); ->>>>>>> dev moltenTank.tankMode = StandardTank.TankMode.INTERNAL; tankManager = new TankManager(moltenTank); } @@ -471,6 +465,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } /* SMP */ + @Override public void getGUINetworkData(int i, int j) { int messageId = tankManager.maxMessageId() + 1; @@ -480,6 +475,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT guiMeltingPoint = j; } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int messageId = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, messageId, heat); diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 37851efa6..829d05013 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -294,6 +294,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } /* SMP GUI */ + @Override public void getGUINetworkData(int i, int j) { i -= tankManager.maxMessageId() + 1; switch (i) { @@ -306,6 +307,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } } + @Override public void sendGUINetworkData(Container container, ICrafting iCrafting) { int i = tankManager.maxMessageId() + 1; iCrafting.sendProgressBarUpdate(container, i, distillationTime); From c7d88d73d3f6f467bc2e1d483baa15b123f545a4 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Mon, 15 Dec 2014 08:15:21 -0800 Subject: [PATCH 057/175] Clean imports --- .../forestry/apiculture/BeekeepingLogic.java | 13 ++-- .../apiculture/FlowerProviderCacti.java | 12 ++-- .../apiculture/FlowerProviderEnd.java | 15 ++-- .../apiculture/FlowerProviderGourd.java | 15 ++-- .../apiculture/FlowerProviderJungle.java | 15 ++-- .../apiculture/FlowerProviderMushroom.java | 15 ++-- .../apiculture/FlowerProviderNetherwart.java | 12 ++-- .../apiculture/FlowerProviderVanilla.java | 17 ++--- .../apiculture/FlowerProviderWheat.java | 15 ++-- .../apiculture/GuiHandlerApiculture.java | 7 +- .../apiculture/PacketHandlerApiculture.java | 6 +- .../SaveEventHandlerApiculture.java | 3 +- .../apiculture/VillageHandlerApiculture.java | 5 +- .../apiculture/commands/BeeModeHelper.java | 8 +-- .../commands/BeeStatsSaveHelper.java | 13 ++-- .../apiculture/commands/CommandBeeGive.java | 14 ++-- .../apiculture/entities/EntityBee.java | 10 ++- .../apiculture/gadgets/BlockAlveary.java | 15 ++-- .../apiculture/gadgets/BlockBeehives.java | 7 +- .../apiculture/gadgets/BlockCandle.java | 20 +++--- .../apiculture/gadgets/BlockStump.java | 19 +++--- .../gadgets/StructureLogicAlveary.java | 10 ++- .../apiculture/gadgets/TileAlveary.java | 5 +- .../gadgets/TileAlvearyHygroregulator.java | 22 +++--- .../apiculture/gadgets/TileAlvearyPlain.java | 11 ++- .../apiculture/gadgets/TileAlvearySieve.java | 9 ++- .../apiculture/gadgets/TileApiary.java | 5 +- .../apiculture/gadgets/TileBeehouse.java | 4 +- .../apiculture/gadgets/TileSwarm.java | 3 +- .../apiculture/genetics/AlleleBeeSpecies.java | 9 ++- .../genetics/AlleleEffectAggressive.java | 12 ++-- .../genetics/AlleleEffectCreeper.java | 10 ++- .../genetics/AlleleEffectExploration.java | 8 +-- .../genetics/AlleleEffectFertile.java | 6 +- .../genetics/AlleleEffectFungification.java | 9 ++- .../genetics/AlleleEffectGlacial.java | 9 ++- .../genetics/AlleleEffectHeroic.java | 10 ++- .../genetics/AlleleEffectIgnition.java | 12 ++-- .../genetics/AlleleEffectMiasmic.java | 14 ++-- .../genetics/AlleleEffectMisanthrope.java | 10 ++- .../apiculture/genetics/AlleleEffectNone.java | 3 +- .../genetics/AlleleEffectPotion.java | 3 +- .../genetics/AlleleEffectRadioactive.java | 20 +++--- .../genetics/AlleleEffectRepulsion.java | 10 ++- .../genetics/AlleleEffectResurrection.java | 12 ++-- .../genetics/AlleleEffectSnowing.java | 10 ++- .../genetics/AlleleEffectThrottled.java | 3 +- .../forestry/apiculture/genetics/Bee.java | 11 ++- .../apiculture/genetics/BeeHelper.java | 26 +++---- .../apiculture/genetics/BeeMutation.java | 11 ++- .../apiculture/genetics/BeeTemplates.java | 1 - .../apiculture/genetics/BeekeepingMode.java | 10 ++- .../apiculture/genetics/HiveDrop.java | 5 +- .../apiculture/genetics/JubilanceDefault.java | 5 +- .../genetics/JubilanceProviderHermit.java | 8 +-- .../apiculture/genetics/JubilanceReqRes.java | 5 +- .../apiculture/genetics/MutationEMC.java | 10 ++- .../apiculture/genetics/MutationReqRes.java | 7 +- .../genetics/MutationTimeLimited.java | 3 +- .../apiculture/gui/ContainerAlveary.java | 7 +- .../apiculture/gui/ContainerAlvearySieve.java | 8 +-- .../gui/ContainerAlvearySwarmer.java | 3 +- .../apiculture/gui/ContainerApiary.java | 9 ++- .../apiculture/gui/ContainerBeealyzer.java | 5 +- .../gui/ContainerHabitatLocator.java | 7 +- .../apiculture/gui/ContainerImprinter.java | 11 ++- .../forestry/apiculture/gui/GuiAlveary.java | 3 +- .../gui/GuiAlvearyHygroregulator.java | 3 +- .../apiculture/gui/GuiAlvearySieve.java | 3 +- .../apiculture/gui/GuiAlvearySwarmer.java | 3 +- .../forestry/apiculture/gui/GuiApiary.java | 3 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 3 +- .../apiculture/gui/GuiHabitatLocator.java | 19 +++--- .../forestry/apiculture/gui/GuiImprinter.java | 5 +- .../apiculture/items/ItemAlvearyBlock.java | 3 +- .../apiculture/items/ItemArmorApiarist.java | 14 ++-- .../forestry/apiculture/items/ItemBeeGE.java | 3 +- .../apiculture/items/ItemBeealyzer.java | 11 ++- .../apiculture/items/ItemBiomefinder.java | 37 +++++----- .../apiculture/items/ItemCandleBlock.java | 10 ++- .../apiculture/items/ItemHiveFrame.java | 3 +- .../apiculture/items/ItemHoneycomb.java | 14 ++-- .../apiculture/items/ItemImprinter.java | 11 ++- .../apiculture/items/ItemWaxCast.java | 3 +- .../proxy/ClientProxyApiculture.java | 9 +-- .../apiculture/proxy/ProxyApiculture.java | 3 +- .../apiculture/render/BeeItemRenderer.java | 17 ++--- .../render/BlockCandleRenderer.java | 10 ++- .../apiculture/render/ModelAnalyzer.java | 7 +- .../forestry/apiculture/render/ModelBee.java | 4 +- .../apiculture/render/ParticleRenderer.java | 22 +++--- .../forestry/apiculture/render/RenderBee.java | 3 +- .../worldgen/ComponentVillageBeeHouse.java | 31 ++++----- .../apiculture/worldgen/HiveDecorator.java | 3 +- .../arboriculture/FruitProviderNone.java | 13 ++-- .../arboriculture/FruitProviderPod.java | 15 ++-- .../arboriculture/FruitProviderRandom.java | 7 +- .../arboriculture/FruitProviderRipening.java | 7 +- .../GuiHandlerArboriculture.java | 7 +- .../PacketHandlerArboriculture.java | 9 +-- .../VillageHandlerArboriculture.java | 13 ++-- .../java/forestry/arboriculture/WoodType.java | 9 +-- .../commands/CommandTreeSpawn.java | 13 ++-- .../arboriculture/commands/TreeGenHelper.java | 5 +- .../commands/TreeModeHelper.java | 8 +-- .../commands/TreeStatsSaveHelper.java | 11 ++- .../arboriculture/gadgets/BlockArbFence.java | 3 +- .../arboriculture/gadgets/BlockArbStairs.java | 15 ++-- .../arboriculture/gadgets/BlockFruitPod.java | 17 ++--- .../arboriculture/gadgets/BlockLog.java | 14 ++-- .../arboriculture/gadgets/BlockPlanks.java | 14 ++-- .../arboriculture/gadgets/BlockSapling.java | 25 +++---- .../arboriculture/gadgets/BlockSlab.java | 14 ++-- .../gadgets/BlockTreeContainer.java | 1 - .../gadgets/ForestryBlockLeaves.java | 9 ++- .../arboriculture/gadgets/TileFruitPod.java | 19 +++--- .../arboriculture/gadgets/TileLeaves.java | 11 ++- .../arboriculture/gadgets/TileSapling.java | 3 +- .../arboriculture/gadgets/TileStairs.java | 7 +- .../genetics/AlleleLeafEffectNone.java | 5 +- .../genetics/AlleleTreeSpecies.java | 22 +++--- .../genetics/ArboristTracker.java | 4 +- .../genetics/GrowthProvider.java | 9 ++- .../genetics/GrowthProviderTropical.java | 8 +-- .../forestry/arboriculture/genetics/Tree.java | 9 ++- .../arboriculture/genetics/TreeGenome.java | 11 ++- .../arboriculture/genetics/TreeHelper.java | 32 ++++----- .../arboriculture/genetics/TreeMutation.java | 5 +- .../genetics/TreekeepingMode.java | 5 +- .../gui/ContainerTreealyzer.java | 5 +- .../arboriculture/gui/GuiTreealyzer.java | 8 +-- .../arboriculture/items/ItemGermlingGE.java | 3 +- .../arboriculture/items/ItemGrafter.java | 8 +-- .../arboriculture/items/ItemLeavesBlock.java | 1 - .../arboriculture/items/ItemStairs.java | 11 ++- .../arboriculture/items/ItemTreealyzer.java | 11 ++- .../arboriculture/items/ItemWoodBlock.java | 7 +- .../network/PacketLeafUpdate.java | 7 +- .../proxy/ClientProxyArboriculture.java | 8 +-- .../render/FenceRenderingHandler.java | 7 +- .../render/FruitPodRenderingHandler.java | 10 ++- .../render/SaplingRenderHandler.java | 14 ++-- .../render/StairItemRenderer.java | 7 +- .../arboriculture/worldgen/BlockTypeLeaf.java | 4 +- .../arboriculture/worldgen/BlockTypeVoid.java | 5 +- .../worldgen/WorldGenAcacia.java | 2 - .../worldgen/WorldGenAcaciaVanilla.java | 2 +- .../worldgen/WorldGenArboriculture.java | 6 +- .../arboriculture/worldgen/WorldGenBalsa.java | 2 - .../worldgen/WorldGenBaobab.java | 2 - .../arboriculture/worldgen/WorldGenBirch.java | 3 +- .../worldgen/WorldGenCherry.java | 2 - .../worldgen/WorldGenChestnut.java | 2 - .../worldgen/WorldGenDarkOak.java | 2 +- .../arboriculture/worldgen/WorldGenDate.java | 2 - .../arboriculture/worldgen/WorldGenEbony.java | 2 - .../worldgen/WorldGenGiganteum.java | 2 - .../worldgen/WorldGenGreenheart.java | 2 - .../worldgen/WorldGenJungle.java | 3 +- .../arboriculture/worldgen/WorldGenKapok.java | 2 - .../arboriculture/worldgen/WorldGenLarch.java | 2 - .../arboriculture/worldgen/WorldGenLemon.java | 2 - .../arboriculture/worldgen/WorldGenLime.java | 2 - .../arboriculture/worldgen/WorldGenMahoe.java | 2 - .../worldgen/WorldGenMahogany.java | 2 - .../arboriculture/worldgen/WorldGenMaple.java | 2 - .../arboriculture/worldgen/WorldGenOak.java | 3 +- .../worldgen/WorldGenPapaya.java | 2 - .../arboriculture/worldgen/WorldGenPine.java | 2 - .../arboriculture/worldgen/WorldGenPlum.java | 2 - .../worldgen/WorldGenPoplar.java | 2 - .../worldgen/WorldGenSequoia.java | 2 - .../worldgen/WorldGenSpruce.java | 3 - .../arboriculture/worldgen/WorldGenTeak.java | 2 - .../arboriculture/worldgen/WorldGenTree.java | 1 - .../worldgen/WorldGenWalnut.java | 2 - .../arboriculture/worldgen/WorldGenWenge.java | 2 - .../worldgen/WorldGenWillow.java | 2 - .../forestry/core/CreativeTabForestry.java | 9 +-- .../java/forestry/core/EnumErrorCode.java | 5 +- .../java/forestry/core/EventHandlerCore.java | 13 ++-- .../java/forestry/core/ForestryClient.java | 1 - src/main/java/forestry/core/ForestryCore.java | 17 ++--- src/main/java/forestry/core/GameMode.java | 8 +-- src/main/java/forestry/core/GuiHandler.java | 6 +- .../java/forestry/core/GuiHandlerBase.java | 8 +-- .../java/forestry/core/PickupHandlerCore.java | 7 +- .../forestry/core/SaveEventHandlerCore.java | 3 +- .../forestry/core/TickHandlerCoreClient.java | 9 +-- .../forestry/core/TickHandlerCoreServer.java | 4 +- .../java/forestry/core/WorldGenerator.java | 10 +-- .../java/forestry/core/circuits/Circuit.java | 3 +- .../forestry/core/circuits/CircuitBoard.java | 5 +- .../core/circuits/CircuitLibrary.java | 3 +- .../core/circuits/CircuitRegistry.java | 12 ++-- .../core/circuits/ContainerSolderingIron.java | 11 ++- .../core/circuits/GuiSolderingIron.java | 7 +- .../core/circuits/ItemCircuitBoard.java | 16 ++--- .../core/circuits/ItemSolderingIron.java | 14 ++-- .../core/commands/CommandHelpers.java | 7 +- .../core/commands/CommandModeInfo.java | 2 - .../core/commands/CommandModeSet.java | 1 - .../core/commands/CommandSaveStats.java | 16 ++--- .../core/commands/CommandVersion.java | 2 +- .../core/commands/IStatsSaveHelper.java | 9 +-- .../commands/TemplateNotFoundException.java | 3 +- .../java/forestry/core/config/Config.java | 1 - .../forestry/core/config/Configuration.java | 3 +- .../java/forestry/core/config/Defaults.java | 1 - .../forestry/core/config/ForestryItem.java | 5 +- .../java/forestry/core/config/Version.java | 10 ++- .../forestry/core/fluids/FluidHelper.java | 8 +-- .../java/forestry/core/fluids/Fluids.java | 5 +- .../forestry/core/fluids/TankManager.java | 40 +++++------ .../core/fluids/tanks/FilteredTank.java | 6 +- .../java/forestry/core/gadgets/BlockBase.java | 20 +++--- .../forestry/core/gadgets/BlockForestry.java | 9 ++- .../forestry/core/gadgets/BlockResource.java | 13 ++-- .../gadgets/BlockResourceStorageBlock.java | 9 ++- .../java/forestry/core/gadgets/BlockSoil.java | 22 +++--- .../core/gadgets/BlockStainedGlass.java | 11 ++- .../forestry/core/gadgets/BlockStructure.java | 13 ++-- .../java/forestry/core/gadgets/Engine.java | 10 +-- .../core/gadgets/MachineDefinition.java | 7 +- .../core/gadgets/MachineNBTDefinition.java | 9 ++- .../forestry/core/gadgets/NaturalistGame.java | 16 ++--- .../forestry/core/gadgets/StructureLogic.java | 8 +-- .../forestry/core/gadgets/TileAnalyzer.java | 31 ++++----- .../java/forestry/core/gadgets/TileBase.java | 6 +- .../forestry/core/gadgets/TileEscritoire.java | 12 ++-- .../forestry/core/gadgets/TileForestry.java | 5 +- .../forestry/core/gadgets/TileMachine.java | 3 +- .../core/gadgets/TileNaturalistChest.java | 11 ++- .../forestry/core/gadgets/TilePowered.java | 10 +-- .../java/forestry/core/genetics/Allele.java | 6 +- .../core/genetics/AllelePlantType.java | 6 +- .../core/genetics/AlleleRegistry.java | 19 +++--- .../forestry/core/genetics/AlleleSpecies.java | 5 +- .../core/genetics/AlleleTolerance.java | 1 - .../core/genetics/BreedingTracker.java | 14 ++-- .../forestry/core/genetics/Chromosome.java | 6 +- .../core/genetics/Classification.java | 5 +- .../forestry/core/genetics/ClimateHelper.java | 5 +- .../forestry/core/genetics/EffectData.java | 3 +- .../forestry/core/genetics/Individual.java | 3 +- .../core/genetics/IndividualLiving.java | 5 +- .../java/forestry/core/genetics/ItemGE.java | 13 ++-- .../core/genetics/ItemResearchNote.java | 30 ++++---- .../java/forestry/core/genetics/Mutation.java | 5 +- .../forestry/core/genetics/SpeciesRoot.java | 3 +- .../forestry/core/gui/ContainerAlyzer.java | 3 +- .../forestry/core/gui/ContainerAnalyzer.java | 5 +- .../core/gui/ContainerEscritoire.java | 12 ++-- .../core/gui/ContainerItemInventory.java | 9 ++- .../core/gui/ContainerLiquidTanks.java | 14 ++-- .../gui/ContainerNaturalistInventory.java | 9 ++- .../forestry/core/gui/ContainerSocketed.java | 9 ++- .../java/forestry/core/gui/ErrorLedger.java | 2 +- .../java/forestry/core/gui/GuiAlyzer.java | 9 ++- .../java/forestry/core/gui/GuiAnalyzer.java | 3 +- .../java/forestry/core/gui/GuiEscritoire.java | 12 ++-- .../java/forestry/core/gui/GuiForestry.java | 8 +-- .../forestry/core/gui/GuiForestryTitled.java | 3 +- .../core/gui/GuiNaturalistInventory.java | 16 ++--- .../java/forestry/core/gui/GuiTextBox.java | 2 - .../java/forestry/core/gui/HintLedger.java | 3 +- .../forestry/core/gui/IGuiSelectable.java | 3 +- src/main/java/forestry/core/gui/Ledger.java | 8 +-- .../java/forestry/core/gui/LedgerManager.java | 9 +-- .../java/forestry/core/gui/OwnerLedger.java | 7 +- .../java/forestry/core/gui/WidgetManager.java | 9 +-- .../core/gui/buttons/GuiBetterButton.java | 13 ++-- .../core/gui/buttons/GuiMultiButton.java | 9 +-- .../core/gui/slots/SlotCraftAuto.java | 3 +- .../forestry/core/gui/slots/SlotForestry.java | 5 +- .../core/gui/slots/SlotItemInventory.java | 3 +- .../core/gui/slots/SlotLiquidContainer.java | 8 +-- .../forestry/core/gui/tooltips/ToolTip.java | 6 +- .../core/gui/widgets/ReservoirWidget.java | 9 +-- .../core/gui/widgets/SocketWidget.java | 8 +-- .../forestry/core/gui/widgets/TankWidget.java | 18 ++--- .../forestry/core/gui/widgets/Widget.java | 3 +- .../core/interfaces/ILiquidTankContainer.java | 1 - .../forestry/core/interfaces/IOwnable.java | 4 +- .../core/interfaces/IPacketHandler.java | 1 - .../core/interfaces/IRenderableMachine.java | 3 +- .../forestry/core/inventory/InvTools.java | 41 ++++++----- .../core/inventory/InventoryAdapter.java | 11 ++- .../core/inventory/InventoryConcatenator.java | 1 - .../core/inventory/InventorySorter.java | 1 - .../core/inventory/ItemInventory.java | 5 +- .../forestry/core/inventory/ItemStackMap.java | 1 - .../forestry/core/inventory/ItemStackSet.java | 1 - .../core/inventory/TileInventoryAdapter.java | 3 +- .../inventory/filters/ArrayStackFilter.java | 3 +- .../manipulators/InventoryManipulator.java | 11 ++- .../inventory/wrappers/InventoryIterator.java | 1 - .../inventory/wrappers/InventoryMapper.java | 1 - .../wrappers/SidedInventoryIterator.java | 1 - .../wrappers/SidedInventoryMapper.java | 1 - .../core/items/ItemArmorNaturalist.java | 16 ++--- .../forestry/core/items/ItemAssemblyKit.java | 3 +- .../java/forestry/core/items/ItemCrated.java | 15 ++-- .../forestry/core/items/ItemForestry.java | 14 ++-- .../forestry/core/items/ItemForestryFood.java | 4 +- .../core/items/ItemForestryMultiPass.java | 4 +- .../core/items/ItemForestryPickaxe.java | 3 +- .../core/items/ItemForestryShovel.java | 3 +- .../forestry/core/items/ItemForestryTool.java | 5 +- .../java/forestry/core/items/ItemFruit.java | 12 ++-- .../forestry/core/items/ItemInventoried.java | 5 +- .../core/items/ItemLiquidContainer.java | 18 ++--- .../java/forestry/core/items/ItemMisc.java | 3 +- .../java/forestry/core/items/ItemNBTTile.java | 1 - .../java/forestry/core/items/ItemOverlay.java | 13 ++-- .../java/forestry/core/items/ItemPipette.java | 18 ++--- .../java/forestry/core/items/ItemWrench.java | 4 +- .../forestry/core/network/ForestryPacket.java | 12 ++-- .../core/network/PacketCoordinates.java | 1 - .../forestry/core/network/PacketFXSignal.java | 7 +- .../core/network/PacketGuiInteger.java | 1 - .../forestry/core/network/PacketHandler.java | 28 +++----- .../core/network/PacketInventoryStack.java | 1 - .../java/forestry/core/network/PacketNBT.java | 1 - .../core/network/PacketSocketUpdate.java | 4 +- .../forestry/core/network/PacketTileNBT.java | 1 - .../core/network/PacketTileUpdate.java | 15 ++-- .../core/proxy/ClientProxyCommon.java | 19 ++---- .../core/proxy/ClientProxyNetwork.java | 3 +- .../core/proxy/ClientProxyRender.java | 10 ++- .../java/forestry/core/proxy/ProxyCommon.java | 3 +- .../java/forestry/core/proxy/ProxyLog.java | 3 +- .../forestry/core/proxy/ProxyNetwork.java | 12 ++-- .../java/forestry/core/proxy/ProxyRender.java | 5 +- .../core/render/BlockRenderingHandler.java | 9 +-- .../forestry/core/render/EntitySnowFX.java | 1 - .../core/render/OverlayRenderingHandler.java | 3 +- .../forestry/core/render/RenderAnalyzer.java | 9 +-- .../core/render/RenderEscritoire.java | 13 ++-- .../forestry/core/render/RenderMachine.java | 17 ++--- .../java/forestry/core/render/RenderMill.java | 11 ++- .../forestry/core/render/TextureManager.java | 11 ++- .../java/forestry/core/utils/BlockUtil.java | 7 +- .../java/forestry/core/utils/EnumAccess.java | 3 +- .../java/forestry/core/utils/FontColour.java | 1 - .../utils/ForestryModEnvWarningCallable.java | 6 +- .../forestry/core/utils/ForestryResource.java | 3 +- .../forestry/core/utils/ItemStackMap.java | 1 - .../forestry/core/utils/LiquidHelper.java | 10 ++- .../java/forestry/core/utils/NBTUtil.java | 16 ++++- .../java/forestry/core/utils/PlayerUtil.java | 1 - .../java/forestry/core/utils/RecipeUtil.java | 15 ++-- .../forestry/core/utils/RevolvingList.java | 4 +- .../core/utils/ShapedRecipeCustom.java | 11 ++- .../java/forestry/core/utils/StackUtils.java | 5 +- src/main/java/forestry/core/utils/Utils.java | 11 ++- .../forestry/core/worldgen/BlockType.java | 5 +- .../forestry/core/worldgen/WorldGenBase.java | 1 - .../core/worldgen/WorldGenMinableMeta.java | 6 +- .../forestry/energy/GuiHandlerEnergy.java | 5 +- .../circuits/CircuitElectricChange.java | 3 +- .../energy/circuits/CircuitFireDampener.java | 3 +- .../energy/gadgets/EngineClockwork.java | 11 ++- .../forestry/energy/gadgets/EngineCopper.java | 11 ++- .../energy/gadgets/EngineDefinition.java | 10 ++- .../forestry/energy/gadgets/EngineTin.java | 20 +++--- .../energy/gui/ContainerEngineCopper.java | 8 +-- .../energy/gui/ContainerEngineTin.java | 5 +- .../forestry/energy/gui/GuiEngineBronze.java | 17 ++--- .../forestry/energy/gui/GuiEngineCopper.java | 4 +- .../forestry/energy/gui/GuiEngineTin.java | 4 +- .../forestry/energy/gui/GuiGenerator.java | 3 +- .../forestry/energy/render/RenderEngine.java | 17 ++--- .../forestry/factory/GuiHandlerFactory.java | 5 +- .../factory/gadgets/MachineCarpenter.java | 47 ++++++------- .../factory/gadgets/MachineCentrifuge.java | 19 +++--- .../factory/gadgets/MachineFabricator.java | 1 - .../factory/gadgets/MachineFermenter.java | 45 ++++++------ .../factory/gadgets/MillRainmaker.java | 5 +- .../factory/gui/ContainerCarpenter.java | 13 ++-- .../factory/gui/ContainerCentrifuge.java | 7 +- .../factory/gui/ContainerMoistener.java | 7 +- .../factory/gui/ContainerRaintank.java | 5 +- .../factory/gui/ContainerSqueezer.java | 6 +- .../forestry/factory/gui/ContainerStill.java | 5 +- .../factory/gui/ContainerWorktable.java | 13 ++-- .../java/forestry/factory/gui/GuiBottler.java | 3 +- .../forestry/factory/gui/GuiCarpenter.java | 3 +- .../forestry/factory/gui/GuiCentrifuge.java | 3 +- .../forestry/factory/gui/GuiFabricator.java | 3 +- .../forestry/factory/gui/GuiFermenter.java | 3 +- .../forestry/factory/gui/GuiMoistener.java | 3 +- .../forestry/factory/gui/GuiRaintank.java | 3 +- .../java/forestry/factory/gui/GuiStill.java | 3 +- .../forestry/factory/gui/SlotCraftMatrix.java | 3 +- .../factory/recipes/CraftGuideBottler.java | 8 +-- .../factory/recipes/CraftGuideCarpenter.java | 10 ++- .../factory/recipes/CraftGuideCentrifuge.java | 9 +-- .../recipes/CraftGuideCustomRecipes.java | 6 +- .../factory/recipes/CraftGuideFabricator.java | 10 ++- .../factory/recipes/CraftGuideFermenter.java | 12 ++-- .../recipes/CraftGuideIntegration.java | 3 +- .../factory/recipes/CraftGuideSqueezer.java | 8 +-- .../factory/recipes/CraftGuideStill.java | 8 +-- .../factory/recipes/RecipeMemory.java | 7 +- .../forestry/farming/EventHandlerFarming.java | 7 +- .../forestry/farming/GuiHandlerFarming.java | 5 +- .../forestry/farming/gadgets/BlockFarm.java | 17 ++--- .../farming/gadgets/BlockMushroom.java | 15 ++-- .../farming/gadgets/StructureLogicFarm.java | 10 ++- .../forestry/farming/gadgets/TileControl.java | 11 ++- .../forestry/farming/gadgets/TileFarm.java | 20 +++--- .../farming/gadgets/TileFarmPlain.java | 43 ++++++------ .../forestry/farming/gadgets/TileHatch.java | 9 ++- .../forestry/farming/gadgets/TileValve.java | 7 +- .../forestry/farming/gui/ContainerFarm.java | 11 ++- .../java/forestry/farming/gui/GuiFarm.java | 10 ++- .../forestry/farming/items/ItemFarmBlock.java | 6 +- .../java/forestry/farming/logic/Crop.java | 10 ++- .../forestry/farming/logic/CropBlock.java | 6 +- .../forestry/farming/logic/CropFruit.java | 12 ++-- .../java/forestry/farming/logic/CropPeat.java | 5 +- .../forestry/farming/logic/CropRubber.java | 12 ++-- .../forestry/farming/logic/FarmLogic.java | 3 +- .../farming/logic/FarmLogicArboreal.java | 15 ++-- .../farming/logic/FarmLogicCereal.java | 6 +- .../farming/logic/FarmLogicCocoa.java | 20 +++--- .../farming/logic/FarmLogicCrops.java | 9 ++- .../farming/logic/FarmLogicGourd.java | 18 ++--- .../farming/logic/FarmLogicHomogeneous.java | 3 +- .../farming/logic/FarmLogicInfernal.java | 20 +++--- .../farming/logic/FarmLogicOrchard.java | 24 +++---- .../forestry/farming/logic/FarmLogicPeat.java | 8 +-- .../farming/logic/FarmLogicPoale.java | 20 +++--- .../farming/logic/FarmLogicRubber.java | 24 +++---- .../farming/logic/FarmLogicShroom.java | 13 ++-- .../farming/logic/FarmLogicSucculent.java | 20 +++--- .../farming/logic/FarmLogicVegetable.java | 6 +- .../farming/logic/FarmLogicWatered.java | 19 +++--- .../forestry/farming/logic/FarmableCocoa.java | 9 ++- .../farming/logic/FarmableFarmCraftory.java | 14 ++-- .../farming/logic/FarmableGenericCrop.java | 7 +- .../farming/logic/FarmableGenericSapling.java | 9 ++- .../forestry/farming/logic/FarmableGourd.java | 7 +- .../farming/logic/FarmableStacked.java | 9 ++- .../farming/logic/FarmableVanillaSapling.java | 10 ++- .../farming/logic/FarmableVanillaShroom.java | 11 ++- .../farming/proxy/ClientProxyFarming.java | 4 +- .../farming/render/FarmItemRenderer.java | 13 ++-- .../farming/render/FarmRenderingHandler.java | 9 ++- .../triggers/TriggerLowFertilizer.java | 1 - .../farming/worldgen/WorldGenBigMushroom.java | 4 +- .../forestry/food/BeverageEffectAntidote.java | 3 +- .../java/forestry/food/GuiHandlerFood.java | 5 +- .../forestry/food/gui/ContainerInfuser.java | 9 ++- .../java/forestry/food/gui/GuiInfuser.java | 5 +- .../forestry/food/items/ItemAmbrosia.java | 5 +- .../forestry/food/items/ItemBeverage.java | 19 +++--- .../java/forestry/food/items/ItemInfuser.java | 14 ++-- .../lepidopterology/ButterflySpawner.java | 3 +- .../GuiHandlerLepidopterology.java | 7 +- .../lepidopterology/MatingRecipe.java | 7 +- .../commands/CommandButterfly.java | 3 +- .../entities/AIButterflyFlee.java | 2 +- .../entities/AIButterflyInteract.java | 3 +- .../entities/AIButterflyMate.java | 10 ++- .../entities/EntityButterfly.java | 24 +++---- .../genetics/AlleleButterflySpecies.java | 23 +++---- .../lepidopterology/genetics/Butterfly.java | 10 ++- .../genetics/ButterflyHelper.java | 21 +++--- .../genetics/LepidopteristTracker.java | 4 +- .../gui/ContainerFlutterlyzer.java | 3 +- .../lepidopterology/gui/GuiFlutterlyzer.java | 7 +- .../items/ItemButterflyGE.java | 3 +- .../items/ItemFlutterlyzer.java | 11 ++- .../proxy/ClientProxyLepidopterology.java | 4 +- .../render/ButterflyItemRenderer.java | 11 ++- .../render/ModelButterfly.java | 1 - .../render/RenderButterfly.java | 5 +- .../java/forestry/mail/EnumDeliveryState.java | 3 +- .../java/forestry/mail/EnumStationState.java | 3 +- .../java/forestry/mail/GuiHandlerMail.java | 7 +- src/main/java/forestry/mail/Letter.java | 14 ++-- src/main/java/forestry/mail/MailAddress.java | 12 ++-- src/main/java/forestry/mail/POBox.java | 9 ++- .../java/forestry/mail/PacketHandlerMail.java | 10 ++- src/main/java/forestry/mail/PostOffice.java | 16 ++--- src/main/java/forestry/mail/PostRegistry.java | 20 +++--- .../java/forestry/mail/PostalCarrier.java | 18 ++--- .../forestry/mail/SaveEventHandlerMail.java | 3 +- .../forestry/mail/TickHandlerMailClient.java | 1 - src/main/java/forestry/mail/TradeStation.java | 3 +- .../forestry/mail/gadgets/MachineMailbox.java | 7 +- .../mail/gadgets/MachinePhilatelist.java | 9 ++- .../forestry/mail/gui/ContainerCatalogue.java | 5 +- .../forestry/mail/gui/ContainerLetter.java | 21 +++--- .../mail/gui/ContainerPhilatelist.java | 5 +- .../forestry/mail/gui/ContainerTradeName.java | 10 ++- .../forestry/mail/gui/ContainerTrader.java | 11 ++- .../java/forestry/mail/gui/GuiCatalogue.java | 15 ++-- .../java/forestry/mail/gui/GuiLetter.java | 19 +++--- .../java/forestry/mail/gui/GuiMailbox.java | 3 +- .../forestry/mail/gui/GuiMailboxInfo.java | 10 ++- .../forestry/mail/gui/GuiPhilatelist.java | 3 +- .../java/forestry/mail/gui/GuiTradeName.java | 11 ++- .../java/forestry/mail/gui/GuiTrader.java | 3 +- .../forestry/mail/items/ItemCatalogue.java | 7 +- .../java/forestry/mail/items/ItemLetter.java | 33 ++++----- .../java/forestry/mail/items/ItemStamps.java | 4 +- .../mail/network/PacketLetterInfo.java | 16 ++--- .../mail/network/PacketPOBoxInfo.java | 5 +- .../java/forestry/mail/proxy/ProxyMail.java | 7 +- .../java/forestry/pipes/EnumFilterType.java | 7 +- .../java/forestry/pipes/GuiHandlerPipes.java | 6 +- .../java/forestry/pipes/PipeIconProvider.java | 4 +- .../forestry/pipes/PipeItemsPropolis.java | 15 ++-- .../forestry/pipes/PipeLogicPropolis.java | 13 ++-- .../pipes/gui/ContainerPropolisPipe.java | 4 +- .../forestry/pipes/gui/GuiPropolisPipe.java | 19 +++--- .../pipes/network/PacketHandlerPipes.java | 11 ++- .../pipes/proxy/ClientProxyPipes.java | 4 +- .../java/forestry/pipes/proxy/ProxyPipes.java | 9 ++- .../java/forestry/plugins/ForestryPlugin.java | 9 +-- .../forestry/plugins/PluginApiculture.java | 42 ++++++------ .../forestry/plugins/PluginArboriculture.java | 30 ++++---- .../plugins/PluginBuildCraftFuels.java | 7 +- .../plugins/PluginBuildCraftRecipes.java | 4 +- .../plugins/PluginBuildCraftStatements.java | 3 +- .../java/forestry/plugins/PluginCore.java | 17 +++-- src/main/java/forestry/plugins/PluginEE.java | 11 ++- .../java/forestry/plugins/PluginEnergy.java | 25 +------ .../java/forestry/plugins/PluginFactory.java | 17 ++--- .../forestry/plugins/PluginFarmCraftory.java | 15 ++-- .../java/forestry/plugins/PluginFarming.java | 3 +- .../java/forestry/plugins/PluginFood.java | 7 +- src/main/java/forestry/plugins/PluginIC2.java | 16 ++--- .../plugins/PluginLepidopterology.java | 18 ++--- .../java/forestry/plugins/PluginMail.java | 12 ++-- .../java/forestry/plugins/PluginManager.java | 5 +- .../java/forestry/plugins/PluginNatura.java | 11 ++- .../forestry/plugins/PluginPropolisPipe.java | 3 +- .../java/forestry/plugins/PluginStorage.java | 68 +++++++++---------- .../forestry/storage/BackpackDefinition.java | 8 +-- .../java/forestry/storage/BackpackHelper.java | 3 +- .../forestry/storage/GuiHandlerStorage.java | 11 ++- .../storage/PickupHandlerStorage.java | 9 ++- .../forestry/storage/ResupplyHandler.java | 11 ++- .../storage/gui/ContainerBackpack.java | 5 +- .../gui/ContainerNaturalistBackpack.java | 7 +- .../forestry/storage/items/ItemBackpack.java | 40 +++++------ .../storage/items/ItemNaturalistBackpack.java | 5 +- 551 files changed, 1944 insertions(+), 2970 deletions(-) diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java index 19ccf272f..032b401af 100755 --- a/src/main/java/forestry/apiculture/BeekeepingLogic.java +++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java @@ -10,26 +10,23 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.Stack; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IApiaristTracker; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingLogic; +import forestry.api.core.IErrorState; import forestry.api.genetics.IEffectData; import forestry.api.genetics.IIndividual; import forestry.core.EnumErrorCode; -import forestry.api.core.IErrorState; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; -import forestry.core.proxy.ProxyLog; import forestry.plugins.PluginApiculture; +import java.util.Stack; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; public class BeekeepingLogic implements IBeekeepingLogic { diff --git a/src/main/java/forestry/apiculture/FlowerProviderCacti.java b/src/main/java/forestry/apiculture/FlowerProviderCacti.java index c3cc19896..251f45f10 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderCacti.java +++ b/src/main/java/forestry/apiculture/FlowerProviderCacti.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderCacti implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderEnd.java b/src/main/java/forestry/apiculture/FlowerProviderEnd.java index 7aabb4c71..f904428a4 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderEnd.java +++ b/src/main/java/forestry/apiculture/FlowerProviderEnd.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderEnd implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderGourd.java b/src/main/java/forestry/apiculture/FlowerProviderGourd.java index 10eb185da..29b2ff473 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderGourd.java +++ b/src/main/java/forestry/apiculture/FlowerProviderGourd.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderGourd implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderJungle.java b/src/main/java/forestry/apiculture/FlowerProviderJungle.java index e223a6ae3..2f4c651e6 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderJungle.java +++ b/src/main/java/forestry/apiculture/FlowerProviderJungle.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderJungle implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java index ad6b1c705..91a030535 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java +++ b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderMushroom implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java b/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java index 66eb64f6c..898b5f89c 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java +++ b/src/main/java/forestry/apiculture/FlowerProviderNetherwart.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderNetherwart implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java index 1698c85a4..11abee91e 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java +++ b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java @@ -10,16 +10,6 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.Collections; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.apiculture.FlowerManager; import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; @@ -27,6 +17,13 @@ import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.utils.StringUtil; +import java.util.Collections; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderVanilla implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/FlowerProviderWheat.java b/src/main/java/forestry/apiculture/FlowerProviderWheat.java index ce2e5eaca..76c9f9d6a 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderWheat.java +++ b/src/main/java/forestry/apiculture/FlowerProviderWheat.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.apiculture; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class FlowerProviderWheat implements IFlowerProvider { diff --git a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java index 3814ca8b8..fac85dfde 100755 --- a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.apiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.apiculture.gadgets.TileAlvearyHygroregulator; import forestry.apiculture.gadgets.TileAlvearyPlain; import forestry.apiculture.gadgets.TileAlvearySieve; @@ -43,6 +39,9 @@ import forestry.apiculture.items.ItemImprinter.ImprinterInventory; import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GuiHandlerApiculture extends GuiHandlerBase { diff --git a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java index 2337a7b32..1549ea933 100755 --- a/src/main/java/forestry/apiculture/PacketHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/PacketHandlerApiculture.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.apiculture; -import java.io.DataInputStream; - -import net.minecraft.entity.player.EntityPlayer; - import forestry.apiculture.gui.ContainerImprinter; import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; +import java.io.DataInputStream; +import net.minecraft.entity.player.EntityPlayer; public class PacketHandlerApiculture implements IPacketHandler { diff --git a/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java b/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java index 1a2ae4d05..c45213340 100755 --- a/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/SaveEventHandlerApiculture.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.apiculture; -import net.minecraft.world.World; - import forestry.core.interfaces.ISaveEventHandler; import forestry.plugins.PluginApiculture; +import net.minecraft.world.World; public class SaveEventHandlerApiculture implements ISaveEventHandler { diff --git a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java index 55e0a0640..c95b27bd0 100755 --- a/src/main/java/forestry/apiculture/VillageHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/VillageHandlerApiculture.java @@ -21,6 +21,8 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; +import java.util.List; +import java.util.Random; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -31,9 +33,6 @@ import net.minecraft.village.MerchantRecipeList; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraft.world.gen.structure.StructureVillagePieces; -import java.util.List; -import java.util.Random; - public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler { public static void registerVillageComponents() { diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java index 5352e23c5..7590864f2 100644 --- a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.apiculture.commands; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.world.World; - import forestry.api.apiculture.IBeekeepingMode; import forestry.core.commands.ICommandModeHelper; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.world.World; public class BeeModeHelper implements ICommandModeHelper { diff --git a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java index ed2e020b2..2cd81afc5 100644 --- a/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeStatsSaveHelper.java @@ -10,12 +10,7 @@ ******************************************************************************/ package forestry.apiculture.commands; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - +import com.mojang.authlib.GameProfile; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.AlleleManager; @@ -25,8 +20,10 @@ import forestry.api.genetics.IBreedingTracker; import forestry.core.commands.IStatsSaveHelper; import forestry.core.utils.StringUtil; import forestry.plugins.PluginApiculture; - -import com.mojang.authlib.GameProfile; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; public class BeeStatsSaveHelper implements IStatsSaveHelper { diff --git a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java index b8a72b595..e3da4d890 100644 --- a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java +++ b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java @@ -10,14 +10,6 @@ ******************************************************************************/ package forestry.apiculture.commands; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; @@ -29,6 +21,12 @@ import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.SubCommand; import forestry.core.commands.TemplateNotFoundException; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class CommandBeeGive extends SubCommand { diff --git a/src/main/java/forestry/apiculture/entities/EntityBee.java b/src/main/java/forestry/apiculture/entities/EntityBee.java index d5716ddb5..3208ec398 100755 --- a/src/main/java/forestry/apiculture/entities/EntityBee.java +++ b/src/main/java/forestry/apiculture/entities/EntityBee.java @@ -10,20 +10,18 @@ ******************************************************************************/ package forestry.apiculture.entities; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.passive.IAnimals; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; import forestry.core.config.Defaults; import forestry.core.utils.ForestryResource; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; public class EntityBee extends EntityCreature implements IAnimals { diff --git a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java index 231e9ae1f..6bae0eed5 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockAlveary.java @@ -10,9 +10,14 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.apiculture.MaterialBeehive; +import forestry.core.gadgets.BlockStructure; +import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -23,14 +28,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.Tabs; -import forestry.apiculture.MaterialBeehive; -import forestry.core.gadgets.BlockStructure; -import forestry.core.render.TextureManager; - public class BlockAlveary extends BlockStructure { public BlockAlveary() { diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index d4ac8c93d..72f9798ee 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -19,6 +19,9 @@ import forestry.apiculture.MaterialBeehive; import forestry.core.config.Config; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import net.minecraft.block.BlockContainer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -31,10 +34,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - public class BlockBeehives extends BlockContainer { public BlockBeehives() { diff --git a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java index 5111fee49..76d59c2b4 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java @@ -10,10 +10,17 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.core.ForestryClient; +import forestry.core.config.Defaults; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.core.utils.StringUtil; import java.util.ArrayList; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockTorch; import net.minecraft.client.renderer.texture.IIconRegister; @@ -29,20 +36,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; -import forestry.api.core.Tabs; -import forestry.core.ForestryClient; -import forestry.core.config.Defaults; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; - public class BlockCandle extends BlockTorch { private final ArrayList lightingItems = new ArrayList(); diff --git a/src/main/java/forestry/apiculture/gadgets/BlockStump.java b/src/main/java/forestry/apiculture/gadgets/BlockStump.java index 53eca9bf4..ad797b592 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockStump.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockStump.java @@ -10,9 +10,16 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.core.utils.StringUtil; import java.util.List; import java.util.Random; - import net.minecraft.block.BlockTorch; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -23,16 +30,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.Tabs; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.core.utils.StringUtil; - public class BlockStump extends BlockTorch { public BlockStump() { diff --git a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java index 57846bbb0..bc13fa17c 100755 --- a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import java.util.HashSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; - import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ITileStructure; import forestry.core.config.ForestryBlock; @@ -24,6 +18,10 @@ import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.utils.Vect; +import java.util.HashSet; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; public class StructureLogicAlveary extends StructureLogic { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 6f9b246e0..40be9194a 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -23,14 +23,13 @@ import forestry.core.config.ForestryBlock; import forestry.core.gadgets.TileForestry; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; +import java.util.Collection; +import java.util.LinkedList; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; -import java.util.LinkedList; - public abstract class TileAlveary extends TileForestry implements IAlvearyComponent { private final IStructureLogic structureLogic; diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 309a35bb6..bc57a0663 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -10,18 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ForestryAPI; import forestry.core.config.Defaults; @@ -34,6 +22,16 @@ import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index a420f8fb7..797097dbd 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -18,7 +18,6 @@ import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; import forestry.api.apiculture.IBeekeepingLogic; import forestry.api.core.BiomeHelper; -import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; @@ -27,20 +26,22 @@ import forestry.api.core.ISpecialInventory; import forestry.api.core.ITileStructure; import forestry.api.genetics.IIndividual; import forestry.apiculture.gui.ContainerAlveary; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.proxy.Proxies; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; +import java.util.LinkedHashSet; +import java.util.Set; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; @@ -51,10 +52,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.ForgeDirection; -import java.util.LinkedHashSet; -import java.util.Set; -import scala.collection.SortedMap; - public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource { // / CONSTANTS diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index dd8536ea9..413ada71e 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeListener; @@ -22,8 +18,11 @@ import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.core.interfaces.ICrafter; -import forestry.core.network.GuiId; import forestry.core.inventory.InventoryAdapter; +import forestry.core.network.GuiId; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener { diff --git a/src/main/java/forestry/apiculture/gadgets/TileApiary.java b/src/main/java/forestry/apiculture/gadgets/TileApiary.java index 00d09357d..c3cb94abb 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileApiary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileApiary.java @@ -20,13 +20,12 @@ import forestry.core.gadgets.TileBase; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.plugins.PluginApiculture; +import java.util.Collection; +import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; -import java.util.LinkedList; - public class TileApiary extends TileBeehouse { @Override diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index f2918bc0f..178b18ca8 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -15,21 +15,21 @@ import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingLogic; -import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; import forestry.api.genetics.IIndividual; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.IClimatised; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java index e9595c0cf..7218eae58 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java +++ b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import forestry.core.inventory.InventoryAdapter; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import forestry.core.inventory.InventoryAdapter; - public class TileSwarm extends TileEntity { public final InventoryAdapter contained = new InventoryAdapter(2, "Contained"); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index 6686924aa..b960f7bff 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -29,15 +29,14 @@ import forestry.core.config.Defaults; import forestry.core.genetics.AlleleSpecies; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Locale; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java index ecfd9b7c3..7f38a2fd7 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectAggressive.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; +import java.util.List; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; public class AlleleEffectAggressive extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java index f3b932bf2..1b0612f0e 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.genetics.EffectData; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; public class AlleleEffectCreeper extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java index 1d73a289f..3a9dee87f 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectExploration.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; public class AlleleEffectExploration extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java index b95979e9e..989efc8ac 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFertile.java @@ -1,11 +1,11 @@ package forestry.apiculture.genetics; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.world.World; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; public class AlleleEffectFertile extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java index cea2123d5..9de179817 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -1,8 +1,11 @@ package forestry.apiculture.genetics; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.core.genetics.EffectData; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityCow; @@ -11,10 +14,6 @@ import net.minecraft.init.Blocks; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenBigMushroom; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; -import forestry.core.genetics.EffectData; public class AlleleEffectFungification extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java index 7bb55b61f..af66476c2 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; import forestry.core.utils.Vect; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; public class AlleleEffectGlacial extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java index bfb0524e1..580eabeff 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectHeroic.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; +import java.util.List; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; public class AlleleEffectHeroic extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java index b834d766f..05029e58d 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.plugins.PluginApiculture; +import java.util.List; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; public class AlleleEffectIgnition extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java index 715db439d..8ce97f3a8 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java @@ -10,19 +10,17 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.plugins.PluginApiculture; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; public class AlleleEffectMiasmic extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java index 9599517b5..a45d208a1 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMisanthrope.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; public class AlleleEffectMisanthrope extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java index d7a4e799c..a7ac786a0 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectNone.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.world.World; - import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.core.genetics.Allele; import forestry.plugins.PluginApiculture; +import net.minecraft.world.World; public class AlleleEffectNone extends Allele implements IAlleleBeeEffect { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java index 1ca3a1674..0d0795022 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectPotion.java @@ -16,13 +16,12 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.proxy.Proxies; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; -import java.util.List; - public class AlleleEffectPotion extends AlleleEffectThrottled { private final Potion potion; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java index fb7601ad9..4f949e6d2 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java @@ -10,17 +10,6 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; @@ -29,6 +18,15 @@ import forestry.apiculture.gadgets.TileAlveary; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; import forestry.core.utils.Vect; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; public class AlleleEffectRadioactive extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java index 72c070217..3bfc605c1 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectRepulsion.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.util.AxisAlignedBB; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; +import java.util.List; +import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.util.AxisAlignedBB; public class AlleleEffectRepulsion extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java index 65e2381d7..6039ac567 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectResurrection.java @@ -10,10 +10,14 @@ ******************************************************************************/ package forestry.apiculture.genetics; +import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeeHousing; +import forestry.api.genetics.IEffectData; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.item.EntityItem; @@ -30,12 +34,6 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; -import forestry.api.apiculture.IBeeGenome; -import forestry.api.apiculture.IBeeHousing; -import forestry.api.genetics.IEffectData; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; - public class AlleleEffectResurrection extends AlleleEffectThrottled { public static class Resurrectable { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java index 9117fad58..864f9d11b 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; import forestry.core.utils.Vect; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; public class AlleleEffectSnowing extends AlleleEffectThrottled { diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index 4fe7543a8..250f86599 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.util.AxisAlignedBB; - import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; @@ -21,6 +19,7 @@ import forestry.core.genetics.Allele; import forestry.core.genetics.EffectData; import forestry.core.utils.Vect; import forestry.plugins.PluginApiculture; +import net.minecraft.util.AxisAlignedBB; public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect { diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index ea52b7f6e..c55a3eeee 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -20,7 +20,6 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeMutation; import forestry.api.apiculture.IBeekeepingMode; import forestry.api.core.BiomeHelper; -import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; @@ -32,6 +31,7 @@ import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; import forestry.core.genetics.Chromosome; import forestry.core.genetics.GenericRatings; @@ -42,17 +42,16 @@ import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.core.utils.Vect; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - public class Bee extends IndividualLiving implements IBee { public IBeeGenome genome; diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index 6bc34f5ba..9eb3963ba 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -10,22 +10,8 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map.Entry; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import cpw.mods.fml.common.FMLCommonHandler; - import com.mojang.authlib.GameProfile; - +import cpw.mods.fml.common.FMLCommonHandler; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -49,6 +35,16 @@ import forestry.apiculture.gadgets.StructureLogicAlveary; import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map.Entry; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class BeeHelper extends SpeciesRoot implements IBeeRoot { diff --git a/src/main/java/forestry/apiculture/genetics/BeeMutation.java b/src/main/java/forestry/apiculture/genetics/BeeMutation.java index 184650b0a..4013e01ba 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeMutation.java +++ b/src/main/java/forestry/apiculture/genetics/BeeMutation.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.ArrayList; - -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - -import net.minecraftforge.common.BiomeDictionary; - import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeMutation; @@ -26,6 +19,10 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.genetics.Mutation; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; public class BeeMutation extends Mutation implements IBeeMutation { diff --git a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java index 55aa04097..dbc0f5b90 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeTemplates.java +++ b/src/main/java/forestry/apiculture/genetics/BeeTemplates.java @@ -14,7 +14,6 @@ import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.genetics.IAllele; import forestry.api.genetics.IMutation; import forestry.core.genetics.Allele; - import java.util.Arrays; public class BeeTemplates { diff --git a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java index 1b928a23e..efc5c64d1 100755 --- a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java +++ b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Random; - -import net.minecraft.world.World; - import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingMode; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Random; +import net.minecraft.world.World; public class BeekeepingMode implements IBeekeepingMode { diff --git a/src/main/java/forestry/apiculture/genetics/HiveDrop.java b/src/main/java/forestry/apiculture/genetics/HiveDrop.java index 11c20ea35..da3c881fc 100755 --- a/src/main/java/forestry/apiculture/genetics/HiveDrop.java +++ b/src/main/java/forestry/apiculture/genetics/HiveDrop.java @@ -15,11 +15,10 @@ import forestry.api.apiculture.IBee; import forestry.api.apiculture.IHiveDrop; import forestry.api.genetics.IAllele; import forestry.plugins.PluginApiculture; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import java.util.ArrayList; import java.util.Collections; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class HiveDrop implements IHiveDrop { diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java index adcc05f01..6b6a1d2c4 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.biome.BiomeGenBase; - import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.utils.Vect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.biome.BiomeGenBase; public class JubilanceDefault implements IJubilanceProvider { diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java index 0285d8e3d..56c37976a 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.List; - -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.AxisAlignedBB; - import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; +import java.util.List; +import net.minecraft.entity.EntityLiving; +import net.minecraft.util.AxisAlignedBB; /** * Hermits will not produce if there are any other living creatures nearby. diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java index ffef6a5f1..5eb1fc8dc 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.core.utils.StackUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; public class JubilanceReqRes implements IJubilanceProvider { diff --git a/src/main/java/forestry/apiculture/genetics/MutationEMC.java b/src/main/java/forestry/apiculture/genetics/MutationEMC.java index 1b18779ff..f893aea25 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationEMC.java +++ b/src/main/java/forestry/apiculture/genetics/MutationEMC.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.lang.reflect.Field; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.proxy.Proxies; import forestry.core.utils.Vect; +import java.lang.reflect.Field; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class MutationEMC extends MutationReqRes { diff --git a/src/main/java/forestry/apiculture/genetics/MutationReqRes.java b/src/main/java/forestry/apiculture/genetics/MutationReqRes.java index 4a51d2d6b..6d7a6fb60 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/MutationReqRes.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.utils.StackUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class MutationReqRes extends BeeMutation { diff --git a/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java b/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java index 244c1a07b..9a8eaf9e5 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java +++ b/src/main/java/forestry/apiculture/genetics/MutationTimeLimited.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.Calendar; - import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; +import java.util.Calendar; public class MutationTimeLimited extends BeeMutation { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java index 6c1d21c4a..5c1f90caf 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import forestry.apiculture.gadgets.TileAlvearyPlain; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotCustom; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; public class ContainerAlveary extends ContainerForestry { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index 0db2433b3..a67f45819 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; - import forestry.apiculture.gadgets.TileAlvearySieve; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotCustom; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; public class ContainerAlvearySieve extends ContainerForestry { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java index bd1f62461..f4caf8a85 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java @@ -14,12 +14,11 @@ import forestry.api.apiculture.BeeManager; import forestry.apiculture.gadgets.TileAlvearySwarmer; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotCustom; +import java.util.Set; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Set; - public class ContainerAlvearySwarmer extends ContainerForestry { public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) { diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index 414118aca..ac13523f9 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; - import forestry.api.apiculture.IHiveFrame; import forestry.apiculture.gadgets.TileBeehouse; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotCustom; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; public class ContainerApiary extends ContainerForestry { diff --git a/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java b/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java index 2dee50281..cec92c298 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.core.gui.ContainerAlyzer; -import forestry.core.config.ForestryItem; import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; - +import forestry.core.config.ForestryItem; +import forestry.core.gui.ContainerAlyzer; import net.minecraft.entity.player.InventoryPlayer; public class ContainerBeealyzer extends ContainerAlyzer { diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index af5b2bbe2..62eef0741 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBiomefinder; import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; @@ -21,6 +17,9 @@ import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotCustom; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; public class ContainerHabitatLocator extends ContainerItemInventory { diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index 1e871c94e..a280a9a05 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemImprinter.ImprinterInventory; import forestry.core.gui.ContainerForestry; @@ -25,6 +19,11 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ContainerImprinter extends ContainerForestry implements IGuiSelectable { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlveary.java b/src/main/java/forestry/apiculture/gui/GuiAlveary.java index 4285f6889..75d5b67fa 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlveary.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlveary.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.apiculture.gadgets.TileAlvearyPlain; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; +import net.minecraft.entity.player.InventoryPlayer; public class GuiAlveary extends GuiForestryTitled { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java index 6a7c16190..ce8051f14 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearyHygroregulator.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.apiculture.gadgets.TileAlvearyHygroregulator; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; +import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearyHygroregulator extends GuiForestryTitled { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java b/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java index 3a57d0801..75fb66a89 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearySieve.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.apiculture.gadgets.TileAlvearySieve; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; +import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearySieve extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java index a07ac33bf..80e2043c3 100755 --- a/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/GuiAlvearySwarmer.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.apiculture.gadgets.TileAlvearySwarmer; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; +import net.minecraft.entity.player.InventoryPlayer; public class GuiAlvearySwarmer extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/gui/GuiApiary.java b/src/main/java/forestry/apiculture/gui/GuiApiary.java index 1a73b16a3..c366a2c3b 100755 --- a/src/main/java/forestry/apiculture/gui/GuiApiary.java +++ b/src/main/java/forestry/apiculture/gui/GuiApiary.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.apiculture.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.apiculture.gadgets.TileApiary; import forestry.apiculture.gadgets.TileBeehouse; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; +import net.minecraft.entity.player.InventoryPlayer; public class GuiApiary extends GuiForestryTitled { diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 01deaf8d2..6cd2f69ca 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -27,11 +27,10 @@ import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.core.utils.Vect; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.ArrayList; - public class GuiBeealyzer extends GuiAlyzer { public GuiBeealyzer(EntityPlayer player, BeealyzerInventory inventory) { diff --git a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java index bee2019f2..24d232510 100755 --- a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java @@ -10,17 +10,6 @@ ******************************************************************************/ package forestry.apiculture.gui; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Locale; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.IIcon; -import net.minecraft.world.biome.BiomeGenBase; - -import org.lwjgl.opengl.GL11; - import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; @@ -30,6 +19,14 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Locale; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraft.world.biome.BiomeGenBase; +import org.lwjgl.opengl.GL11; public class GuiHabitatLocator extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java index 7eaf63246..0d677d7c1 100755 --- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java +++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java @@ -20,11 +20,10 @@ import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.HashMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; public class GuiImprinter extends GuiForestry { diff --git a/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java b/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java index 90f6f7b8c..fa37001c6 100755 --- a/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java +++ b/src/main/java/forestry/apiculture/items/ItemAlvearyBlock.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.apiculture.items; -import net.minecraft.block.Block; - import forestry.core.gadgets.IStructureBlockItem; import forestry.core.items.ItemForestryBlock; +import net.minecraft.block.Block; /** * diff --git a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java index 5a5efabe4..8466cd361 100755 --- a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java +++ b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java @@ -10,16 +10,8 @@ ******************************************************************************/ package forestry.apiculture.items; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.apiculture.IArmorApiarist; import forestry.api.core.IArmorNaturalist; import forestry.api.core.Tabs; @@ -27,6 +19,12 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist { diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java index 5f19e8b7f..eb5decdff 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java +++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java @@ -27,6 +27,7 @@ import forestry.core.config.Config; import forestry.core.genetics.ItemGE; import forestry.core.utils.StringUtil; import forestry.plugins.PluginApiculture; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -35,8 +36,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; -import java.util.List; - public class ItemBeeGE extends ItemGE { private final EnumBeeType type; diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index c2ec454a4..bbd2df988 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.apiculture.items; -import forestry.core.inventory.AlyzerInventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; @@ -24,10 +18,15 @@ import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.AlyzerInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemBeealyzer extends ItemInventoried { diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java index 0836ef00d..88301d50d 100755 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java @@ -10,8 +10,24 @@ ******************************************************************************/ package forestry.apiculture.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.apiculture.IBee; +import forestry.api.core.ForestryAPI; +import forestry.api.core.Tabs; +import forestry.apiculture.render.TextureBiomefinder; +import forestry.core.EnumErrorCode; +import forestry.core.config.Config; +import forestry.core.config.ForestryItem; +import forestry.core.interfaces.IErrorSource; +import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.ItemInventory; +import forestry.core.items.ItemInventoried; +import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; +import forestry.core.utils.Vect; +import forestry.plugins.PluginApiculture; import java.util.ArrayList; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; @@ -23,25 +39,6 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.apiculture.IBee; -import forestry.api.core.ForestryAPI; -import forestry.api.core.Tabs; -import forestry.apiculture.render.TextureBiomefinder; -import forestry.core.EnumErrorCode; -import forestry.core.config.Config; -import forestry.core.config.ForestryItem; -import forestry.core.interfaces.IErrorSource; -import forestry.core.interfaces.IHintSource; -import forestry.core.items.ItemInventoried; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.inventory.ItemInventory; -import forestry.core.utils.Vect; -import forestry.plugins.PluginApiculture; - public class ItemBiomefinder extends ItemInventoried { public static class BiomefinderInventory extends ItemInventory implements IErrorSource, IHintSource { diff --git a/src/main/java/forestry/apiculture/items/ItemCandleBlock.java b/src/main/java/forestry/apiculture/items/ItemCandleBlock.java index 951beb0c4..f76cf7f25 100755 --- a/src/main/java/forestry/apiculture/items/ItemCandleBlock.java +++ b/src/main/java/forestry/apiculture/items/ItemCandleBlock.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.apiculture.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.apiculture.gadgets.BlockCandle; +import forestry.core.items.ItemForestryBlock; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.apiculture.gadgets.BlockCandle; -import forestry.core.items.ItemForestryBlock; - public class ItemCandleBlock extends ItemForestryBlock { public ItemCandleBlock(Block block) { diff --git a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java index c23d3edcf..2a7f25e88 100755 --- a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java +++ b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.apiculture.items; -import net.minecraft.item.ItemStack; - import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IHiveFrame; import forestry.api.core.Tabs; import forestry.core.items.ItemForestry; +import net.minecraft.item.ItemStack; public class ItemHiveFrame extends ItemForestry implements IHiveFrame { diff --git a/src/main/java/forestry/apiculture/items/ItemHoneycomb.java b/src/main/java/forestry/apiculture/items/ItemHoneycomb.java index 1c2ba6041..c75dc42a2 100755 --- a/src/main/java/forestry/apiculture/items/ItemHoneycomb.java +++ b/src/main/java/forestry/apiculture/items/ItemHoneycomb.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture.items; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import forestry.api.core.Tabs; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.items.ItemForestryMultiPass; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class ItemHoneycomb extends ItemForestryMultiPass { diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 3c61ff934..70512ecf4 100755 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.apiculture.items; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; @@ -25,6 +19,11 @@ import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemImprinter extends ItemForestry { diff --git a/src/main/java/forestry/apiculture/items/ItemWaxCast.java b/src/main/java/forestry/apiculture/items/ItemWaxCast.java index dae81a1be..df600f0b5 100755 --- a/src/main/java/forestry/apiculture/items/ItemWaxCast.java +++ b/src/main/java/forestry/apiculture/items/ItemWaxCast.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.apiculture.items; -import net.minecraft.item.ItemStack; - import forestry.core.interfaces.ICraftingPlan; import forestry.core.items.ItemForestry; +import net.minecraft.item.ItemStack; public class ItemWaxCast extends ItemForestry implements ICraftingPlan { diff --git a/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java b/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java index 167b26122..bb6516859 100755 --- a/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java +++ b/src/main/java/forestry/apiculture/proxy/ClientProxyApiculture.java @@ -10,13 +10,7 @@ ******************************************************************************/ package forestry.apiculture.proxy; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.world.World; - import cpw.mods.fml.client.registry.RenderingRegistry; - -import net.minecraftforge.client.MinecraftForgeClient; - import forestry.apiculture.entities.EntityBee; import forestry.apiculture.render.BeeItemRenderer; import forestry.apiculture.render.EntityBeeFX; @@ -28,6 +22,9 @@ import forestry.core.interfaces.IBlockRenderer; import forestry.core.render.RenderAnalyzer; import forestry.core.render.TextureManager; import forestry.plugins.PluginApiculture; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyApiculture extends ProxyApiculture { diff --git a/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java index 267396f1b..939dd6b42 100755 --- a/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java +++ b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.apiculture.proxy; -import net.minecraft.world.World; - import forestry.core.interfaces.IBlockRenderer; +import net.minecraft.world.World; public class ProxyApiculture { public void addBeeHiveFX(String texture, World world, double xCoord, double yCoord, double zCoord, int color, int areaX, int areaY, int areaZ) { diff --git a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java index 130114b50..c8ba2b5d5 100755 --- a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java +++ b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.apiculture.render; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.client.IItemRenderer; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - import forestry.api.apiculture.IBee; import forestry.apiculture.entities.EntityBee; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; public class BeeItemRenderer implements IItemRenderer { diff --git a/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java b/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java index c525fbc99..40c18927d 100755 --- a/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java +++ b/src/main/java/forestry/apiculture/render/BlockCandleRenderer.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.apiculture.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import forestry.apiculture.gadgets.BlockCandle; +import forestry.apiculture.gadgets.TileCandle; +import forestry.core.ForestryClient; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - -import forestry.apiculture.gadgets.BlockCandle; -import forestry.apiculture.gadgets.TileCandle; -import forestry.core.ForestryClient; - public class BlockCandleRenderer implements ISimpleBlockRenderingHandler { @Override diff --git a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java index 1cd316b8b..80fcd495c 100755 --- a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java +++ b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.apiculture.render; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.util.ResourceLocation; - import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; - public class ModelAnalyzer extends ModelBase { private final ModelRenderer pedestal; diff --git a/src/main/java/forestry/apiculture/render/ModelBee.java b/src/main/java/forestry/apiculture/render/ModelBee.java index 56ff58961..c3c715640 100755 --- a/src/main/java/forestry/apiculture/render/ModelBee.java +++ b/src/main/java/forestry/apiculture/render/ModelBee.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.apiculture.render; +import forestry.api.apiculture.EnumBeeType; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; - import org.lwjgl.opengl.GL11; -import forestry.api.apiculture.EnumBeeType; - public class ModelBee extends ModelBase { //fields diff --git a/src/main/java/forestry/apiculture/render/ParticleRenderer.java b/src/main/java/forestry/apiculture/render/ParticleRenderer.java index 805f4b2f6..ea5633154 100755 --- a/src/main/java/forestry/apiculture/render/ParticleRenderer.java +++ b/src/main/java/forestry/apiculture/render/ParticleRenderer.java @@ -10,28 +10,24 @@ ******************************************************************************/ package forestry.apiculture.render; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.EntityLivingBase; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.WorldEvent; - import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) diff --git a/src/main/java/forestry/apiculture/render/RenderBee.java b/src/main/java/forestry/apiculture/render/RenderBee.java index 61ff1608c..02cf0fb6e 100755 --- a/src/main/java/forestry/apiculture/render/RenderBee.java +++ b/src/main/java/forestry/apiculture/render/RenderBee.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.apiculture.render; +import forestry.apiculture.entities.EntityBee; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import forestry.apiculture.entities.EntityBee; - public class RenderBee extends RenderLiving { private final ModelBee beeModel; diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index bb5eeb796..69f15b3e9 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -10,23 +10,6 @@ ******************************************************************************/ package forestry.apiculture.worldgen; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; - -import net.minecraftforge.common.ChestGenHooks; - import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -42,6 +25,20 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.utils.StackUtils; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraftforge.common.ChestGenHooks; public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 65ea83051..5869040af 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -17,6 +17,7 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.Config; import forestry.core.config.Defaults; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -25,8 +26,6 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType; import net.minecraftforge.event.terraingen.TerrainGen; -import java.util.Random; - /** * * @author CovertJaguar diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java index b9b6ead28..47804f0c8 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderNone.java +++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.arboriculture; -import java.util.HashMap; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IFruitFamily; import forestry.core.render.TextureManager; +import java.util.HashMap; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class FruitProviderNone implements IFruitProvider { diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index 128630dc2..f94e05a75 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -10,17 +10,8 @@ ******************************************************************************/ package forestry.arboriculture; -import java.util.Locale; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.ITreeGenome; @@ -28,6 +19,12 @@ import forestry.api.genetics.IFruitFamily; import forestry.core.render.TextureManager; import forestry.core.utils.BlockUtil; import forestry.plugins.PluginArboriculture; +import java.util.Locale; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class FruitProviderPod extends FruitProviderNone { diff --git a/src/main/java/forestry/arboriculture/FruitProviderRandom.java b/src/main/java/forestry/arboriculture/FruitProviderRandom.java index c9194eae2..e353d1def 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRandom.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRandom.java @@ -13,14 +13,13 @@ package forestry.arboriculture; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IFruitFamily; import forestry.plugins.PluginArboriculture; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; /** * Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none. diff --git a/src/main/java/forestry/arboriculture/FruitProviderRipening.java b/src/main/java/forestry/arboriculture/FruitProviderRipening.java index 3d7c83320..69ba7afcd 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderRipening.java +++ b/src/main/java/forestry/arboriculture/FruitProviderRipening.java @@ -13,14 +13,13 @@ package forestry.arboriculture; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IFruitFamily; import forestry.plugins.PluginArboriculture; -import net.minecraft.item.ItemStack; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; public class FruitProviderRipening extends FruitProviderNone { diff --git a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java index b0c9fa378..481604189 100755 --- a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java @@ -10,16 +10,15 @@ ******************************************************************************/ package forestry.arboriculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.arboriculture.genetics.TreeHelper; import forestry.arboriculture.gui.ContainerTreealyzer; import forestry.arboriculture.gui.GuiTreealyzer; import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GuiHandlerArboriculture extends GuiHandlerBase { diff --git a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java index 9f275d5c2..a7588eb54 100755 --- a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.arboriculture; -import java.io.DataInputStream; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; - import forestry.arboriculture.gadgets.TileLeaves; import forestry.arboriculture.network.PacketLeafUpdate; import forestry.core.interfaces.IPacketHandler; -import forestry.core.network.ILocatedPacket; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; +import java.io.DataInputStream; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; public class PacketHandlerArboriculture implements IPacketHandler { diff --git a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java index d661c3a04..14a2e7f79 100755 --- a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java @@ -10,8 +10,12 @@ ******************************************************************************/ package forestry.arboriculture; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.plugins.PluginArboriculture; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; @@ -19,13 +23,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; - -import forestry.api.arboriculture.EnumGermlingType; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.plugins.PluginArboriculture; - public class VillageHandlerArboriculture implements IVillageTradeHandler { @SuppressWarnings("unchecked") diff --git a/src/main/java/forestry/arboriculture/WoodType.java b/src/main/java/forestry/arboriculture/WoodType.java index 0086a0317..1e6420c98 100755 --- a/src/main/java/forestry/arboriculture/WoodType.java +++ b/src/main/java/forestry/arboriculture/WoodType.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.arboriculture; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.render.TextureManager; import java.util.Locale; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.render.TextureManager; - public enum WoodType { LARCH, TEAK, ACACIA, LIME, CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f), KAPOK, EBONY, MAHOGANY, BALSA(1.0f), WILLOW, WALNUT, GREENHEART(7.5f), CHERRY, MAHOE, POPLAR, PALM, PAPAYA, PINE( 3.0f), PLUM, MAPLE, CITRUS, GIGANTEUM(2.0f, false); diff --git a/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java index 39341c665..eb273dc58 100644 --- a/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java +++ b/src/main/java/forestry/arboriculture/commands/CommandTreeSpawn.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.arboriculture.commands; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.command.ICommandSender; -import net.minecraft.command.PlayerNotFoundException; -import net.minecraft.entity.player.EntityPlayer; - import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.core.commands.CommandHelpers; import forestry.core.commands.SubCommand; - +import java.util.ArrayList; +import java.util.List; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.entity.player.EntityPlayer; import org.apache.commons.lang3.StringUtils; public final class CommandTreeSpawn extends SubCommand { diff --git a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java index 870b7d1b6..977d3c318 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.commands; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.gen.feature.WorldGenerator; - import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; @@ -22,6 +19,8 @@ import forestry.core.commands.SpeciesNotFoundException; import forestry.core.commands.TemplateNotFoundException; import forestry.core.worldgen.WorldGenBase; import forestry.plugins.PluginArboriculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.gen.feature.WorldGenerator; public final class TreeGenHelper { diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java index 61c4b5fc1..cf84d8016 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.commands; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.world.World; - import forestry.api.arboriculture.ITreekeepingMode; import forestry.core.commands.ICommandModeHelper; import forestry.plugins.PluginArboriculture; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.world.World; public class TreeModeHelper implements ICommandModeHelper { diff --git a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java index 8eae52876..94f5a7f9e 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeStatsSaveHelper.java @@ -10,11 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.commands; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.world.World; - +import com.mojang.authlib.GameProfile; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; @@ -22,8 +18,9 @@ import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; import forestry.core.commands.IStatsSaveHelper; import forestry.plugins.PluginArboriculture; - -import com.mojang.authlib.GameProfile; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.world.World; public class TreeStatsSaveHelper implements IStatsSaveHelper { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index ade3bccf6..48233a27c 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -16,6 +16,7 @@ import forestry.api.core.Tabs; import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; import forestry.plugins.PluginArboriculture; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.material.Material; @@ -28,8 +29,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.List; - public class BlockArbFence extends BlockFence implements IWoodTyped { public static enum FenceCat { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index 89ae9b7a8..6c2c5b554 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -10,9 +10,14 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.arboriculture.WoodType; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; import net.minecraft.client.renderer.texture.IIconRegister; @@ -26,14 +31,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.Tabs; -import forestry.arboriculture.WoodType; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; - public class BlockArbStairs extends BlockStairs { public BlockArbStairs(Block par2Block, int par3) { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java b/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java index ee1fedd29..14d768c90 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockFruitPod.java @@ -10,9 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.BlockUtil; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginArboriculture; import java.util.ArrayList; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; import net.minecraft.client.renderer.texture.IIconRegister; @@ -23,15 +29,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginArboriculture; - public class BlockFruitPod extends BlockCocoa { public BlockFruitPod() { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java index 86279c6a2..97ab2f49a 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java @@ -10,8 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -22,16 +26,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; - public class BlockLog extends Block implements IWoodTyped { public enum LogCat { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java index 2404d5f62..d46cbaea0 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java @@ -10,8 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -21,16 +25,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; - public class BlockPlanks extends Block implements IWoodTyped { public static enum PlankCat { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index 0c1365832..72185c13b 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -10,8 +10,18 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IAlleleFruit; +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginArboriculture; import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -24,19 +34,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IAlleleFruit; -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import forestry.plugins.PluginArboriculture; - public class BlockSapling extends BlockTreeContainer { public static TileSapling getSaplingTile(IBlockAccess world, int x, int y, int z) { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index 7f6e61789..f72dfa92f 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -10,9 +10,13 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; import java.util.List; import java.util.Random; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -22,16 +26,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; - public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped { public static enum SlabCat { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java b/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java index 897f98536..ac5f3cc30 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockTreeContainer.java @@ -11,7 +11,6 @@ package forestry.arboriculture.gadgets; import java.util.Random; - import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 652a3b447..bf08afde0 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -24,6 +24,10 @@ import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; import forestry.plugins.PluginArboriculture; import forestry.plugins.PluginLepidopterology; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; import net.minecraft.block.BlockNewLeaf; import net.minecraft.block.ITileEntityProvider; import net.minecraft.client.renderer.texture.IIconRegister; @@ -40,11 +44,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; - public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider { public ForestryBlockLeaves() { diff --git a/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java b/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java index 90834d341..fd3599612 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileFruitPod.java @@ -10,19 +10,8 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.arboriculture.IAlleleFruit; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; @@ -35,6 +24,14 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruitBearer { diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 0c474ea9b..6aff7149f 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -17,7 +17,6 @@ import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ILeafTickHandler; import forestry.api.arboriculture.ITree; -import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IErrorState; @@ -31,12 +30,17 @@ import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.lepidopterology.IButterflyRoot; import forestry.arboriculture.network.PacketLeafUpdate; +import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; import forestry.core.network.ForestryPacket; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -47,11 +51,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.EnumPlantType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; - public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery { private int colourLeaves; diff --git a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java index 93e5f5968..39bc6c663 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileSapling.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import forestry.plugins.PluginArboriculture; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.gen.feature.WorldGenerator; -import forestry.plugins.PluginArboriculture; - public class TileSapling extends TileTreeContainer { private int timesTicked = 0; diff --git a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java b/src/main/java/forestry/arboriculture/gadgets/TileStairs.java index 7af38b34b..d659b1766 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileStairs.java @@ -10,16 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; - import forestry.arboriculture.WoodType; import forestry.core.network.ForestryPacket; import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; import forestry.core.proxy.Proxies; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; public class TileStairs extends TileEntity implements INetworkedEntity { diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java index 8013dc1ae..f011cdd38 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; - import forestry.api.arboriculture.IAlleleLeafEffect; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IEffectData; import forestry.core.genetics.Allele; import forestry.core.utils.Vect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; public class AlleleLeafEffectNone extends Allele implements IAlleleLeafEffect { diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java index 08e001ca3..16144fe76 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleTreeSpecies.java @@ -10,21 +10,8 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import java.util.ArrayList; -import java.util.HashMap; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.IAlleleTreeSpecies; @@ -43,6 +30,15 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.AlleleSpecies; import forestry.core.render.TextureManager; import forestry.core.utils.Utils; +import java.util.ArrayList; +import java.util.HashMap; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.EnumPlantType; public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpecies, IIconProvider { diff --git a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java index 35ff15bd4..eb42b0197 100755 --- a/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java +++ b/src/main/java/forestry/arboriculture/genetics/ArboristTracker.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import net.minecraft.entity.player.EntityPlayer; - import com.mojang.authlib.GameProfile; - import forestry.api.arboriculture.IArboristTracker; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginArboriculture; +import net.minecraft.entity.player.EntityPlayer; public class ArboristTracker extends BreedingTracker implements IArboristTracker { diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java index 9f367b6d2..7047f7910 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java @@ -10,18 +10,17 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import forestry.core.utils.StringUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.IGrowthProvider; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeGenome; import forestry.arboriculture.gadgets.TileSapling; +import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.core.utils.Vect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; public class GrowthProvider implements IGrowthProvider { diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java index 2c3125665..879e4e892 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProviderTropical.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import java.util.EnumSet; - -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.World; - import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.ITreeGenome; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; public class GrowthProviderTropical extends GrowthProvider { diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 4f3e71e83..b8ab72fff 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -31,6 +31,10 @@ import forestry.core.genetics.Chromosome; import forestry.core.genetics.Individual; import forestry.core.utils.StringUtil; import forestry.plugins.PluginArboriculture; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumSet; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -42,11 +46,6 @@ import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; - public class Tree extends Individual implements ITree, ITreeGenData, IPlantable { private ITreeGenome genome; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java index c1d3586d4..fd8468608 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import java.util.EnumSet; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; @@ -35,6 +28,10 @@ import forestry.core.genetics.AllelePlantType; import forestry.core.genetics.Chromosome; import forestry.core.genetics.Genome; import forestry.plugins.PluginArboriculture; +import java.util.EnumSet; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.EnumPlantType; public class TreeGenome extends Genome implements ITreeGenome { diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index 03150c448..c615a6ea0 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -10,25 +10,8 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Locale; -import java.util.Map.Entry; - -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import cpw.mods.fml.common.FMLCommonHandler; - import com.mojang.authlib.GameProfile; - +import cpw.mods.fml.common.FMLCommonHandler; import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; @@ -55,6 +38,19 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.core.utils.BlockUtil; import forestry.plugins.PluginArboriculture; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map.Entry; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class TreeHelper extends SpeciesRoot implements ITreeRoot { diff --git a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java index 043572ee5..2ebaadb06 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeMutation.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeMutation.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreeMutation; import forestry.api.arboriculture.ITreeRoot; @@ -21,6 +18,8 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.genetics.Mutation; import forestry.plugins.PluginArboriculture; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; public class TreeMutation extends Mutation implements ITreeMutation { diff --git a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java index e7083d3d9..04e623520 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java +++ b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.genetics; -import java.util.ArrayList; -import java.util.Locale; - import forestry.api.arboriculture.ITreeGenome; import forestry.api.arboriculture.ITreekeepingMode; +import java.util.ArrayList; +import java.util.Locale; public class TreekeepingMode implements ITreekeepingMode { diff --git a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java index 6d92cae38..25dc69b6d 100755 --- a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java @@ -11,11 +11,10 @@ package forestry.arboriculture.gui; import forestry.api.genetics.AlleleManager; -import forestry.core.gui.ContainerAlyzer; -import forestry.core.config.ForestryItem; import forestry.arboriculture.items.ItemGermlingGE; import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; - +import forestry.core.config.ForestryItem; +import forestry.core.gui.ContainerAlyzer; import net.minecraft.entity.player.InventoryPlayer; import org.apache.commons.lang3.ArrayUtils; diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index 34e130e7b..e15442e58 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -15,7 +15,6 @@ import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; import forestry.api.arboriculture.ITree; -import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleFloat; import forestry.api.genetics.IAlleleInteger; @@ -30,14 +29,13 @@ import forestry.core.genetics.AllelePlantType; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.plugins.PluginArboriculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.EnumPlantType; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.EnumPlantType; public class GuiTreealyzer extends GuiAlyzer { diff --git a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java index f31a42b97..f153237b4 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java +++ b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java @@ -31,6 +31,7 @@ import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; +import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -39,8 +40,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import java.util.List; - public class ItemGermlingGE extends ItemGE implements IVariableFermentable { private final EnumGermlingType type; diff --git a/src/main/java/forestry/arboriculture/items/ItemGrafter.java b/src/main/java/forestry/arboriculture/items/ItemGrafter.java index a97b60cfd..84d55f901 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGrafter.java +++ b/src/main/java/forestry/arboriculture/items/ItemGrafter.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.arboriculture.items; +import forestry.api.arboriculture.IToolGrafter; +import forestry.api.core.Tabs; +import forestry.core.items.ItemForestry; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import net.minecraftforge.common.ForgeHooks; -import forestry.api.arboriculture.IToolGrafter; -import forestry.api.core.Tabs; -import forestry.core.items.ItemForestry; - public class ItemGrafter extends ItemForestry implements IToolGrafter { private final float efficiencyOnProperMaterial; diff --git a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java index c07e726fb..53b7685a8 100644 --- a/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemLeavesBlock.java @@ -9,7 +9,6 @@ import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class ItemLeavesBlock extends ItemForestryBlock { diff --git a/src/main/java/forestry/arboriculture/items/ItemStairs.java b/src/main/java/forestry/arboriculture/items/ItemStairs.java index 531e25b91..4be8db5c3 100755 --- a/src/main/java/forestry/arboriculture/items/ItemStairs.java +++ b/src/main/java/forestry/arboriculture/items/ItemStairs.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.arboriculture.items; -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; - import forestry.arboriculture.WoodType; import forestry.arboriculture.gadgets.TileStairs; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.items.ItemForestryBlock; +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; public class ItemStairs extends ItemForestryBlock { diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 2d43d08f2..823507c18 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.items; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import forestry.core.inventory.AlyzerInventory; import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; @@ -24,11 +18,16 @@ import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.AlyzerInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemTreealyzer extends ItemInventoried { diff --git a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java index 6a1435151..73c61e383 100755 --- a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java @@ -11,13 +11,12 @@ package forestry.arboriculture.items; import forestry.arboriculture.IWoodFireproof; -import forestry.core.utils.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import forestry.arboriculture.IWoodTyped; import forestry.arboriculture.WoodType; import forestry.core.items.ItemForestryBlock; +import forestry.core.utils.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; public class ItemWoodBlock extends ItemForestryBlock { diff --git a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java index abcff5967..11398d46b 100755 --- a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java +++ b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.network; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import forestry.arboriculture.gadgets.TileLeaves; import forestry.core.network.PacketIds; import forestry.core.network.PacketTileNBT; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; public class PacketLeafUpdate extends PacketTileNBT { diff --git a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java index 1f3e27e96..dd163b039 100755 --- a/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java +++ b/src/main/java/forestry/arboriculture/proxy/ClientProxyArboriculture.java @@ -10,13 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.proxy; -import net.minecraft.item.Item; -import net.minecraft.world.ColorizerFoliage; - import cpw.mods.fml.client.registry.RenderingRegistry; - -import net.minecraftforge.client.MinecraftForgeClient; - import forestry.arboriculture.render.FenceRenderingHandler; import forestry.arboriculture.render.FruitPodRenderingHandler; import forestry.arboriculture.render.LeavesRenderingHandler; @@ -24,6 +18,8 @@ import forestry.arboriculture.render.SaplingRenderHandler; import forestry.arboriculture.render.StairItemRenderer; import forestry.core.config.ForestryBlock; import forestry.plugins.PluginArboriculture; +import net.minecraft.world.ColorizerFoliage; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyArboriculture extends ProxyArboriculture { @Override diff --git a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java index 619fabf54..b06e6610d 100755 --- a/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/FenceRenderingHandler.java @@ -10,18 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; - -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - import org.lwjgl.opengl.GL11; -import forestry.plugins.PluginArboriculture; - public class FenceRenderingHandler implements ISimpleBlockRenderingHandler { @Override diff --git a/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java b/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java index 0c7a34959..dcf2d7b3a 100755 --- a/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/FruitPodRenderingHandler.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import forestry.arboriculture.gadgets.BlockFruitPod; +import forestry.arboriculture.gadgets.TileFruitPod; +import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.client.renderer.RenderBlocks; @@ -17,12 +21,6 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - -import forestry.arboriculture.gadgets.BlockFruitPod; -import forestry.arboriculture.gadgets.TileFruitPod; -import forestry.plugins.PluginArboriculture; - public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler { @Override diff --git a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java index b65e70a9b..a77201f72 100755 --- a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java +++ b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.arboriculture.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.IAlleleTreeSpecies; +import forestry.arboriculture.gadgets.BlockSapling; +import forestry.arboriculture.gadgets.TileSapling; +import forestry.plugins.PluginArboriculture; import net.minecraft.block.Block; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -17,14 +23,6 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.IAlleleTreeSpecies; -import forestry.arboriculture.gadgets.BlockSapling; -import forestry.arboriculture.gadgets.TileSapling; -import forestry.plugins.PluginArboriculture; - public class SaplingRenderHandler implements ISimpleBlockRenderingHandler { public static int renderLayer = 0; diff --git a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java index d2add95b1..8f9b0dbc4 100755 --- a/src/main/java/forestry/arboriculture/render/StairItemRenderer.java +++ b/src/main/java/forestry/arboriculture/render/StairItemRenderer.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.arboriculture.render; +import forestry.arboriculture.WoodType; +import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; -import forestry.arboriculture.WoodType; -import forestry.core.utils.StackUtils; - public class StairItemRenderer implements IItemRenderer { private void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float f, float g, float h) { diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java index c2af659d4..0038053da 100755 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeLeaf.java @@ -10,13 +10,11 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.world.World; - import com.mojang.authlib.GameProfile; - import forestry.api.world.ITreeGenData; import forestry.core.config.ForestryBlock; import forestry.core.worldgen.BlockType; +import net.minecraft.world.World; public class BlockTypeLeaf extends BlockType { diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java index 884e6da7a..1f07fd2ac 100755 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; - import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; public class BlockTypeVoid extends BlockType { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java index 56a233291..6f7e5c966 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenAcacia extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java index 9fe119e25..fa0baa824 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcaciaVanilla.java @@ -10,9 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; public class WorldGenAcaciaVanilla extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index f93b72d7d..ac89f234b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; - import com.mojang.authlib.GameProfile; - import forestry.api.world.ITreeGenData; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.Utils; import forestry.core.utils.Vect; import forestry.core.worldgen.BlockType; import forestry.core.worldgen.WorldGenBase; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; public abstract class WorldGenArboriculture extends WorldGenBase { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java index 0bdcde71b..605fae511 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenBalsa extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java index e4e22fb73..2b53012c8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenBaobab extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java index 419c9ebf8..5dfc1c96b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBirch.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; public class WorldGenBirch extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java index 775ae8030..a8f37be32 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenCherry extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java index 28bfc8589..ab2e2208e 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenChestnut extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java index 97c5bef38..7dbda55a8 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDarkOak.java @@ -10,9 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; public class WorldGenDarkOak extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java index 896debc79..f417707a0 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenDate extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java index 7e876e6bf..8bc0b01cb 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenEbony.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenEbony extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java index ad32a8c94..0777a34f2 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenGiganteum.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenGiganteum extends WorldGenSequoia { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java index 3ebdf1b27..b89ff2e48 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenGreenheart extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java index a886f1e5b..60a438e7a 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; /** * This is a dummy and needs to be replaced with something proper. diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java index bf5024372..093fda86b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenKapok extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java index 5acc0af6c..9538e7bd8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenLarch extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java index 0dbf4ddc2..9046d47bf 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenLemon extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java index aa17569fc..ae8c0a042 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenLime extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java index 37256c938..06a9582cb 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenMahoe extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java index e43b3246d..010403379 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenMahogany extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java index 239abd278..a6a543d01 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenMaple extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java index 488720a41..274b68da0 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenOak.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; import forestry.core.worldgen.BlockType; +import net.minecraft.init.Blocks; public class WorldGenOak extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java index 1c86f58f9..5ec3d0830 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenPapaya extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java index 5c93ebedf..694aba393 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenPine extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java index 9036dbf7a..dc1080cb1 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenPlum extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java index 9de0d72f0..c907db527 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenPoplar extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java index b6ab46e0e..60e79b659 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenSequoia extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java index 0889e7cf2..82b301495 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java @@ -10,10 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import net.minecraft.init.Blocks; - import forestry.api.world.ITreeGenData; -import forestry.core.worldgen.BlockType; public class WorldGenSpruce extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java index 1a7e0bd0b..b0adfd9df 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenTeak extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java index d0cf8d808..ff308cb79 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java @@ -11,7 +11,6 @@ package forestry.arboriculture.worldgen; import com.mojang.authlib.GameProfile; - import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.genetics.IAlleleBoolean; import forestry.api.world.ITreeGenData; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java index 98e62a503..f5c0e0d72 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenWalnut extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java index f962592ed..451ae6a1a 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenWenge extends WorldGenTree { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java index a81ec973a..187314929 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java @@ -11,8 +11,6 @@ package forestry.arboriculture.worldgen; import forestry.api.world.ITreeGenData; -import forestry.core.config.ForestryBlock; -import forestry.core.worldgen.BlockType; public class WorldGenWillow extends WorldGenTree { diff --git a/src/main/java/forestry/core/CreativeTabForestry.java b/src/main/java/forestry/core/CreativeTabForestry.java index 77172eeb5..a2026a194 100755 --- a/src/main/java/forestry/core/CreativeTabForestry.java +++ b/src/main/java/forestry/core/CreativeTabForestry.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.core; +import cpw.mods.fml.common.registry.GameRegistry; +import forestry.api.core.Tabs; +import forestry.core.config.ForestryItem; import forestry.plugins.PluginManager; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.registry.GameData; -import cpw.mods.fml.common.registry.GameRegistry; - -import forestry.api.core.Tabs; -import forestry.core.config.ForestryItem; - public class CreativeTabForestry extends CreativeTabs { static { diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index 6fcaa0fa8..4fb450e9a 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -5,13 +5,12 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.ErrorStateRegistry; import forestry.api.core.IErrorState; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public enum EnumErrorCode implements IErrorState { diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index 13c061bac..dd5caadce 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -10,25 +10,22 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.oredict.OreDictionary; - import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.ErrorStateRegistry; - import forestry.core.fluids.Fluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.render.TextureManager; import forestry.plugins.PluginManager; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.oredict.OreDictionary; public class EventHandlerCore { diff --git a/src/main/java/forestry/core/ForestryClient.java b/src/main/java/forestry/core/ForestryClient.java index 616413cbe..ab3a36520 100755 --- a/src/main/java/forestry/core/ForestryClient.java +++ b/src/main/java/forestry/core/ForestryClient.java @@ -11,7 +11,6 @@ package forestry.core; import cpw.mods.fml.client.registry.RenderingRegistry; - import forestry.apiculture.render.BlockCandleRenderer; import forestry.core.proxy.Proxies; import forestry.core.render.BlockRenderingHandler; diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 2b797d3af..12da31df3 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -11,21 +11,10 @@ package forestry.core; import com.google.common.collect.ImmutableList; - -import java.io.File; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; - -import net.minecraftforge.common.MinecraftForge; - import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; - import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; @@ -45,6 +34,12 @@ import forestry.core.gadgets.TileMill; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; import forestry.plugins.PluginManager; +import java.io.File; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.MinecraftForge; public class ForestryCore { diff --git a/src/main/java/forestry/core/GameMode.java b/src/main/java/forestry/core/GameMode.java index eb421fa6b..6ca77066a 100755 --- a/src/main/java/forestry/core/GameMode.java +++ b/src/main/java/forestry/core/GameMode.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.core; -import java.util.HashMap; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - import forestry.api.core.ForestryAPI; import forestry.api.core.IGameMode; import forestry.core.config.Config; @@ -23,6 +18,9 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.config.Property; import forestry.core.proxy.Proxies; +import java.util.HashMap; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; public class GameMode implements IGameMode { diff --git a/src/main/java/forestry/core/GuiHandler.java b/src/main/java/forestry/core/GuiHandler.java index 675d7fb68..d130c6a76 100755 --- a/src/main/java/forestry/core/GuiHandler.java +++ b/src/main/java/forestry/core/GuiHandler.java @@ -10,11 +10,7 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - import cpw.mods.fml.common.network.IGuiHandler; - import forestry.core.circuits.ContainerSolderingIron; import forestry.core.circuits.GuiSolderingIron; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; @@ -26,6 +22,8 @@ import forestry.core.gui.GuiAnalyzer; import forestry.core.gui.GuiEscritoire; import forestry.core.network.GuiId; import forestry.plugins.PluginManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class GuiHandler extends GuiHandlerBase { diff --git a/src/main/java/forestry/core/GuiHandlerBase.java b/src/main/java/forestry/core/GuiHandlerBase.java index 83c96e77a..8b0af8053 100755 --- a/src/main/java/forestry/core/GuiHandlerBase.java +++ b/src/main/java/forestry/core/GuiHandlerBase.java @@ -10,12 +10,7 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import cpw.mods.fml.common.network.IGuiHandler; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.ISpeciesRoot; import forestry.core.gadgets.TileForestry; @@ -23,6 +18,9 @@ import forestry.core.gadgets.TileNaturalistChest; import forestry.core.gui.ContainerNaturalistInventory; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public abstract class GuiHandlerBase implements IGuiHandler { diff --git a/src/main/java/forestry/core/PickupHandlerCore.java b/src/main/java/forestry/core/PickupHandlerCore.java index e27f04063..83170fb46 100755 --- a/src/main/java/forestry/core/PickupHandlerCore.java +++ b/src/main/java/forestry/core/PickupHandlerCore.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.ISpeciesRoot; import forestry.core.interfaces.IPickupHandler; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class PickupHandlerCore implements IPickupHandler { diff --git a/src/main/java/forestry/core/SaveEventHandlerCore.java b/src/main/java/forestry/core/SaveEventHandlerCore.java index b51152825..5375d81e1 100755 --- a/src/main/java/forestry/core/SaveEventHandlerCore.java +++ b/src/main/java/forestry/core/SaveEventHandlerCore.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.world.World; - import forestry.core.interfaces.ISaveEventHandler; +import net.minecraft.world.World; public class SaveEventHandlerCore implements ISaveEventHandler { diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index 99ffeb4f6..b31091770 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.core; -import java.util.concurrent.ConcurrentLinkedQueue; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; - import forestry.core.config.Config; import forestry.core.config.Version; import forestry.core.proxy.Proxies; import forestry.core.utils.Utils; +import java.util.concurrent.ConcurrentLinkedQueue; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; public class TickHandlerCoreClient { diff --git a/src/main/java/forestry/core/TickHandlerCoreServer.java b/src/main/java/forestry/core/TickHandlerCoreServer.java index 3345d7214..ac90cedf4 100755 --- a/src/main/java/forestry/core/TickHandlerCoreServer.java +++ b/src/main/java/forestry/core/TickHandlerCoreServer.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.core; -import net.minecraft.entity.player.EntityPlayer; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; - import forestry.core.interfaces.IResupplyHandler; import forestry.plugins.PluginManager; +import net.minecraft.entity.player.EntityPlayer; public class TickHandlerCoreServer { public TickHandlerCoreServer() { diff --git a/src/main/java/forestry/core/WorldGenerator.java b/src/main/java/forestry/core/WorldGenerator.java index ea57f2105..5b199687d 100755 --- a/src/main/java/forestry/core/WorldGenerator.java +++ b/src/main/java/forestry/core/WorldGenerator.java @@ -10,19 +10,15 @@ ******************************************************************************/ package forestry.core; -import java.util.Random; - -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; - import cpw.mods.fml.common.IWorldGenerator; - import forestry.core.config.Config; import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.worldgen.WorldGenMinableMeta; -import forestry.plugins.ForestryPlugin; import forestry.plugins.PluginManager; +import java.util.Random; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; public class WorldGenerator implements IWorldGenerator { diff --git a/src/main/java/forestry/core/circuits/Circuit.java b/src/main/java/forestry/core/circuits/Circuit.java index ac8b4989e..be7061f2f 100755 --- a/src/main/java/forestry/core/circuits/Circuit.java +++ b/src/main/java/forestry/core/circuits/Circuit.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.circuits; -import java.util.List; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.core.utils.StringUtil; +import java.util.List; public abstract class Circuit implements ICircuit { diff --git a/src/main/java/forestry/core/circuits/CircuitBoard.java b/src/main/java/forestry/core/circuits/CircuitBoard.java index 744bffaff..009ddb54a 100755 --- a/src/main/java/forestry/core/circuits/CircuitBoard.java +++ b/src/main/java/forestry/core/circuits/CircuitBoard.java @@ -14,13 +14,12 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; +import java.util.ArrayList; +import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -import java.util.ArrayList; -import java.util.List; - public class CircuitBoard implements ICircuitBoard { EnumCircuitBoardType type; diff --git a/src/main/java/forestry/core/circuits/CircuitLibrary.java b/src/main/java/forestry/core/circuits/CircuitLibrary.java index 22d9d6d09..591d5de80 100755 --- a/src/main/java/forestry/core/circuits/CircuitLibrary.java +++ b/src/main/java/forestry/core/circuits/CircuitLibrary.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.circuits; +import forestry.api.circuits.ICircuitLibrary; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.WorldSavedData; -import forestry.api.circuits.ICircuitLibrary; - public class CircuitLibrary extends WorldSavedData implements ICircuitLibrary { public CircuitLibrary(String par1Str) { diff --git a/src/main/java/forestry/core/circuits/CircuitRegistry.java b/src/main/java/forestry/core/circuits/CircuitRegistry.java index 3d316449f..00f496615 100755 --- a/src/main/java/forestry/core/circuits/CircuitRegistry.java +++ b/src/main/java/forestry/core/circuits/CircuitRegistry.java @@ -10,20 +10,18 @@ ******************************************************************************/ package forestry.core.circuits; -import java.util.HashMap; -import java.util.LinkedHashMap; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; import forestry.api.circuits.ICircuitLibrary; import forestry.api.circuits.ICircuitRegistry; import forestry.core.config.ForestryItem; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class CircuitRegistry implements ICircuitRegistry { diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index 5c4555a28..43845eaa0 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.core.circuits; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.circuits.ICircuitLayout; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; import forestry.core.gui.ContainerItemInventory; @@ -25,6 +19,11 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ContainerSolderingIron extends ContainerItemInventory implements IGuiSelectable { diff --git a/src/main/java/forestry/core/circuits/GuiSolderingIron.java b/src/main/java/forestry/core/circuits/GuiSolderingIron.java index 5f47254c2..68ed4d15a 100755 --- a/src/main/java/forestry/core/circuits/GuiSolderingIron.java +++ b/src/main/java/forestry/core/circuits/GuiSolderingIron.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.core.circuits; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; - import forestry.api.circuits.ICircuitLayout; import forestry.core.circuits.ItemSolderingIron.CircuitRecipe; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; @@ -22,6 +18,9 @@ import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; public class GuiSolderingIron extends GuiForestry { diff --git a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java index 626d549a0..22999f920 100755 --- a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java +++ b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java @@ -10,21 +10,19 @@ ******************************************************************************/ package forestry.core.circuits; -import java.util.List; -import java.util.Locale; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitLayout; import forestry.core.config.ForestryItem; import forestry.core.items.ItemForestryMultiPass; +import java.util.List; +import java.util.Locale; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class ItemCircuitBoard extends ItemForestryMultiPass { diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index b93e219e7..5fb8c6f61 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -10,14 +10,6 @@ ******************************************************************************/ package forestry.core.circuits; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitLayout; @@ -31,6 +23,12 @@ import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.RevolvingList; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemSolderingIron extends ItemForestry implements ISolderingIron { diff --git a/src/main/java/forestry/core/commands/CommandHelpers.java b/src/main/java/forestry/core/commands/CommandHelpers.java index 71d440ca3..f2f5100fa 100644 --- a/src/main/java/forestry/core/commands/CommandHelpers.java +++ b/src/main/java/forestry/core/commands/CommandHelpers.java @@ -11,6 +11,9 @@ package forestry.core.commands; import forestry.core.utils.StringUtil; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; @@ -22,10 +25,6 @@ import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * * @author CovertJaguar diff --git a/src/main/java/forestry/core/commands/CommandModeInfo.java b/src/main/java/forestry/core/commands/CommandModeInfo.java index 419e5cd09..62b3ce7dc 100644 --- a/src/main/java/forestry/core/commands/CommandModeInfo.java +++ b/src/main/java/forestry/core/commands/CommandModeInfo.java @@ -11,12 +11,10 @@ package forestry.core.commands; import java.util.List; - import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; - import org.apache.commons.lang3.StringUtils; public class CommandModeInfo extends SubCommand { diff --git a/src/main/java/forestry/core/commands/CommandModeSet.java b/src/main/java/forestry/core/commands/CommandModeSet.java index 1fd50ba9d..c7071d405 100644 --- a/src/main/java/forestry/core/commands/CommandModeSet.java +++ b/src/main/java/forestry/core/commands/CommandModeSet.java @@ -11,7 +11,6 @@ package forestry.core.commands; import java.util.List; - import net.minecraft.command.ICommandSender; import net.minecraft.world.World; diff --git a/src/main/java/forestry/core/commands/CommandSaveStats.java b/src/main/java/forestry/core/commands/CommandSaveStats.java index 658d15086..7c0d457d0 100644 --- a/src/main/java/forestry/core/commands/CommandSaveStats.java +++ b/src/main/java/forestry/core/commands/CommandSaveStats.java @@ -10,6 +10,13 @@ ******************************************************************************/ package forestry.core.commands; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.core.config.Defaults; +import forestry.core.config.Version; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -21,20 +28,11 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Locale; - import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IBreedingTracker; -import forestry.core.config.Defaults; -import forestry.core.config.Version; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; - public final class CommandSaveStats extends SubCommand { private static final String discoveredSymbol; diff --git a/src/main/java/forestry/core/commands/CommandVersion.java b/src/main/java/forestry/core/commands/CommandVersion.java index 045aaf84d..feee964df 100644 --- a/src/main/java/forestry/core/commands/CommandVersion.java +++ b/src/main/java/forestry/core/commands/CommandVersion.java @@ -10,9 +10,9 @@ ******************************************************************************/ package forestry.core.commands; -import net.minecraft.command.ICommandSender; import forestry.core.config.Version; import forestry.core.proxy.Proxies; +import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatStyle; import net.minecraft.util.EnumChatFormatting; diff --git a/src/main/java/forestry/core/commands/IStatsSaveHelper.java b/src/main/java/forestry/core/commands/IStatsSaveHelper.java index 51ab4d130..8a671b739 100644 --- a/src/main/java/forestry/core/commands/IStatsSaveHelper.java +++ b/src/main/java/forestry/core/commands/IStatsSaveHelper.java @@ -10,14 +10,11 @@ ******************************************************************************/ package forestry.core.commands; -import java.util.Collection; - -import net.minecraft.world.World; - +import com.mojang.authlib.GameProfile; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; - -import com.mojang.authlib.GameProfile; +import java.util.Collection; +import net.minecraft.world.World; public interface IStatsSaveHelper { diff --git a/src/main/java/forestry/core/commands/TemplateNotFoundException.java b/src/main/java/forestry/core/commands/TemplateNotFoundException.java index 06da28fc5..a8a6cea35 100644 --- a/src/main/java/forestry/core/commands/TemplateNotFoundException.java +++ b/src/main/java/forestry/core/commands/TemplateNotFoundException.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.commands; -import net.minecraft.command.CommandException; - import forestry.api.genetics.IAlleleSpecies; +import net.minecraft.command.CommandException; public class TemplateNotFoundException extends CommandException { diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 52b01dc0f..34ccbeb14 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -11,7 +11,6 @@ package forestry.core.config; import forestry.core.proxy.Proxies; - import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index 2f6eabbc9..4c6f105b2 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -11,8 +11,6 @@ package forestry.core.config; import forestry.core.proxy.Proxies; -import net.minecraftforge.common.config.Configuration.UnicodeInputStreamReader; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -24,6 +22,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import net.minecraftforge.common.config.Configuration.UnicodeInputStreamReader; public class Configuration { diff --git a/src/main/java/forestry/core/config/Defaults.java b/src/main/java/forestry/core/config/Defaults.java index 97122bd75..2cfad766a 100755 --- a/src/main/java/forestry/core/config/Defaults.java +++ b/src/main/java/forestry/core/config/Defaults.java @@ -11,7 +11,6 @@ package forestry.core.config; import java.util.Locale; - import net.minecraftforge.oredict.OreDictionary; public class Defaults { diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index eb8838dae..46465d42c 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core.config; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; import forestry.plugins.PluginManager.Stage; import java.util.EnumSet; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; /** diff --git a/src/main/java/forestry/core/config/Version.java b/src/main/java/forestry/core/config/Version.java index 0d675b126..464813d01 100755 --- a/src/main/java/forestry/core/config/Version.java +++ b/src/main/java/forestry/core/config/Version.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.core.config; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import forestry.Forestry; +import forestry.core.proxy.Proxies; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.versioning.DefaultArtifactVersion; - -import forestry.Forestry; -import forestry.core.proxy.Proxies; - /** * With permission from pahimar. * diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 593ed4d4d..6320b5979 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.core.fluids; +import forestry.core.fluids.tanks.StandardTank; +import forestry.core.inventory.InvTools; +import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.entity.player.EntityPlayer; @@ -18,7 +21,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -29,10 +31,6 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -import forestry.core.fluids.tanks.StandardTank; -import forestry.core.inventory.InvTools; -import forestry.core.utils.StackUtils; - /** * * @author CovertJaguar diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 46e294f8f..12040b03a 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.core.fluids; +import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; import java.util.Locale; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import forestry.core.render.TextureManager; - /** * * @author CovertJaguar diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index 65b8c7357..85b348684 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -11,28 +11,6 @@ package forestry.core.fluids; import com.google.common.collect.ForwardingList; - -import java.io.DataInputStream; -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.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - import forestry.core.fluids.tanks.FakeTank; import forestry.core.fluids.tanks.StandardTank; import forestry.core.inventory.ITileFilter; @@ -40,6 +18,24 @@ 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; +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.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; /** * diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index 18c67dbce..5766aa800 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -11,14 +11,14 @@ package forestry.core.fluids.tanks; import forestry.core.gui.tooltips.ToolTipLine; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; 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; /** * diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 48d766f23..a7b4bc486 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -10,9 +10,16 @@ ******************************************************************************/ package forestry.core.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.fluids.FluidHelper; +import forestry.core.interfaces.IOwnable; +import forestry.core.items.ItemNBTTile; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; +import forestry.core.utils.Utils; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -26,21 +33,10 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.fluids.FluidHelper; -import forestry.core.interfaces.IOwnable; -import forestry.core.items.ItemNBTTile; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; -import forestry.core.utils.Utils; - public class BlockBase extends BlockForestry { private final List definitions = new ArrayList(); diff --git a/src/main/java/forestry/core/gadgets/BlockForestry.java b/src/main/java/forestry/core/gadgets/BlockForestry.java index 5c9fab2e3..1ddf1c8dc 100755 --- a/src/main/java/forestry/core/gadgets/BlockForestry.java +++ b/src/main/java/forestry/core/gadgets/BlockForestry.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.core.gadgets; +import forestry.core.CreativeTabForestry; +import forestry.core.interfaces.IOwnable; +import forestry.core.proxy.Proxies; +import forestry.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -19,11 +23,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import forestry.core.CreativeTabForestry; -import forestry.core.interfaces.IOwnable; -import forestry.core.proxy.Proxies; -import forestry.core.utils.Utils; - public abstract class BlockForestry extends BlockContainer { public BlockForestry(Material material) { diff --git a/src/main/java/forestry/core/gadgets/BlockResource.java b/src/main/java/forestry/core/gadgets/BlockResource.java index 66fd7b3ff..cf9ef65e3 100755 --- a/src/main/java/forestry/core/gadgets/BlockResource.java +++ b/src/main/java/forestry/core/gadgets/BlockResource.java @@ -10,9 +10,13 @@ ******************************************************************************/ package forestry.core.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -23,13 +27,6 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.CreativeTabForestry; -import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; - public class BlockResource extends Block { public BlockResource() { super(Material.rock); diff --git a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java index bd0a97c4d..816a34681 100644 --- a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java +++ b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java @@ -1,7 +1,10 @@ package forestry.core.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.render.TextureManager; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -9,10 +12,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.render.TextureManager; public class BlockResourceStorageBlock extends Block { diff --git a/src/main/java/forestry/core/gadgets/BlockSoil.java b/src/main/java/forestry/core/gadgets/BlockSoil.java index 08d67af41..6f1740e42 100755 --- a/src/main/java/forestry/core/gadgets/BlockSoil.java +++ b/src/main/java/forestry/core/gadgets/BlockSoil.java @@ -10,11 +10,18 @@ ******************************************************************************/ package forestry.core.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.IItemTyped; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; import java.util.ArrayList; import java.util.List; import java.util.Random; - -import forestry.core.IItemTyped; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -25,21 +32,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; -import forestry.core.CreativeTabForestry; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; - /** * Humus, bog earth, peat */ diff --git a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java index ff4e31e05..2cd12a511 100755 --- a/src/main/java/forestry/core/gadgets/BlockStainedGlass.java +++ b/src/main/java/forestry/core/gadgets/BlockStainedGlass.java @@ -10,9 +10,12 @@ ******************************************************************************/ package forestry.core.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.render.TextureManager; import java.util.List; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockBreakable; import net.minecraft.block.material.Material; @@ -23,12 +26,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.CreativeTabForestry; -import forestry.core.render.TextureManager; - public class BlockStainedGlass extends BlockBreakable { public BlockStainedGlass() { diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index a26f5b69f..268f71697 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.core.gadgets; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.world.World; import forestry.api.core.ITileStructure; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; public abstract class BlockStructure extends BlockForestry { diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index b64929df5..8c48940d4 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -11,6 +11,11 @@ package forestry.core.gadgets; import cofh.api.energy.IEnergyConnection; +import forestry.core.TemperatureState; +import forestry.core.config.Defaults; +import forestry.core.network.PacketPayload; +import forestry.core.utils.BlockUtil; +import forestry.energy.EnergyManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -19,11 +24,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import forestry.core.TemperatureState; -import forestry.core.config.Defaults; -import forestry.core.network.PacketPayload; -import forestry.core.utils.BlockUtil; -import forestry.energy.EnergyManager; public abstract class Engine extends TileBase implements IEnergyConnection { diff --git a/src/main/java/forestry/core/gadgets/MachineDefinition.java b/src/main/java/forestry/core/gadgets/MachineDefinition.java index 99a644b1f..de0c5a9a7 100755 --- a/src/main/java/forestry/core/gadgets/MachineDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineDefinition.java @@ -16,6 +16,9 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.core.interfaces.IBlockRenderer; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -30,10 +33,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - /** * This will replace the whole {@link Gadget}-nonsense at some point, using the proper Forge hook. Will hopefully sort out any issues with interfaces. */ diff --git a/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java b/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java index a0dbf916b..338a8a3e9 100755 --- a/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineNBTDefinition.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.core.gadgets; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -17,11 +21,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; - public class MachineNBTDefinition extends MachineDefinition { public MachineNBTDefinition(int meta, String teIdent, Class teClass, IRecipe... recipes) { diff --git a/src/main/java/forestry/core/gadgets/NaturalistGame.java b/src/main/java/forestry/core/gadgets/NaturalistGame.java index e55f3d5b0..399c041d5 100755 --- a/src/main/java/forestry/core/gadgets/NaturalistGame.java +++ b/src/main/java/forestry/core/gadgets/NaturalistGame.java @@ -10,21 +10,19 @@ ******************************************************************************/ package forestry.core.gadgets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Random; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - import forestry.api.core.INBTTagable; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.api.genetics.ISpeciesRoot; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Random; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; public class NaturalistGame implements INBTTagable { diff --git a/src/main/java/forestry/core/gadgets/StructureLogic.java b/src/main/java/forestry/core/gadgets/StructureLogic.java index 4180424e7..bf7ec925d 100755 --- a/src/main/java/forestry/core/gadgets/StructureLogic.java +++ b/src/main/java/forestry/core/gadgets/StructureLogic.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.core.gadgets; -import java.util.HashMap; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - import forestry.api.core.IStructureLogic; import forestry.api.core.ITileStructure; import forestry.core.config.Defaults; @@ -22,6 +17,9 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.utils.Vect; +import java.util.HashMap; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; public abstract class StructureLogic implements IStructureLogic { diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 762880da6..9dde8f4f6 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -10,26 +10,10 @@ ******************************************************************************/ package forestry.core.gadgets; -import java.util.Stack; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; +import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.FluidHelper; @@ -43,6 +27,19 @@ import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; +import java.util.Stack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer { diff --git a/src/main/java/forestry/core/gadgets/TileBase.java b/src/main/java/forestry/core/gadgets/TileBase.java index c4d9982f5..33f9e9e8e 100755 --- a/src/main/java/forestry/core/gadgets/TileBase.java +++ b/src/main/java/forestry/core/gadgets/TileBase.java @@ -10,14 +10,10 @@ ******************************************************************************/ package forestry.core.gadgets; -import net.minecraft.entity.player.EntityPlayer; - import forestry.core.interfaces.IHintSource; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumAccess; -import forestry.core.utils.PlayerUtil; -import forestry.core.utils.Utils; +import net.minecraft.entity.player.EntityPlayer; public abstract class TileBase extends TileForestry implements IHintSource { diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 047f0c9c2..4a94eec1d 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -10,18 +10,13 @@ ******************************************************************************/ package forestry.core.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - import com.mojang.authlib.GameProfile; - import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.IRenderableMachine; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.ForestryPacket; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -29,8 +24,11 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class TileEscritoire extends TileBase implements ISidedInventory, IRenderableMachine, ICrafter { diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 4ee898b19..2f3452031 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -21,15 +21,16 @@ import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IOwnable; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.ForestryPacket; import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketPayload; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Vect; +import java.util.Collection; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -41,8 +42,6 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; - @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") public abstract class TileForestry extends TileEntity implements INetworkedEntity, IOwnable, IErrorSource, ITriggerProvider { diff --git a/src/main/java/forestry/core/gadgets/TileMachine.java b/src/main/java/forestry/core/gadgets/TileMachine.java index 532cfc120..55d6f212a 100755 --- a/src/main/java/forestry/core/gadgets/TileMachine.java +++ b/src/main/java/forestry/core/gadgets/TileMachine.java @@ -24,13 +24,12 @@ import forestry.plugins.PluginEnergy; import forestry.plugins.PluginFactory; import forestry.plugins.PluginIC2; import forestry.plugins.PluginMail; +import java.util.HashMap; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import java.util.HashMap; - public abstract class TileMachine extends TileForestry implements IClimatised, IHintSource { public TileMachine() { diff --git a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java index e3ea31c2c..cec96a706 100755 --- a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java +++ b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.core.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - import forestry.api.core.ForestryAPI; import forestry.api.genetics.ISpeciesRoot; import forestry.core.GuiHandler; import forestry.core.config.Config; import forestry.core.gui.IPagedInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; public abstract class TileNaturalistChest extends TileBase implements IInventory, IPagedInventory { diff --git a/src/main/java/forestry/core/gadgets/TilePowered.java b/src/main/java/forestry/core/gadgets/TilePowered.java index b62b23fb6..587725271 100644 --- a/src/main/java/forestry/core/gadgets/TilePowered.java +++ b/src/main/java/forestry/core/gadgets/TilePowered.java @@ -10,19 +10,15 @@ ******************************************************************************/ package forestry.core.gadgets; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.common.util.ForgeDirection; - +import buildcraft.api.tiles.IHasWork; import cpw.mods.fml.common.Optional; - import forestry.core.interfaces.IPowerHandler; import forestry.core.interfaces.IRenderableMachine; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.energy.EnergyManager; - -import buildcraft.api.tiles.IHasWork; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; @Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork { diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index e36f76e85..b652ae3ac 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.EnumSet; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAllele; import forestry.api.genetics.ILegacyHandler; import forestry.core.config.Defaults; import forestry.core.utils.StringUtil; +import java.util.EnumSet; +import net.minecraftforge.common.EnumPlantType; public class Allele implements IAllele { diff --git a/src/main/java/forestry/core/genetics/AllelePlantType.java b/src/main/java/forestry/core/genetics/AllelePlantType.java index 756f9737c..25c1be1cf 100755 --- a/src/main/java/forestry/core/genetics/AllelePlantType.java +++ b/src/main/java/forestry/core/genetics/AllelePlantType.java @@ -10,11 +10,9 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.EnumSet; - -import net.minecraftforge.common.EnumPlantType; - import forestry.api.genetics.IAllelePlantType; +import java.util.EnumSet; +import net.minecraftforge.common.EnumPlantType; public class AllelePlantType extends Allele implements IAllelePlantType { diff --git a/src/main/java/forestry/core/genetics/AlleleRegistry.java b/src/main/java/forestry/core/genetics/AlleleRegistry.java index 3b3f8588c..fa390ba02 100755 --- a/src/main/java/forestry/core/genetics/AlleleRegistry.java +++ b/src/main/java/forestry/core/genetics/AlleleRegistry.java @@ -10,18 +10,7 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; - -import net.minecraft.item.ItemStack; - import com.mojang.authlib.GameProfile; - import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleHandler; import forestry.api.genetics.IAlleleRegistry; @@ -35,6 +24,14 @@ import forestry.api.genetics.IMutation; import forestry.api.genetics.ISpeciesRoot; import forestry.core.config.ForestryItem; import forestry.core.genetics.ItemResearchNote.EnumNoteType; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import net.minecraft.item.ItemStack; public class AlleleRegistry implements IAlleleRegistry, ILegacyHandler { diff --git a/src/main/java/forestry/core/genetics/AlleleSpecies.java b/src/main/java/forestry/core/genetics/AlleleSpecies.java index a387ecc31..c993de517 100755 --- a/src/main/java/forestry/core/genetics/AlleleSpecies.java +++ b/src/main/java/forestry/core/genetics/AlleleSpecies.java @@ -24,11 +24,10 @@ import forestry.api.genetics.IMutation; import forestry.core.config.ForestryItem; import forestry.core.utils.StackUtils; import forestry.core.utils.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import java.util.Collection; import java.util.Map; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public abstract class AlleleSpecies extends Allele implements IAlleleSpecies { diff --git a/src/main/java/forestry/core/genetics/AlleleTolerance.java b/src/main/java/forestry/core/genetics/AlleleTolerance.java index e046cc4d6..0a13075d9 100755 --- a/src/main/java/forestry/core/genetics/AlleleTolerance.java +++ b/src/main/java/forestry/core/genetics/AlleleTolerance.java @@ -12,7 +12,6 @@ package forestry.core.genetics; import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IAlleleTolerance; -import forestry.core.utils.StringUtil; public class AlleleTolerance extends Allele implements IAlleleTolerance { diff --git a/src/main/java/forestry/core/genetics/BreedingTracker.java b/src/main/java/forestry/core/genetics/BreedingTracker.java index b3b1d8c1d..90b3f71a9 100755 --- a/src/main/java/forestry/core/genetics/BreedingTracker.java +++ b/src/main/java/forestry/core/genetics/BreedingTracker.java @@ -10,16 +10,7 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.WorldSavedData; - -import net.minecraftforge.common.MinecraftForge; - import com.mojang.authlib.GameProfile; - import forestry.api.core.ForestryEvent; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; @@ -29,6 +20,11 @@ import forestry.api.genetics.IMutation; import forestry.core.network.PacketIds; import forestry.core.network.PacketNBT; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldSavedData; +import net.minecraftforge.common.MinecraftForge; public abstract class BreedingTracker extends WorldSavedData implements IBreedingTracker { diff --git a/src/main/java/forestry/core/genetics/Chromosome.java b/src/main/java/forestry/core/genetics/Chromosome.java index 36e9253ec..4b4a4e0f4 100755 --- a/src/main/java/forestry/core/genetics/Chromosome.java +++ b/src/main/java/forestry/core/genetics/Chromosome.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.Random; - -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosome; import forestry.api.genetics.ILegacyHandler; +import java.util.Random; +import net.minecraft.nbt.NBTTagCompound; public class Chromosome implements IChromosome { diff --git a/src/main/java/forestry/core/genetics/Classification.java b/src/main/java/forestry/core/genetics/Classification.java index 1641cbe72..9120725f9 100755 --- a/src/main/java/forestry/core/genetics/Classification.java +++ b/src/main/java/forestry/core/genetics/Classification.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.ArrayList; -import java.util.Locale; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IClassification; import forestry.core.utils.StringUtil; +import java.util.ArrayList; +import java.util.Locale; public class Classification implements IClassification { diff --git a/src/main/java/forestry/core/genetics/ClimateHelper.java b/src/main/java/forestry/core/genetics/ClimateHelper.java index b0cc7384d..27e0f425c 100755 --- a/src/main/java/forestry/core/genetics/ClimateHelper.java +++ b/src/main/java/forestry/core/genetics/ClimateHelper.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.ArrayList; -import java.util.Locale; - import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IClimateHelper; import forestry.core.utils.StringUtil; +import java.util.ArrayList; +import java.util.Locale; public class ClimateHelper implements IClimateHelper { diff --git a/src/main/java/forestry/core/genetics/EffectData.java b/src/main/java/forestry/core/genetics/EffectData.java index 075199735..70d7feda2 100755 --- a/src/main/java/forestry/core/genetics/EffectData.java +++ b/src/main/java/forestry/core/genetics/EffectData.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.genetics; -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.genetics.IEffectData; +import net.minecraft.nbt.NBTTagCompound; public class EffectData implements IEffectData { diff --git a/src/main/java/forestry/core/genetics/Individual.java b/src/main/java/forestry/core/genetics/Individual.java index bb03a385f..70c86e9f7 100755 --- a/src/main/java/forestry/core/genetics/Individual.java +++ b/src/main/java/forestry/core/genetics/Individual.java @@ -11,9 +11,8 @@ package forestry.core.genetics; import forestry.api.genetics.IChromosomeType; -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.genetics.IIndividual; +import net.minecraft.nbt.NBTTagCompound; public abstract class Individual implements IIndividual { diff --git a/src/main/java/forestry/core/genetics/IndividualLiving.java b/src/main/java/forestry/core/genetics/IndividualLiving.java index b48058f9d..9781aa5db 100755 --- a/src/main/java/forestry/core/genetics/IndividualLiving.java +++ b/src/main/java/forestry/core/genetics/IndividualLiving.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.genetics; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividualLiving; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public abstract class IndividualLiving extends Individual implements IIndividualLiving { diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index 0d3395dc0..669763d7e 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.core.genetics; -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IIndividual; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public abstract class ItemGE extends Item { diff --git a/src/main/java/forestry/core/genetics/ItemResearchNote.java b/src/main/java/forestry/core/genetics/ItemResearchNote.java index 0025a41ef..38eeb9256 100755 --- a/src/main/java/forestry/core/genetics/ItemResearchNote.java +++ b/src/main/java/forestry/core/genetics/ItemResearchNote.java @@ -10,12 +10,21 @@ ******************************************************************************/ package forestry.core.genetics; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; +import forestry.core.items.ItemForestry; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; import java.util.ArrayList; -import java.util.IllegalFormatException; import java.util.List; import java.util.Locale; - -import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -25,23 +34,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import com.mojang.authlib.GameProfile; - -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IBreedingTracker; -import forestry.api.genetics.IMutation; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.items.ItemForestry; -import forestry.core.proxy.Proxies; - public class ItemResearchNote extends ItemForestry { public static enum EnumNoteType { diff --git a/src/main/java/forestry/core/genetics/Mutation.java b/src/main/java/forestry/core/genetics/Mutation.java index 41cfc1ffa..031e8aabf 100755 --- a/src/main/java/forestry/core/genetics/Mutation.java +++ b/src/main/java/forestry/core/genetics/Mutation.java @@ -11,13 +11,12 @@ package forestry.core.genetics; -import java.util.ArrayList; -import java.util.Collection; - import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IAllele; import forestry.api.genetics.IMutation; +import java.util.ArrayList; +import java.util.Collection; public abstract class Mutation implements IMutation { diff --git a/src/main/java/forestry/core/genetics/SpeciesRoot.java b/src/main/java/forestry/core/genetics/SpeciesRoot.java index 62c5ce923..1db63e276 100755 --- a/src/main/java/forestry/core/genetics/SpeciesRoot.java +++ b/src/main/java/forestry/core/genetics/SpeciesRoot.java @@ -15,8 +15,6 @@ import forestry.api.genetics.IChromosome; import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IMutation; import forestry.api.genetics.ISpeciesRoot; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -24,6 +22,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; +import net.minecraft.item.ItemStack; public abstract class SpeciesRoot implements ISpeciesRoot { diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index eddc05d5f..360a13805 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -1,9 +1,8 @@ package forestry.core.gui; import forestry.core.gui.slots.SlotCustom; -import forestry.core.proxy.Proxies; import forestry.core.inventory.AlyzerInventory; - +import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index b6cfbd5f2..43c99f5ee 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -12,14 +12,13 @@ package forestry.core.gui; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import forestry.core.gadgets.TileAnalyzer; import forestry.core.genetics.ItemGE; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerAnalyzer extends ContainerLiquidTanks { diff --git a/src/main/java/forestry/core/gui/ContainerEscritoire.java b/src/main/java/forestry/core/gui/ContainerEscritoire.java index cb279ddc9..11ae103ac 100755 --- a/src/main/java/forestry/core/gui/ContainerEscritoire.java +++ b/src/main/java/forestry/core/gui/ContainerEscritoire.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.Slot; - import forestry.api.genetics.AlleleManager; import forestry.core.gadgets.TileEscritoire; import forestry.core.gui.slots.SlotClosed; @@ -25,6 +18,11 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Slot; public class ContainerEscritoire extends ContainerForestry implements IGuiSelectable { diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index 755b88708..0cee5c7c5 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.core.gui; +import forestry.core.gui.slots.SlotItemInventory; +import forestry.core.gui.slots.SlotLocked; +import forestry.core.inventory.ItemInventory; +import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import forestry.core.gui.slots.SlotItemInventory; -import forestry.core.gui.slots.SlotLocked; -import forestry.core.proxy.Proxies; -import forestry.core.inventory.ItemInventory; - public abstract class ContainerItemInventory extends ContainerForestry { protected final EntityPlayer player; diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 1def8b1f0..0c8cc1b09 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -10,14 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - import forestry.api.core.IToolPipette; import forestry.core.fluids.tanks.StandardTank; import forestry.core.interfaces.ILiquidTankContainer; @@ -25,6 +17,12 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public class ContainerLiquidTanks extends ContainerForestry { diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index 156ba3b65..0eaa91cac 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import forestry.api.genetics.ISpeciesRoot; import forestry.core.gui.slots.SlotCustom; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class ContainerNaturalistInventory extends ContainerForestry implements IGuiSelectable { diff --git a/src/main/java/forestry/core/gui/ContainerSocketed.java b/src/main/java/forestry/core/gui/ContainerSocketed.java index 9489911a7..90ad17791 100755 --- a/src/main/java/forestry/core/gui/ContainerSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerSocketed.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - import forestry.core.interfaces.ISocketable; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; @@ -22,6 +17,10 @@ import forestry.core.network.PacketSocketUpdate; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class ContainerSocketed extends ContainerForestry { diff --git a/src/main/java/forestry/core/gui/ErrorLedger.java b/src/main/java/forestry/core/gui/ErrorLedger.java index 7ea4c454b..9e5fda8e8 100755 --- a/src/main/java/forestry/core/gui/ErrorLedger.java +++ b/src/main/java/forestry/core/gui/ErrorLedger.java @@ -10,8 +10,8 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.core.EnumErrorCode; import forestry.api.core.IErrorState; +import forestry.core.EnumErrorCode; import forestry.core.interfaces.IErrorSource; import forestry.core.utils.StringUtil; diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index 10d3fa55b..d7bfc4090 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -28,6 +28,10 @@ import forestry.core.gadgets.TileForestry; import forestry.core.genetics.EnumMutateChance; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Stack; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -35,11 +39,6 @@ import net.minecraft.item.ItemStack; import org.apache.commons.lang3.StringUtils; import org.lwjgl.opengl.GL11; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Stack; - public abstract class GuiAlyzer extends GuiForestry { protected static final int COLUMN_0 = 12; diff --git a/src/main/java/forestry/core/gui/GuiAnalyzer.java b/src/main/java/forestry/core/gui/GuiAnalyzer.java index f03f2b9d4..6211b4639 100755 --- a/src/main/java/forestry/core/gui/GuiAnalyzer.java +++ b/src/main/java/forestry/core/gui/GuiAnalyzer.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gadgets.TileAnalyzer; import forestry.core.gui.widgets.TankWidget; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; +import net.minecraft.entity.player.InventoryPlayer; public class GuiAnalyzer extends GuiForestryTitled { diff --git a/src/main/java/forestry/core/gui/GuiEscritoire.java b/src/main/java/forestry/core/gui/GuiEscritoire.java index 515e56643..ec3b69252 100755 --- a/src/main/java/forestry/core/gui/GuiEscritoire.java +++ b/src/main/java/forestry/core/gui/GuiEscritoire.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - import forestry.core.config.Defaults; import forestry.core.gadgets.NaturalistGame; import forestry.core.gadgets.NaturalistGame.GameToken; @@ -26,6 +19,11 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; public class GuiEscritoire extends GuiForestry { diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index dd55ed8ac..7f4e0dffb 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -16,7 +16,6 @@ import codechicken.nei.api.TaggedInventoryArea; import cpw.mods.fml.common.Optional; import forestry.core.config.Config; import forestry.core.gadgets.TileForestry; -import forestry.core.gui.slots.SlotForestry; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; import forestry.core.gui.tooltips.ToolTipLine; @@ -28,6 +27,9 @@ import forestry.core.interfaces.IOwnable; import forestry.core.interfaces.IPowerHandler; import forestry.core.proxy.Proxies; import forestry.core.utils.FontColour; +import java.awt.Color; +import java.util.Collection; +import java.util.List; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; @@ -41,10 +43,6 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.awt.Color; -import java.util.Collection; -import java.util.List; - @Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") public abstract class GuiForestry extends GuiContainer implements INEIGuiHandler { diff --git a/src/main/java/forestry/core/gui/GuiForestryTitled.java b/src/main/java/forestry/core/gui/GuiForestryTitled.java index d09b4ec30..f4550559b 100644 --- a/src/main/java/forestry/core/gui/GuiForestryTitled.java +++ b/src/main/java/forestry/core/gui/GuiForestryTitled.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.util.ResourceLocation; - import forestry.core.gadgets.TileForestry; import forestry.core.utils.StringUtil; +import net.minecraft.util.ResourceLocation; public abstract class GuiForestryTitled extends GuiForestry { diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index 9f94c4f2e..643c2d80c 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -10,16 +10,8 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.HashMap; - -import forestry.api.arboriculture.EnumTreeChromosome; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import forestry.api.apiculture.IApiaristTracker; +import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; @@ -35,6 +27,12 @@ import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import java.util.HashMap; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class GuiNaturalistInventory extends GuiForestry { private final ISpeciesRoot speciesRoot; diff --git a/src/main/java/forestry/core/gui/GuiTextBox.java b/src/main/java/forestry/core/gui/GuiTextBox.java index 48a92b981..174330634 100755 --- a/src/main/java/forestry/core/gui/GuiTextBox.java +++ b/src/main/java/forestry/core/gui/GuiTextBox.java @@ -10,9 +10,7 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.Iterator; import java.util.List; - import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; diff --git a/src/main/java/forestry/core/gui/HintLedger.java b/src/main/java/forestry/core/gui/HintLedger.java index 61a2f4141..710ebde32 100755 --- a/src/main/java/forestry/core/gui/HintLedger.java +++ b/src/main/java/forestry/core/gui/HintLedger.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.Random; - import forestry.core.interfaces.IHintSource; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import java.util.Random; public class HintLedger extends Ledger { diff --git a/src/main/java/forestry/core/gui/IGuiSelectable.java b/src/main/java/forestry/core/gui/IGuiSelectable.java index f1e6349c2..d231aba5d 100755 --- a/src/main/java/forestry/core/gui/IGuiSelectable.java +++ b/src/main/java/forestry/core/gui/IGuiSelectable.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.entity.player.EntityPlayer; - import forestry.core.network.PacketUpdate; +import net.minecraft.entity.player.EntityPlayer; public interface IGuiSelectable { void handleSelectionChange(EntityPlayer player, PacketUpdate packet); diff --git a/src/main/java/forestry/core/gui/Ledger.java b/src/main/java/forestry/core/gui/Ledger.java index c011ee618..8621d3f4f 100755 --- a/src/main/java/forestry/core/gui/Ledger.java +++ b/src/main/java/forestry/core/gui/Ledger.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.core.gui; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - import forestry.core.config.Defaults; import forestry.core.config.SessionVars; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.utils.ForestryResource; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; /** * Side ledger for guis diff --git a/src/main/java/forestry/core/gui/LedgerManager.java b/src/main/java/forestry/core/gui/LedgerManager.java index 69aa3353c..53f9d9f78 100755 --- a/src/main/java/forestry/core/gui/LedgerManager.java +++ b/src/main/java/forestry/core/gui/LedgerManager.java @@ -10,15 +10,12 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.ArrayList; - -import net.minecraft.client.Minecraft; - -import org.lwjgl.opengl.GL11; - import forestry.core.config.SessionVars; import forestry.core.gadgets.TileForestry; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL11; public class LedgerManager { diff --git a/src/main/java/forestry/core/gui/OwnerLedger.java b/src/main/java/forestry/core/gui/OwnerLedger.java index 0fa6803b4..e501a585a 100755 --- a/src/main/java/forestry/core/gui/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/OwnerLedger.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.Locale; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; import forestry.core.interfaces.IOwnable; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; @@ -21,6 +17,9 @@ import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.EnumAccess; import forestry.core.utils.StringUtil; +import java.util.Locale; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; /** * Ledger displaying ownership information diff --git a/src/main/java/forestry/core/gui/WidgetManager.java b/src/main/java/forestry/core/gui/WidgetManager.java index f96f66a4b..38cc516be 100755 --- a/src/main/java/forestry/core/gui/WidgetManager.java +++ b/src/main/java/forestry/core/gui/WidgetManager.java @@ -10,15 +10,12 @@ ******************************************************************************/ package forestry.core.gui; -import java.util.ArrayList; - -import net.minecraft.client.Minecraft; - -import org.lwjgl.opengl.GL11; - import forestry.core.gadgets.TileForestry; import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL11; public class WidgetManager { diff --git a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java index 4a3fa0782..a21c8887a 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiBetterButton.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.core.gui.buttons; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.config.Defaults; +import forestry.core.gui.tooltips.IToolTipProvider; +import forestry.core.gui.tooltips.ToolTip; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import org.lwjgl.opengl.GL11; -import forestry.core.config.Defaults; -import forestry.core.gui.tooltips.IToolTipProvider; -import forestry.core.gui.tooltips.ToolTip; - @SideOnly(Side.CLIENT) public class GuiBetterButton extends GuiButton implements IToolTipProvider{ diff --git a/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java b/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java index dcadc2621..85873f60f 100755 --- a/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java +++ b/src/main/java/forestry/core/gui/buttons/GuiMultiButton.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.core.gui.buttons; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import forestry.core.gui.tooltips.ToolTip; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import forestry.core.gui.tooltips.ToolTip; - /** * * @author CovertJaguar diff --git a/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java b/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java index 51687ae8c..44f1c9074 100755 --- a/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java +++ b/src/main/java/forestry/core/gui/slots/SlotCraftAuto.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.gui.slots; +import forestry.core.interfaces.IContainerCrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -import forestry.core.interfaces.IContainerCrafting; - /** * Informs the passed container of slot changes. */ diff --git a/src/main/java/forestry/core/gui/slots/SlotForestry.java b/src/main/java/forestry/core/gui/slots/SlotForestry.java index 1171bda30..2c6807e46 100755 --- a/src/main/java/forestry/core/gui/slots/SlotForestry.java +++ b/src/main/java/forestry/core/gui/slots/SlotForestry.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.core.gui.slots; +import forestry.core.gui.tooltips.IToolTipProvider; +import forestry.core.gui.tooltips.ToolTip; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import forestry.core.gui.tooltips.IToolTipProvider; -import forestry.core.gui.tooltips.ToolTip; - public class SlotForestry extends Slot implements IToolTipProvider{ protected boolean isPhantom; diff --git a/src/main/java/forestry/core/gui/slots/SlotItemInventory.java b/src/main/java/forestry/core/gui/slots/SlotItemInventory.java index d2f99fb1b..d4a6e05f1 100755 --- a/src/main/java/forestry/core/gui/slots/SlotItemInventory.java +++ b/src/main/java/forestry/core/gui/slots/SlotItemInventory.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core.gui.slots; +import forestry.core.gui.ContainerItemInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import forestry.core.gui.ContainerItemInventory; - public class SlotItemInventory extends Slot { private final EntityPlayer player; diff --git a/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java b/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java index 2a73c551d..0637d577e 100755 --- a/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java +++ b/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.core.gui.slots; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.core.fluids.FluidHelper; - import forestry.core.render.TextureManager; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraftforge.fluids.Fluid; public class SlotLiquidContainer extends SlotForestry { diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTip.java b/src/main/java/forestry/core/gui/tooltips/ToolTip.java index d254a0ff8..7676e25ea 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTip.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTip.java @@ -10,13 +10,11 @@ ******************************************************************************/ package forestry.core.gui.tooltips; +import com.google.common.collect.ForwardingList; +import forestry.core.utils.StringUtil; import java.util.ArrayList; import java.util.List; -import com.google.common.collect.ForwardingList; - -import forestry.core.utils.StringUtil; - /** * @author CovertJaguar */ diff --git a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java index e10165d82..1660c9a1a 100755 --- a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java +++ b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java @@ -10,15 +10,12 @@ ******************************************************************************/ package forestry.core.gui.widgets; -import net.minecraft.util.IIcon; - -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - import forestry.core.gui.WidgetManager; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; public class ReservoirWidget extends TankWidget { diff --git a/src/main/java/forestry/core/gui/widgets/SocketWidget.java b/src/main/java/forestry/core/gui/widgets/SocketWidget.java index 68d10ad25..f2a98eb9d 100755 --- a/src/main/java/forestry/core/gui/widgets/SocketWidget.java +++ b/src/main/java/forestry/core/gui/widgets/SocketWidget.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.core.gui.widgets; -import java.util.List; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import forestry.core.circuits.ISolderingIron; import forestry.core.circuits.ItemCircuitBoard; import forestry.core.gui.ContainerSocketed; @@ -24,6 +19,9 @@ import forestry.core.gui.tooltips.ToolTip; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; +import java.util.List; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class SocketWidget extends Widget { diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index 67ea39a73..d74db7e4c 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -10,24 +10,20 @@ ******************************************************************************/ 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; - -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - import forestry.api.core.IToolPipette; import forestry.core.fluids.tanks.StandardTank; -import forestry.core.gui.ContainerForestry; import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.WidgetManager; import forestry.core.gui.tooltips.ToolTip; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; +import forestry.farming.gui.ContainerFarm; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; /** * Slot for liquid tanks diff --git a/src/main/java/forestry/core/gui/widgets/Widget.java b/src/main/java/forestry/core/gui/widgets/Widget.java index e0e2e45d6..d9a57c6ab 100755 --- a/src/main/java/forestry/core/gui/widgets/Widget.java +++ b/src/main/java/forestry/core/gui/widgets/Widget.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.gui.widgets; -import net.minecraft.entity.player.EntityPlayer; - import forestry.core.gui.WidgetManager; import forestry.core.gui.tooltips.IToolTipProvider; import forestry.core.gui.tooltips.ToolTip; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; /** * Basic non-ItemStack slot diff --git a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java index f3b410ba7..5dbf7fff5 100755 --- a/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java +++ b/src/main/java/forestry/core/interfaces/ILiquidTankContainer.java @@ -11,7 +11,6 @@ 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; diff --git a/src/main/java/forestry/core/interfaces/IOwnable.java b/src/main/java/forestry/core/interfaces/IOwnable.java index ef87cd4f8..f79c7770a 100755 --- a/src/main/java/forestry/core/interfaces/IOwnable.java +++ b/src/main/java/forestry/core/interfaces/IOwnable.java @@ -10,11 +10,9 @@ ******************************************************************************/ package forestry.core.interfaces; -import net.minecraft.entity.player.EntityPlayer; - import com.mojang.authlib.GameProfile; - import forestry.core.utils.EnumAccess; +import net.minecraft.entity.player.EntityPlayer; public interface IOwnable { diff --git a/src/main/java/forestry/core/interfaces/IPacketHandler.java b/src/main/java/forestry/core/interfaces/IPacketHandler.java index ab17f5b0a..70e7f6efa 100755 --- a/src/main/java/forestry/core/interfaces/IPacketHandler.java +++ b/src/main/java/forestry/core/interfaces/IPacketHandler.java @@ -11,7 +11,6 @@ package forestry.core.interfaces; import java.io.DataInputStream; - import net.minecraft.entity.player.EntityPlayer; public interface IPacketHandler { diff --git a/src/main/java/forestry/core/interfaces/IRenderableMachine.java b/src/main/java/forestry/core/interfaces/IRenderableMachine.java index 6a36d9135..8a9741878 100755 --- a/src/main/java/forestry/core/interfaces/IRenderableMachine.java +++ b/src/main/java/forestry/core/interfaces/IRenderableMachine.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.interfaces; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.core.utils.EnumTankLevel; +import net.minecraftforge.common.util.ForgeDirection; public interface IRenderableMachine { diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index d0c13abf2..582687b48 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -10,28 +10,6 @@ ******************************************************************************/ package forestry.core.inventory; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; - import buildcraft.api.transport.PipeManager; import forestry.api.core.ISpecialInventory; import forestry.core.inventory.filters.ArrayStackFilter; @@ -45,6 +23,25 @@ import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; import forestry.core.utils.PlainInventory; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; public abstract class InvTools { diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index dc35a1fbb..3966f48ce 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.core.inventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; - import forestry.api.core.INBTTagable; import forestry.core.config.Defaults; import forestry.core.utils.PlainInventory; import forestry.core.utils.StackUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; /** * With permission from Krapht. diff --git a/src/main/java/forestry/core/inventory/InventoryConcatenator.java b/src/main/java/forestry/core/inventory/InventoryConcatenator.java index 55c0d31bb..0bdaa174c 100755 --- a/src/main/java/forestry/core/inventory/InventoryConcatenator.java +++ b/src/main/java/forestry/core/inventory/InventoryConcatenator.java @@ -12,7 +12,6 @@ package forestry.core.inventory; import java.util.ArrayList; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/inventory/InventorySorter.java b/src/main/java/forestry/core/inventory/InventorySorter.java index b20aabb8c..f40398ba4 100755 --- a/src/main/java/forestry/core/inventory/InventorySorter.java +++ b/src/main/java/forestry/core/inventory/InventorySorter.java @@ -11,7 +11,6 @@ package forestry.core.inventory; import java.util.Comparator; - import net.minecraft.inventory.IInventory; /** diff --git a/src/main/java/forestry/core/inventory/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java index 99f0425b1..267d099da 100755 --- a/src/main/java/forestry/core/inventory/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.inventory; +import forestry.api.core.INBTTagable; +import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -17,9 +19,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import forestry.api.core.INBTTagable; -import forestry.core.utils.Utils; - public class ItemInventory implements IInventory, INBTTagable { public final Class itemClass; diff --git a/src/main/java/forestry/core/inventory/ItemStackMap.java b/src/main/java/forestry/core/inventory/ItemStackMap.java index 85e18cab6..8fee3212d 100755 --- a/src/main/java/forestry/core/inventory/ItemStackMap.java +++ b/src/main/java/forestry/core/inventory/ItemStackMap.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; - import net.minecraft.item.ItemStack; /** diff --git a/src/main/java/forestry/core/inventory/ItemStackSet.java b/src/main/java/forestry/core/inventory/ItemStackSet.java index af3d35be0..73ea63f82 100755 --- a/src/main/java/forestry/core/inventory/ItemStackSet.java +++ b/src/main/java/forestry/core/inventory/ItemStackSet.java @@ -15,7 +15,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; - import net.minecraft.item.ItemStack; /** diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index 4e225033c..139cab099 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.inventory; -import net.minecraft.entity.player.EntityPlayer; - import forestry.core.gadgets.TileForestry; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Utils; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; public class TileInventoryAdapter extends InventoryAdapter { diff --git a/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java b/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java index 9e9a7fb3a..3b8f166f4 100755 --- a/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java +++ b/src/main/java/forestry/core/inventory/filters/ArrayStackFilter.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.inventory.filters; -import net.minecraft.item.ItemStack; - import forestry.core.inventory.InvTools; +import net.minecraft.item.ItemStack; /** * @author CovertJaguar diff --git a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java index 0b175bfd1..f3651041a 100755 --- a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java +++ b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.core.inventory.manipulators; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -import forestry.api.core.ISpecialInventory; import forestry.core.inventory.InvTools; import forestry.core.inventory.filters.IStackFilter; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; /** * @author CovertJaguar diff --git a/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java b/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java index 653c6b935..f9f4c3a7d 100755 --- a/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java +++ b/src/main/java/forestry/core/inventory/wrappers/InventoryIterator.java @@ -11,7 +11,6 @@ package forestry.core.inventory.wrappers; import java.util.Iterator; - import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java b/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java index a13246998..a5b83e189 100755 --- a/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java +++ b/src/main/java/forestry/core/inventory/wrappers/InventoryMapper.java @@ -13,7 +13,6 @@ package forestry.core.inventory.wrappers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; - import net.minecraftforge.common.util.ForgeDirection; /** diff --git a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java index 71ca7007a..aa823fd2d 100755 --- a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java +++ b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryIterator.java @@ -11,7 +11,6 @@ package forestry.core.inventory.wrappers; import java.util.Iterator; - import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java index 4b3afe28e..dcb013c9e 100755 --- a/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java +++ b/src/main/java/forestry/core/inventory/wrappers/SidedInventoryMapper.java @@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; - import net.minecraftforge.common.util.ForgeDirection; /** diff --git a/src/main/java/forestry/core/items/ItemArmorNaturalist.java b/src/main/java/forestry/core/items/ItemArmorNaturalist.java index b61620889..d533b9e0e 100755 --- a/src/main/java/forestry/core/items/ItemArmorNaturalist.java +++ b/src/main/java/forestry/core/items/ItemArmorNaturalist.java @@ -10,6 +10,13 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.IArmorNaturalist; +import forestry.core.CreativeTabForestry; +import forestry.core.config.Defaults; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -17,15 +24,6 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.IArmorNaturalist; -import forestry.core.CreativeTabForestry; -import forestry.core.config.Defaults; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; - public class ItemArmorNaturalist extends ItemArmor implements IArmorNaturalist { public ItemArmorNaturalist(int slot) { diff --git a/src/main/java/forestry/core/items/ItemAssemblyKit.java b/src/main/java/forestry/core/items/ItemAssemblyKit.java index 803e53ec0..27a74f9b8 100755 --- a/src/main/java/forestry/core/items/ItemAssemblyKit.java +++ b/src/main/java/forestry/core/items/ItemAssemblyKit.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.core.items; +import forestry.core.proxy.Proxies; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import forestry.core.proxy.Proxies; - public class ItemAssemblyKit extends ItemForestry { private final ItemStack assembled; private final boolean motionOnOpen; diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 1a20d8510..3a0650f5b 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -10,8 +10,13 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.recipes.IGenericCrate; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; import java.util.Locale; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -20,14 +25,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.recipes.IGenericCrate; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; - public class ItemCrated extends Item implements IGenericCrate { private ItemStack contained; diff --git a/src/main/java/forestry/core/items/ItemForestry.java b/src/main/java/forestry/core/items/ItemForestry.java index 86720698b..a97d79330 100755 --- a/src/main/java/forestry/core/items/ItemForestry.java +++ b/src/main/java/forestry/core/items/ItemForestry.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -17,14 +23,6 @@ import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.CreativeTabForestry; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; - public class ItemForestry extends Item { private boolean isBonemeal = false; diff --git a/src/main/java/forestry/core/items/ItemForestryFood.java b/src/main/java/forestry/core/items/ItemForestryFood.java index d490402ac..7acaf4fba 100755 --- a/src/main/java/forestry/core/items/ItemForestryFood.java +++ b/src/main/java/forestry/core/items/ItemForestryFood.java @@ -12,6 +12,7 @@ package forestry.core.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.IIconRegister; @@ -19,9 +20,6 @@ import net.minecraft.item.EnumAction; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; - -import forestry.core.CreativeTabForestry; - public class ItemForestryFood extends ItemFood { private boolean isDrink = false; diff --git a/src/main/java/forestry/core/items/ItemForestryMultiPass.java b/src/main/java/forestry/core/items/ItemForestryMultiPass.java index 5b8d28cae..2dd577742 100644 --- a/src/main/java/forestry/core/items/ItemForestryMultiPass.java +++ b/src/main/java/forestry/core/items/ItemForestryMultiPass.java @@ -10,13 +10,11 @@ ******************************************************************************/ package forestry.core.items; -import net.minecraft.client.renderer.texture.IIconRegister; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; public class ItemForestryMultiPass extends ItemForestry { diff --git a/src/main/java/forestry/core/items/ItemForestryPickaxe.java b/src/main/java/forestry/core/items/ItemForestryPickaxe.java index 992bb7ca9..f4f996028 100755 --- a/src/main/java/forestry/core/items/ItemForestryPickaxe.java +++ b/src/main/java/forestry/core/items/ItemForestryPickaxe.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.items; +import forestry.core.config.ForestryBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import forestry.core.config.ForestryBlock; - public class ItemForestryPickaxe extends ItemForestryTool { private static final Block blocksEffectiveAgainst[]; diff --git a/src/main/java/forestry/core/items/ItemForestryShovel.java b/src/main/java/forestry/core/items/ItemForestryShovel.java index e0076734f..ee82a3987 100755 --- a/src/main/java/forestry/core/items/ItemForestryShovel.java +++ b/src/main/java/forestry/core/items/ItemForestryShovel.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.items; +import forestry.core.config.ForestryBlock; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import forestry.core.config.ForestryBlock; - public class ItemForestryShovel extends ItemForestryTool { private static final Block blocksEffectiveAgainst[]; diff --git a/src/main/java/forestry/core/items/ItemForestryTool.java b/src/main/java/forestry/core/items/ItemForestryTool.java index 866bcc48e..16a5f4f6e 100755 --- a/src/main/java/forestry/core/items/ItemForestryTool.java +++ b/src/main/java/forestry/core/items/ItemForestryTool.java @@ -12,6 +12,8 @@ package forestry.core.items; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import forestry.core.proxy.Proxies; +import java.util.Arrays; +import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -20,9 +22,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; -import java.util.Arrays; -import java.util.List; - public class ItemForestryTool extends ItemForestry { private final ItemStack remnants; diff --git a/src/main/java/forestry/core/items/ItemFruit.java b/src/main/java/forestry/core/items/ItemFruit.java index 15591a8a5..66b6f0bc9 100755 --- a/src/main/java/forestry/core/items/ItemFruit.java +++ b/src/main/java/forestry/core/items/ItemFruit.java @@ -10,23 +10,19 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.config.ForestryItem; +import forestry.core.render.TextureManager; import java.util.List; import java.util.Locale; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.config.ForestryItem; -import forestry.core.render.TextureManager; - public class ItemFruit extends ItemForestryFood { public static enum EnumFruit { diff --git a/src/main/java/forestry/core/items/ItemInventoried.java b/src/main/java/forestry/core/items/ItemInventoried.java index 936027863..8c31da6d6 100755 --- a/src/main/java/forestry/core/items/ItemInventoried.java +++ b/src/main/java/forestry/core/items/ItemInventoried.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.core.items; +import forestry.core.gui.ContainerItemInventory; +import forestry.core.interfaces.IInventoriedItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import forestry.core.gui.ContainerItemInventory; -import forestry.core.interfaces.IInventoriedItem; - public abstract class ItemInventoried extends ItemForestry implements IInventoriedItem { public ItemInventoried() { diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 61254b4a9..0b2056840 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -10,8 +10,13 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.CreativeTabForestry; +import forestry.core.fluids.FluidHelper; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; import java.util.Locale; - import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -23,21 +28,10 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; -import forestry.core.CreativeTabForestry; -import forestry.core.fluids.FluidHelper; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.LiquidHelper; - public class ItemLiquidContainer extends Item { public static enum EnumContainerType { diff --git a/src/main/java/forestry/core/items/ItemMisc.java b/src/main/java/forestry/core/items/ItemMisc.java index f166f60b8..ff6b34593 100755 --- a/src/main/java/forestry/core/items/ItemMisc.java +++ b/src/main/java/forestry/core/items/ItemMisc.java @@ -13,14 +13,13 @@ package forestry.core.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.core.render.TextureManager; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import java.util.List; - public class ItemMisc extends ItemForestry { private final String[] definition = new String[]{"pulsatingDust", "pulsatingMesh", "silkWisp", "wovenSilk", "dissipationCharge", "iceShard", "scentedPaneling"}; diff --git a/src/main/java/forestry/core/items/ItemNBTTile.java b/src/main/java/forestry/core/items/ItemNBTTile.java index b3e6f1e66..902e34732 100755 --- a/src/main/java/forestry/core/items/ItemNBTTile.java +++ b/src/main/java/forestry/core/items/ItemNBTTile.java @@ -11,7 +11,6 @@ package forestry.core.items; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/core/items/ItemOverlay.java b/src/main/java/forestry/core/items/ItemOverlay.java index 910835fdc..4c3df94ed 100755 --- a/src/main/java/forestry/core/items/ItemOverlay.java +++ b/src/main/java/forestry/core/items/ItemOverlay.java @@ -10,21 +10,18 @@ ******************************************************************************/ package forestry.core.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.config.Config; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.config.Config; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; - public class ItemOverlay extends ItemForestry { public static class OverlayInfo { diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index 473b0bacc..a284f834e 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -10,25 +10,21 @@ ******************************************************************************/ package forestry.core.items; -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraftforge.fluids.FluidStack; - import forestry.api.core.INBTTagable; import forestry.api.core.IToolPipette; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidStack; public class ItemPipette extends ItemForestry implements IToolPipette { diff --git a/src/main/java/forestry/core/items/ItemWrench.java b/src/main/java/forestry/core/items/ItemWrench.java index efb993dc2..a863758dd 100755 --- a/src/main/java/forestry/core/items/ItemWrench.java +++ b/src/main/java/forestry/core/items/ItemWrench.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.core.items; +import buildcraft.api.tools.IToolWrench; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; - public class ItemWrench extends ItemForestry implements IToolWrench { public ItemWrench() { diff --git a/src/main/java/forestry/core/network/ForestryPacket.java b/src/main/java/forestry/core/network/ForestryPacket.java index 2e527f2f5..7e741ea0a 100755 --- a/src/main/java/forestry/core/network/ForestryPacket.java +++ b/src/main/java/forestry/core/network/ForestryPacket.java @@ -10,24 +10,20 @@ ******************************************************************************/ package forestry.core.network; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.common.registry.GameData; +import forestry.core.proxy.Proxies; +import io.netty.buffer.Unpooled; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; -import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import cpw.mods.fml.common.registry.GameData; - -import io.netty.buffer.Unpooled; - -import forestry.core.proxy.Proxies; - public class ForestryPacket { protected int id; diff --git a/src/main/java/forestry/core/network/PacketCoordinates.java b/src/main/java/forestry/core/network/PacketCoordinates.java index 16cd80d0e..daca65865 100755 --- a/src/main/java/forestry/core/network/PacketCoordinates.java +++ b/src/main/java/forestry/core/network/PacketCoordinates.java @@ -13,7 +13,6 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; diff --git a/src/main/java/forestry/core/network/PacketFXSignal.java b/src/main/java/forestry/core/network/PacketFXSignal.java index a41f76e5b..02d9d2187 100755 --- a/src/main/java/forestry/core/network/PacketFXSignal.java +++ b/src/main/java/forestry/core/network/PacketFXSignal.java @@ -10,16 +10,13 @@ ******************************************************************************/ package forestry.core.network; +import cpw.mods.fml.common.registry.GameData; +import forestry.core.proxy.Proxies; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.block.Block; -import cpw.mods.fml.common.registry.GameData; - -import forestry.core.proxy.Proxies; - public class PacketFXSignal extends ForestryPacket { public static enum VisualFXType { diff --git a/src/main/java/forestry/core/network/PacketGuiInteger.java b/src/main/java/forestry/core/network/PacketGuiInteger.java index 7b7ff9eb7..673e3d36d 100644 --- a/src/main/java/forestry/core/network/PacketGuiInteger.java +++ b/src/main/java/forestry/core/network/PacketGuiInteger.java @@ -14,7 +14,6 @@ import cpw.mods.fml.client.FMLClientHandler; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.client.entity.EntityClientPlayerMP; /** diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index 0a796444e..fb7014aa5 100755 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -10,17 +10,6 @@ ******************************************************************************/ package forestry.core.network; -import java.io.DataInputStream; -import java.io.InputStream; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.tileentity.TileEntity; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLEventChannel; @@ -28,24 +17,29 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; - -import net.minecraftforge.common.MinecraftForge; - -import io.netty.buffer.ByteBufInputStream; - import forestry.api.core.ForestryEvent; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.ISpeciesRoot; import forestry.core.circuits.ItemCircuitBoard; import forestry.core.gadgets.TileForestry; -import forestry.core.gui.ContainerForestry; import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.ContainerSocketed; import forestry.core.gui.IGuiSelectable; import forestry.core.interfaces.ISocketable; import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; +import io.netty.buffer.ByteBufInputStream; +import java.io.DataInputStream; +import java.io.InputStream; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; public class PacketHandler { public PacketHandler() { diff --git a/src/main/java/forestry/core/network/PacketInventoryStack.java b/src/main/java/forestry/core/network/PacketInventoryStack.java index 6a4ee5358..721ea9150 100755 --- a/src/main/java/forestry/core/network/PacketInventoryStack.java +++ b/src/main/java/forestry/core/network/PacketInventoryStack.java @@ -13,7 +13,6 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.item.ItemStack; public class PacketInventoryStack extends PacketCoordinates { diff --git a/src/main/java/forestry/core/network/PacketNBT.java b/src/main/java/forestry/core/network/PacketNBT.java index 5e6851d6b..f0da32597 100755 --- a/src/main/java/forestry/core/network/PacketNBT.java +++ b/src/main/java/forestry/core/network/PacketNBT.java @@ -14,7 +14,6 @@ import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/forestry/core/network/PacketSocketUpdate.java b/src/main/java/forestry/core/network/PacketSocketUpdate.java index 0a8991727..ddb095c86 100755 --- a/src/main/java/forestry/core/network/PacketSocketUpdate.java +++ b/src/main/java/forestry/core/network/PacketSocketUpdate.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.core.network; +import forestry.core.interfaces.ISocketable; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.item.ItemStack; -import forestry.core.interfaces.ISocketable; - public class PacketSocketUpdate extends PacketCoordinates { public ItemStack[] itemstacks; diff --git a/src/main/java/forestry/core/network/PacketTileNBT.java b/src/main/java/forestry/core/network/PacketTileNBT.java index a502f5afe..7805e8daf 100755 --- a/src/main/java/forestry/core/network/PacketTileNBT.java +++ b/src/main/java/forestry/core/network/PacketTileNBT.java @@ -13,7 +13,6 @@ package forestry.core.network; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index 2935c4479..ede729579 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -10,21 +10,18 @@ ******************************************************************************/ package forestry.core.network; +import com.mojang.authlib.GameProfile; +import forestry.api.core.ErrorStateRegistry; +import forestry.api.core.IErrorState; +import forestry.core.EnumErrorCode; +import forestry.core.gadgets.TileForestry; +import forestry.core.utils.EnumAccess; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.UUID; - import net.minecraftforge.common.util.ForgeDirection; -import com.mojang.authlib.GameProfile; -import forestry.api.core.ErrorStateRegistry; -import forestry.api.core.IErrorState; - -import forestry.core.EnumErrorCode; -import forestry.core.gadgets.TileForestry; -import forestry.core.utils.EnumAccess; - public class PacketTileUpdate extends PacketUpdate { private ForgeDirection orientation = ForgeDirection.WEST; diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index fe48e0ded..c98a7a3c8 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -10,10 +10,13 @@ ******************************************************************************/ package forestry.core.proxy; -import java.io.File; - import com.mojang.authlib.GameProfile; - +import forestry.apiculture.render.TextureBiomefinder; +import forestry.core.ForestryClient; +import forestry.core.TickHandlerCoreClient; +import forestry.core.config.Config; +import forestry.core.render.SpriteSheet; +import java.io.File; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; @@ -25,18 +28,8 @@ 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; -import forestry.apiculture.render.TextureBiomefinder; -import forestry.core.ForestryClient; -import forestry.core.TickHandlerCoreClient; -import forestry.core.config.Config; -import forestry.core.render.SpriteSheet; - public class ClientProxyCommon extends ProxyCommon { @Override diff --git a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java index b55ad8e65..196163796 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyNetwork.java +++ b/src/main/java/forestry/core/proxy/ClientProxyNetwork.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.proxy; -import net.minecraft.client.network.NetHandlerPlayClient; - import forestry.core.network.ForestryPacket; +import net.minecraft.client.network.NetHandlerPlayClient; public class ClientProxyNetwork extends ProxyNetwork { diff --git a/src/main/java/forestry/core/proxy/ClientProxyRender.java b/src/main/java/forestry/core/proxy/ClientProxyRender.java index ee78420e9..8674cb7b2 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyRender.java +++ b/src/main/java/forestry/core/proxy/ClientProxyRender.java @@ -10,16 +10,10 @@ ******************************************************************************/ package forestry.core.proxy; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.world.World; - import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; - import forestry.core.config.Config; import forestry.core.gadgets.MachineDefinition; import forestry.core.interfaces.IBlockRenderer; @@ -31,6 +25,10 @@ import forestry.core.render.RenderMill; import forestry.core.render.TextureManager; import forestry.core.render.TileRendererIndex; import forestry.core.utils.ForestryResource; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.world.World; public class ClientProxyRender extends ProxyRender { diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index 9e34c3563..cfad6e3ac 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -31,6 +31,7 @@ import forestry.core.network.PacketFXSignal; import forestry.core.network.PacketIds; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; +import java.io.File; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResourceManager; @@ -50,8 +51,6 @@ import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.io.File; - public class ProxyCommon { public String getMinecraftVersion() { diff --git a/src/main/java/forestry/core/proxy/ProxyLog.java b/src/main/java/forestry/core/proxy/ProxyLog.java index 7b4e168dc..1669a8e7f 100755 --- a/src/main/java/forestry/core/proxy/ProxyLog.java +++ b/src/main/java/forestry/core/proxy/ProxyLog.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.proxy; +import forestry.core.config.Defaults; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; - -import forestry.core.config.Defaults; import org.apache.logging.log4j.message.MessageFormatMessage; public class ProxyLog { diff --git a/src/main/java/forestry/core/proxy/ProxyNetwork.java b/src/main/java/forestry/core/proxy/ProxyNetwork.java index 29264c722..4d64755bc 100755 --- a/src/main/java/forestry/core/proxy/ProxyNetwork.java +++ b/src/main/java/forestry/core/proxy/ProxyNetwork.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.core.proxy; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.world.World; - -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.common.util.FakePlayer; - import forestry.Forestry; import forestry.core.config.Defaults; import forestry.core.network.ForestryPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.FakePlayer; public class ProxyNetwork { diff --git a/src/main/java/forestry/core/proxy/ProxyRender.java b/src/main/java/forestry/core/proxy/ProxyRender.java index 3a439e812..9eb5d5560 100755 --- a/src/main/java/forestry/core/proxy/ProxyRender.java +++ b/src/main/java/forestry/core/proxy/ProxyRender.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.proxy; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.world.World; - import forestry.core.gadgets.MachineDefinition; import forestry.core.interfaces.IBlockRenderer; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.world.World; public class ProxyRender { diff --git a/src/main/java/forestry/core/render/BlockRenderingHandler.java b/src/main/java/forestry/core/render/BlockRenderingHandler.java index 1993f8e65..1a26c2b12 100755 --- a/src/main/java/forestry/core/render/BlockRenderingHandler.java +++ b/src/main/java/forestry/core/render/BlockRenderingHandler.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.core.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import forestry.core.ForestryClient; +import forestry.core.interfaces.IBlockRenderer; import java.util.HashMap; - import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - -import forestry.core.ForestryClient; -import forestry.core.interfaces.IBlockRenderer; - public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { public static final HashMap byBlockRenderer = new HashMap(); diff --git a/src/main/java/forestry/core/render/EntitySnowFX.java b/src/main/java/forestry/core/render/EntitySnowFX.java index 92ad917cb..65926c336 100755 --- a/src/main/java/forestry/core/render/EntitySnowFX.java +++ b/src/main/java/forestry/core/render/EntitySnowFX.java @@ -11,7 +11,6 @@ package forestry.core.render; import java.util.Random; - import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; diff --git a/src/main/java/forestry/core/render/OverlayRenderingHandler.java b/src/main/java/forestry/core/render/OverlayRenderingHandler.java index 5558c7d5d..066c0b7b0 100755 --- a/src/main/java/forestry/core/render/OverlayRenderingHandler.java +++ b/src/main/java/forestry/core/render/OverlayRenderingHandler.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.core.render; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; - public abstract class OverlayRenderingHandler implements ISimpleBlockRenderingHandler { protected static final double OVERLAY_SHIFT = 0.001; diff --git a/src/main/java/forestry/core/render/RenderAnalyzer.java b/src/main/java/forestry/core/render/RenderAnalyzer.java index bd41cdc8d..a44b3eefa 100755 --- a/src/main/java/forestry/core/render/RenderAnalyzer.java +++ b/src/main/java/forestry/core/render/RenderAnalyzer.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.core.render; +import forestry.apiculture.render.ModelAnalyzer; +import forestry.core.gadgets.TileAnalyzer; +import forestry.core.interfaces.IBlockRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -17,15 +20,9 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import forestry.apiculture.render.ModelAnalyzer; -import forestry.core.gadgets.TileAnalyzer; -import forestry.core.interfaces.IBlockRenderer; - public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockRenderer { private ModelAnalyzer model; diff --git a/src/main/java/forestry/core/render/RenderEscritoire.java b/src/main/java/forestry/core/render/RenderEscritoire.java index 64b8441fd..4a03a16ec 100755 --- a/src/main/java/forestry/core/render/RenderEscritoire.java +++ b/src/main/java/forestry/core/render/RenderEscritoire.java @@ -10,23 +10,20 @@ ******************************************************************************/ package forestry.core.render; +import forestry.core.config.Defaults; +import forestry.core.gadgets.TileEscritoire; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import forestry.core.config.Defaults; -import forestry.core.gadgets.TileEscritoire; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; - public class RenderEscritoire extends TileEntitySpecialRenderer implements IBlockRenderer { private final ModelEscritoire modelEscritoire; diff --git a/src/main/java/forestry/core/render/RenderMachine.java b/src/main/java/forestry/core/render/RenderMachine.java index 04f78a275..e4cad8d1d 100755 --- a/src/main/java/forestry/core/render/RenderMachine.java +++ b/src/main/java/forestry/core/render/RenderMachine.java @@ -10,21 +10,18 @@ ******************************************************************************/ package forestry.core.render; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.common.util.ForgeDirection; - -import org.lwjgl.opengl.GL11; - import forestry.core.interfaces.IBlockRenderer; import forestry.core.interfaces.IRenderableMachine; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.ForestryResource; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; public class RenderMachine extends TileEntitySpecialRenderer implements IBlockRenderer { diff --git a/src/main/java/forestry/core/render/RenderMill.java b/src/main/java/forestry/core/render/RenderMill.java index d4ce46d9d..710d3f6ef 100755 --- a/src/main/java/forestry/core/render/RenderMill.java +++ b/src/main/java/forestry/core/render/RenderMill.java @@ -10,21 +10,18 @@ ******************************************************************************/ package forestry.core.render; +import forestry.core.gadgets.Mill; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import forestry.core.gadgets.Mill; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; - public class RenderMill extends TileEntitySpecialRenderer implements IBlockRenderer { private final ModelBase model = new ModelBase() { diff --git a/src/main/java/forestry/core/render/TextureManager.java b/src/main/java/forestry/core/render/TextureManager.java index 66b5e09dc..a47334ddf 100755 --- a/src/main/java/forestry/core/render/TextureManager.java +++ b/src/main/java/forestry/core/render/TextureManager.java @@ -10,18 +10,15 @@ ******************************************************************************/ package forestry.core.render; -import java.util.ArrayList; -import java.util.HashMap; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.core.ForestryAPI; import forestry.api.core.IIconProvider; import forestry.api.core.ITextureManager; +import java.util.ArrayList; +import java.util.HashMap; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; @SideOnly(Side.CLIENT) public class TextureManager implements ITextureManager { diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index f015c1b07..a6b504ce9 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -17,6 +17,9 @@ import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import cofh.api.energy.IEnergyHandler; import forestry.core.config.Defaults; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; import net.minecraft.block.BlockLog; @@ -29,10 +32,6 @@ import net.minecraft.util.Direction; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; - public class BlockUtil { public static ArrayList getBlockItemStack(World world, Vect posBlock) { diff --git a/src/main/java/forestry/core/utils/EnumAccess.java b/src/main/java/forestry/core/utils/EnumAccess.java index 30f983b7b..dde751fda 100755 --- a/src/main/java/forestry/core/utils/EnumAccess.java +++ b/src/main/java/forestry/core/utils/EnumAccess.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.utils; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; public enum EnumAccess { SHARED("gui.rule.shared"), VIEWABLE("gui.rule.restricted"), PRIVATE("gui.rule.private"); diff --git a/src/main/java/forestry/core/utils/FontColour.java b/src/main/java/forestry/core/utils/FontColour.java index ded493d51..9d5e50ffe 100755 --- a/src/main/java/forestry/core/utils/FontColour.java +++ b/src/main/java/forestry/core/utils/FontColour.java @@ -12,7 +12,6 @@ package forestry.core.utils; import java.io.InputStream; import java.util.Properties; - import net.minecraft.client.resources.IResourceManager; public class FontColour { diff --git a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java index f6ad50df2..b62cd4dc8 100755 --- a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java +++ b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.core.utils; -import java.util.ArrayList; -import java.util.List; - import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.ICrashCallable; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; - import forestry.core.config.Defaults; +import java.util.ArrayList; +import java.util.List; public class ForestryModEnvWarningCallable implements ICrashCallable { diff --git a/src/main/java/forestry/core/utils/ForestryResource.java b/src/main/java/forestry/core/utils/ForestryResource.java index 00e301d25..a6947e7cb 100755 --- a/src/main/java/forestry/core/utils/ForestryResource.java +++ b/src/main/java/forestry/core/utils/ForestryResource.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.core.utils; -import net.minecraft.util.ResourceLocation; - import forestry.core.config.Defaults; +import net.minecraft.util.ResourceLocation; public class ForestryResource extends ResourceLocation { diff --git a/src/main/java/forestry/core/utils/ItemStackMap.java b/src/main/java/forestry/core/utils/ItemStackMap.java index 2cecc37d4..440f58a3f 100755 --- a/src/main/java/forestry/core/utils/ItemStackMap.java +++ b/src/main/java/forestry/core/utils/ItemStackMap.java @@ -13,7 +13,6 @@ package forestry.core.utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - import net.minecraftforge.oredict.OreDictionary; public class ItemStackMap extends StackMap { diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index e6ec5a3a7..fda0feff9 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.core.utils; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; - import forestry.api.recipes.RecipeManagers; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.fluids.FluidStack; public class LiquidHelper { diff --git a/src/main/java/forestry/core/utils/NBTUtil.java b/src/main/java/forestry/core/utils/NBTUtil.java index 59cd1c1fc..5ad5089d7 100644 --- a/src/main/java/forestry/core/utils/NBTUtil.java +++ b/src/main/java/forestry/core/utils/NBTUtil.java @@ -12,11 +12,21 @@ package forestry.core.utils; import com.google.common.collect.ForwardingList; import cpw.mods.fml.common.ObfuscationReflectionHelper; - import java.util.ArrayList; import java.util.List; - -import net.minecraft.nbt.*; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagByteArray; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagEnd; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; +import net.minecraft.nbt.NBTTagIntArray; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagLong; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.nbt.NBTTagString; /** * @author CovertJaguar diff --git a/src/main/java/forestry/core/utils/PlayerUtil.java b/src/main/java/forestry/core/utils/PlayerUtil.java index fc93320ea..4e70d19cf 100644 --- a/src/main/java/forestry/core/utils/PlayerUtil.java +++ b/src/main/java/forestry/core/utils/PlayerUtil.java @@ -1,7 +1,6 @@ package forestry.core.utils; import com.mojang.authlib.GameProfile; - import java.util.UUID; public class PlayerUtil { diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index fe1fb3d63..6804a3c3e 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -10,27 +10,22 @@ ******************************************************************************/ package forestry.core.utils; +import forestry.api.recipes.RecipeManagers; +import forestry.core.fluids.Fluids; +import forestry.core.gui.ContainerDummy; +import forestry.core.interfaces.IDescriptiveRecipe; +import forestry.core.proxy.Proxies; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; - import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import forestry.api.recipes.RecipeManagers; -import forestry.core.config.Defaults; -import forestry.core.fluids.Fluids; -import forestry.core.gui.ContainerDummy; -import forestry.core.interfaces.IDescriptiveRecipe; -import forestry.core.proxy.Proxies; - public class RecipeUtil { private static final Container DUMMY_CONTAINER = new ContainerDummy(); diff --git a/src/main/java/forestry/core/utils/RevolvingList.java b/src/main/java/forestry/core/utils/RevolvingList.java index 7a5a385f2..8a89b9e83 100644 --- a/src/main/java/forestry/core/utils/RevolvingList.java +++ b/src/main/java/forestry/core/utils/RevolvingList.java @@ -11,7 +11,9 @@ package forestry.core.utils; import com.google.common.collect.ForwardingCollection; -import java.util.*; +import java.util.Collection; +import java.util.Deque; +import java.util.LinkedList; /** * diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index 0534f79a5..2e72e78d6 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -10,9 +10,12 @@ ******************************************************************************/ package forestry.core.utils; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.interfaces.IDescriptiveRecipe; import java.util.ArrayList; import java.util.HashMap; - import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; @@ -20,14 +23,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; - import net.minecraftforge.oredict.OreDictionary; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.interfaces.IDescriptiveRecipe; - public class ShapedRecipeCustom implements IDescriptiveRecipe { private final int width; diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index e6d04335b..edf75a91f 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -10,10 +10,10 @@ ******************************************************************************/ package forestry.core.utils; +import forestry.core.config.Defaults; import forestry.core.inventory.InventoryAdapter; import java.util.ArrayList; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -23,13 +23,10 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.oredict.OreDictionary; -import forestry.core.config.Defaults; - public class StackUtils { public static final ItemStack[] EMPTY_STACK_ARRAY = new ItemStack[0]; diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 179154b4b..3871bdf85 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -24,6 +24,11 @@ import forestry.api.genetics.IPollinatable; import forestry.core.gadgets.TileForestry; import forestry.core.proxy.Proxies; import forestry.plugins.PluginArboriculture; +import java.security.MessageDigest; +import java.security.cert.Certificate; +import java.util.Arrays; +import java.util.Map; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -40,12 +45,6 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import java.security.MessageDigest; -import java.security.cert.Certificate; -import java.util.Arrays; -import java.util.Map; -import java.util.Random; - public class Utils { private static Random rand; diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java index 549a49498..222d65467 100755 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ b/src/main/java/forestry/core/worldgen/BlockType.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core.worldgen; -import net.minecraft.block.Block; -import net.minecraft.world.World; - import forestry.api.world.ITreeGenData; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; +import net.minecraft.block.Block; +import net.minecraft.world.World; public class BlockType { diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index 332e46770..867374d3d 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -11,7 +11,6 @@ package forestry.core.worldgen; import java.util.Random; - import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; diff --git a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java index 810e499f4..89dca4851 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java +++ b/src/main/java/forestry/core/worldgen/WorldGenMinableMeta.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.core.worldgen; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; - public class WorldGenMinableMeta extends WorldGenerator { private final Block mineableBlock; diff --git a/src/main/java/forestry/energy/GuiHandlerEnergy.java b/src/main/java/forestry/energy/GuiHandlerEnergy.java index 6da6891c8..b382f15e6 100755 --- a/src/main/java/forestry/energy/GuiHandlerEnergy.java +++ b/src/main/java/forestry/energy/GuiHandlerEnergy.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.energy; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -30,6 +27,8 @@ import forestry.energy.gui.GuiEngineBronze; import forestry.energy.gui.GuiEngineCopper; import forestry.energy.gui.GuiEngineTin; import forestry.energy.gui.GuiGenerator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class GuiHandlerEnergy extends GuiHandlerBase { diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java b/src/main/java/forestry/energy/circuits/CircuitElectricChange.java index 9b9ac78fa..370da2a20 100755 --- a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java +++ b/src/main/java/forestry/energy/circuits/CircuitElectricChange.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.energy.circuits; -import net.minecraft.tileentity.TileEntity; - import forestry.core.circuits.Circuit; import forestry.energy.gadgets.EngineTin; +import net.minecraft.tileentity.TileEntity; public abstract class CircuitElectricChange extends Circuit { diff --git a/src/main/java/forestry/energy/circuits/CircuitFireDampener.java b/src/main/java/forestry/energy/circuits/CircuitFireDampener.java index f8fe35a4e..5c436eb74 100755 --- a/src/main/java/forestry/energy/circuits/CircuitFireDampener.java +++ b/src/main/java/forestry/energy/circuits/CircuitFireDampener.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.energy.circuits; -import net.minecraft.tileentity.TileEntity; - import forestry.core.circuits.Circuit; import forestry.energy.gadgets.EngineCopper; +import net.minecraft.tileentity.TileEntity; public class CircuitFireDampener extends Circuit { diff --git a/src/main/java/forestry/energy/gadgets/EngineClockwork.java b/src/main/java/forestry/energy/gadgets/EngineClockwork.java index 4a3ceb903..c2675bdd6 100755 --- a/src/main/java/forestry/energy/gadgets/EngineClockwork.java +++ b/src/main/java/forestry/energy/gadgets/EngineClockwork.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.energy.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.nbt.NBTTagCompound; - import forestry.core.TemperatureState; import forestry.core.config.Defaults; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.utils.DamageSourceForestry; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; public class EngineClockwork extends Engine { diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 98cbf01b3..5d97b19a4 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -13,19 +13,22 @@ package forestry.energy.gadgets; import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameData; -import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; +import forestry.core.EnumErrorCode; import forestry.core.TemperatureState; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.BlockUtil; -import forestry.core.inventory.TileInventoryAdapter; import forestry.factory.triggers.FactoryTriggers; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -36,10 +39,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; - public class EngineCopper extends Engine implements ISidedInventory { /* CONSTANTS */ diff --git a/src/main/java/forestry/energy/gadgets/EngineDefinition.java b/src/main/java/forestry/energy/gadgets/EngineDefinition.java index 271f7e1ad..f91f18890 100755 --- a/src/main/java/forestry/energy/gadgets/EngineDefinition.java +++ b/src/main/java/forestry/energy/gadgets/EngineDefinition.java @@ -10,19 +10,17 @@ ******************************************************************************/ package forestry.energy.gadgets; +import forestry.core.gadgets.Engine; +import forestry.core.gadgets.MachineDefinition; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.crafting.IRecipe; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; -import forestry.core.gadgets.Engine; -import forestry.core.gadgets.MachineDefinition; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.utils.Utils; - public class EngineDefinition extends MachineDefinition { public EngineDefinition(int meta, String teIdent, Class teClass, IBlockRenderer renderer, IRecipe... recipes) { diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index 204f3140d..fe5e76bb1 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -10,15 +10,6 @@ ******************************************************************************/ package forestry.energy.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import ic2.api.energy.prefab.BasicSink; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.ForestryAPI; @@ -29,12 +20,19 @@ import forestry.core.config.Defaults; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ISocketable; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.DelayTimer; import forestry.core.utils.EnumTankLevel; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.inventory.TileInventoryAdapter; import forestry.plugins.PluginIC2; +import ic2.api.energy.prefab.BasicSink; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class EngineTin extends Engine implements ISocketable, IInventory { diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index f73280ee4..ecb09027c 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.energy.gadgets.EngineCopper; -import scala.collection.parallel.ParSeqLike.Updated; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; public class ContainerEngineCopper extends ContainerForestry { diff --git a/src/main/java/forestry/energy/gui/ContainerEngineTin.java b/src/main/java/forestry/energy/gui/ContainerEngineTin.java index d026931ce..f2887abdb 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineTin.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineTin.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.energy.gui; +import forestry.core.gui.ContainerSocketed; +import forestry.energy.gadgets.EngineTin; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; -import forestry.core.gui.ContainerSocketed; -import forestry.energy.gadgets.EngineTin; - public class ContainerEngineTin extends ContainerSocketed { protected final EngineTin tile; diff --git a/src/main/java/forestry/energy/gui/GuiEngineBronze.java b/src/main/java/forestry/energy/gui/GuiEngineBronze.java index c73d78556..b867fe27c 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineBronze.java +++ b/src/main/java/forestry/energy/gui/GuiEngineBronze.java @@ -10,16 +10,6 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.IIcon; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - import forestry.core.config.Defaults; import forestry.core.gui.WidgetManager; import forestry.core.gui.widgets.TankWidget; @@ -28,6 +18,13 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; import forestry.energy.gadgets.EngineBronze; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; public class GuiEngineBronze extends GuiEngine { diff --git a/src/main/java/forestry/energy/gui/GuiEngineCopper.java b/src/main/java/forestry/energy/gui/GuiEngineCopper.java index 304746688..d2d33f815 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineCopper.java +++ b/src/main/java/forestry/energy/gui/GuiEngineCopper.java @@ -10,11 +10,9 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; -import forestry.core.utils.StringUtil; import forestry.energy.gadgets.EngineCopper; +import net.minecraft.entity.player.InventoryPlayer; public class GuiEngineCopper extends GuiEngine { diff --git a/src/main/java/forestry/energy/gui/GuiEngineTin.java b/src/main/java/forestry/energy/gui/GuiEngineTin.java index f1942c073..1aac72cea 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineTin.java +++ b/src/main/java/forestry/energy/gui/GuiEngineTin.java @@ -10,13 +10,11 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.widgets.SocketWidget; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.StringUtil; import forestry.energy.gadgets.EngineTin; +import net.minecraft.entity.player.InventoryPlayer; public class GuiEngineTin extends GuiEngine { diff --git a/src/main/java/forestry/energy/gui/GuiGenerator.java b/src/main/java/forestry/energy/gui/GuiGenerator.java index 673f10fd4..8f534bd9b 100755 --- a/src/main/java/forestry/energy/gui/GuiGenerator.java +++ b/src/main/java/forestry/energy/gui/GuiGenerator.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.energy.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.energy.gadgets.MachineGenerator; +import net.minecraft.entity.player.InventoryPlayer; public class GuiGenerator extends GuiForestryTitled { diff --git a/src/main/java/forestry/energy/render/RenderEngine.java b/src/main/java/forestry/energy/render/RenderEngine.java index 910709249..0a2ab054d 100755 --- a/src/main/java/forestry/energy/render/RenderEngine.java +++ b/src/main/java/forestry/energy/render/RenderEngine.java @@ -10,22 +10,19 @@ ******************************************************************************/ package forestry.energy.render; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.common.util.ForgeDirection; - -import org.lwjgl.opengl.GL11; - import forestry.core.TemperatureState; import forestry.core.config.Defaults; import forestry.core.gadgets.Engine; import forestry.core.interfaces.IBlockRenderer; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryResource; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRenderer { diff --git a/src/main/java/forestry/factory/GuiHandlerFactory.java b/src/main/java/forestry/factory/GuiHandlerFactory.java index 59a41f147..d639f15ba 100755 --- a/src/main/java/forestry/factory/GuiHandlerFactory.java +++ b/src/main/java/forestry/factory/GuiHandlerFactory.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.factory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.factory.gadgets.MachineBottler; @@ -45,6 +42,8 @@ import forestry.factory.gui.GuiRaintank; import forestry.factory.gui.GuiSqueezer; import forestry.factory.gui.GuiStill; import forestry.factory.gui.GuiWorktable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class GuiHandlerFactory extends GuiHandlerBase { diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 2b16f0284..8ab5f23a5 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -10,31 +10,9 @@ ******************************************************************************/ package forestry.factory.gadgets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICarpenterManager; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; @@ -46,16 +24,33 @@ import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; -import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.Utils; import forestry.factory.gui.ContainerCarpenter; -import net.minecraftforge.fluids.FluidRegistry; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; public class MachineCarpenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index eb3aea99b..15d7568e5 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -19,12 +19,17 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; -import forestry.core.network.GuiId; -import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.utils.StackUtils; +import forestry.core.network.GuiId; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; +import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -35,14 +40,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - public class MachineCentrifuge extends TilePowered implements ISidedInventory { /* CONSTANTS */ diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 461b27435..66727aa10 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -45,7 +45,6 @@ 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 net.minecraftforge.fluids.FluidTankInfo; diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 8859f197d..1bad21ddb 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -10,33 +10,13 @@ ******************************************************************************/ package forestry.factory.gadgets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Map; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - +import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; - -import forestry.core.EnumErrorCode; import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.recipes.IFermenterManager; import forestry.api.recipes.IVariableFermentable; +import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.fluids.FluidHelper; @@ -47,13 +27,28 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; - -import buildcraft.api.statements.ITriggerExternal; -import forestry.core.inventory.TileInventoryAdapter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { diff --git a/src/main/java/forestry/factory/gadgets/MillRainmaker.java b/src/main/java/forestry/factory/gadgets/MillRainmaker.java index 436b3156e..12098ae3b 100755 --- a/src/main/java/forestry/factory/gadgets/MillRainmaker.java +++ b/src/main/java/forestry/factory/gadgets/MillRainmaker.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.factory.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; - import forestry.api.fuels.FuelManager; import forestry.api.fuels.RainSubstrate; import forestry.core.gadgets.Mill; import forestry.core.gadgets.TileBase; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; public class MillRainmaker extends Mill { diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index a418c847c..41c5db9f4 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCraftResult; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotCraftAuto; import forestry.core.gui.slots.SlotLiquidContainer; @@ -25,6 +18,12 @@ import forestry.core.gui.slots.SlotOutput; import forestry.core.interfaces.IContainerCrafting; import forestry.core.proxy.Proxies; import forestry.factory.gadgets.MachineCarpenter; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class ContainerCarpenter extends ContainerLiquidTanks implements IContainerCrafting { diff --git a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java index bdf321b41..dcbfbcdc8 100755 --- a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java +++ b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.factory.gadgets.MachineCentrifuge; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; public class ContainerCentrifuge extends ContainerForestry { diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index b94d3152d..5070b8b26 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotCraftAuto; import forestry.core.gui.slots.SlotWorking; import forestry.core.interfaces.IContainerCrafting; import forestry.factory.gadgets.MachineMoistener; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; public class ContainerMoistener extends ContainerLiquidTanks implements IContainerCrafting { diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index b3ade0028..e21be8b92 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineRaintank; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class ContainerRaintank extends ContainerLiquidTanks { diff --git a/src/main/java/forestry/factory/gui/ContainerSqueezer.java b/src/main/java/forestry/factory/gui/ContainerSqueezer.java index 7c236ca59..b542da864 100755 --- a/src/main/java/forestry/factory/gui/ContainerSqueezer.java +++ b/src/main/java/forestry/factory/gui/ContainerSqueezer.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineSqueezer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class ContainerSqueezer extends ContainerLiquidTanks { diff --git a/src/main/java/forestry/factory/gui/ContainerStill.java b/src/main/java/forestry/factory/gui/ContainerStill.java index 41dcb6217..19f47f3fd 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineStill; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class ContainerStill extends ContainerLiquidTanks { diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index 472064ebe..1395912f3 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.utils.StackUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCraftResult; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerForestry; import forestry.core.gui.IGuiSelectable; import forestry.core.gui.slots.SlotCrafter; @@ -25,7 +18,13 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; import forestry.factory.gadgets.TileWorktable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerWorktable extends ContainerForestry implements IContainerCrafting, IGuiSelectable { diff --git a/src/main/java/forestry/factory/gui/GuiBottler.java b/src/main/java/forestry/factory/gui/GuiBottler.java index fd24dc271..6d0293689 100755 --- a/src/main/java/forestry/factory/gui/GuiBottler.java +++ b/src/main/java/forestry/factory/gui/GuiBottler.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineBottler; +import net.minecraft.entity.player.InventoryPlayer; public class GuiBottler extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiCarpenter.java b/src/main/java/forestry/factory/gui/GuiCarpenter.java index 655e8df89..a6bb17de7 100755 --- a/src/main/java/forestry/factory/gui/GuiCarpenter.java +++ b/src/main/java/forestry/factory/gui/GuiCarpenter.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineCarpenter; +import net.minecraft.entity.player.InventoryPlayer; public class GuiCarpenter extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiCentrifuge.java b/src/main/java/forestry/factory/gui/GuiCentrifuge.java index dde1b62c8..a81cf5470 100755 --- a/src/main/java/forestry/factory/gui/GuiCentrifuge.java +++ b/src/main/java/forestry/factory/gui/GuiCentrifuge.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.factory.gadgets.MachineCentrifuge; +import net.minecraft.entity.player.InventoryPlayer; public class GuiCentrifuge extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiFabricator.java b/src/main/java/forestry/factory/gui/GuiFabricator.java index f2b48da1c..21cb5f40e 100755 --- a/src/main/java/forestry/factory/gui/GuiFabricator.java +++ b/src/main/java/forestry/factory/gui/GuiFabricator.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.ReservoirWidget; import forestry.factory.gadgets.MachineFabricator; +import net.minecraft.entity.player.InventoryPlayer; public class GuiFabricator extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiFermenter.java b/src/main/java/forestry/factory/gui/GuiFermenter.java index 1d51ba00b..752659428 100755 --- a/src/main/java/forestry/factory/gui/GuiFermenter.java +++ b/src/main/java/forestry/factory/gui/GuiFermenter.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineFermenter; +import net.minecraft.entity.player.InventoryPlayer; public class GuiFermenter extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiMoistener.java b/src/main/java/forestry/factory/gui/GuiMoistener.java index e4fbd864d..22b0ed895 100755 --- a/src/main/java/forestry/factory/gui/GuiMoistener.java +++ b/src/main/java/forestry/factory/gui/GuiMoistener.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineMoistener; +import net.minecraft.entity.player.InventoryPlayer; public class GuiMoistener extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiRaintank.java b/src/main/java/forestry/factory/gui/GuiRaintank.java index 02a93a01c..457d2b534 100755 --- a/src/main/java/forestry/factory/gui/GuiRaintank.java +++ b/src/main/java/forestry/factory/gui/GuiRaintank.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineRaintank; +import net.minecraft.entity.player.InventoryPlayer; public class GuiRaintank extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/GuiStill.java b/src/main/java/forestry/factory/gui/GuiStill.java index 2fcb8cd1f..cbfc65c0f 100755 --- a/src/main/java/forestry/factory/gui/GuiStill.java +++ b/src/main/java/forestry/factory/gui/GuiStill.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.widgets.TankWidget; import forestry.factory.gadgets.MachineStill; +import net.minecraft.entity.player.InventoryPlayer; public class GuiStill extends GuiForestryTitled { diff --git a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java b/src/main/java/forestry/factory/gui/SlotCraftMatrix.java index e627b984b..39ed2820f 100755 --- a/src/main/java/forestry/factory/gui/SlotCraftMatrix.java +++ b/src/main/java/forestry/factory/gui/SlotCraftMatrix.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.factory.gui; -import net.minecraft.inventory.IInventory; - import forestry.core.gui.slots.SlotForestry; import forestry.core.interfaces.IContainerCrafting; +import net.minecraft.inventory.IInventory; /** * Informs the passed container of slot changes. Contains a dummy itemstack. diff --git a/src/main/java/forestry/factory/recipes/CraftGuideBottler.java b/src/main/java/forestry/factory/recipes/CraftGuideBottler.java index b430f0623..70d426fda 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideBottler.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideBottler.java @@ -10,8 +10,10 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.factory.gadgets.MachineBottler; import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -20,10 +22,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.factory.gadgets.MachineBottler; - public class CraftGuideBottler implements RecipeProvider { private final Slot[] slots = new Slot[4]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java b/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java index df737e54c..ecf5213cd 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCarpenter.java @@ -10,8 +10,11 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.utils.RecipeUtil; +import forestry.factory.gadgets.MachineCarpenter; import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -20,11 +23,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.utils.RecipeUtil; -import forestry.factory.gadgets.MachineCarpenter; - public class CraftGuideCarpenter implements RecipeProvider { private final Slot[] slots = new Slot[12]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java b/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java index 243bdba52..f24659aaa 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCentrifuge.java @@ -10,11 +10,12 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.factory.gadgets.MachineCentrifuge; import java.util.ArrayList; import java.util.Map.Entry; - import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ChanceSlot; import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -23,10 +24,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.factory.gadgets.MachineCentrifuge; - public class CraftGuideCentrifuge implements RecipeProvider { private final Slot[] slots = new Slot[11]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java b/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java index e1309171c..e1ed7c04d 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideCustomRecipes.java @@ -10,19 +10,17 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.interfaces.IDescriptiveRecipe; +import forestry.core.utils.RecipeUtil; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; import uristqwerty.CraftGuide.api.RecipeProvider; import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.interfaces.IDescriptiveRecipe; -import forestry.core.utils.RecipeUtil; - public class CraftGuideCustomRecipes implements RecipeProvider { private final ItemSlot[] slots = new ItemSlot[10]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java index f193a0a59..67b48c5b6 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideFabricator.java @@ -10,8 +10,11 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.utils.RecipeUtil; +import forestry.factory.gadgets.MachineFabricator; import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -20,11 +23,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.utils.RecipeUtil; -import forestry.factory.gadgets.MachineFabricator; - public class CraftGuideFabricator implements RecipeProvider { private final Slot[] slots = new Slot[12]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java b/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java index 970966bca..60c8b403f 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideFermenter.java @@ -10,13 +10,14 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.api.fuels.FuelManager; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.factory.gadgets.MachineFermenter; import java.util.ArrayList; import java.util.List; - import net.minecraft.item.ItemStack; - import net.minecraftforge.fluids.FluidStack; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -25,11 +26,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.api.fuels.FuelManager; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.factory.gadgets.MachineFermenter; - public class CraftGuideFermenter implements RecipeProvider { private final Slot[] slots = new Slot[5]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java b/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java index ed00830e9..9ead8d2f4 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideIntegration.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.factory.recipes; -import java.lang.reflect.Method; - import forestry.core.proxy.Proxies; +import java.lang.reflect.Method; public class CraftGuideIntegration { diff --git a/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java b/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java index e7a1286dc..0fcc8ca10 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideSqueezer.java @@ -10,8 +10,10 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.factory.gadgets.MachineSqueezer; import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ChanceSlot; import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; @@ -21,10 +23,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.factory.gadgets.MachineSqueezer; - public class CraftGuideSqueezer implements RecipeProvider { private final Slot[] slots = new Slot[12]; diff --git a/src/main/java/forestry/factory/recipes/CraftGuideStill.java b/src/main/java/forestry/factory/recipes/CraftGuideStill.java index 5384e84ad..2bce6fff2 100755 --- a/src/main/java/forestry/factory/recipes/CraftGuideStill.java +++ b/src/main/java/forestry/factory/recipes/CraftGuideStill.java @@ -10,8 +10,10 @@ ******************************************************************************/ package forestry.factory.recipes; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.factory.gadgets.MachineStill; import net.minecraft.item.ItemStack; - import uristqwerty.CraftGuide.api.ItemSlot; import uristqwerty.CraftGuide.api.LiquidSlot; import uristqwerty.CraftGuide.api.RecipeGenerator; @@ -20,10 +22,6 @@ import uristqwerty.CraftGuide.api.RecipeTemplate; import uristqwerty.CraftGuide.api.Slot; import uristqwerty.CraftGuide.api.SlotType; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.factory.gadgets.MachineStill; - public class CraftGuideStill implements RecipeProvider { private final Slot[] slots = new Slot[3]; diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index fd7d1c2c2..3a5cdf560 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -14,6 +14,9 @@ import forestry.api.core.INBTTagable; import forestry.core.gui.ContainerDummy; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.PlainInventory; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; @@ -25,10 +28,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - public class RecipeMemory implements INBTTagable { public static final class Recipe implements INBTTagable { diff --git a/src/main/java/forestry/farming/EventHandlerFarming.java b/src/main/java/forestry/farming/EventHandlerFarming.java index b0049dba9..a2ed61201 100755 --- a/src/main/java/forestry/farming/EventHandlerFarming.java +++ b/src/main/java/forestry/farming/EventHandlerFarming.java @@ -10,16 +10,13 @@ ******************************************************************************/ package forestry.farming; -import net.minecraft.block.Block; - import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -import net.minecraftforge.event.entity.player.BonemealEvent; - import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.farming.gadgets.BlockMushroom; +import net.minecraft.block.Block; +import net.minecraftforge.event.entity.player.BonemealEvent; public class EventHandlerFarming { diff --git a/src/main/java/forestry/farming/GuiHandlerFarming.java b/src/main/java/forestry/farming/GuiHandlerFarming.java index 88456e447..4f4538a4d 100755 --- a/src/main/java/forestry/farming/GuiHandlerFarming.java +++ b/src/main/java/forestry/farming/GuiHandlerFarming.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.farming; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -21,6 +18,8 @@ import forestry.core.proxy.Proxies; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gui.ContainerFarm; import forestry.farming.gui.GuiFarm; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class GuiHandlerFarming extends GuiHandlerBase { diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index 4a156aaca..b0e368b97 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -10,9 +10,15 @@ ******************************************************************************/ package forestry.farming.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.gadgets.BlockStructure; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; +import forestry.farming.gadgets.TileFarm.EnumFarmBlock; +import forestry.plugins.PluginFarming; import java.util.ArrayList; import java.util.List; - import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -27,15 +33,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.gadgets.BlockStructure; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; -import forestry.plugins.PluginFarming; - public class BlockFarm extends BlockStructure { public BlockFarm() { diff --git a/src/main/java/forestry/farming/gadgets/BlockMushroom.java b/src/main/java/forestry/farming/gadgets/BlockMushroom.java index b61eff722..40a56e8f8 100755 --- a/src/main/java/forestry/farming/gadgets/BlockMushroom.java +++ b/src/main/java/forestry/farming/gadgets/BlockMushroom.java @@ -10,11 +10,15 @@ ******************************************************************************/ package forestry.farming.gadgets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.core.IItemTyped; +import forestry.core.config.Defaults; +import forestry.core.proxy.Proxies; +import forestry.farming.worldgen.WorldGenBigMushroom; import java.util.ArrayList; import java.util.List; import java.util.Random; - -import forestry.core.IItemTyped; import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; import net.minecraft.client.renderer.texture.IIconRegister; @@ -26,13 +30,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.config.Defaults; -import forestry.core.proxy.Proxies; -import forestry.farming.worldgen.WorldGenBigMushroom; - public class BlockMushroom extends BlockSapling implements IItemTyped { public enum MushroomType { diff --git a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java index 88036724b..ce6371ba7 100755 --- a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java +++ b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.farming.gadgets; -import java.util.HashSet; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; - import forestry.api.core.ITileStructure; import forestry.api.farming.IFarmComponent; import forestry.core.gadgets.BlockStructure.EnumStructureState; @@ -23,7 +17,11 @@ import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; import forestry.core.utils.Vect; +import java.util.HashSet; import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; public class StructureLogicFarm extends StructureLogic { diff --git a/src/main/java/forestry/farming/gadgets/TileControl.java b/src/main/java/forestry/farming/gadgets/TileControl.java index c0493fe78..54b90f082 100755 --- a/src/main/java/forestry/farming/gadgets/TileControl.java +++ b/src/main/java/forestry/farming/gadgets/TileControl.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.farming.gadgets; -import java.util.Collection; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.core.ITileStructure; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; import forestry.core.utils.Vect; +import java.util.Collection; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; public class TileControl extends TileFarm implements IFarmListener { diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 8f9dedaaf..479b342e8 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -10,18 +10,8 @@ ******************************************************************************/ package forestry.farming.gadgets; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.core.ForestryAPI; import forestry.api.core.IStructureLogic; import forestry.api.core.ITileStructure; @@ -33,8 +23,14 @@ import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; -import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.utils.Utils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; public abstract class TileFarm extends TileForestry implements IFarmComponent { diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index b5d5a1c16..884071ab9 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -10,32 +10,9 @@ ******************************************************************************/ package forestry.farming.gadgets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.BiomeHelper; -import forestry.core.EnumErrorCode; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.farming.ICrop; @@ -44,6 +21,7 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; +import forestry.core.EnumErrorCode; import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Defaults; @@ -64,6 +42,25 @@ import forestry.core.utils.Vect; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.TreeMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource { diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index eb94e4fab..9cede7c5e 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -17,6 +17,10 @@ import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.farming.triggers.FarmingTriggers; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; @@ -25,11 +29,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; - public class TileHatch extends TileFarm implements ISidedInventory { public TileHatch() { diff --git a/src/main/java/forestry/farming/gadgets/TileValve.java b/src/main/java/forestry/farming/gadgets/TileValve.java index d51fce0a1..318a5e92d 100755 --- a/src/main/java/forestry/farming/gadgets/TileValve.java +++ b/src/main/java/forestry/farming/gadgets/TileValve.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.farming.gadgets; +import forestry.core.fluids.TankManager; +import forestry.core.fluids.tanks.FakeTank; +import forestry.core.interfaces.ILiquidTankContainer; 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.TankManager; -import forestry.core.fluids.tanks.FakeTank; import net.minecraftforge.fluids.FluidTankInfo; public class TileValve extends TileFarm implements ILiquidTankContainer { diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 396727d2f..1f1c30d41 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.farming.gui; -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 forestry.api.farming.IFarmLogic; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.StandardTank; @@ -26,6 +20,11 @@ import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; import forestry.farming.gadgets.TileFarmPlain; import forestry.plugins.PluginFarming; +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; public class ContainerFarm extends ContainerSocketed { diff --git a/src/main/java/forestry/farming/gui/GuiFarm.java b/src/main/java/forestry/farming/gui/GuiFarm.java index 6220f0cdc..652c5709b 100755 --- a/src/main/java/forestry/farming/gui/GuiFarm.java +++ b/src/main/java/forestry/farming/gui/GuiFarm.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.farming.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; - -import org.lwjgl.opengl.GL11; - import forestry.api.farming.IFarmLogic; import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; @@ -28,6 +22,10 @@ import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import forestry.farming.gadgets.TileFarmPlain; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import org.lwjgl.opengl.GL11; public class GuiFarm extends GuiForestry { diff --git a/src/main/java/forestry/farming/items/ItemFarmBlock.java b/src/main/java/forestry/farming/items/ItemFarmBlock.java index 875840447..09ceb6b7b 100755 --- a/src/main/java/forestry/farming/items/ItemFarmBlock.java +++ b/src/main/java/forestry/farming/items/ItemFarmBlock.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.farming.items; +import forestry.core.gadgets.IStructureBlockItem; +import forestry.farming.gadgets.TileFarm.EnumFarmBlock; import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import forestry.core.gadgets.IStructureBlockItem; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; - public class ItemFarmBlock extends ItemBlock implements IStructureBlockItem { public ItemFarmBlock(Block block) { diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index 06985d5d6..2262e944c 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.farming.ICrop; import forestry.core.config.Defaults; import forestry.core.utils.Vect; +import java.util.Collection; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public abstract class Crop implements ICrop { diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index b7990157f..82e555ca9 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.farming.logic; +import forestry.core.proxy.Proxies; +import forestry.core.utils.Vect; import java.util.Collection; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; - public class CropBlock extends Crop { Block block; diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index 82538f73d..ffc199471 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import forestry.api.genetics.IFruitBearer; import forestry.api.genetics.IFruitFamily; import forestry.core.network.PacketFXSignal; import forestry.core.proxy.Proxies; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class CropFruit extends Crop { diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index 9c180b115..949deefec 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -14,14 +14,13 @@ import forestry.core.gadgets.BlockSoil; import forestry.core.proxy.Proxies; import forestry.core.utils.BlockUtil; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.Collection; - public class CropPeat extends Crop { public CropPeat(World world, Vect position) { diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index 21906120e..ac7dfc885 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.core.utils.Vect; import forestry.plugins.PluginIC2; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class CropRubber extends CropBlock { diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index e054c7389..97e1419f4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -16,6 +16,7 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.render.SpriteSheet; import forestry.core.utils.Vect; +import java.util.HashSet; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -24,8 +25,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.HashSet; - public abstract class FarmLogic implements IFarmLogic { IFarmHousing housing; diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index f7f623ed8..00352ab7c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -20,6 +20,13 @@ import forestry.core.config.ForestryBlock; import forestry.core.gadgets.BlockSoil; import forestry.core.render.SpriteSheet; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -31,14 +38,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Stack; - public class FarmLogicArboreal extends FarmLogicHomogeneous { public FarmLogicArboreal(IFarmHousing housing, ItemStack[] resource, ItemStack ground, IFarmable[] germlings) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicCereal.java b/src/main/java/forestry/farming/logic/FarmLogicCereal.java index 1d06d7f02..2880c647c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCereal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCereal.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.farming.logic; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; public class FarmLogicCereal extends FarmLogicCrops { diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 8cfec943f..5a1c4eedb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -10,30 +10,26 @@ ******************************************************************************/ package forestry.farming.logic; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; +import forestry.core.utils.Vect; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import java.util.Stack; - import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.utils.Vect; -import java.util.HashSet; -import java.util.Set; - public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 9baa9f173..29e9a2b95 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -17,6 +17,10 @@ import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Stack; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; @@ -25,11 +29,6 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Stack; - public abstract class FarmLogicCrops extends FarmLogicWatered { private final IFarmable[] seeds; diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 8fcb2d31a..4af434431 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -10,24 +10,20 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.Vect; +import java.util.Collection; +import java.util.Stack; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicGourd extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index b832d8970..5fa931400 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -15,11 +15,10 @@ import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; - public abstract class FarmLogicHomogeneous extends FarmLogic { protected final ItemStack[] resource; diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 218e2fc25..2eb3af892 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -10,26 +10,22 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.Utils; import forestry.core.utils.Vect; +import java.util.Collection; +import java.util.Stack; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicInfernal extends FarmLogicHomogeneous { diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 3aa2f21bc..642b930ed 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -10,29 +10,25 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Stack; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.genetics.IFruitBearer; import forestry.core.config.ForestryItem; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.Stack; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicOrchard extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 7b9eb0326..f37cf7575 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -14,22 +14,18 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockSoil; -import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import java.util.Collection; +import java.util.Stack; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; -import java.util.Stack; - public class FarmLogicPeat extends FarmLogicWatered { public FarmLogicPeat(IFarmHousing housing) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPoale.java b/src/main/java/forestry/farming/logic/FarmLogicPoale.java index c4546de0f..cca789b17 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPoale.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPoale.java @@ -10,26 +10,22 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import java.util.Collection; +import java.util.Stack; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicPoale extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 7dcc81f01..53fc99782 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -10,30 +10,26 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Stack; - -import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; import forestry.plugins.PluginIC2; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; +import java.util.Stack; +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicRubber extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmLogicShroom.java b/src/main/java/forestry/farming/logic/FarmLogicShroom.java index 9126b4df5..0fae43117 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicShroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicShroom.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; public class FarmLogicShroom extends FarmLogicArboreal { diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index e87c7da8b..68a2ec2fb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -10,26 +10,22 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import java.util.Collection; +import java.util.Stack; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicSucculent extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java index 1116fadac..73d12aeca 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java +++ b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.farming.logic; -import net.minecraft.init.Items; -import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; public class FarmLogicVegetable extends FarmLogicCrops { diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 9899b59fb..7dd55ac91 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -10,23 +10,20 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - import forestry.api.farming.IFarmHousing; import forestry.core.fluids.Fluids; import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.utils.Vect; +import java.util.ArrayList; +import java.util.Collection; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; public abstract class FarmLogicWatered extends FarmLogic { diff --git a/src/main/java/forestry/farming/logic/FarmableCocoa.java b/src/main/java/forestry/farming/logic/FarmableCocoa.java index 47d0a380b..a5874201b 100755 --- a/src/main/java/forestry/farming/logic/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmableCocoa.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.farming.logic; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.core.utils.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -18,11 +22,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.Vect; - public class FarmableCocoa implements IFarmable { public static final Block COCOA_PLANT = Blocks.cocoa; diff --git a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java index bf8fa7cf2..ce13c3ca7 100755 --- a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java +++ b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java @@ -10,19 +10,17 @@ ******************************************************************************/ 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; - import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; import forestry.plugins.PluginFarmCraftory; +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; public class FarmableFarmCraftory implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 60c7c7d55..632ce5344 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.farming.logic; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.Vect; 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.Vect; - public class FarmableGenericCrop implements IFarmable { private final ItemStack seed; diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index d75de37c5..f49c16760 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -10,15 +10,14 @@ ******************************************************************************/ 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.Vect; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class FarmableGenericSapling implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 989fedc80..7d340265d 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.farming.logic; -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.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class FarmableGourd implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index 6b22e542f..50311afeb 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -10,16 +10,15 @@ ******************************************************************************/ 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.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class FarmableStacked implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java index 83b810b17..ab4168aaa 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java @@ -10,19 +10,17 @@ ******************************************************************************/ package forestry.farming.logic; +import forestry.api.arboriculture.ITree; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IIndividual; +import forestry.plugins.PluginArboriculture; 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; import net.minecraft.world.World; -import forestry.api.arboriculture.ITree; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IIndividual; -import forestry.plugins.PluginArboriculture; - public class FarmableVanillaSapling extends FarmableGenericSapling { public FarmableVanillaSapling() { diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java index 4754ebf3a..0b739124b 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java @@ -10,18 +10,17 @@ ******************************************************************************/ 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; - import forestry.api.farming.ICrop; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.core.utils.Vect; +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; public class FarmableVanillaShroom extends FarmableGenericSapling { diff --git a/src/main/java/forestry/farming/proxy/ClientProxyFarming.java b/src/main/java/forestry/farming/proxy/ClientProxyFarming.java index a7da85f32..db427229a 100755 --- a/src/main/java/forestry/farming/proxy/ClientProxyFarming.java +++ b/src/main/java/forestry/farming/proxy/ClientProxyFarming.java @@ -12,13 +12,11 @@ package forestry.farming.proxy; import cpw.mods.fml.client.registry.RenderingRegistry; - -import net.minecraftforge.client.MinecraftForgeClient; - import forestry.core.config.ForestryBlock; import forestry.farming.render.FarmItemRenderer; import forestry.farming.render.FarmRenderingHandler; import forestry.plugins.PluginFarming; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyFarming extends ProxyFarming { diff --git a/src/main/java/forestry/farming/render/FarmItemRenderer.java b/src/main/java/forestry/farming/render/FarmItemRenderer.java index 21b94dbe2..215a346a2 100755 --- a/src/main/java/forestry/farming/render/FarmItemRenderer.java +++ b/src/main/java/forestry/farming/render/FarmItemRenderer.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.farming.render; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.client.IItemRenderer; - -import org.lwjgl.opengl.GL11; - import forestry.core.utils.StackUtils; import forestry.farming.gadgets.BlockFarm; import forestry.farming.gadgets.TileFarm.EnumFarmBlock; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; public class FarmItemRenderer implements IItemRenderer { diff --git a/src/main/java/forestry/farming/render/FarmRenderingHandler.java b/src/main/java/forestry/farming/render/FarmRenderingHandler.java index 4d703ae35..46487c7d9 100755 --- a/src/main/java/forestry/farming/render/FarmRenderingHandler.java +++ b/src/main/java/forestry/farming/render/FarmRenderingHandler.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.farming.render; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.world.IBlockAccess; - import forestry.core.config.ForestryBlock; import forestry.core.render.OverlayRenderingHandler; import forestry.farming.gadgets.BlockFarm; import forestry.plugins.PluginFarming; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; public class FarmRenderingHandler extends OverlayRenderingHandler { diff --git a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java index 755dbd358..1c833a2b0 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java @@ -16,7 +16,6 @@ import forestry.api.core.ITileStructure; import forestry.core.triggers.Trigger; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileHatch; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java b/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java index a46b69ea8..5494ab277 100755 --- a/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java +++ b/src/main/java/forestry/farming/worldgen/WorldGenBigMushroom.java @@ -14,15 +14,13 @@ package forestry.farming.worldgen; +import forestry.core.config.Defaults; import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; -import forestry.core.config.Defaults; - // Referenced classes of package net.minecraft.src: // WorldGenerator, World, Block, BlockLeaves, // BlockGrass, BlockMycelium, BlockFlower diff --git a/src/main/java/forestry/food/BeverageEffectAntidote.java b/src/main/java/forestry/food/BeverageEffectAntidote.java index c8648fb86..892bad0a6 100755 --- a/src/main/java/forestry/food/BeverageEffectAntidote.java +++ b/src/main/java/forestry/food/BeverageEffectAntidote.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.food; +import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.world.World; -import forestry.core.proxy.Proxies; - public class BeverageEffectAntidote extends BeverageEffect { private float chance = 0.2f; diff --git a/src/main/java/forestry/food/GuiHandlerFood.java b/src/main/java/forestry/food/GuiHandlerFood.java index 826ef6a2a..0fe74e5d5 100755 --- a/src/main/java/forestry/food/GuiHandlerFood.java +++ b/src/main/java/forestry/food/GuiHandlerFood.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.food; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.food.gui.ContainerInfuser; import forestry.food.gui.GuiInfuser; import forestry.food.items.ItemInfuser.InfuserInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class GuiHandlerFood extends GuiHandlerBase { @Override diff --git a/src/main/java/forestry/food/gui/ContainerInfuser.java b/src/main/java/forestry/food/gui/ContainerInfuser.java index 4935d518d..70991252e 100755 --- a/src/main/java/forestry/food/gui/ContainerInfuser.java +++ b/src/main/java/forestry/food/gui/ContainerInfuser.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.food.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotCustom; import forestry.core.proxy.Proxies; import forestry.food.items.ItemBeverage; import forestry.food.items.ItemInfuser.InfuserInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; public class ContainerInfuser extends ContainerForestry { diff --git a/src/main/java/forestry/food/gui/GuiInfuser.java b/src/main/java/forestry/food/gui/GuiInfuser.java index 6178e44b7..4bd839eb1 100755 --- a/src/main/java/forestry/food/gui/GuiInfuser.java +++ b/src/main/java/forestry/food/gui/GuiInfuser.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.food.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; - import forestry.api.food.BeverageManager; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.food.items.ItemInfuser.InfuserInventory; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; public class GuiInfuser extends GuiForestry { diff --git a/src/main/java/forestry/food/items/ItemAmbrosia.java b/src/main/java/forestry/food/items/ItemAmbrosia.java index 5c9acb1d8..3e27ee04f 100755 --- a/src/main/java/forestry/food/items/ItemAmbrosia.java +++ b/src/main/java/forestry/food/items/ItemAmbrosia.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.food.items; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; - import forestry.core.config.Defaults; import forestry.core.items.ItemForestryFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; public class ItemAmbrosia extends ItemForestryFood { diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index 1e69a1a9a..c5c965164 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -10,9 +10,15 @@ ******************************************************************************/ package forestry.food.items; -import java.util.List; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.food.BeverageManager; +import forestry.api.food.IBeverageEffect; +import forestry.core.config.Config; import forestry.core.items.ItemForestryFood; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -24,15 +30,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.food.BeverageManager; -import forestry.api.food.IBeverageEffect; -import forestry.core.config.Config; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; - public class ItemBeverage extends ItemForestryFood { public static class BeverageInfo { diff --git a/src/main/java/forestry/food/items/ItemInfuser.java b/src/main/java/forestry/food/items/ItemInfuser.java index a4518c939..f8bd67405 100755 --- a/src/main/java/forestry/food/items/ItemInfuser.java +++ b/src/main/java/forestry/food/items/ItemInfuser.java @@ -10,14 +10,6 @@ ******************************************************************************/ package forestry.food.items; -import java.util.ArrayList; -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.core.ForestryAPI; import forestry.api.food.BeverageManager; import forestry.api.food.IBeverageEffect; @@ -30,6 +22,12 @@ import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.food.BeverageEffect; import forestry.plugins.PluginManager; +import java.util.ArrayList; +import java.util.Arrays; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ItemInfuser extends ItemForestry { diff --git a/src/main/java/forestry/lepidopterology/ButterflySpawner.java b/src/main/java/forestry/lepidopterology/ButterflySpawner.java index 0fd991a00..8e9e9f505 100755 --- a/src/main/java/forestry/lepidopterology/ButterflySpawner.java +++ b/src/main/java/forestry/lepidopterology/ButterflySpawner.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.lepidopterology; -import net.minecraft.world.World; - import forestry.api.arboriculture.ILeafTickHandler; import forestry.api.arboriculture.ITree; import forestry.api.lepidopterology.IButterfly; import forestry.core.proxy.Proxies; import forestry.lepidopterology.entities.EntityButterfly; import forestry.plugins.PluginLepidopterology; +import net.minecraft.world.World; public class ButterflySpawner implements ILeafTickHandler { diff --git a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java index 0e9167c05..687af84fd 100755 --- a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java @@ -10,16 +10,15 @@ ******************************************************************************/ package forestry.lepidopterology; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.lepidopterology.genetics.ButterflyHelper; import forestry.lepidopterology.gui.ContainerFlutterlyzer; import forestry.lepidopterology.gui.GuiFlutterlyzer; import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GuiHandlerLepidopterology extends GuiHandlerBase { diff --git a/src/main/java/forestry/lepidopterology/MatingRecipe.java b/src/main/java/forestry/lepidopterology/MatingRecipe.java index 51572ce42..518f42678 100755 --- a/src/main/java/forestry/lepidopterology/MatingRecipe.java +++ b/src/main/java/forestry/lepidopterology/MatingRecipe.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.lepidopterology; +import forestry.api.lepidopterology.EnumFlutterType; +import forestry.api.lepidopterology.IButterfly; +import forestry.plugins.PluginLepidopterology; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; -import forestry.api.lepidopterology.EnumFlutterType; -import forestry.api.lepidopterology.IButterfly; -import forestry.plugins.PluginLepidopterology; - public class MatingRecipe implements IRecipe { private final ItemStack unknown; diff --git a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java index 6c9fb9288..26d9c9c56 100644 --- a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java +++ b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java @@ -10,7 +10,8 @@ ******************************************************************************/ package forestry.lepidopterology.commands; -import forestry.core.commands.*; +import forestry.core.commands.CommandHelpers; +import forestry.core.commands.SubCommand; import forestry.lepidopterology.entities.EntityButterfly; import net.minecraft.command.ICommandSender; import net.minecraft.world.World; diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java index d968b5aaa..bc3db0eb0 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java @@ -10,8 +10,8 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import net.minecraft.entity.player.EntityPlayer; import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; +import net.minecraft.entity.player.EntityPlayer; public class AIButterflyFlee extends AIButterflyMovement { diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java index 9ad6ea3e3..bc4056294 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyInteract.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import net.minecraft.util.ChunkCoordinates; - import forestry.lepidopterology.entities.EntityButterfly.EnumButterflyState; +import net.minecraft.util.ChunkCoordinates; public abstract class AIButterflyInteract extends AIButterflyBase { diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index a585e1982..099924a8b 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import java.util.Map; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - import forestry.api.arboriculture.ITreeRoot; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.api.lepidopterology.IButterflyNursery; import forestry.core.utils.StackUtils; +import java.util.Map; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class AIButterflyMate extends AIButterflyInteract { diff --git a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java index 9656b22ea..f922e3ae4 100755 --- a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java +++ b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java @@ -10,21 +10,8 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.IEntityLivingData; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.arboriculture.EnumGermlingType; import forestry.api.core.IToolScoop; import forestry.api.genetics.AlleleManager; @@ -45,7 +32,18 @@ import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockWall; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.IPlantable; diff --git a/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java b/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java index 2b057c0a9..4320c48ad 100755 --- a/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java +++ b/src/main/java/forestry/lepidopterology/genetics/AlleleButterflySpecies.java @@ -10,22 +10,9 @@ ******************************************************************************/ package forestry.lepidopterology.genetics; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - +import com.mojang.authlib.GameProfile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraftforge.common.BiomeDictionary; - -import com.mojang.authlib.GameProfile; - import forestry.api.core.IIconProvider; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IClassification; @@ -35,6 +22,14 @@ import forestry.api.lepidopterology.IAlleleButterflySpecies; import forestry.api.lepidopterology.IButterflyRoot; import forestry.core.config.Defaults; import forestry.core.genetics.AlleleSpecies; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.BiomeDictionary; public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButterflySpecies { diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index 6ce4fcf00..b4a5c4959 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -28,10 +28,13 @@ import forestry.api.lepidopterology.IEntityButterfly; import forestry.core.genetics.Chromosome; import forestry.core.genetics.GenericRatings; import forestry.core.genetics.IndividualLiving; -import forestry.core.utils.StackUtils; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginLepidopterology; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; import net.minecraft.entity.EntityCreature; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -39,11 +42,6 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Map; - public class Butterfly extends IndividualLiving implements IButterfly { public IButterflyGenome genome; diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java index 88eee4880..6426fb66b 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java @@ -10,19 +10,7 @@ ******************************************************************************/ package forestry.lepidopterology.genetics; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Map.Entry; - -import net.minecraft.entity.EntityLiving; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - import com.mojang.authlib.GameProfile; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosomeType; @@ -41,6 +29,15 @@ import forestry.core.genetics.SpeciesRoot; import forestry.core.utils.Utils; import forestry.lepidopterology.entities.EntityButterfly; import forestry.plugins.PluginLepidopterology; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Map.Entry; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { diff --git a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java index 3716a0ab6..0afe9bf8a 100755 --- a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java +++ b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java @@ -10,16 +10,14 @@ ******************************************************************************/ package forestry.lepidopterology.genetics; -import net.minecraft.entity.player.EntityPlayer; - import com.mojang.authlib.GameProfile; - import forestry.api.genetics.IBreedingTracker; import forestry.api.genetics.IIndividual; import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.ILepidopteristTracker; import forestry.core.genetics.BreedingTracker; import forestry.plugins.PluginLepidopterology; +import net.minecraft.entity.player.EntityPlayer; public class LepidopteristTracker extends BreedingTracker implements ILepidopteristTracker { diff --git a/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java index 2c2e3d7cd..5c23e09ff 100755 --- a/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.lepidopterology.gui; -import forestry.core.gui.ContainerAlyzer; import forestry.core.config.ForestryItem; +import forestry.core.gui.ContainerAlyzer; import forestry.lepidopterology.items.ItemButterflyGE; import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; - import net.minecraft.entity.player.InventoryPlayer; public class ContainerFlutterlyzer extends ContainerAlyzer { diff --git a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java index 3d9f1acfe..e04b5ebea 100755 --- a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java @@ -27,13 +27,12 @@ import forestry.lepidopterology.genetics.ButterflyGenome; import forestry.lepidopterology.items.ItemButterflyGE; import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; import forestry.plugins.PluginLepidopterology; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class GuiFlutterlyzer extends GuiAlyzer { diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 520258050..41beb4bad 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -28,6 +28,7 @@ import forestry.core.utils.Utils; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.genetics.ButterflyGenome; import forestry.plugins.PluginLepidopterology; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; @@ -38,8 +39,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import java.util.List; - public class ItemButterflyGE extends ItemGE { private final EnumFlutterType type; diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index 4f355bb74..7b879591c 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -10,12 +10,6 @@ ******************************************************************************/ package forestry.lepidopterology.items; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import forestry.core.inventory.AlyzerInventory; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.api.lepidopterology.IButterfly; @@ -24,10 +18,15 @@ import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.AlyzerInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginLepidopterology; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class ItemFlutterlyzer extends ItemInventoried { diff --git a/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java b/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java index d2b1f94da..72426cac4 100755 --- a/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/proxy/ClientProxyLepidopterology.java @@ -11,13 +11,11 @@ package forestry.lepidopterology.proxy; import cpw.mods.fml.client.registry.RenderingRegistry; - -import net.minecraftforge.client.MinecraftForgeClient; - import forestry.core.config.ForestryItem; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.render.ButterflyItemRenderer; import forestry.lepidopterology.render.RenderButterfly; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxyLepidopterology extends ProxyLepidopterology { diff --git a/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java b/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java index 531e21195..67fb890b8 100755 --- a/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java +++ b/src/main/java/forestry/lepidopterology/render/ButterflyItemRenderer.java @@ -10,22 +10,19 @@ ******************************************************************************/ package forestry.lepidopterology.render; +import forestry.api.lepidopterology.IButterfly; +import forestry.core.proxy.Proxies; +import forestry.lepidopterology.entities.EntityButterfly; +import forestry.plugins.PluginLepidopterology; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.item.ItemStack; - import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import forestry.api.lepidopterology.IButterfly; -import forestry.core.proxy.Proxies; -import forestry.lepidopterology.entities.EntityButterfly; -import forestry.plugins.PluginLepidopterology; - public class ButterflyItemRenderer implements IItemRenderer { private final ModelButterfly model; diff --git a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java index 48dffa992..2c0457100 100755 --- a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java @@ -14,7 +14,6 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; - import org.lwjgl.opengl.GL11; public class ModelButterfly extends ModelBase { diff --git a/src/main/java/forestry/lepidopterology/render/RenderButterfly.java b/src/main/java/forestry/lepidopterology/render/RenderButterfly.java index b2083ac86..8f93636b5 100755 --- a/src/main/java/forestry/lepidopterology/render/RenderButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/RenderButterfly.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.lepidopterology.render; +import forestry.lepidopterology.entities.EntityButterfly; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; - -import forestry.lepidopterology.entities.EntityButterfly; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; public class RenderButterfly extends RenderLiving { diff --git a/src/main/java/forestry/mail/EnumDeliveryState.java b/src/main/java/forestry/mail/EnumDeliveryState.java index 776192db6..1165837b9 100755 --- a/src/main/java/forestry/mail/EnumDeliveryState.java +++ b/src/main/java/forestry/mail/EnumDeliveryState.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.mail; -import java.util.Locale; - import forestry.api.mail.IPostalState; +import java.util.Locale; public enum EnumDeliveryState implements IPostalState { OK, NO_MAILBOX, NOT_MAILABLE, ALREADY_MAILED, NOT_POSTPAID, MAILBOX_FULL, RESPONSE_NOT_MAILABLE; diff --git a/src/main/java/forestry/mail/EnumStationState.java b/src/main/java/forestry/mail/EnumStationState.java index 8402fe4bf..3dfa094d8 100755 --- a/src/main/java/forestry/mail/EnumStationState.java +++ b/src/main/java/forestry/mail/EnumStationState.java @@ -10,9 +10,8 @@ ******************************************************************************/ package forestry.mail; -import java.util.Locale; - import forestry.api.mail.IPostalState; +import java.util.Locale; public enum EnumStationState implements IPostalState { OK, INSUFFICIENT_OFFER, INSUFFICIENT_TRADE_GOOD, INSUFFICIENT_BUFFER, INSUFFICIENT_PAPER, INSUFFICIENT_STAMPS; diff --git a/src/main/java/forestry/mail/GuiHandlerMail.java b/src/main/java/forestry/mail/GuiHandlerMail.java index a360f14d8..eee2a1c7f 100755 --- a/src/main/java/forestry/mail/GuiHandlerMail.java +++ b/src/main/java/forestry/mail/GuiHandlerMail.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.mail; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.core.GuiHandlerBase; import forestry.core.network.GuiId; import forestry.mail.gadgets.MachineMailbox; @@ -34,6 +30,9 @@ import forestry.mail.gui.GuiTrader; import forestry.mail.items.ItemCatalogue; import forestry.mail.items.ItemLetter; import forestry.mail.items.ItemLetter.LetterInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GuiHandlerMail extends GuiHandlerBase { diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 05f5610c9..803a02127 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.mail; +import forestry.api.core.INBTTagable; +import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; +import forestry.api.mail.IStamps; +import forestry.core.inventory.InventoryAdapter; +import forestry.core.utils.StringUtil; import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; - -import forestry.api.core.INBTTagable; -import forestry.api.mail.ILetter; -import forestry.api.mail.IStamps; -import forestry.api.mail.IMailAddress; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.utils.StringUtil; import org.apache.commons.lang3.StringUtils; public class Letter implements ILetter, INBTTagable { diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index c78e63091..c4a22fa4a 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -10,19 +10,15 @@ ******************************************************************************/ package forestry.mail; -import java.util.Locale; -import java.util.UUID; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; - import com.mojang.authlib.GameProfile; - import forestry.api.core.INBTTagable; import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; -import forestry.core.network.PacketPayload; import forestry.core.utils.PlayerUtil; +import java.util.Locale; +import java.util.UUID; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; public class MailAddress implements INBTTagable, IMailAddress { diff --git a/src/main/java/forestry/mail/POBox.java b/src/main/java/forestry/mail/POBox.java index a229d5308..851cf1b3e 100755 --- a/src/main/java/forestry/mail/POBox.java +++ b/src/main/java/forestry/mail/POBox.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.mail; +import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; +import forestry.api.mail.PostManager; +import forestry.core.inventory.InventoryAdapter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.WorldSavedData; -import forestry.api.mail.ILetter; -import forestry.api.mail.PostManager; -import forestry.api.mail.IMailAddress; -import forestry.core.inventory.InventoryAdapter; - public class POBox extends WorldSavedData implements IInventory { public static final String SAVE_NAME = "POBox_"; diff --git a/src/main/java/forestry/mail/PacketHandlerMail.java b/src/main/java/forestry/mail/PacketHandlerMail.java index d971f9446..3df5b6e8e 100755 --- a/src/main/java/forestry/mail/PacketHandlerMail.java +++ b/src/main/java/forestry/mail/PacketHandlerMail.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.mail; -import java.io.DataInputStream; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; - import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketIds; import forestry.core.network.PacketUpdate; @@ -22,9 +17,12 @@ import forestry.core.proxy.Proxies; import forestry.mail.gui.ContainerCatalogue; import forestry.mail.gui.ContainerLetter; import forestry.mail.gui.ContainerTradeName; -import forestry.mail.network.PacketPOBoxInfo; import forestry.mail.network.PacketLetterInfo; +import forestry.mail.network.PacketPOBoxInfo; import forestry.plugins.PluginMail; +import java.io.DataInputStream; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; public class PacketHandlerMail implements IPacketHandler { diff --git a/src/main/java/forestry/mail/PostOffice.java b/src/main/java/forestry/mail/PostOffice.java index 611765e40..a89507cc6 100755 --- a/src/main/java/forestry/mail/PostOffice.java +++ b/src/main/java/forestry/mail/PostOffice.java @@ -10,24 +10,22 @@ ******************************************************************************/ package forestry.mail; -import java.io.File; -import java.util.LinkedHashMap; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraft.world.WorldSavedData; - import forestry.api.mail.EnumPostage; import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostOffice; import forestry.api.mail.IPostalCarrier; import forestry.api.mail.IPostalState; import forestry.api.mail.IStamps; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; -import forestry.api.mail.IMailAddress; import forestry.core.config.ForestryItem; +import java.io.File; +import java.util.LinkedHashMap; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; public class PostOffice extends WorldSavedData implements IPostOffice { diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index e52783c12..0b814ea80 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -10,28 +10,24 @@ ******************************************************************************/ package forestry.mail; -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; - import com.mojang.authlib.GameProfile; - +import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostOffice; import forestry.api.mail.IPostRegistry; import forestry.api.mail.IPostalCarrier; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; -import forestry.api.mail.IMailAddress; -import forestry.api.mail.EnumAddressee; import forestry.core.config.ForestryItem; import forestry.mail.items.ItemLetter; import forestry.plugins.PluginMail; +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; public class PostRegistry implements IPostRegistry { diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index ca0301eaf..dddc710e4 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -10,19 +10,21 @@ ******************************************************************************/ package forestry.mail; -import java.util.Locale; - -import forestry.api.mail.*; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import forestry.api.mail.EnumAddressee; +import forestry.api.mail.IMailAddress; +import forestry.api.mail.IPostOffice; +import forestry.api.mail.IPostalCarrier; +import forestry.api.mail.IPostalState; +import forestry.api.mail.ITradeStation; +import forestry.api.mail.PostManager; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; import forestry.plugins.PluginMail; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; public class PostalCarrier implements IPostalCarrier { diff --git a/src/main/java/forestry/mail/SaveEventHandlerMail.java b/src/main/java/forestry/mail/SaveEventHandlerMail.java index 906b63f37..e3bd96af7 100755 --- a/src/main/java/forestry/mail/SaveEventHandlerMail.java +++ b/src/main/java/forestry/mail/SaveEventHandlerMail.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.mail; -import net.minecraft.world.World; - import forestry.core.interfaces.ISaveEventHandler; import forestry.plugins.PluginMail; +import net.minecraft.world.World; public class SaveEventHandlerMail implements ISaveEventHandler { diff --git a/src/main/java/forestry/mail/TickHandlerMailClient.java b/src/main/java/forestry/mail/TickHandlerMailClient.java index ebb367494..cc65cfb8c 100755 --- a/src/main/java/forestry/mail/TickHandlerMailClient.java +++ b/src/main/java/forestry/mail/TickHandlerMailClient.java @@ -14,7 +14,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; - import forestry.mail.gui.GuiMailboxInfo; import forestry.plugins.PluginMail; diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index 002014b2f..f7a5b7d3a 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -24,6 +24,7 @@ import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StackUtils; import forestry.mail.items.ItemLetter; +import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; @@ -33,8 +34,6 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; -import java.util.ArrayList; - public class TradeStation extends WorldSavedData implements ITradeStation, ISidedInventory { // / CONSTANTS diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 6a34a372d..320a59123 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -20,14 +20,16 @@ import forestry.api.mail.IPostalState; import forestry.api.mail.PostManager; import forestry.core.config.Config; import forestry.core.gadgets.TileBase; +import forestry.core.inventory.InventoryAdapter; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.inventory.InventoryAdapter; import forestry.mail.EnumDeliveryState; import forestry.mail.IMailContainer; import forestry.mail.POBox; import forestry.mail.PostRegistry; import forestry.plugins.PluginMail; +import java.util.Collection; +import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -36,9 +38,6 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; -import java.util.LinkedList; - public class MachineMailbox extends TileBase implements IMailContainer { private boolean isLinked = false; diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 6d45de2ff..c317533d2 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -10,18 +10,17 @@ ******************************************************************************/ package forestry.mail.gadgets; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - import forestry.api.core.ForestryAPI; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.core.gadgets.TileBase; -import forestry.core.network.GuiId; import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.network.GuiId; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; public class MachinePhilatelist extends TileBase implements IInventory { diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 4d6728c2c..939592dbe 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -24,13 +24,12 @@ import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.mail.EnumStationState; import forestry.mail.network.PacketLetterInfo; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; - import java.util.EnumSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Set; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; public class ContainerCatalogue extends ContainerForestry implements IGuiSelectable { diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index 16252c599..f5798f318 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -10,24 +10,14 @@ ******************************************************************************/ package forestry.mail.gui; -import java.util.Iterator; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; - import com.mojang.authlib.GameProfile; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; - +import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostalCarrier; import forestry.api.mail.ITradeStation; -import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; -import forestry.api.mail.EnumAddressee; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotCustom; @@ -40,6 +30,13 @@ import forestry.mail.items.ItemLetter; import forestry.mail.items.ItemLetter.LetterInventory; import forestry.mail.items.ItemStamps; import forestry.mail.network.PacketLetterInfo; +import java.util.Iterator; +import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import org.apache.commons.lang3.StringUtils; public class ContainerLetter extends ContainerItemInventory { diff --git a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java index ed4b671f3..155d708b6 100755 --- a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java +++ b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotCustom; import forestry.mail.gadgets.MachinePhilatelist; import forestry.mail.items.ItemStamps; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; public class ContainerPhilatelist extends ContainerForestry { diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index 869a77edb..da5b8db84 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -10,18 +10,16 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; - +import forestry.api.mail.IMailAddress; +import forestry.api.mail.PostManager; import forestry.core.gui.ContainerForestry; +import forestry.core.inventory.InventoryAdapter; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import forestry.core.inventory.InventoryAdapter; import forestry.mail.gadgets.MachineTrader; -import forestry.api.mail.PostManager; -import forestry.api.mail.IMailAddress; - +import net.minecraft.entity.player.InventoryPlayer; import org.apache.commons.lang3.StringUtils; public class ContainerTradeName extends ContainerForestry { diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index eee985f89..8401aaba0 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; - +import forestry.api.mail.IMailAddress; import forestry.core.gui.ContainerForestry; import forestry.core.gui.slots.SlotCustom; import forestry.mail.TradeStation; import forestry.mail.gadgets.MachineTrader; import forestry.mail.items.ItemStamps; -import forestry.api.mail.IMailAddress; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; public class ContainerTrader extends ContainerForestry { diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 4c380ebb1..40ea3a7bb 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - +import forestry.api.mail.EnumAddressee; import forestry.api.mail.TradeStationInfo; import forestry.core.config.SessionVars; import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.utils.StringUtil; -import forestry.api.mail.EnumAddressee; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; public class GuiCatalogue extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiLetter.java b/src/main/java/forestry/mail/gui/GuiLetter.java index f5af7a737..3135b6c1f 100755 --- a/src/main/java/forestry/mail/gui/GuiLetter.java +++ b/src/main/java/forestry/mail/gui/GuiLetter.java @@ -10,17 +10,9 @@ ******************************************************************************/ package forestry.mail.gui; -import java.util.ArrayList; - -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.EntityPlayer; - -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; - -import forestry.api.mail.IPostalCarrier; +import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; +import forestry.api.mail.IPostalCarrier; import forestry.api.mail.PostManager; import forestry.core.config.Defaults; import forestry.core.config.SessionVars; @@ -30,8 +22,13 @@ import forestry.core.gui.GuiTextBox; import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import forestry.api.mail.EnumAddressee; import forestry.mail.items.ItemLetter.LetterInventory; +import java.util.ArrayList; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.EntityPlayer; +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; public class GuiLetter extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiMailbox.java b/src/main/java/forestry/mail/gui/GuiMailbox.java index 7a4682458..100e317a4 100755 --- a/src/main/java/forestry/mail/gui/GuiMailbox.java +++ b/src/main/java/forestry/mail/gui/GuiMailbox.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.mail.gadgets.MachineMailbox; +import net.minecraft.entity.player.InventoryPlayer; public class GuiMailbox extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java index d46c0f8de..612e37025 100755 --- a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java +++ b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryResource; import forestry.mail.POBoxInfo; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; public class GuiMailboxInfo extends Gui { diff --git a/src/main/java/forestry/mail/gui/GuiPhilatelist.java b/src/main/java/forestry/mail/gui/GuiPhilatelist.java index d02767d61..3b0a05445 100755 --- a/src/main/java/forestry/mail/gui/GuiPhilatelist.java +++ b/src/main/java/forestry/mail/gui/GuiPhilatelist.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.mail.gadgets.MachinePhilatelist; +import net.minecraft.entity.player.InventoryPlayer; public class GuiPhilatelist extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiTradeName.java b/src/main/java/forestry/mail/gui/GuiTradeName.java index d660bc1ca..d8e8f4b47 100755 --- a/src/main/java/forestry/mail/gui/GuiTradeName.java +++ b/src/main/java/forestry/mail/gui/GuiTradeName.java @@ -10,17 +10,14 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.InventoryPlayer; - -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.input.Keyboard; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.core.utils.StringUtil; import forestry.mail.gadgets.MachineTrader; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.entity.player.InventoryPlayer; +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.input.Keyboard; public class GuiTradeName extends GuiForestry { diff --git a/src/main/java/forestry/mail/gui/GuiTrader.java b/src/main/java/forestry/mail/gui/GuiTrader.java index 5e9999436..c021cfb8c 100755 --- a/src/main/java/forestry/mail/gui/GuiTrader.java +++ b/src/main/java/forestry/mail/gui/GuiTrader.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.mail.gui; -import net.minecraft.entity.player.InventoryPlayer; - import forestry.core.config.Defaults; import forestry.core.gui.GuiForestry; import forestry.core.utils.StringUtil; import forestry.mail.gadgets.MachineTrader; +import net.minecraft.entity.player.InventoryPlayer; public class GuiTrader extends GuiForestry { diff --git a/src/main/java/forestry/mail/items/ItemCatalogue.java b/src/main/java/forestry/mail/items/ItemCatalogue.java index 9140f005e..a670049d5 100755 --- a/src/main/java/forestry/mail/items/ItemCatalogue.java +++ b/src/main/java/forestry/mail/items/ItemCatalogue.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.mail.items; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.core.ForestryAPI; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class ItemCatalogue extends ItemForestry { diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index deb9e9c73..26f8a6686 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -10,8 +10,22 @@ ******************************************************************************/ package forestry.mail.items; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.ForestryAPI; +import forestry.api.mail.ILetter; +import forestry.core.EnumErrorCode; +import forestry.core.config.Config; +import forestry.core.interfaces.IErrorSource; +import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.ItemInventory; +import forestry.core.items.ItemInventoried; +import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; +import forestry.mail.Letter; import java.util.List; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -20,23 +34,6 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.api.core.ForestryAPI; -import forestry.api.mail.ILetter; -import forestry.core.EnumErrorCode; -import forestry.core.config.Config; -import forestry.core.interfaces.IErrorSource; -import forestry.core.interfaces.IHintSource; -import forestry.core.items.ItemInventoried; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.inventory.ItemInventory; -import forestry.core.utils.StringUtil; -import forestry.mail.Letter; - public class ItemLetter extends ItemInventoried { public static class LetterInventory extends ItemInventory implements IErrorSource, IHintSource { diff --git a/src/main/java/forestry/mail/items/ItemStamps.java b/src/main/java/forestry/mail/items/ItemStamps.java index 0315d5f81..f4029c064 100755 --- a/src/main/java/forestry/mail/items/ItemStamps.java +++ b/src/main/java/forestry/mail/items/ItemStamps.java @@ -10,13 +10,11 @@ ******************************************************************************/ package forestry.mail.items; -import net.minecraft.item.ItemStack; - import forestry.api.mail.EnumPostage; import forestry.api.mail.IStamps; import forestry.core.CreativeTabForestry; import forestry.core.items.ItemOverlay; -import forestry.core.utils.StringUtil; +import net.minecraft.item.ItemStack; public class ItemStamps extends ItemOverlay implements IStamps { diff --git a/src/main/java/forestry/mail/network/PacketLetterInfo.java b/src/main/java/forestry/mail/network/PacketLetterInfo.java index 857939524..92348d8e7 100644 --- a/src/main/java/forestry/mail/network/PacketLetterInfo.java +++ b/src/main/java/forestry/mail/network/PacketLetterInfo.java @@ -10,20 +10,18 @@ ******************************************************************************/ package forestry.mail.network; +import com.mojang.authlib.GameProfile; +import forestry.api.mail.EnumAddressee; +import forestry.api.mail.IMailAddress; +import forestry.api.mail.PostManager; +import forestry.api.mail.TradeStationInfo; +import forestry.core.network.ForestryPacket; +import forestry.mail.EnumStationState; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.UUID; - import net.minecraft.item.ItemStack; -import com.mojang.authlib.GameProfile; - -import forestry.api.mail.TradeStationInfo; -import forestry.api.mail.IMailAddress; -import forestry.api.mail.EnumAddressee; -import forestry.api.mail.PostManager; -import forestry.core.network.ForestryPacket; -import forestry.mail.EnumStationState; public class PacketLetterInfo extends ForestryPacket { diff --git a/src/main/java/forestry/mail/network/PacketPOBoxInfo.java b/src/main/java/forestry/mail/network/PacketPOBoxInfo.java index 2a8f22e1d..008fb6942 100755 --- a/src/main/java/forestry/mail/network/PacketPOBoxInfo.java +++ b/src/main/java/forestry/mail/network/PacketPOBoxInfo.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.mail.network; +import forestry.core.network.ForestryPacket; +import forestry.mail.POBoxInfo; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import forestry.core.network.ForestryPacket; -import forestry.mail.POBoxInfo; - public class PacketPOBoxInfo extends ForestryPacket { public POBoxInfo poboxInfo; diff --git a/src/main/java/forestry/mail/proxy/ProxyMail.java b/src/main/java/forestry/mail/proxy/ProxyMail.java index acb3221c5..53586dd28 100755 --- a/src/main/java/forestry/mail/proxy/ProxyMail.java +++ b/src/main/java/forestry/mail/proxy/ProxyMail.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.mail.proxy; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - +import forestry.api.mail.IMailAddress; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; import forestry.mail.POBoxInfo; import forestry.mail.network.PacketPOBoxInfo; -import forestry.api.mail.IMailAddress; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; public class ProxyMail { diff --git a/src/main/java/forestry/pipes/EnumFilterType.java b/src/main/java/forestry/pipes/EnumFilterType.java index 677a4aca9..863367b5d 100755 --- a/src/main/java/forestry/pipes/EnumFilterType.java +++ b/src/main/java/forestry/pipes/EnumFilterType.java @@ -7,14 +7,13 @@ ******************************************************************************/ package forestry.pipes; -import java.util.Locale; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.core.config.ForestryItem; import forestry.core.render.TextureManager; +import java.util.Locale; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; public enum EnumFilterType { diff --git a/src/main/java/forestry/pipes/GuiHandlerPipes.java b/src/main/java/forestry/pipes/GuiHandlerPipes.java index 938319638..d8cf9d0df 100755 --- a/src/main/java/forestry/pipes/GuiHandlerPipes.java +++ b/src/main/java/forestry/pipes/GuiHandlerPipes.java @@ -7,9 +7,6 @@ ******************************************************************************/ package forestry.pipes; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import buildcraft.transport.Pipe; import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.common.network.IGuiHandler; @@ -17,6 +14,9 @@ import forestry.core.network.GuiId; import forestry.pipes.gui.ContainerPropolisPipe; import forestry.pipes.gui.GuiPropolisPipe; import forestry.plugins.PluginApiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class GuiHandlerPipes implements IGuiHandler { diff --git a/src/main/java/forestry/pipes/PipeIconProvider.java b/src/main/java/forestry/pipes/PipeIconProvider.java index bd5de5aac..088050708 100755 --- a/src/main/java/forestry/pipes/PipeIconProvider.java +++ b/src/main/java/forestry/pipes/PipeIconProvider.java @@ -7,12 +7,12 @@ ******************************************************************************/ package forestry.pipes; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.core.render.TextureManager; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class PipeIconProvider implements IIconProvider { diff --git a/src/main/java/forestry/pipes/PipeItemsPropolis.java b/src/main/java/forestry/pipes/PipeItemsPropolis.java index 6f4f7a1b9..c77c59175 100755 --- a/src/main/java/forestry/pipes/PipeItemsPropolis.java +++ b/src/main/java/forestry/pipes/PipeItemsPropolis.java @@ -7,14 +7,6 @@ ******************************************************************************/ package forestry.pipes; -import java.util.ArrayList; -import java.util.LinkedList; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.IIconProvider; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Pipe; @@ -29,6 +21,13 @@ import forestry.api.genetics.IAllele; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; +import java.util.ArrayList; +import java.util.LinkedList; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsPropolis extends Pipe { diff --git a/src/main/java/forestry/pipes/PipeLogicPropolis.java b/src/main/java/forestry/pipes/PipeLogicPropolis.java index 86a5d79d8..7a5dc9cd6 100755 --- a/src/main/java/forestry/pipes/PipeLogicPropolis.java +++ b/src/main/java/forestry/pipes/PipeLogicPropolis.java @@ -7,27 +7,22 @@ ******************************************************************************/ package forestry.pipes; -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Pipe; import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IBee; -import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleSpecies; -import forestry.core.network.GuiId; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; import forestry.core.network.PacketNBT; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; public class PipeLogicPropolis { diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index 8af254003..a071a9583 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -8,12 +8,12 @@ */ package forestry.pipes.gui; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerForestry; import forestry.core.inventory.InventoryAdapter; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; public class ContainerPropolisPipe extends ContainerForestry { diff --git a/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java b/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java index f133b482e..3dbdd2c1a 100755 --- a/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/GuiPropolisPipe.java @@ -7,16 +7,6 @@ ******************************************************************************/ package forestry.pipes.gui; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map.Entry; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.IIcon; -import net.minecraftforge.common.util.ForgeDirection; - -import org.lwjgl.opengl.GL11; - import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IApiaristTracker; import forestry.api.genetics.AlleleManager; @@ -28,8 +18,8 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.gadgets.TileForestry; import forestry.core.genetics.ItemGE; -import forestry.core.gui.widgets.Widget; import forestry.core.gui.GuiForestry; +import forestry.core.gui.widgets.Widget; import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; @@ -37,6 +27,13 @@ import forestry.pipes.EnumFilterType; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; import forestry.plugins.PluginApiculture; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map.Entry; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; /** * GuiScreen for propolis pipes. diff --git a/src/main/java/forestry/pipes/network/PacketHandlerPipes.java b/src/main/java/forestry/pipes/network/PacketHandlerPipes.java index 8d08d8d57..bbd0ace57 100755 --- a/src/main/java/forestry/pipes/network/PacketHandlerPipes.java +++ b/src/main/java/forestry/pipes/network/PacketHandlerPipes.java @@ -7,12 +7,6 @@ ******************************************************************************/ package forestry.pipes.network; -import java.io.DataInputStream; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import buildcraft.transport.Pipe; import buildcraft.transport.TileGenericPipe; import forestry.core.interfaces.IPacketHandler; @@ -24,6 +18,11 @@ import forestry.core.proxy.Proxies; import forestry.pipes.PipeItemsPropolis; import forestry.pipes.PipeLogicPropolis; import forestry.pipes.gui.ContainerPropolisPipe; +import java.io.DataInputStream; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class PacketHandlerPipes implements IPacketHandler { diff --git a/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java b/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java index b2996274a..f66305bb1 100755 --- a/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java +++ b/src/main/java/forestry/pipes/proxy/ClientProxyPipes.java @@ -7,11 +7,11 @@ ******************************************************************************/ package forestry.pipes.proxy; +import buildcraft.transport.TransportProxyClient; +import forestry.plugins.PluginPropolisPipe; import net.minecraft.item.Item; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; -import buildcraft.transport.TransportProxyClient; -import forestry.plugins.PluginPropolisPipe; public class ClientProxyPipes extends ProxyPipes { diff --git a/src/main/java/forestry/pipes/proxy/ProxyPipes.java b/src/main/java/forestry/pipes/proxy/ProxyPipes.java index 1c6f1a424..3024428fb 100755 --- a/src/main/java/forestry/pipes/proxy/ProxyPipes.java +++ b/src/main/java/forestry/pipes/proxy/ProxyPipes.java @@ -7,11 +7,6 @@ ******************************************************************************/ package forestry.pipes.proxy; -import java.lang.reflect.Constructor; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.IItemRenderer; import buildcraft.BuildCraftTransport; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.transport.BlockGenericPipe; @@ -21,6 +16,10 @@ import buildcraft.transport.TransportProxy; import cpw.mods.fml.common.registry.GameRegistry; import forestry.pipes.PipeItemsPropolis; import forestry.plugins.PluginPropolisPipe; +import java.lang.reflect.Constructor; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; public class ProxyPipes { diff --git a/src/main/java/forestry/plugins/ForestryPlugin.java b/src/main/java/forestry/plugins/ForestryPlugin.java index c1027b777..e5b8577f0 100755 --- a/src/main/java/forestry/plugins/ForestryPlugin.java +++ b/src/main/java/forestry/plugins/ForestryPlugin.java @@ -11,20 +11,17 @@ package forestry.plugins; import cpw.mods.fml.common.IFuelHandler; -import java.util.Random; - -import net.minecraft.command.ICommand; -import net.minecraft.world.World; - import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.IGuiHandler; - import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPacketHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.IResupplyHandler; import forestry.core.interfaces.ISaveEventHandler; import java.util.EnumSet; +import java.util.Random; +import net.minecraft.command.ICommand; +import net.minecraft.world.World; public abstract class ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 4a6d187a8..d660a22d2 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -10,28 +10,6 @@ ******************************************************************************/ package forestry.plugins; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.util.IIcon; -import net.minecraft.util.WeightedRandomChestContent; - -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; - import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -42,7 +20,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -161,6 +138,25 @@ import forestry.core.items.ItemScoop; import forestry.core.proxy.Proxies; import forestry.core.render.EntitySnowFX; import forestry.core.utils.ShapedRecipeCustom; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.IIcon; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; @Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description") public class PluginApiculture extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 1a3ad311b..b1428866f 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -10,22 +10,6 @@ ******************************************************************************/ package forestry.plugins; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.WeightedRandomChestContent; - -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; - import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -33,7 +17,6 @@ import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; - import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeRoot; @@ -140,6 +123,19 @@ import forestry.core.items.ItemFruit.EnumFruit; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; import forestry.core.utils.ShapedRecipeCustom; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; @Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description") public class PluginArboriculture extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index 0e38ec085..eacab05c8 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -10,18 +10,15 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraftforge.fluids.Fluid; - +import buildcraft.api.fuels.BuildcraftFuelRegistry; import cpw.mods.fml.common.Optional; - import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; - -import buildcraft.api.fuels.BuildcraftFuelRegistry; +import net.minecraftforge.fluids.Fluid; @Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 2f1ad1cb5..2fa56db8b 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -10,14 +10,12 @@ ******************************************************************************/ package forestry.plugins; +import buildcraft.api.recipes.BuildcraftRecipeRegistry; import cpw.mods.fml.common.Optional; - import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; -import buildcraft.api.recipes.BuildcraftRecipeRegistry; - @Plugin(pluginID = "BC6|Recipes", name = "BuildCraft 6 Recipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftRecipes extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java index 61c9ed4f3..089957562 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java @@ -18,11 +18,10 @@ import buildcraft.api.statements.StatementManager; import cpw.mods.fml.common.Optional; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; +import java.util.Collection; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collection; - @Plugin(pluginID = "BC6|Statements", name = "BuildCraft 6 Statements", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") @Optional.Interface(iface = "ITriggerProvider", modid = "BuildCraftAPI|statements") public class PluginBuildCraftStatements extends ForestryPlugin implements ITriggerProvider { diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index f904f8b00..ba033a27e 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -10,14 +10,6 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.RecipeSorter; import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.network.IGuiHandler; import forestry.api.circuits.ChipsetManager; @@ -69,8 +61,15 @@ import forestry.core.items.ItemWrench; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryModEnvWarningCallable; import forestry.core.utils.ShapedRecipeCustom; - import java.util.ArrayList; +import net.minecraft.block.material.Material; +import net.minecraft.command.ICommand; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.RecipeSorter; @Plugin(pluginID = "Core", name = "Core", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.core.description") public class PluginCore extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginEE.java b/src/main/java/forestry/plugins/PluginEE.java index c684ce36f..d68e343f0 100755 --- a/src/main/java/forestry/plugins/PluginEE.java +++ b/src/main/java/forestry/plugins/PluginEE.java @@ -10,13 +10,6 @@ ******************************************************************************/ package forestry.plugins; -import java.lang.reflect.Field; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.common.BiomeDictionary; - import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IMutation; import forestry.apiculture.genetics.AlleleBeeSpecies; @@ -27,6 +20,10 @@ import forestry.apiculture.genetics.MutationEMC; import forestry.core.config.Defaults; import forestry.core.genetics.Allele; import forestry.core.proxy.Proxies; +import java.lang.reflect.Field; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.BiomeDictionary; @Plugin(pluginID = "EqEx2", name = "Equivalent Exchange 2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ee2.description") public class PluginEE extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginEnergy.java b/src/main/java/forestry/plugins/PluginEnergy.java index 443578996..a9679a6d7 100755 --- a/src/main/java/forestry/plugins/PluginEnergy.java +++ b/src/main/java/forestry/plugins/PluginEnergy.java @@ -10,23 +10,9 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; - -import net.minecraftforge.fluids.FluidStack; - import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; - -import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.ICircuitLayout; -import forestry.api.fuels.FuelManager; -import forestry.api.fuels.GeneratorFuel; import forestry.core.GameMode; -import forestry.core.circuits.Circuit; -import forestry.core.circuits.CircuitId; -import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; @@ -35,21 +21,16 @@ import forestry.core.gadgets.MachineDefinition; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; -import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.core.utils.ShapedRecipeCustom; import forestry.energy.GuiHandlerEnergy; -import forestry.energy.circuits.CircuitElectricBoost; -import forestry.energy.circuits.CircuitElectricChoke; -import forestry.energy.circuits.CircuitElectricEfficiency; -import forestry.energy.circuits.CircuitFireDampener; import forestry.energy.gadgets.EngineBronze; import forestry.energy.gadgets.EngineClockwork; import forestry.energy.gadgets.EngineCopper; import forestry.energy.gadgets.EngineDefinition; -import forestry.energy.gadgets.EngineTin; -import forestry.energy.gadgets.MachineGenerator; import forestry.energy.proxy.ProxyEnergy; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; @Plugin(pluginID = "Energy", name = "Energy", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.energy.description") public class PluginEnergy extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index d8306553d..8b974b6d4 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -10,18 +10,7 @@ ******************************************************************************/ package forestry.plugins; -import java.util.ArrayList; - -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.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - import cpw.mods.fml.common.network.IGuiHandler; - import forestry.api.recipes.ICraftingProvider; import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; @@ -53,6 +42,12 @@ import forestry.factory.gadgets.MillRainmaker; import forestry.factory.gadgets.TileWorktable; import forestry.factory.recipes.CraftGuideIntegration; import forestry.factory.triggers.FactoryTriggers; +import java.util.ArrayList; +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; @Plugin(pluginID = "Factory", name = "Factory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.factory.description") public class PluginFactory extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginFarmCraftory.java b/src/main/java/forestry/plugins/PluginFarmCraftory.java index 5a785612d..ba527c9e1 100755 --- a/src/main/java/forestry/plugins/PluginFarmCraftory.java +++ b/src/main/java/forestry/plugins/PluginFarmCraftory.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.plugins; -import java.lang.reflect.Method; -import java.util.HashMap; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - - import forestry.api.farming.Farmables; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; import forestry.farming.logic.FarmableFarmCraftory; +import java.lang.reflect.Method; +import java.util.HashMap; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; @Plugin(pluginID = "FarmCraftory", name = "FarmCraftory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.farmcraftory.description") public class PluginFarmCraftory extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 0c9187319..12c8782c2 100755 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -62,6 +62,7 @@ import forestry.farming.logic.FarmableVanillaSapling; import forestry.farming.logic.FarmableVanillaShroom; import forestry.farming.proxy.ProxyFarming; import forestry.farming.triggers.FarmingTriggers; +import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -70,8 +71,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; -import java.util.ArrayList; - @Plugin(pluginID = "Farming", name = "Farming", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.farming.description") public class PluginFarming extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index 47426ea22..5bf4f5b29 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -10,14 +10,9 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - import cpw.mods.fml.common.network.IGuiHandler; - import forestry.api.food.BeverageManager; import forestry.api.food.IBeverageEffect; -import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; @@ -32,6 +27,8 @@ import forestry.food.items.ItemAmbrosia; import forestry.food.items.ItemBeverage; import forestry.food.items.ItemBeverage.BeverageInfo; import forestry.food.items.ItemInfuser; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; @Plugin(pluginID = "Food", name = "Food", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.food.description") public class PluginFood extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index a0c9c382a..e8d6ca8df 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -10,19 +10,9 @@ ******************************************************************************/ package forestry.plugins; -import java.util.EnumSet; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; - import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitLayout; import forestry.api.fuels.FuelManager; @@ -56,10 +46,14 @@ import forestry.energy.gadgets.EngineTin; import forestry.energy.gadgets.MachineGenerator; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicRubber; - import ic2.api.item.IC2Items; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.Recipes; +import java.util.EnumSet; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; @Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index 9f7eff777..e5df08f22 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -10,19 +10,8 @@ ******************************************************************************/ package forestry.plugins; -import java.util.EnumSet; -import java.util.Locale; - -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.crafting.CraftingManager; - -import net.minecraftforge.oredict.RecipeSorter; - import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; - import forestry.api.arboriculture.ITreeRoot; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -59,6 +48,13 @@ import forestry.lepidopterology.genetics.ButterflyTemplates; import forestry.lepidopterology.items.ItemButterflyGE; import forestry.lepidopterology.items.ItemFlutterlyzer; import forestry.lepidopterology.proxy.ProxyLepidopterology; +import java.util.EnumSet; +import java.util.Locale; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraftforge.oredict.RecipeSorter; @Plugin(pluginID = "Lepidopterology", name = "Lepidopterology", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.lepidopterology.description") public class PluginLepidopterology extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index 0a81a1899..ac6715446 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -10,15 +10,8 @@ ******************************************************************************/ package forestry.plugins; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; - import forestry.api.mail.EnumAddressee; import forestry.api.mail.EnumPostage; import forestry.api.mail.PostManager; @@ -57,6 +50,11 @@ import forestry.mail.triggers.TriggerHasMail; import forestry.mail.triggers.TriggerLowInput; import forestry.mail.triggers.TriggerLowPaper; import forestry.mail.triggers.TriggerLowStamps; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; @Plugin(pluginID = "Mail", name = "Mail", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.mail.description") public class PluginMail extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index cc5628a8f..3de650512 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -11,16 +11,12 @@ package forestry.plugins; import com.google.common.collect.ImmutableList; -import java.util.ArrayList; - import com.google.common.collect.Lists; - import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameRegistry; import forestry.Forestry; - import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPacketHandler; import forestry.core.interfaces.IPickupHandler; @@ -28,6 +24,7 @@ import forestry.core.interfaces.IResupplyHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.proxy.Proxies; import java.io.File; +import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; import java.util.Locale; diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 5d2270cae..0cc9b89ca 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -10,21 +10,18 @@ ******************************************************************************/ package forestry.plugins; -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; - import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; +import java.util.ArrayList; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; @Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.natura.description") public class PluginNatura extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginPropolisPipe.java b/src/main/java/forestry/plugins/PluginPropolisPipe.java index 5e3f45715..13fe70503 100755 --- a/src/main/java/forestry/plugins/PluginPropolisPipe.java +++ b/src/main/java/forestry/plugins/PluginPropolisPipe.java @@ -16,9 +16,8 @@ import forestry.core.proxy.Proxies; import forestry.pipes.GuiHandlerPipes; import forestry.pipes.network.PacketHandlerPipes; import forestry.pipes.proxy.ProxyPipes; -import net.minecraft.item.Item; - import java.util.EnumSet; +import net.minecraft.item.Item; @Plugin(pluginID = "Pipes", name = "Pipes", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.pipes.description") public class PluginPropolisPipe extends ForestryPlugin { diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 0888e78c4..9f9a99262 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -10,45 +10,9 @@ ******************************************************************************/ package forestry.plugins; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockBasePressurePlate; -import net.minecraft.block.BlockButton; -import net.minecraft.block.BlockChest; -import net.minecraft.block.BlockFence; -import net.minecraft.block.BlockFenceGate; -import net.minecraft.block.BlockFurnace; -import net.minecraft.block.BlockLadder; -import net.minecraft.block.BlockLever; -import net.minecraft.block.BlockLog; -import net.minecraft.block.BlockMelon; -import net.minecraft.block.BlockPumpkin; -import net.minecraft.block.BlockRedstoneDiode; -import net.minecraft.block.BlockStairs; -import net.minecraft.block.BlockTorch; -import net.minecraft.block.BlockTrapDoor; -import net.minecraft.block.BlockWall; -import net.minecraft.block.BlockWorkbench; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemDoor; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.IShearable; -import net.minecraftforge.oredict.OreDictionary; - import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; - import forestry.api.core.Tabs; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; @@ -75,6 +39,38 @@ import forestry.storage.ResupplyHandler; import forestry.storage.items.ItemNaturalistBackpack; import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionApiarist; import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionLepidopterist; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.minecraft.block.Block; +import net.minecraft.block.BlockBasePressurePlate; +import net.minecraft.block.BlockButton; +import net.minecraft.block.BlockChest; +import net.minecraft.block.BlockFence; +import net.minecraft.block.BlockFenceGate; +import net.minecraft.block.BlockFurnace; +import net.minecraft.block.BlockLadder; +import net.minecraft.block.BlockLever; +import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockMelon; +import net.minecraft.block.BlockPumpkin; +import net.minecraft.block.BlockRedstoneDiode; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockTorch; +import net.minecraft.block.BlockTrapDoor; +import net.minecraft.block.BlockWall; +import net.minecraft.block.BlockWorkbench; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDoor; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.IShearable; +import net.minecraftforge.oredict.OreDictionary; @Plugin(pluginID = "Storage", name = "Storage", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.storage.description") public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandler { diff --git a/src/main/java/forestry/storage/BackpackDefinition.java b/src/main/java/forestry/storage/BackpackDefinition.java index a17d205e1..b46a1cb64 100755 --- a/src/main/java/forestry/storage/BackpackDefinition.java +++ b/src/main/java/forestry/storage/BackpackDefinition.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.storage; +import forestry.api.storage.IBackpackDefinition; +import forestry.core.utils.StackUtils; import java.util.ArrayList; import java.util.List; - -import forestry.core.utils.StackUtils; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import forestry.api.storage.IBackpackDefinition; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; diff --git a/src/main/java/forestry/storage/BackpackHelper.java b/src/main/java/forestry/storage/BackpackHelper.java index 6fdb5b07c..19573b5d7 100755 --- a/src/main/java/forestry/storage/BackpackHelper.java +++ b/src/main/java/forestry/storage/BackpackHelper.java @@ -10,13 +10,12 @@ ******************************************************************************/ package forestry.storage; -import net.minecraft.item.Item; - import forestry.api.storage.BackpackManager; import forestry.api.storage.EnumBackpackType; import forestry.api.storage.IBackpackDefinition; import forestry.api.storage.IBackpackInterface; import forestry.storage.items.ItemBackpack; +import net.minecraft.item.Item; public class BackpackHelper implements IBackpackInterface { diff --git a/src/main/java/forestry/storage/GuiHandlerStorage.java b/src/main/java/forestry/storage/GuiHandlerStorage.java index 835145b0c..8624dc305 100755 --- a/src/main/java/forestry/storage/GuiHandlerStorage.java +++ b/src/main/java/forestry/storage/GuiHandlerStorage.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.storage; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.ISpeciesRoot; @@ -22,13 +17,17 @@ import forestry.core.GuiHandlerBase; import forestry.core.config.Defaults; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.gui.IPagedInventory; -import forestry.core.network.GuiId; import forestry.core.inventory.ItemInventory; +import forestry.core.network.GuiId; import forestry.storage.gui.ContainerBackpack; import forestry.storage.gui.ContainerNaturalistBackpack; import forestry.storage.gui.GuiBackpack; import forestry.storage.gui.GuiBackpackT2; import forestry.storage.items.ItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class GuiHandlerStorage extends GuiHandlerBase { diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index 766f9ae4d..81380ffb9 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -10,15 +10,14 @@ ******************************************************************************/ package forestry.storage; +import forestry.core.interfaces.IPickupHandler; +import forestry.storage.gui.ContainerBackpack; +import forestry.storage.gui.ContainerNaturalistBackpack; +import forestry.storage.items.ItemBackpack; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import forestry.storage.gui.ContainerNaturalistBackpack; -import forestry.core.interfaces.IPickupHandler; -import forestry.storage.gui.ContainerBackpack; -import forestry.storage.items.ItemBackpack; - public class PickupHandlerStorage implements IPickupHandler { @Override diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index aefbf8ba7..b94471da8 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -10,20 +10,17 @@ ******************************************************************************/ package forestry.storage; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ContainerPlayer; -import net.minecraft.item.ItemStack; - import cpw.mods.fml.common.eventhandler.Event; - -import net.minecraftforge.common.MinecraftForge; - import forestry.api.storage.BackpackManager; import forestry.api.storage.BackpackResupplyEvent; import forestry.api.storage.IBackpackDefinition; import forestry.core.interfaces.IResupplyHandler; import forestry.core.inventory.ItemInventory; import forestry.storage.items.ItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; public class ResupplyHandler implements IResupplyHandler { diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index 0ce3de1f5..f64acf725 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.storage.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import forestry.core.config.Defaults; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.slots.SlotForestry; import forestry.core.inventory.ItemInventory; import forestry.storage.items.ItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class ContainerBackpack extends ContainerItemInventory { diff --git a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java index d0322062d..8f140a334 100755 --- a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.storage.gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - import forestry.api.genetics.ISpeciesRoot; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.IGuiSelectable; @@ -21,6 +17,9 @@ import forestry.core.gui.slots.SlotCustom; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.storage.GuiHandlerStorage.PagedInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; public class ContainerNaturalistBackpack extends ContainerItemInventory implements IGuiSelectable { diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 0b8e6f18e..dc99247a2 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -10,9 +10,26 @@ ******************************************************************************/ package forestry.storage.items; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.core.ForestryAPI; +import forestry.api.storage.BackpackStowEvent; +import forestry.api.storage.EnumBackpackType; +import forestry.api.storage.IBackpackDefinition; +import forestry.core.config.Defaults; +import forestry.core.inventory.InvTools; +import forestry.core.inventory.ItemInventory; +import forestry.core.inventory.wrappers.IInvSlot; +import forestry.core.inventory.wrappers.InventoryIterator; +import forestry.core.items.ItemInventoried; +import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; +import forestry.storage.BackpackMode; import java.util.List; import java.util.Locale; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -20,30 +37,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Event; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import forestry.api.core.ForestryAPI; -import forestry.api.storage.BackpackStowEvent; -import forestry.api.storage.EnumBackpackType; -import forestry.api.storage.IBackpackDefinition; -import forestry.core.config.Defaults; -import forestry.core.inventory.InvTools; -import forestry.core.inventory.wrappers.IInvSlot; -import forestry.core.inventory.wrappers.InventoryIterator; -import forestry.core.items.ItemInventoried; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.inventory.ItemInventory; -import forestry.core.utils.StringUtil; -import forestry.storage.BackpackMode; - public class ItemBackpack extends ItemInventoried { private final IBackpackDefinition info; diff --git a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java index 281e7a4d2..3397e9fa1 100755 --- a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java +++ b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java @@ -10,14 +10,13 @@ ******************************************************************************/ package forestry.storage.items; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import forestry.api.core.ForestryAPI; import forestry.api.storage.EnumBackpackType; import forestry.plugins.PluginApiculture; import forestry.plugins.PluginLepidopterology; import forestry.storage.BackpackDefinition; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; public class ItemNaturalistBackpack extends ItemBackpack { From 89c3fb8bdf8a62b31b64957216266c46a1e43ec5 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 16 Dec 2014 03:09:15 -0800 Subject: [PATCH 058/175] Attempt to fix issues with structure inventories. Also cleaned up the Hatch pipe/inventory interaction code, modernizing it and removing duplicate code. This involved adding my AdjecentInventoryCache and AdjecentTileCache code from Railcraft for greatly improved performance. ISpecialInventory is now 100% unused. --- api | 2 +- .../apiculture/gadgets/TileAlveary.java | 9 +- .../gadgets/TileAlvearyHygroregulator.java | 8 +- .../apiculture/gadgets/TileAlvearyPlain.java | 182 +++++++++--------- .../gadgets/TileAlvearyStabiliser.java | 1 + .../gadgets/TileAlvearySwarmer.java | 6 - .../arboriculture/gadgets/BlockSapling.java | 1 + .../forestry/core/gadgets/BlockForestry.java | 14 ++ .../forestry/core/gadgets/BlockStructure.java | 2 +- .../forestry/core/gadgets/TileForestry.java | 23 +++ .../inventory/AdjacentInventoryCache.java | 84 ++++++++ .../forestry/core/inventory/InvTools.java | 123 +++++++++--- .../core/utils/AdjacentTileCache.java | 134 +++++++++++++ .../java/forestry/core/utils/BlockUtil.java | 12 +- src/main/java/forestry/core/utils/Timer.java | 36 ++++ .../forestry/farming/gadgets/TileFarm.java | 8 +- .../forestry/farming/gadgets/TileHatch.java | 129 +++---------- 17 files changed, 535 insertions(+), 239 deletions(-) create mode 100644 src/main/java/forestry/core/inventory/AdjacentInventoryCache.java create mode 100644 src/main/java/forestry/core/utils/AdjacentTileCache.java create mode 100644 src/main/java/forestry/core/utils/Timer.java diff --git a/api b/api index 89067121c..20c3aa3ee 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 89067121c057bda5c535bf7a46c0112e245e311b +Subproject commit 20c3aa3eeee65fcec5b0590fce83445ec27c27b9 diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 40be9194a..f373d3a9c 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -26,6 +26,7 @@ import forestry.core.proxy.Proxies; import java.util.Collection; import java.util.LinkedList; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -125,7 +126,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon } /* ITILESTRUCTURE */ - @Override public String getTypeUID() { return structureLogic.getTypeUID(); @@ -208,7 +208,12 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon } @Override - public IInventory getInventory() { + public final IInventory getInventory() { + return getStructureInventory(); + } + + @Override + public ISidedInventory getStructureInventory() { return getInternalInventory(); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index bc57a0663..57dd6e24c 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -134,9 +134,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory TileInventoryAdapter canInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot - if (canInventory.getStackInSlot(0) != null) { + if (canInventory.getStackInSlot(0) != null) FluidHelper.drainContainers(tankManager, canInventory, 0); - } } @@ -179,11 +178,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory return BlockAlveary.ALVEARY_HYGRO; } - @Override - public IInventory getInventory() { - return getInternalInventory(); - } - /* IINVENTORY */ @Override public int getSizeInventory() { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 797097dbd..02c8e8dc1 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -22,14 +22,12 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; import forestry.api.core.IErrorState; -import forestry.api.core.ISpecialInventory; import forestry.api.core.ITileStructure; import forestry.api.genetics.IIndividual; import forestry.apiculture.gui.ContainerAlveary; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; -import forestry.core.config.ForestryItem; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; @@ -50,9 +48,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; -public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource { +public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource { // / CONSTANTS public static final int SLOT_QUEEN = 0; @@ -144,7 +141,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS // Add swarm effects if (worldObj.getTotalWorldTime() % 200 * 10 == 0) - onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN)); + onQueenChange(getStructureInventory().getStackInSlot(SLOT_QUEEN)); if (getErrorState() == EnumErrorCode.OK) queen.doFX(beekeepingLogic.getEffectData(), this); @@ -169,13 +166,13 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS if (!isMaster()) return; - if (getInternalInventory() == null) + if (getStructureInventory() == null) return; // / Multiplayer FX - if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) + if (PluginApiculture.beeInterface.isMated(getStructureInventory().getStackInSlot(SLOT_QUEEN))) if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) { - IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN)); + IBee displayQueen = PluginApiculture.beeInterface.getMember(getStructureInventory().getStackInSlot(SLOT_QUEEN)); displayQueen.doFX(beekeepingLogic.getEffectData(), this); } } @@ -200,7 +197,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS /* STATE INFORMATION */ private int getHealthDisplay() { - IInventory inventory = getInternalInventory(); + IInventory inventory = getStructureInventory(); if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -213,7 +210,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS } private int getMaxHealthDisplay() { - IInventory inventory = getInternalInventory(); + IInventory inventory = getStructureInventory(); if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -431,7 +428,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public boolean addProduct(ItemStack product, boolean all) { - TileInventoryAdapter inventory = getInternalInventory(); + TileInventoryAdapter inventory = getStructureInventory(); if (inventory == null) return false; @@ -530,7 +527,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS } /* IINVENTORY */ - private IInventory getStructureInventory() { + @Override + public TileInventoryAdapter getStructureInventory() { TileInventoryAdapter inventory = getInternalInventory(); if (inventory != null) { if (isMaster() || !Proxies.common.isSimulating(worldObj)) @@ -538,9 +536,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS } else if (hasMaster()) { ITileStructure central = getCentralTE(); if (central != null) - return central.getInventory(); + return (TileInventoryAdapter) central.getInventory(); } - return null; } @@ -582,12 +579,13 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - TileInventoryAdapter inventory = getInternalInventory(); - // Client side handling for container synch - if (inventory == null && !Proxies.common.isSimulating(worldObj)) - createInventory(); - IInventory inv = getStructureInventory(); + + // Client side handling for container synch + if (inv == null && !Proxies.common.isSimulating(worldObj)) { + createInventory(); + inv = getInternalInventory(); + } if (inv != null) inv.setInventorySlotContents(slotIndex, itemstack); } @@ -626,7 +624,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - TileInventoryAdapter inventory = getInternalInventory(); + ISidedInventory inventory = getStructureInventory(); if (inventory == null) return false; @@ -646,7 +644,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - TileInventoryAdapter inventory = getInternalInventory(); + ISidedInventory inventory = getStructureInventory(); if (inventory == null) return false; if (!inventory.canExtractItem(slotIndex, itemstack, side)) @@ -657,83 +655,83 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS @Override public int[] getAccessibleSlotsFromSide(int side) { - TileInventoryAdapter inventory = getInternalInventory(); + ISidedInventory inventory = getStructureInventory(); if (inventory == null) return Defaults.FACINGS_NONE; return inventory.getAccessibleSlotsFromSide(side); } /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { - - IInventory inv = getStructureInventory(); - if (inv == null) - return 0; - - // Princesses && Queens - if (ForestryItem.beePrincessGE.isItemEqual(stack) || ForestryItem.beeQueenGE.isItemEqual(stack)) - if (inv.getStackInSlot(SLOT_QUEEN) == null) { - if (doAdd) { - inv.setInventorySlotContents(SLOT_QUEEN, stack.copy()); - inv.getStackInSlot(SLOT_QUEEN).stackSize = 1; - } - return 1; - } - - // Drones - if (ForestryItem.beeDroneGE.isItemEqual(stack)) { - - ItemStack droneStack = inv.getStackInSlot(SLOT_DRONE); - if (droneStack == null) { - if (doAdd) - inv.setInventorySlotContents(SLOT_DRONE, stack.copy()); - return stack.stackSize; - } else { - if (!droneStack.isItemEqual(stack)) - return 0; - if (!ItemStack.areItemStackTagsEqual(droneStack, stack)) - return 0; - int space = droneStack.getMaxStackSize() - droneStack.stackSize; - if (space <= 0) - return 0; - - int added = space > stack.stackSize ? stack.stackSize : space; - if (doAdd) - droneStack.stackSize += added; - return added; - } - } - - return 0; - } - - @Override - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - - IInventory inv = getStructureInventory(); - if (inv == null) - return new ItemStack[0]; - - ItemStack product = null; - - for (int i = SLOT_PRODUCT_1; i < inv.getSizeInventory(); i++) { - if (inv.getStackInSlot(i) == null) - continue; - - ItemStack stack = inv.getStackInSlot(i); - - if (doRemove) - product = inv.decrStackSize(i, 1); - else { - product = stack.copy(); - product.stackSize = 1; - } - break; - } - - return new ItemStack[]{product}; - } +// @Override +// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { +// +// IInventory inv = getStructureInventory(); +// if (inv == null) +// return 0; +// +// // Princesses && Queens +// if (ForestryItem.beePrincessGE.isItemEqual(stack) || ForestryItem.beeQueenGE.isItemEqual(stack)) +// if (inv.getStackInSlot(SLOT_QUEEN) == null) { +// if (doAdd) { +// inv.setInventorySlotContents(SLOT_QUEEN, stack.copy()); +// inv.getStackInSlot(SLOT_QUEEN).stackSize = 1; +// } +// return 1; +// } +// +// // Drones +// if (ForestryItem.beeDroneGE.isItemEqual(stack)) { +// +// ItemStack droneStack = inv.getStackInSlot(SLOT_DRONE); +// if (droneStack == null) { +// if (doAdd) +// inv.setInventorySlotContents(SLOT_DRONE, stack.copy()); +// return stack.stackSize; +// } else { +// if (!droneStack.isItemEqual(stack)) +// return 0; +// if (!ItemStack.areItemStackTagsEqual(droneStack, stack)) +// return 0; +// int space = droneStack.getMaxStackSize() - droneStack.stackSize; +// if (space <= 0) +// return 0; +// +// int added = space > stack.stackSize ? stack.stackSize : space; +// if (doAdd) +// droneStack.stackSize += added; +// return added; +// } +// } +// +// return 0; +// } +// +// @Override +// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { +// +// IInventory inv = getStructureInventory(); +// if (inv == null) +// return new ItemStack[0]; +// +// ItemStack product = null; +// +// for (int i = SLOT_PRODUCT_1; i < inv.getSizeInventory(); i++) { +// if (inv.getStackInSlot(i) == null) +// continue; +// +// ItemStack stack = inv.getStackInSlot(i); +// +// if (doRemove) +// product = inv.decrStackSize(i, 1); +// else { +// product = stack.copy(); +// product.stackSize = 1; +// } +// break; +// } +// +// return new ItemStack[]{product}; +// } /* SMP GUI */ public void getGUINetworkData(int i, int j) { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java index a2da88c4c..c59947690 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyStabiliser.java @@ -53,6 +53,7 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier { } /* TEXTURES */ + @Override public int getIcon(int side, int metadata) { if(side == 0 || side == 1) return BlockAlveary.BOTTOM; diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index 129ebd5ee..a8f2f4aa2 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -32,7 +32,6 @@ import forestry.plugins.PluginApiculture; import java.util.Map.Entry; import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -219,11 +218,6 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv")); } - @Override - public IInventory getInventory() { - return getInternalInventory(); - } - /* IINVENTORY */ @Override public int getSizeInventory() { diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index 72185c13b..cf5cc876f 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -130,6 +130,7 @@ public class BlockSapling extends BlockTreeContainer { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbour) { + super.onNeighborBlockChange(world, x, y, z, neighbour); if (Proxies.common.isSimulating(world) && !this.canBlockStay(world, x, y, z)) { dropAsSapling(world, x, y, z); world.setBlockToAir(x, y, z); diff --git a/src/main/java/forestry/core/gadgets/BlockForestry.java b/src/main/java/forestry/core/gadgets/BlockForestry.java index 1ddf1c8dc..6ffd6e735 100755 --- a/src/main/java/forestry/core/gadgets/BlockForestry.java +++ b/src/main/java/forestry/core/gadgets/BlockForestry.java @@ -22,6 +22,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import org.apache.logging.log4j.Level; public abstract class BlockForestry extends BlockContainer { @@ -65,4 +66,17 @@ public abstract class BlockForestry extends BlockContainer { if (entityliving instanceof EntityPlayer) tile.setOwner(((EntityPlayer) entityliving)); } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + try { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileForestry) + ((TileForestry) tile).onNeighborBlockChange(block); + } catch (StackOverflowError error) { + Proxies.log.logThrowable(Level.ERROR, "Stack Overflow Error in BlockMachine.onNeighborBlockChange()", 10, error); + throw error; + } + } + } diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index 268f71697..7a74218c8 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -87,7 +87,7 @@ public abstract class BlockStructure extends BlockForestry { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { - + super.onNeighborBlockChange(world, x, y, z, neighbor); if (!Proxies.common.isSimulating(world)) return; diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 2f3452031..d8c777ec9 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -27,10 +27,12 @@ import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketPayload; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; +import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Vect; import java.util.Collection; +import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -45,9 +47,30 @@ import net.minecraftforge.common.util.ForgeDirection; @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") public abstract class TileForestry extends TileEntity implements INetworkedEntity, IOwnable, IErrorSource, ITriggerProvider { + protected final AdjacentTileCache tileCache = new AdjacentTileCache(this); protected boolean isInited = false; private TileInventoryAdapter inventory; + public AdjacentTileCache getTileCache() { + return tileCache; + } + + public void onNeighborBlockChange(Block id) { + tileCache.onNeighborChange(); + } + + @Override + public void invalidate() { + tileCache.purge(); + super.invalidate(); + } + + @Override + public void validate() { + tileCache.purge(); + super.validate(); + } + public Vect Coords() { return new Vect(xCoord, yCoord, zCoord); } diff --git a/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java new file mode 100644 index 000000000..d77b7695f --- /dev/null +++ b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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.inventory; + +import forestry.core.utils.AdjacentTileCache; +import java.util.*; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * + * @author CovertJaguar + */ +public final class AdjacentInventoryCache implements AdjacentTileCache.ICacheListener { + + private final AdjacentTileCache cache; + private boolean changed = true; + private final List invs = new LinkedList(); + private final IInventory[] sides = new IInventory[6]; + private final Comparator sorter; + private final ITileFilter filter; + + public AdjacentInventoryCache(TileEntity tile, AdjacentTileCache cache) { + this(tile, cache, null, null); + } + + public AdjacentInventoryCache(TileEntity tile, AdjacentTileCache cache, ITileFilter filter, Comparator sorter) { + this.cache = cache; + this.filter = filter; + this.sorter = sorter; + cache.addListener(this); + } + + public IInventory getAdjecentInventory(ForgeDirection side) { + checkChanged(); + return sides[side.ordinal()]; + } + + public Collection getAdjecentInventories() { + checkChanged(); + return invs; + } + + @Override + public void changed() { + changed = true; + } + + @Override + public void purge() { + invs.clear(); + Arrays.fill(sides, null); + } + + private void checkChanged() { + cache.refresh(); + if (changed) { + changed = false; + purge(); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = cache.getTileOnSide(side); + if (tile != null && (filter == null || filter.matches(tile))) { + IInventory inv = InvTools.getInventoryFromTile(tile, side.getOpposite()); + if (inv != null) { + sides[side.ordinal()] = inv; + invs.add(inv); + } + } + } + if (sorter != null) + Collections.sort(invs, sorter); + } + } + +} diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 582687b48..f18d5f780 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -10,8 +10,8 @@ ******************************************************************************/ package forestry.core.inventory; +import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeManager; -import forestry.api.core.ISpecialInventory; import forestry.core.inventory.filters.ArrayStackFilter; import forestry.core.inventory.filters.IStackFilter; import forestry.core.inventory.filters.InvertedStackFilter; @@ -19,9 +19,11 @@ import forestry.core.inventory.filters.StackFilter; import forestry.core.inventory.manipulators.InventoryManipulator; import forestry.core.inventory.wrappers.ChestWrapper; import forestry.core.inventory.wrappers.IInvSlot; +import forestry.core.inventory.wrappers.InventoryCopy; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; +import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.PlainInventory; import java.util.ArrayList; import java.util.Collection; @@ -46,9 +48,9 @@ import net.minecraftforge.oredict.OreDictionary; public abstract class InvTools { /*private static final String TAG_ID = "id"; - private static final String TAG_SIZE = "stackSize"; - private static final String TAG_DAMAGE = "Damage"; - private static final String TAG_COUNT = "Count";*/ + private static final String TAG_SIZE = "stackSize"; + private static final String TAG_DAMAGE = "Damage"; + private static final String TAG_COUNT = "Count";*/ private static final String TAG_SLOT = "Slot"; public static int getXOnSide(int x, ForgeDirection side) { @@ -168,15 +170,14 @@ public abstract class InvTools { } /*public static void addItemToolTip(ItemStack stack, String tag, String msg) { - NBTTagCompound nbt = getItemData(stack); - NBTTagCompound display = nbt.getCompoundTag("display"); - nbt.setTag("display", display); - NBTTagList lore = display.getTagList("Lore", 8); // 8 = String - display.setTag("Lore", lore); - //lore.appendTag(new NBTTagString(tag, msg)); - lore.appendTag(new NBTTagString(msg)); - }*/ - + NBTTagCompound nbt = getItemData(stack); + NBTTagCompound display = nbt.getCompoundTag("display"); + nbt.setTag("display", display); + NBTTagList lore = display.getTagList("Lore", 8); // 8 = String + display.setTag("Lore", lore); + //lore.appendTag(new NBTTagString(tag, msg)); + lore.appendTag(new NBTTagString(msg)); + }*/ public static NBTTagCompound getItemData(ItemStack stack) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { @@ -321,7 +322,7 @@ public abstract class InvTools { return count; } - public static int countItems(Collection inventories, ItemStack... filter) { + public static int countItems(Iterable inventories, ItemStack... filter) { int count = 0; for (IInventory inv : inventories) { count += InvTools.countItems(inv, filter); @@ -409,7 +410,7 @@ public abstract class InvTools { * @param filters * @return */ - public static ItemStack moveOneItem(Collection sources, IInventory dest, ItemStack... filters) { + public static ItemStack moveOneItem(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItem(inv, dest, filters); if (moved != null) @@ -426,7 +427,7 @@ public abstract class InvTools { * @param filter * @return */ - public static ItemStack moveOneItem(Collection sources, IInventory dest, IStackFilter filter) { + public static ItemStack moveOneItem(Iterable sources, IInventory dest, IStackFilter filter) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItem(inv, dest, filter); if (moved != null) @@ -443,7 +444,7 @@ public abstract class InvTools { * @param filters * @return */ - public static ItemStack moveOneItem(IInventory source, Collection destinations, ItemStack... filters) { + public static ItemStack moveOneItem(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { ItemStack moved = InvTools.moveOneItem(source, dest, filters); if (moved != null) @@ -474,7 +475,7 @@ public abstract class InvTools { * @param filters * @return */ - public static ItemStack moveOneItemExcept(Collection sources, IInventory dest, ItemStack... filters) { + public static ItemStack moveOneItemExcept(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { ItemStack moved = InvTools.moveOneItemExcept(inv, dest, filters); if (moved != null) @@ -491,7 +492,7 @@ public abstract class InvTools { * @param filters * @return */ - public static ItemStack moveOneItemExcept(IInventory source, Collection destinations, ItemStack... filters) { + public static ItemStack moveOneItemExcept(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { ItemStack moved = InvTools.moveOneItemExcept(source, dest, filters); if (moved != null) @@ -650,6 +651,41 @@ public abstract class InvTools { return im.addStack(stack); } + /** + * Attempts to move an ItemStack from one inventory to another. + * + * @param source The source IInventory. + * @param dest The destination IInventory. + * @return true if any items were moved + */ + public static boolean moveItemStack(IInventory source, IInventory dest) { + InventoryManipulator im = InventoryManipulator.get(dest); + for (IInvSlot slot : InventoryIterator.getIterable(source)) { + ItemStack stack = slot.getStackInSlot(); + if (stack != null) { + ItemStack remainder = im.addStack(stack); + slot.setStackInSlot(remainder); + return !isItemEqualStrict(stack, remainder); + } + } + return false; + } + + /** + * Attempts to move an ItemStack from one inventory to another. + * + * @param source The source IInventory. + * @param destinations The destination IInventory. + * @return true if any items were moved + */ + public static boolean moveItemStack(IInventory source, Iterable destinations) { + for (IInventory dest : destinations) { + if (moveItemStack(source, dest)) + return true; + } + return false; + } + /** * Checks if there is room for the ItemStack in the inventory. * @@ -673,8 +709,6 @@ public abstract class InvTools { * @return */ public static ItemStack[] removeItems(IInventory inv, int numItems) { - if (inv instanceof ISpecialInventory) - return ((ISpecialInventory) inv).extractItem(true, ForgeDirection.UNKNOWN, numItems); PlainInventory output = new PlainInventory(27, "temp"); for (int i = 0; i < inv.getSizeInventory(); i++) { if (numItems <= 0) @@ -743,7 +777,7 @@ public abstract class InvTools { * @param filter EnumItemType to match against * @return An ItemStack */ - public static ItemStack removeOneItem(Collection invs, IStackFilter filter) { + public static ItemStack removeOneItem(Iterable invs, IStackFilter filter) { for (IInventory inv : invs) { ItemStack stack = removeOneItem(inv, filter); if (stack != null) @@ -752,6 +786,51 @@ public abstract class InvTools { return null; } + /** + * Attempts to move a single item from the source inventory into a adjacent Buildcraft pipe. + * If the attempt fails, the source Inventory will not be modified. + * + * @param source The source inventory + * @param tileCache The tile cache of the source block. + * @return true if an item was inserted, otherwise false. + */ + public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + IInventory invClone = new InventoryCopy(source); + ItemStack stackToMove = removeOneItem(invClone); + if (stackToMove == null) + return false; + if (stackToMove.stackSize <= 0) + return false; + + IPipeTile[] pipes = new IPipeTile[6]; + boolean foundPipe = false; + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = tileCache.getTileOnSide(side); + if (tile instanceof IPipeTile) { + IPipeTile pipe = (IPipeTile) tile; + if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { + pipes[side.ordinal()] = pipe; + foundPipe = true; + } + } + } + + if (!foundPipe) + return false; + + int choice = tileCache.getSource().getWorldObj().rand.nextInt(6); + + ForgeDirection side = ForgeDirection.getOrientation(choice); + + IPipeTile pipe = pipes[choice]; + if (pipe.injectItem(stackToMove, false, side.getOpposite()) > 0) + if (removeOneItem(source, stackToMove) != null) { + pipe.injectItem(stackToMove, true, side.getOpposite()); + return true; + } + return false; + } + public static void writeInvToNBT(IInventory inv, String tag, NBTTagCompound data) { NBTTagList list = new NBTTagList(); for (byte slot = 0; slot < inv.getSizeInventory(); slot++) { diff --git a/src/main/java/forestry/core/utils/AdjacentTileCache.java b/src/main/java/forestry/core/utils/AdjacentTileCache.java new file mode 100644 index 000000000..9b58edddf --- /dev/null +++ b/src/main/java/forestry/core/utils/AdjacentTileCache.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.Set; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * + * @author CovertJaguar + */ +public final class AdjacentTileCache { + + private static final int DELAY_MIN = 20; + private static final int DELAY_MAX = 2400; + private static final int DELAY_STEP = 2; + private final Timer[] timer = new Timer[6]; + private final TileEntity[] cache = new TileEntity[6]; + private final int[] delay = new int[6]; + private final TileEntity source; + private final Set listeners = new LinkedHashSet(); + + public static interface ICacheListener { + + void changed(); + + void purge(); + + } + + public AdjacentTileCache(TileEntity tile) { + this.source = tile; + Arrays.fill(delay, DELAY_MIN); + for (int i = 0; i < timer.length; i++) { + timer[i] = new Timer(); + } + } + + public void addListener(ICacheListener listener) { + listeners.add(listener); + } + + private TileEntity searchSide(ForgeDirection side) { + World world = source.getWorldObj(); + int sx = source.xCoord + side.offsetX; + int sy = source.yCoord + side.offsetY; + int sz = source.zCoord + side.offsetZ; + if (world.blockExists(sx, sy, sz) && world.getBlock(sx, sy, sz) != Blocks.air) + return world.getTileEntity(sx, sy, sz); + return null; + } + + public void refresh() { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + getTileOnSide(side); + } + } + + public void purge() { + Arrays.fill(cache, null); + Arrays.fill(delay, DELAY_MIN); + for (Timer t : timer) { + t.reset(); + } + changed(); + for (ICacheListener listener : listeners) { + listener.purge(); + } + } + + public void onNeighborChange() { + Arrays.fill(delay, DELAY_MIN); + } + + protected void setTile(int side, TileEntity tile) { + if (cache[side] != tile) { + cache[side] = tile; + changed(); + } + } + + private void changed() { + for (ICacheListener listener : listeners) { + listener.changed(); + } + } + + private boolean areCoordinatesOnSide(ForgeDirection side, TileEntity target) { + return source.xCoord + side.offsetX == target.xCoord && source.yCoord + side.offsetY == target.yCoord && source.zCoord + side.offsetZ == target.zCoord; + } + + public TileEntity getTileOnSide(ForgeDirection side) { + int s = side.ordinal(); + if (cache[s] != null) + if (cache[s].isInvalid() || !areCoordinatesOnSide(side, cache[s])) + setTile(s, null); + else + return cache[s]; + + if (timer[s].hasTriggered(source.getWorldObj(), delay[s])) { + setTile(s, searchSide(side)); + if (cache[s] == null) + incrementDelay(s); + else + delay[s] = DELAY_MIN; + } + + return cache[s]; + } + + private void incrementDelay(int side) { + delay[side] += DELAY_STEP; + if (delay[side] > DELAY_MAX) + delay[side] = DELAY_MAX; + } + + public TileEntity getSource() { + return source; + } + +} diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index a6b504ce9..de6782603 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -49,10 +49,13 @@ public class BlockUtil { * @param blockPos * @param from * @return + * @deprecated Use AdjacentInventoryCache instead */ + @Deprecated public static IInventory[] getAdjacentInventories(World world, Vect blockPos, ForgeDirection from) { ArrayList inventories = new ArrayList(); + // WTF is this? A loop that only picks the opposite direction? -CovertJaguar for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if (from != ForgeDirection.UNKNOWN && from != dir.getOpposite()) continue; @@ -88,12 +91,12 @@ public class BlockUtil { TileEntity pipeEntry = world.getTileEntity((int) posPipe.x, (int) posPipe.y, (int) posPipe.z); if (pipeEntry instanceof IPipeTile) { - IPipeTile pipe = (IPipeTile)pipeEntry; + IPipeTile pipe = (IPipeTile) pipeEntry; if (from != ForgeDirection.UNKNOWN && pipeEntry instanceof IPipeConnection) { if (((IPipeConnection) pipeEntry).overridePipeConnection(PipeType.ITEM, from) != ConnectOverride.DISCONNECT) possiblePipes.add(dir); - } else if(pipe.getPipeType() == PipeType.ITEM && pipe.isPipeConnected(dir.getOpposite())) + } else if (pipe.getPipeType() == PipeType.ITEM && pipe.isPipeConnected(dir.getOpposite())) possiblePipes.add(dir); } } @@ -106,9 +109,10 @@ public class BlockUtil { ArrayList filtered = new ArrayList(); ArrayList excludeList = new ArrayList(Arrays.asList(exclude)); - for (ForgeDirection direction : allDirections) + for (ForgeDirection direction : allDirections) { if (!excludeList.contains(direction)) filtered.add(direction); + } return filtered; @@ -137,7 +141,7 @@ public class BlockUtil { IPipeTile pipe = (IPipeTile) tile.getWorldObj().getTileEntity((int) pipePos.x, (int) pipePos.y, (int) pipePos.z); ItemStack payload = stack.splitStack(1); - if(pipe.injectItem(payload, true, itemPos.orientation.getOpposite()) > 0) + if (pipe.injectItem(payload, true, itemPos.orientation.getOpposite()) > 0) return true; else pipes.remove(choice); diff --git a/src/main/java/forestry/core/utils/Timer.java b/src/main/java/forestry/core/utils/Timer.java new file mode 100644 index 000000000..68126fa6b --- /dev/null +++ b/src/main/java/forestry/core/utils/Timer.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import net.minecraft.world.World; + +/** + * + * @author CovertJaguar + */ +public class Timer { + + private long startTime = Long.MIN_VALUE; + + public boolean hasTriggered(World world, int ticks) { + long currentTime = world.getTotalWorldTime(); + if (currentTime >= (ticks + startTime) || startTime > currentTime) { + startTime = currentTime; + return true; + } + return false; + } + + public void reset() { + startTime = Long.MIN_VALUE; + } + +} diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 479b342e8..448e669ae 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -27,6 +27,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -315,7 +316,12 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { } @Override - public IInventory getInventory() { + public final IInventory getInventory() { + return getStructureInventory(); + } + + @Override + public ISidedInventory getStructureInventory() { return getInternalInventory(); } diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 9cede7c5e..ad1e019ef 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -13,13 +13,14 @@ package forestry.farming.gadgets; import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import forestry.api.core.ITileStructure; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.StackUtils; +import forestry.core.inventory.AdjacentInventoryCache; +import forestry.core.inventory.ITileFilter; +import forestry.core.inventory.InvTools; +import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.utils.Utils; import forestry.farming.triggers.FarmingTriggers; -import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -31,6 +32,14 @@ import net.minecraftforge.fluids.FluidContainerRegistry; public class TileHatch extends TileFarm implements ISidedInventory { + private final AdjacentInventoryCache inventoryCache = new AdjacentInventoryCache(this, getTileCache(), new ITileFilter() { + + @Override + public boolean matches(TileEntity tile) { + return !(tile instanceof TileFarm); + } + }, null); + public TileHatch() { fixedType = TYPE_HATCH; } @@ -47,82 +56,30 @@ public class TileHatch extends TileFarm implements ISidedInventory { } /* AUTO-EJECTING */ + private IInventory getProductInventory() { + return new InventoryMapper(getStructureInventory(), TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION); + } + protected void dumpStash() { if (!hasMaster()) return; - ArrayList pipes = new ArrayList(); - ForgeDirection[] tmp = BlockUtil.getPipeDirections(worldObj, Coords(), ForgeDirection.UP); - Collections.addAll(pipes, tmp); - - if (pipes.size() > 0) - dumpToPipe(pipes); - else { - IInventory[] inventories = BlockUtil.getAdjacentInventories(worldObj, Coords(), ForgeDirection.UP); - dumpToInventory(inventories); + if (!InvTools.moveOneItemToPipe(getProductInventory(), tileCache)) { + IInventory struct = getStructureInventory(); + if (struct != null) + InvTools.moveItemStack(getProductInventory(), inventoryCache.getAdjecentInventories()); } } - private void dumpToPipe(ArrayList pipes) { - - ItemStack[] products = extractItem(true, ForgeDirection.DOWN, 1); - for (ItemStack product : products) { - while (product.stackSize > 0) { - BlockUtil.putFromStackIntoPipe(this, pipes, product); - } - } - - } - - private void dumpToInventory(IInventory[] inventories) { - - ITileStructure central = getCentralTE(); - if (central == null) - return; - IInventory inv = central.getInventory(); - - for (int i = TileFarmPlain.SLOT_PRODUCTION_1; i < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; i++) { - if (inv.getStackInSlot(i) == null) - continue; - - ItemStack stack = inv.getStackInSlot(i); - - if (stack.stackSize <= 0) - continue; - - for (IInventory inventory : inventories) { - - // Don't dump in arboretums! - if (inventory.getSizeInventory() < 4) - continue; - - // Get complete inventory (for double chests) - IInventory completeInventory = Utils.getChest(inventory); - if (completeInventory instanceof ISidedInventory) { - ISidedInventory sidedInventory = (ISidedInventory) completeInventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.UP.ordinal()); - for (int sl = 0; sl < slots.length; ++sl) { - StackUtils.stowInInventory(stack, sidedInventory, true, sl, 1); - } - } else { - StackUtils.stowInInventory(stack, completeInventory, true); - if (stack.stackSize <= 0) { - inv.setInventorySlotContents(i, null); - break; - } - } - } - } - - } - /* IINVENTORY */ - private ISidedInventory getStructureInventory() { + @Override + public TileInventoryAdapter getStructureInventory() { if (hasMaster()) { ITileStructure central = getCentralTE(); - if (central != null) - return (ISidedInventory) central.getInventory(); + if (central != null){ + return (TileInventoryAdapter) central.getInventory(); + } } return null; @@ -248,40 +205,6 @@ public class TileHatch extends TileFarm implements ISidedInventory { return getStructureInventory().getAccessibleSlotsFromSide(side); } - public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { - - IInventory inv; - if (hasMaster()) { - ITileStructure central = getCentralTE(); - if (central == null) - return new ItemStack[0]; - inv = getCentralTE().getInventory(); - } else - return StackUtils.EMPTY_STACK_ARRAY; - - ItemStack product = null; - - for (int i = TileFarmPlain.SLOT_PRODUCTION_1; i < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; i++) { - if (inv.getStackInSlot(i) == null) - continue; - - ItemStack stack = inv.getStackInSlot(i); - - if (doRemove) - product = inv.decrStackSize(i, 1); - else { - product = stack.copy(); - product.stackSize = 1; - } - break; - } - - if (product != null) - return new ItemStack[]{product}; - else - return StackUtils.EMPTY_STACK_ARRAY; - } - /* ITRIGGERPROVIDER */ @Optional.Method(modid = "BuildCraftAPI|statements") @Override From 35afdc66b8b7259fd72b1c03e538bba4779f9345 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 15 Dec 2014 23:14:04 -0800 Subject: [PATCH 059/175] Remove unused config options, fix enableBackpackResupply option --- .../forestry/core/TickHandlerCoreClient.java | 15 ++++------ .../forestry/core/TickHandlerCoreServer.java | 16 ++++++---- .../java/forestry/core/config/Config.java | 29 ++----------------- .../forestry/storage/items/ItemBackpack.java | 15 +++++----- 4 files changed, 25 insertions(+), 50 deletions(-) diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index b31091770..c89cafe19 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -10,17 +10,20 @@ ******************************************************************************/ package forestry.core; +import java.util.concurrent.ConcurrentLinkedQueue; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; + import forestry.core.config.Config; import forestry.core.config.Version; import forestry.core.proxy.Proxies; import forestry.core.utils.Utils; -import java.util.concurrent.ConcurrentLinkedQueue; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; public class TickHandlerCoreClient { @@ -56,12 +59,6 @@ public class TickHandlerCoreClient { } } - /* - if (!Config.disableNags) - if (Proxies.common.isModLoaded("GregTech_Addon")) - queueChatMessage("\u00A76Forestry may have been modified by GregTech. It may behave unexpectedly and some config options may not work. Do not report issues with this install! You can disable this nag in the config."); - */ - if (!naggedVersion && !Config.disableVersionCheck && Version.needsUpdateNoticeAndMarkAsSeen()) { queueChatMessage(String.format("\u00A7cNew version of Forestry available: %s for Minecraft %s", Version.getRecommendedVersion(), Proxies.common.getMinecraftVersion())); diff --git a/src/main/java/forestry/core/TickHandlerCoreServer.java b/src/main/java/forestry/core/TickHandlerCoreServer.java index ac90cedf4..dfa355c52 100755 --- a/src/main/java/forestry/core/TickHandlerCoreServer.java +++ b/src/main/java/forestry/core/TickHandlerCoreServer.java @@ -10,13 +10,16 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.entity.player.EntityPlayer; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; + +import forestry.core.config.Config; import forestry.core.interfaces.IResupplyHandler; import forestry.plugins.PluginManager; -import net.minecraft.entity.player.EntityPlayer; public class TickHandlerCoreServer { public TickHandlerCoreServer() { @@ -27,11 +30,12 @@ public class TickHandlerCoreServer { public void onWorldTick(WorldTickEvent event) { if (event.phase != Phase.END) return; - for (Object obj : event.world.playerEntities) { - EntityPlayer player = (EntityPlayer) obj; - for (IResupplyHandler handler : PluginManager.resupplyHandlers) - handler.resupply(player); + if (Config.enableBackpackResupply) { + for (Object obj : event.world.playerEntities) { + EntityPlayer player = (EntityPlayer) obj; + for (IResupplyHandler handler : PluginManager.resupplyHandlers) + handler.resupply(player); + } } - } } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 34ccbeb14..99aa51e59 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.core.config; -import forestry.core.proxy.Proxies; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; @@ -22,6 +21,8 @@ import java.util.HashSet; import java.util.Locale; import java.util.Properties; +import forestry.core.proxy.Proxies; + public class Config { public static final String CATEGORY_COMMON = "common"; @@ -36,7 +37,6 @@ public class Config { public static boolean isDebug = false; public static boolean disablePermissions = false; - public static boolean disableNags = false; public static boolean disableVersionCheck = false; public static boolean invalidFingerprint = false; @@ -55,23 +55,14 @@ public class Config { public static boolean generateCopperOre = true; public static boolean generateTinOre = true; public static boolean generateBeehives = true; - public static boolean generateBogEarth = false; public static boolean generateBeehivesDebug = false; // Performance public static boolean enableBackpackResupply = true; - public static int planterThrottle; - public static int harvesterThrottle; // Customization public static boolean tooltipLiquidAmount = true; - public static boolean planterSideSensitive = true; - /** - * True if the harvester should decide output to pipes according to side. - */ - public static boolean harvesterSideSensitive = true; - /* GO AWAY GRED */ private static boolean craftingBronzeEnabled = true; public static boolean getCraftingBronzeEnabled() { @@ -81,7 +72,6 @@ public class Config { public static boolean craftingStampsEnabled = true; public static final ArrayList collectorStamps = new ArrayList(); - public static boolean applePickup = true; public static boolean squareFarms = false; // Mail @@ -160,13 +150,6 @@ public class Config { genTinOre.Comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; generateTinOre = Boolean.parseBoolean(genTinOre.Value); - Property planterSideSense = config.get("planters.sidesensitive", CATEGORY_COMMON, true); - planterSideSense.Comment = "set to false if farms should output all harvested products regardless of side a pipe is attached to"; - planterSideSensitive = Boolean.parseBoolean(planterSideSense.Value); - Property harvesterSideSense = config.get("harvesters.sidesensitive", CATEGORY_COMMON, true); - harvesterSideSense.Comment = "set to false if harvesters should output all harvested products regardless of side a pipe is attached to"; - harvesterSideSensitive = Boolean.parseBoolean(harvesterSideSense.Value); - Property bronzeRecipe = config.get("crafting.bronze.enabled", CATEGORY_COMMON, true); bronzeRecipe.Comment = "set to false to disable crafting recipe for bronze"; craftingBronzeEnabled = Boolean.parseBoolean(bronzeRecipe.Value); @@ -189,10 +172,6 @@ public class Config { indicatorEnable.Comment = "set to false to disable the mail alert box"; mailAlertEnabled = Boolean.parseBoolean(indicatorEnable.Value); - Property appleHarvest = config.get("tweaks.apple.pickup.enabled", CATEGORY_COMMON, true); - appleHarvest.Comment = "set to false to disable apple pickup by appropriate harvesters"; - applePickup = Boolean.parseBoolean(appleHarvest.Value); - Property clearGenome = config.get("genetics.clear.invalid.chromosomes", CATEGORY_COMMON, clearInvalidChromosomes); clearGenome.Comment = "set to true to clear chromosomes which contain invalid alleles. might rescue your save if it is crashing after the removal of a bee addon."; clearInvalidChromosomes = Boolean.parseBoolean(clearGenome.Value); @@ -219,10 +198,6 @@ public class Config { property.Comment = "set to true to disable access restrictions on forestry machines."; Config.disablePermissions = Boolean.parseBoolean(property.Value); - property = config.get("tweaks.nags.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable some nagging and warnings (e.g. GregTech)."; - Config.disableNags = Boolean.parseBoolean(property.Value); - property = config.get("tweaks.upgradenotice.disabled", CATEGORY_COMMON, false); property.Comment = "set to true to disable update and version check notice."; Config.disableVersionCheck = isDebug || Boolean.parseBoolean(property.Value); diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index dc99247a2..825bdc2b3 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -17,6 +17,7 @@ import forestry.api.core.ForestryAPI; import forestry.api.storage.BackpackStowEvent; import forestry.api.storage.EnumBackpackType; import forestry.api.storage.IBackpackDefinition; +import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.inventory.InvTools; import forestry.core.inventory.ItemInventory; @@ -120,14 +121,12 @@ public class ItemBackpack extends ItemInventoried { private void switchMode(ItemStack itemstack) { BackpackMode mode = getMode(itemstack); - if (mode == BackpackMode.RESUPPLY) - itemstack.setItemDamage(0); - else if (mode == BackpackMode.RECEIVE) - itemstack.setItemDamage(3); - else if (mode == BackpackMode.LOCKED) - itemstack.setItemDamage(2); - else - itemstack.setItemDamage(1); + int nextMode = mode.ordinal() + 1; + if (!Config.enableBackpackResupply && nextMode == BackpackMode.RESUPPLY.ordinal()) { + nextMode++; + } + nextMode %= BackpackMode.values().length; + itemstack.setItemDamage(nextMode); } private IInventory getInventoryHit(World world, int x, int y, int z, int side) { From 45f167754a92c3481efbc7479aeccb4ee3ec985f Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 16 Dec 2014 00:27:13 -0800 Subject: [PATCH 060/175] Cleanup TODOs --- .../worldgen/ComponentVillageBeeHouse.java | 3 +- .../forestry/mail/gadgets/MachineMailbox.java | 131 +++--------------- .../java/forestry/plugins/PluginFactory.java | 58 +++----- .../storage/PickupHandlerStorage.java | 13 +- 4 files changed, 43 insertions(+), 162 deletions(-) diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 69f15b3e9..93cf2872b 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -369,8 +369,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { } private boolean isAirBlockAtCurrentPosition(World world, int x, int y, int z, StructureBoundingBox box) { - // TODO: replace with isAir - return getBlockAtCurrentPosition(world, x, y, z, box) == Blocks.air; + return getBlockAtCurrentPosition(world, x, y, z, box).isAir(world, x, y, z); } } diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 320a59123..75be347e2 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -10,9 +10,22 @@ ******************************************************************************/ package forestry.mail.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.api.core.ForestryAPI; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -28,15 +41,8 @@ import forestry.mail.IMailContainer; import forestry.mail.POBox; import forestry.mail.PostRegistry; import forestry.plugins.PluginMail; -import java.util.Collection; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.ITriggerExternal; public class MachineMailbox extends TileBase implements IMailContainer { @@ -117,109 +123,4 @@ public class MachineMailbox extends TileBase implements IMailContainer { res.add(PluginMail.triggerHasMail); return res; } - - /* ISPECIALINVENTORY */ -// @Override -// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { -// if (!PostManager.postRegistry.isLetter(stack)) -// return 0; -// -// IPostalState result = tryDispatchLetter(stack, doAdd); -// -// if (!result.isOk()) -// return 0; -// else -// return 1; -// } -// -// @Override -// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { -// -// ItemStack product = null; -// IInventory mailInventory = getOrCreateMailInventory(worldObj, getOwnerProfile()); -// -// for (int i = 0; i < mailInventory.getSizeInventory(); i++) { -// ItemStack slotStack = mailInventory.getStackInSlot(i); -// if (slotStack == null) -// continue; -// -// product = slotStack; -// if (doRemove) -// mailInventory.setInventorySlotContents(i, null); -// break; -// } -// -// if (product != null) -// return new ItemStack[]{product}; -// else -// return new ItemStack[0]; -// } - -// @Override -// public int getSizeInventory() { -// return 0; -// } -// -// @Override -// public ItemStack getStackInSlot(int var1) { -// return null; -// } -// -// @Override -// public ItemStack decrStackSize(int var1, int var2) { -// return null; -// } -// -// @Override -// public ItemStack getStackInSlotOnClosing(int var1) { -// return null; -// } -// -// @Override -// public void setInventorySlotContents(int var1, ItemStack var2) { -// } -// -// @Override -// public int getInventoryStackLimit() { -// return 0; -// } -// -// @Override -// public boolean isUseableByPlayer(EntityPlayer player) { -// return Utils.isUseableByPlayer(player, this); -// } -// -// @Override -// public boolean hasCustomInventoryName() { -// return false; -// } -// -// // TODO: This is broken mezz, I don't know how to fix -CovertJaguar -// @Override -// public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { -// return super.isItemValidForSlot(slotIndex, itemstack); -// } -// -// @Override -// public boolean canInsertItem(int i, ItemStack itemstack, int j) { -// return super.canInsertItem(i, itemstack, j); -// } -// -// @Override -// public boolean canExtractItem(int i, ItemStack itemstack, int j) { -// return super.canExtractItem(i, itemstack, j); -// } -// -// @Override -// public int[] getAccessibleSlotsFromSide(int side) { -// return super.getAccessibleSlotsFromSide(side); -// } -// -// @Override -// public void openInventory() { -// } -// -// @Override -// public void closeInventory() { -// } } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index 8b974b6d4..b757cd5ee 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -10,8 +10,17 @@ ******************************************************************************/ package forestry.plugins; +import java.util.Arrays; + +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.network.IGuiHandler; -import forestry.api.recipes.ICraftingProvider; + import forestry.api.recipes.RecipeManagers; import forestry.core.GameMode; import forestry.core.config.Defaults; @@ -21,8 +30,6 @@ import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; import forestry.core.gadgets.MachineNBTDefinition; -import forestry.core.interfaces.IOreDictionaryHandler; -import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; @@ -42,12 +49,7 @@ import forestry.factory.gadgets.MillRainmaker; import forestry.factory.gadgets.TileWorktable; import forestry.factory.recipes.CraftGuideIntegration; import forestry.factory.triggers.FactoryTriggers; -import java.util.ArrayList; -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; + @Plugin(pluginID = "Factory", name = "Factory", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.factory.description") public class PluginFactory extends ForestryPlugin { @@ -68,21 +70,15 @@ public class PluginFactory extends ForestryPlugin { public void preInit() { super.preInit(); - RecipeManagers.craftingProviders = new ArrayList(); - // Init carpenter manager - RecipeManagers.craftingProviders.add(RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager()); - // Init centrifuge manager - RecipeManagers.craftingProviders.add(RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager()); - // Init fabricator manager - RecipeManagers.craftingProviders.add(RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager()); - // Init fermenter manager - RecipeManagers.craftingProviders.add(RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager()); - // Init moistener manager - RecipeManagers.craftingProviders.add(RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager()); - // Init squeezer manager - RecipeManagers.craftingProviders.add(RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager()); - // Init still manager - RecipeManagers.craftingProviders.add(RecipeManagers.stillManager = new MachineStill.RecipeManager()); + RecipeManagers.craftingProviders = Arrays.asList( + RecipeManagers.carpenterManager = new MachineCarpenter.RecipeManager(), + RecipeManagers.centrifugeManager = new MachineCentrifuge.RecipeManager(), + RecipeManagers.fabricatorManager = new MachineFabricator.RecipeManager(), + RecipeManagers.fermenterManager = new MachineFermenter.RecipeManager(), + RecipeManagers.moistenerManager = new MachineMoistener.RecipeManager(), + RecipeManagers.squeezerManager = new MachineSqueezer.RecipeManager(), + RecipeManagers.stillManager = new MachineStill.RecipeManager() + ); ForestryBlock.factoryTESR.registerBlock(new BlockBase(Material.iron, true), ItemForestryBlock.class, "factory"); @@ -497,23 +493,9 @@ public class PluginFactory extends ForestryPlugin { } } - @Override - protected void registerCrates() { - // TODO Auto-generated method stub - } - @Override public IGuiHandler getGuiHandler() { return new GuiHandlerFactory(); } - @Override - public ISaveEventHandler getSaveEventHandler() { - return null; - } - - @Override - public IOreDictionaryHandler getDictionaryHandler() { - return null; - } } diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index 81380ffb9..f63b1d2e8 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -10,13 +10,14 @@ ******************************************************************************/ package forestry.storage; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.core.interfaces.IPickupHandler; import forestry.storage.gui.ContainerBackpack; import forestry.storage.gui.ContainerNaturalistBackpack; import forestry.storage.items.ItemBackpack; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class PickupHandlerStorage implements IPickupHandler { @@ -27,13 +28,11 @@ public class PickupHandlerStorage implements IPickupHandler { if (itemstack == null || itemstack.stackSize <= 0) return false; - // Do not pick up if a backpack is open // FIXME: Must not contain - // anything from apiculture + // Do not pick up if a backpack is open if (player.openContainer instanceof ContainerBackpack || player.openContainer instanceof ContainerNaturalistBackpack) return true; - // Make sure to top off manually placed itemstacks in player - // inventory first + // Make sure to top off manually placed itemstacks in player inventory first topOffPlayerInventory(player, itemstack); for (ItemStack pack : player.inventory.mainInventory) { From 947717873dde8f94c460e3be32d5cc60f5f00d05 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Tue, 16 Dec 2014 23:44:39 -0800 Subject: [PATCH 061/175] Fix faulty pipe selection randomizer in moveOneItemToPipe() --- .../java/forestry/core/inventory/InvTools.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index f18d5f780..3996b923c 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -25,6 +25,7 @@ import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.PlainInventory; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; @@ -802,14 +803,14 @@ public abstract class InvTools { if (stackToMove.stackSize <= 0) return false; - IPipeTile[] pipes = new IPipeTile[6]; + List> pipes = new ArrayList>(); boolean foundPipe = false; for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = tileCache.getTileOnSide(side); if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { - pipes[side.ordinal()] = pipe; + pipes.add(new AbstractMap.SimpleEntry(side, pipe)); foundPipe = true; } } @@ -818,14 +819,11 @@ public abstract class InvTools { if (!foundPipe) return false; - int choice = tileCache.getSource().getWorldObj().rand.nextInt(6); - - ForgeDirection side = ForgeDirection.getOrientation(choice); - - IPipeTile pipe = pipes[choice]; - if (pipe.injectItem(stackToMove, false, side.getOpposite()) > 0) + int choice = tileCache.getSource().getWorldObj().rand.nextInt(pipes.size()); + Map.Entry pipe = pipes.get(choice); + if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite()) > 0) if (removeOneItem(source, stackToMove) != null) { - pipe.injectItem(stackToMove, true, side.getOpposite()); + pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite()); return true; } return false; From 4e963ca6e1605dca4e67c81e26878833915b8f85 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 17 Dec 2014 00:28:21 -0800 Subject: [PATCH 062/175] Improve ErrorStateRegistry --- api | 2 +- src/main/java/forestry/core/EnumErrorCode.java | 6 ++++++ src/main/java/forestry/core/network/PacketTileUpdate.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api b/api index 20c3aa3ee..8799e138d 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 20c3aa3eeee65fcec5b0590fce83445ec27c27b9 +Subproject commit 8799e138dab95de6504ecdbe158aef9a12ec9c35 diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index 4fb450e9a..4faceb025 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.ErrorStateRegistry; import forestry.api.core.IErrorState; +import forestry.core.config.Defaults; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; @@ -96,6 +97,11 @@ public enum EnumErrorCode implements IErrorState { return (short) ordinal(); } + @Override + public String getUniqueName() { + return Defaults.MOD + ":" + name; + } + public static void init() { for (IErrorState code : values()) { ErrorStateRegistry.registerErrorState(code); diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index ede729579..e5a1f523d 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -86,7 +86,7 @@ public class PacketTileUpdate extends PacketUpdate { posZ = data.readInt(); orientation = ForgeDirection.getOrientation(data.readByte()); - errorState = ErrorStateRegistry.getErrorStateFromCode(data.readShort()); + errorState = ErrorStateRegistry.getErrorState(data.readShort()); int ordinal = data.readByte(); isOwnable = ordinal >= 0; From 2d8cadea2667ae7eb226b7af9595153b7ad44738 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 17 Dec 2014 23:12:13 -0800 Subject: [PATCH 063/175] Fix #376 Farm Hatch does not accept any items --- src/main/java/forestry/farming/gadgets/TileHatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index ad1e019ef..374174749 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -189,7 +189,7 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(xCoord, itemstack); + return isItemValidForSlot(slotIndex, itemstack); } @Override From a1cf0ddf779a92e9a2836557cc4ce046acc112b0 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 17 Dec 2014 23:18:30 -0800 Subject: [PATCH 064/175] Fix #377 Centrifuge, Peat Engine, Analyzer won't accept items --- src/main/java/forestry/core/gadgets/TileAnalyzer.java | 2 +- src/main/java/forestry/energy/gadgets/EngineCopper.java | 4 ++-- src/main/java/forestry/factory/gadgets/MachineCentrifuge.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 9dde8f4f6..fab454295 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -358,7 +358,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui @Override public boolean canInsertItem(int slot, ItemStack stack, int side) { - return isItemValidForSlot(side, stack); + return isItemValidForSlot(slot, stack); } @Override diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 5d97b19a4..cc58dfaec 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -409,8 +409,8 @@ public class EngineCopper extends Engine implements ISidedInventory { /* ISIDEDINVENTORY */ @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - return isItemValidForSlot(xCoord, itemstack); + public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { + return isItemValidForSlot(slotIndex, itemstack); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 15d7568e5..19730c47e 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -396,7 +396,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { /* ISIDEDINVENTORY */ @Override public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(xCoord, itemstack); + return isItemValidForSlot(slotIndex, itemstack); } @Override From e55b21028e519b0f6c872d07596679e96ee9c8d5 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 18 Dec 2014 00:29:19 -0800 Subject: [PATCH 065/175] #232 #373 Stop shipping the BuildCraft API in Jar --- build.gradle | 5 +++ .../forestry/mail/gadgets/MachineMailbox.java | 4 +- .../forestry/mail/gadgets/MachineTrader.java | 45 ++++++++++--------- .../forestry/mail/triggers/MailTriggers.java | 37 +++++++++++++++ .../plugins/PluginBuildCraftStatements.java | 2 +- .../java/forestry/plugins/PluginMail.java | 41 +++++------------ 6 files changed, 82 insertions(+), 52 deletions(-) create mode 100644 src/main/java/forestry/mail/triggers/MailTriggers.java diff --git a/build.gradle b/build.gradle index 2d32dfbb6..b409aeda8 100755 --- a/build.gradle +++ b/build.gradle @@ -192,6 +192,7 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) { exclude '**/api/**' exclude '**/codechicken/**' exclude '**/old/lang/**' + exclude '**/buildcraft/api/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -219,6 +220,7 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) { include '**' exclude '**/codechicken/**' exclude '**/old/lang/**' + exclude '**/buildcraft/api/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -232,6 +234,7 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) { exclude '**/api/**' exclude '**/codechicken/**' exclude '**/old/lang/**' + exclude '**/buildcraft/api/**' } destinationDir = file("build/tmp") @@ -258,12 +261,14 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) { include '**' exclude '**/codechicken/**' exclude '**/old/lang/**' + exclude '**/buildcraft/api/**' } from(sourceSets.main.output) { include '**' exclude '**/codechicken/**' exclude '**/old/lang/**' + exclude '**/buildcraft/api/**' } from { diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 75be347e2..27a8ea980 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -40,7 +40,7 @@ import forestry.mail.EnumDeliveryState; import forestry.mail.IMailContainer; import forestry.mail.POBox; import forestry.mail.PostRegistry; -import forestry.plugins.PluginMail; +import forestry.mail.triggers.MailTriggers; import buildcraft.api.statements.ITriggerExternal; @@ -120,7 +120,7 @@ public class MachineMailbox extends TileBase implements IMailContainer { @Override public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { LinkedList res = new LinkedList(); - res.add(PluginMail.triggerHasMail); + res.add(MailTriggers.triggerHasMail); return res; } } diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 82a439587..593d45451 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -10,8 +10,21 @@ ******************************************************************************/ package forestry.mail.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.api.core.ForestryAPI; import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; @@ -27,17 +40,9 @@ import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.mail.MailAddress; import forestry.mail.TradeStation; -import forestry.plugins.PluginMail; -import java.util.Collection; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import forestry.mail.triggers.MailTriggers; + +import buildcraft.api.statements.ITriggerExternal; public class MachineTrader extends TileBase implements ISidedInventory { @@ -364,14 +369,14 @@ public class MachineTrader extends TileBase implements ISidedInventory { @Override public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { LinkedList res = new LinkedList(); - res.add(PluginMail.lowPaper64); - res.add(PluginMail.lowPaper32); - res.add(PluginMail.lowInput25); - res.add(PluginMail.lowInput10); - res.add(PluginMail.lowPostage40); - res.add(PluginMail.lowPostage20); - res.add(PluginMail.highBuffer90); - res.add(PluginMail.highBuffer75); + res.add(MailTriggers.lowPaper64); + res.add(MailTriggers.lowPaper32); + res.add(MailTriggers.lowInput25); + res.add(MailTriggers.lowInput10); + res.add(MailTriggers.lowPostage40); + res.add(MailTriggers.lowPostage20); + res.add(MailTriggers.highBuffer90); + res.add(MailTriggers.highBuffer75); return res; } diff --git a/src/main/java/forestry/mail/triggers/MailTriggers.java b/src/main/java/forestry/mail/triggers/MailTriggers.java new file mode 100644 index 000000000..aa57d1d73 --- /dev/null +++ b/src/main/java/forestry/mail/triggers/MailTriggers.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.mail.triggers; + +import forestry.core.triggers.Trigger; + +public class MailTriggers { + public static Trigger triggerHasMail; + public static Trigger lowPaper64; + public static Trigger lowPaper32; + public static Trigger lowPostage40; + public static Trigger lowPostage20; + public static Trigger lowInput25; + public static Trigger lowInput10; + public static Trigger highBuffer75; + public static Trigger highBuffer90; + + public static void initialize() { + triggerHasMail = new TriggerHasMail(); + lowPaper64 = new TriggerLowPaper("mail.lowPaper.64", 64); + lowPaper32 = new TriggerLowPaper("mail.lowPaper.32", 32); + lowPostage40 = new TriggerLowStamps("mail.lowStamps.40", 40); + lowPostage20 = new TriggerLowStamps("mail.lowStamps.20", 20); + lowInput25 = new TriggerLowInput("mail.lowInput.25", 0.25f); + lowInput10 = new TriggerLowInput("mail.lowInput.10", 0.1f); + highBuffer75 = new TriggerBuffer("mail.lowBuffer.75", 0.75f); + highBuffer90 = new TriggerBuffer("mail.lowBuffer.90", 0.90f); + } +} diff --git a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java index 089957562..fc6705261 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java @@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @Plugin(pluginID = "BC6|Statements", name = "BuildCraft 6 Statements", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") -@Optional.Interface(iface = "ITriggerProvider", modid = "BuildCraftAPI|statements") +@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") public class PluginBuildCraftStatements extends ForestryPlugin implements ITriggerProvider { @Override diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index ac6715446..91f256930 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -10,8 +10,15 @@ ******************************************************************************/ package forestry.plugins; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.EnumPostage; import forestry.api.mail.PostManager; @@ -28,7 +35,6 @@ import forestry.core.interfaces.IPacketHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemForestryBlock; import forestry.core.proxy.Proxies; -import forestry.core.triggers.Trigger; import forestry.core.utils.ShapedRecipeCustom; import forestry.mail.GuiHandlerMail; import forestry.mail.PacketHandlerMail; @@ -45,31 +51,13 @@ import forestry.mail.items.ItemLetter; import forestry.mail.items.ItemStamps; import forestry.mail.items.ItemStamps.StampInfo; import forestry.mail.proxy.ProxyMail; -import forestry.mail.triggers.TriggerBuffer; -import forestry.mail.triggers.TriggerHasMail; -import forestry.mail.triggers.TriggerLowInput; -import forestry.mail.triggers.TriggerLowPaper; -import forestry.mail.triggers.TriggerLowStamps; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import forestry.mail.triggers.MailTriggers; @Plugin(pluginID = "Mail", name = "Mail", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.mail.description") public class PluginMail extends ForestryPlugin { @SidedProxy(clientSide = "forestry.mail.proxy.ClientProxyMail", serverSide = "forestry.mail.proxy.ProxyMail") public static ProxyMail proxy; - public static Trigger triggerHasMail; - public static Trigger lowPaper64; - public static Trigger lowPaper32; - public static Trigger lowPostage40; - public static Trigger lowPostage20; - public static Trigger lowInput25; - public static Trigger lowInput10; - public static Trigger highBuffer75; - public static Trigger highBuffer90; public static MachineDefinition definitionMailbox; public static MachineDefinition definitionTradestation; public static MachineDefinition definitionPhilatelist; @@ -83,15 +71,10 @@ public class PluginMail extends ForestryPlugin { new TickHandlerMailClient(); - triggerHasMail = new TriggerHasMail(); - lowPaper64 = new TriggerLowPaper("mail.lowPaper.64", 64); - lowPaper32 = new TriggerLowPaper("mail.lowPaper.32", 32); - lowPostage40 = new TriggerLowStamps("mail.lowStamps.40", 40); - lowPostage20 = new TriggerLowStamps("mail.lowStamps.20", 20); - lowInput25 = new TriggerLowInput("mail.lowInput.25", 0.25f); - lowInput10 = new TriggerLowInput("mail.lowInput.10", 0.1f); - highBuffer75 = new TriggerBuffer("mail.lowBuffer.75", 0.75f); - highBuffer90 = new TriggerBuffer("mail.lowBuffer.90", 0.90f); + // Triggers + if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) { + MailTriggers.initialize(); + } ForestryBlock.mail.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "mail"); From 8406073107d9e45f198687116fb5b3c6bcc8be9a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 18 Dec 2014 01:53:55 -0800 Subject: [PATCH 066/175] Fixes #378 Alveary should ensure it has a an inventory before it tries to read item into it. --- src/main/java/forestry/apiculture/gadgets/TileAlveary.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index f373d3a9c..8985493cf 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -87,8 +87,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon /* LOADING & SAVING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - this.isMaster = nbttagcompound.getBoolean("IsMaster"); this.masterX = nbttagcompound.getInteger("MasterX"); this.masterY = nbttagcompound.getInteger("MasterY"); @@ -96,7 +94,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon // Init for master state if (isMaster) - makeMaster(); + makeMaster(); + + super.readFromNBT(nbttagcompound); structureLogic.readFromNBT(nbttagcompound); } From 06549d1e2dcbcaad3f929516d77f3a62b45b5010 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 18 Dec 2014 06:01:42 -0800 Subject: [PATCH 067/175] Fix usage usability checks to account for access setting. --- .../apiculture/gadgets/TileAlvearyHygroregulator.java | 3 +++ .../java/forestry/apiculture/gadgets/TileAlvearyPlain.java | 3 +++ .../forestry/apiculture/gadgets/TileAlvearySwarmer.java | 4 ++++ src/main/java/forestry/core/gadgets/BlockBase.java | 4 +++- src/main/java/forestry/core/gadgets/BlockStructure.java | 7 +++---- .../java/forestry/core/inventory/TileInventoryAdapter.java | 5 +---- .../java/forestry/factory/gadgets/MachineCentrifuge.java | 2 +- .../java/forestry/factory/gadgets/MachineFabricator.java | 2 +- .../java/forestry/factory/gadgets/MachineFermenter.java | 2 +- .../java/forestry/factory/gadgets/MachineMoistener.java | 2 +- .../java/forestry/factory/gadgets/MachineRaintank.java | 2 +- .../java/forestry/factory/gadgets/MachineSqueezer.java | 2 +- src/main/java/forestry/factory/gadgets/MachineStill.java | 2 +- src/main/java/forestry/farming/gadgets/TileHatch.java | 6 ++++-- .../java/forestry/mail/gadgets/MachinePhilatelist.java | 3 +-- src/main/java/forestry/mail/gadgets/MachineTrader.java | 4 +++- 16 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 57dd6e24c..948d9cbdb 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -231,6 +231,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory @Override public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getInternalInventory(); + if (inv != null) + return inv.isUseableByPlayer(player); return Utils.isUseableByPlayer(player, this); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 02c8e8dc1..2db92b886 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -614,6 +614,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getStructureInventory(); + if (inv != null) + return inv.isUseableByPlayer(player); return Utils.isUseableByPlayer(player, this); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index a8f2f4aa2..7e68b4c09 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -32,6 +32,7 @@ import forestry.plugins.PluginApiculture; import java.util.Map.Entry; import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -284,6 +285,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { @Override public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getInternalInventory(); + if (inv != null) + return inv.isUseableByPlayer(player); return Utils.isUseableByPlayer(player, this); } diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index a7b4bc486..8a9c30e26 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -16,6 +16,8 @@ import forestry.core.fluids.FluidHelper; import forestry.core.interfaces.IOwnable; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; +import forestry.core.utils.EnumAccess; +import forestry.core.utils.PlayerUtil; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; import java.util.ArrayList; @@ -164,7 +166,7 @@ public class BlockBase extends BlockForestry { return false; ItemStack current = player.getCurrentEquippedItem(); - if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler) { + if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsInteraction(player)) { if (Proxies.common.isSimulating(world)) { if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { return true; diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index 7a74218c8..1b26d285a 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -71,16 +71,15 @@ public abstract class BlockStructure extends BlockForestry { if (!((ITileStructure) tile).isIntegratedIntoStructure()) return false; - if (tile.allowsInteraction(player)) { + if (tile.allowsInteraction(player)) tile.openGui(player); - } else { String ownerName = StringUtil.localize("gui.derelict"); - + if (tile.getOwnerProfile() != null) ownerName = tile.getOwnerProfile().getName(); - player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked",ownerName)); + player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", ownerName)); } return true; } diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index 139cab099..e2b8d7d7a 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -12,7 +12,6 @@ package forestry.core.inventory; import forestry.core.gadgets.TileForestry; import forestry.core.utils.EnumAccess; -import forestry.core.utils.PlayerUtil; import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -34,9 +33,7 @@ public class TileInventoryAdapter extends InventoryAdapter { public boolean isUseableByPlayer(EntityPlayer player) { if (!Utils.isUseableByPlayer(player, tile)) return false; - if (tile.getAccess() == EnumAccess.PRIVATE) - return PlayerUtil.isSameGameProfile(tile.getOwnerProfile(), player.getGameProfile()); - return true; + return tile.allowsInteraction(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 19730c47e..33944549f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -378,7 +378,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 66727aa10..19813a7a1 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -522,7 +522,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 1bad21ddb..c0089d4ad 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -547,7 +547,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 4d222c6aa..28338d621 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -559,7 +559,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index cdc89f0a9..74e987486 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -193,7 +193,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index fbe2de012..3b2eb8cf8 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -440,7 +440,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 829d05013..e4b22ddff 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -355,7 +355,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 374174749..dec38f7f0 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -77,9 +77,8 @@ public class TileHatch extends TileFarm implements ISidedInventory { public TileInventoryAdapter getStructureInventory() { if (hasMaster()) { ITileStructure central = getCentralTE(); - if (central != null){ + if (central != null) return (TileInventoryAdapter) central.getInventory(); - } } return null; @@ -152,6 +151,9 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public boolean isUseableByPlayer(EntityPlayer player) { + IInventory inv = getStructureInventory(); + if (inv != null) + return inv.isUseableByPlayer(player); return Utils.isUseableByPlayer(player, this); } diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index c317533d2..3d885e651 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -17,7 +17,6 @@ import forestry.core.gadgets.TileBase; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -108,7 +107,7 @@ public class MachinePhilatelist extends TileBase implements IInventory { @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + return getInternalInventory().isUseableByPlayer(player); } @Override diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 593d45451..3b356198b 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -332,7 +332,9 @@ public class MachineTrader extends TileBase implements ISidedInventory { @Override public boolean isUseableByPlayer(EntityPlayer player) { - return Utils.isUseableByPlayer(player, this); + if (!Utils.isUseableByPlayer(player, this)) + return false; + return getOrCreateTradeInventory().isUseableByPlayer(player); } /* ISIDEDINVENTORY */ From db0ab5fedab253f638d6d029c86116000db403fa Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 18 Dec 2014 06:02:38 -0800 Subject: [PATCH 068/175] Fixes #379 Clean up and fix Naturalist Chest --- .../core/gadgets/TileNaturalistChest.java | 73 +++---------------- 1 file changed, 10 insertions(+), 63 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java index cec96a706..1b9d5eba2 100755 --- a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java +++ b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java @@ -15,19 +15,18 @@ import forestry.api.genetics.ISpeciesRoot; import forestry.core.GuiHandler; import forestry.core.config.Config; import forestry.core.gui.IPagedInventory; +import forestry.core.inventory.TileInventoryAdapter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; public abstract class TileNaturalistChest extends TileBase implements IInventory, IPagedInventory { - private ItemStack[] inventoryStacks = new ItemStack[125]; private final ISpeciesRoot speciesRoot; private final int guiID; public TileNaturalistChest(ISpeciesRoot speciesRoot, int guiId) { + setInternalInventory(new TileInventoryAdapter(this, 125, "Items")); setHints(Config.hints.get("apiarist.chest")); this.speciesRoot = speciesRoot; this.guiID = guiId; @@ -48,38 +47,6 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(guiID, page), player.worldObj, xCoord, yCoord, zCoord); } - /* SAVING & LOADING */ - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - NBTTagList nbttaglist = new NBTTagList(); - for (int i = 0; i < inventoryStacks.length; i++) { - if (inventoryStacks[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - inventoryStacks[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("Items", nbttaglist); - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10); - inventoryStacks = new ItemStack[getSizeInventory()]; - for (int i = 0; i < nbttaglist.tagCount(); i++) { - - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - byte byte0 = nbttagcompound1.getByte("Slot"); - if (byte0 >= 0 && byte0 < inventoryStacks.length) - inventoryStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - /* UPDATING */ @Override public void updateServerSide() { @@ -99,47 +66,27 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory @Override public int getSizeInventory() { - return inventoryStacks.length; + return getInternalInventory().getSizeInventory(); } @Override - public ItemStack getStackInSlot(int i) { - return inventoryStacks[i]; + public ItemStack getStackInSlot(int slotIndex) { + return getInternalInventory().getStackInSlot(slotIndex); } @Override - public ItemStack decrStackSize(int i, int j) { - if (inventoryStacks[i] == null) - return null; - - ItemStack product; - if (inventoryStacks[i].stackSize <= j) { - product = inventoryStacks[i]; - inventoryStacks[i] = null; - return product; - } else { - product = inventoryStacks[i].splitStack(j); - if (inventoryStacks[i].stackSize == 0) - inventoryStacks[i] = null; - - return product; - } + public ItemStack decrStackSize(int slotIndex, int count) { + return getInternalInventory().decrStackSize(slotIndex, count); } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventoryStacks[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - itemstack.stackSize = getInventoryStackLimit(); + public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(slotIndex, itemstack); } @Override public ItemStack getStackInSlotOnClosing(int slot) { - if (inventoryStacks[slot] == null) - return null; - ItemStack toReturn = inventoryStacks[slot]; - inventoryStacks[slot] = null; - return toReturn; + return getInternalInventory().getStackInSlotOnClosing(slot); } @Override From 90f80da4dae08f95959e1c1cb6862671bef0664d Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 18 Dec 2014 22:46:54 -0800 Subject: [PATCH 069/175] Clean up pollination. Add pollination for vanilla Acacia and Dark Oak --- .../forestry/apiculture/genetics/Bee.java | 53 +++----- .../arboriculture/gadgets/TileLeaves.java | 34 +++-- .../arboriculture/items/ItemTreealyzer.java | 13 +- .../forestry/core/TickHandlerCoreClient.java | 4 +- .../forestry/core/gadgets/TileEscritoire.java | 14 +- .../forestry/core/utils/GeneticsUtil.java | 123 ++++++++++++++++++ .../java/forestry/core/utils/StackUtils.java | 4 + src/main/java/forestry/core/utils/Utils.java | 87 ++----------- .../entities/AIButterflyMate.java | 32 ++--- .../entities/AIButterflyPollinate.java | 4 +- .../forestry/plugins/PluginArboriculture.java | 4 + 11 files changed, 209 insertions(+), 163 deletions(-) create mode 100644 src/main/java/forestry/core/utils/GeneticsUtil.java diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index c55a3eeee..43f0547ff 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -31,21 +31,22 @@ import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; import forestry.core.genetics.Chromosome; import forestry.core.genetics.GenericRatings; import forestry.core.genetics.IndividualLiving; import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; import forestry.core.utils.StringUtil; -import forestry.core.utils.Utils; import forestry.core.utils.Vect; import forestry.plugins.PluginApiculture; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -604,39 +605,26 @@ public class Bee extends IndividualLiving implements IBee { if (area.z < 1) area.z = 1; - // We have up to ten attempts + World world = housing.getWorld(); + Random random = world.rand; + + Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); + + IIndividual pollen = null; + for (int i = 0; i < 20; i++) { + Vect randomPos = new Vect(random.nextInt(area.x), random.nextInt(area.y), random.nextInt(area.z)); + Vect blockPos = housingPos.add(randomPos).add(offset); + TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z); - Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z)); - - Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord())); - posBlock = posBlock.add(offset); - - TileEntity tile = housing.getWorld().getTileEntity(posBlock.x, posBlock.y, posBlock.z); - if (!(tile instanceof IPollinatable)) { - if (housing.getWorld().isAirBlock(posBlock.x, posBlock.y, posBlock.z)) - continue; - - // Test for ersatz genomes - for (Map.Entry entry : AlleleManager.ersatzSpecimen.entrySet()) { - if (!StackUtils.equals(housing.getWorld().getBlock(posBlock.x, posBlock.y, posBlock.z), entry.getKey())) - continue; - if (entry.getKey().getItemDamage() != housing.getWorld().getBlockMetadata(posBlock.x, posBlock.y, posBlock.z)) - continue; - - // We matched, return ersatz genome - return entry.getValue().copy(); - } - - continue; + if (tile instanceof IPollinatable) { + IPollinatable pitcher = (IPollinatable) tile; + if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) + pollen = pitcher.getPollen(); + } else { + pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z); } - IPollinatable pitcher = (IPollinatable) tile; - if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), pitcher)) - continue; - - IIndividual pollen = pitcher.getPollen(); - if (pollen != null) return pollen; } @@ -664,7 +652,6 @@ public class Bee extends IndividualLiving implements IBee { if (area.z < 1) area.z = 1; - // We have up to ten attempts for (int i = 0; i < 30; i++) { Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z)); @@ -672,7 +659,7 @@ public class Bee extends IndividualLiving implements IBee { Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord())); posBlock = posBlock.add(offset); - IPollinatable receiver = Utils.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z); + IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z); if(receiver == null) continue; diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 6aff7149f..8034eef4a 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -10,9 +10,27 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.EnumPlantType; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IFruitProvider; import forestry.api.arboriculture.ILeafTickHandler; @@ -30,6 +48,7 @@ import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.lepidopterology.IButterflyRoot; import forestry.arboriculture.network.PacketLeafUpdate; +import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; import forestry.core.network.ForestryPacket; @@ -37,19 +56,6 @@ import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.EnumPlantType; public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery { @@ -175,7 +181,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } public int getFoliageColour(EntityPlayer player) { - return isPollinatedState & Utils.hasNaturalistEye(player) ? 0xffffff : colourLeaves; + return isPollinatedState & GeneticsUtil.hasNaturalistEye(player) ? 0xffffff : colourLeaves; } public int getFruitColour() { diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 823507c18..a0fdfbc40 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -10,9 +10,15 @@ ******************************************************************************/ package forestry.arboriculture.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; +import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; @@ -22,12 +28,7 @@ import forestry.core.inventory.AlyzerInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.Utils; import forestry.plugins.PluginArboriculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ItemTreealyzer extends ItemInventoried { @@ -62,7 +63,7 @@ public class ItemTreealyzer extends ItemInventoried { return; if (!PluginArboriculture.treeInterface.isMember(getStackInSlot(SLOT_SPECIMEN))) { - ItemStack ersatz = Utils.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN)); + ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN)); if (ersatz != null) setInventorySlotContents(SLOT_SPECIMEN, ersatz); } diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index c89cafe19..ca2708997 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -20,10 +20,10 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import forestry.core.utils.GeneticsUtil; import forestry.core.config.Config; import forestry.core.config.Version; import forestry.core.proxy.Proxies; -import forestry.core.utils.Utils; public class TickHandlerCoreClient { @@ -44,7 +44,7 @@ public class TickHandlerCoreClient { if (event.phase != Phase.END) return; EntityPlayer player = Proxies.common.getClientInstance().thePlayer; - boolean hasNaturalistEye = Utils.hasNaturalistEye(player); + boolean hasNaturalistEye = GeneticsUtil.hasNaturalistEye(player); if (hasNaturalistEye != hasNaturalistView) { hasNaturalistView = !hasNaturalistView; Proxies.common.getClientInstance().renderGlobal.markBlockRangeForRenderUpdate( diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 4a94eec1d..813d1a9be 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -10,10 +10,17 @@ ******************************************************************************/ package forestry.core.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.mojang.authlib.GameProfile; + import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; +import forestry.core.utils.GeneticsUtil; import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.IRenderableMachine; import forestry.core.inventory.TileInventoryAdapter; @@ -24,11 +31,6 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; -import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class TileEscritoire extends TileBase implements ISidedInventory, IRenderableMachine, ICrafter { @@ -151,7 +153,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { if (!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE)) && inventory.getStackInSlot(SLOT_ANALYZE) != null) { - ItemStack ersatz = Utils.convertSaplingToGeneticEquivalent(inventory.getStackInSlot(SLOT_ANALYZE)); + ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(inventory.getStackInSlot(SLOT_ANALYZE)); if (ersatz != null) inventory.setInventorySlotContents(SLOT_ANALYZE, ersatz); } diff --git a/src/main/java/forestry/core/utils/GeneticsUtil.java b/src/main/java/forestry/core/utils/GeneticsUtil.java new file mode 100644 index 000000000..a1a28f67d --- /dev/null +++ b/src/main/java/forestry/core/utils/GeneticsUtil.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.arboriculture.EnumGermlingType; +import forestry.api.arboriculture.ITree; +import forestry.api.core.IArmorNaturalist; +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IPollinatable; +import forestry.plugins.PluginArboriculture; + +public class GeneticsUtil { + + private static Set ersatzSpecimenMaterials; + + private static Set getErsatzSpecimenMaterials() { + if (ersatzSpecimenMaterials == null) { + ersatzSpecimenMaterials = new HashSet(); + for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) { + Block ersatzBlock = StackUtils.getBlock(ersatzSpecimen); + if (ersatzBlock != null) + ersatzSpecimenMaterials.add(ersatzBlock.getMaterial()); + } + } + return ersatzSpecimenMaterials; + } + + private static boolean isErsatzMaterial(Block block) { + return block != null && getErsatzSpecimenMaterials().contains(block.getMaterial()); + } + + public static boolean hasNaturalistEye(EntityPlayer player) { + ItemStack armorItem = player.inventory.armorInventory[3]; + return armorItem != null && armorItem.getItem() instanceof IArmorNaturalist + && ((IArmorNaturalist) armorItem.getItem()).canSeePollination(player, armorItem, true); + } + + public static IPollinatable getOrCreatePollinatable(GameProfile owner, World world, final int x, final int y, final int z) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof IPollinatable) { + return (IPollinatable) tile; + } + + IIndividual pollen = getErsatzPollen(world, x, y, z); + if (pollen != null) { + PluginArboriculture.treeInterface.setLeaves(world, pollen, owner, x, y, z); + return (IPollinatable) world.getTileEntity(x, y, z); + } + + return null; + } + + public static IIndividual getErsatzPollen(World world, final int x, final int y, final int z) { + Block block = world.getBlock(x, y, z); + if (!isErsatzMaterial(block)) + return null; + + int meta = world.getBlockMetadata(x, y, z); + + if (Blocks.leaves == block || Blocks.leaves2 == block) { + if ((meta & 4) != 0) { + // no-decay vanilla leaves. http://minecraft.gamepedia.com/Data_values#Leaves + // Treat them as decorative and don't pollinate. + return null; + } + meta %= 3; + } + + // Find the matching ersatz genome + for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) { + if (StackUtils.equals(block, meta, ersatzSpecimen)) { + return AlleleManager.ersatzSpecimen.get(ersatzSpecimen).copy(); + } + } + + return null; + } + + public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) { + + ItemStack ersatz = null; + ITree tree = null; + + for (Map.Entry entry : AlleleManager.ersatzSaplings.entrySet()) { + if (entry.getKey().getItem() != foreign.getItem()) + continue; + if (entry.getKey().getItemDamage() != foreign.getItemDamage()) + continue; + + if (entry.getValue() instanceof ITree) + tree = (ITree) entry.getValue(); + + ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); + ersatz.stackSize = foreign.stackSize; + } + + return ersatz; + } +} diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index edf75a91f..f3dd2d587 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -425,4 +425,8 @@ public class StackUtils { public static boolean equals(Block block, ItemStack stack) { return block == getBlock(stack); } + + public static boolean equals(Block block, int meta, ItemStack stack) { + return block == getBlock(stack) && meta == stack.getItemDamage(); + } } diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 3871bdf85..a05a1c523 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -10,25 +10,11 @@ ******************************************************************************/ package forestry.core.utils; -import buildcraft.api.tools.IToolWrench; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.common.registry.EntityRegistry; -import forestry.api.arboriculture.EnumGermlingType; -import forestry.api.arboriculture.ITree; -import forestry.api.core.ForestryAPI; -import forestry.api.core.IArmorNaturalist; -import forestry.api.core.ITileStructure; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IPollinatable; -import forestry.core.gadgets.TileForestry; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginArboriculture; import java.security.MessageDigest; import java.security.cert.Certificate; import java.util.Arrays; -import java.util.Map; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -45,6 +31,15 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import cpw.mods.fml.common.registry.EntityRegistry; + +import forestry.api.core.ForestryAPI; +import forestry.api.core.ITileStructure; +import forestry.core.gadgets.TileForestry; +import forestry.core.proxy.Proxies; + +import buildcraft.api.tools.IToolWrench; + public class Utils { private static Random rand; @@ -115,12 +110,6 @@ public class Utils { } - public static boolean hasNaturalistEye(EntityPlayer player) { - ItemStack armorItem = player.inventory.armorInventory[3]; - return armorItem != null && armorItem.getItem() instanceof IArmorNaturalist - && ((IArmorNaturalist) armorItem.getItem()).canSeePollination(player, armorItem, true); - } - public static IInventory getChest(IInventory inventory) { if (!(inventory instanceof TileEntityChest)) return inventory; @@ -320,60 +309,4 @@ public class Utils { } return hex.toString(); } - - public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) { - - ItemStack ersatz = null; - ITree tree = null; - - for (Map.Entry entry : AlleleManager.ersatzSaplings.entrySet()) { - if (entry.getKey().getItem() != foreign.getItem()) - continue; - if (entry.getKey().getItemDamage() != foreign.getItemDamage()) - continue; - - if (entry.getValue() instanceof ITree) - tree = (ITree) entry.getValue(); - - ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); - ersatz.stackSize = foreign.stackSize; - } - - return ersatz; - } - - public static IPollinatable getOrCreatePollinatable(GameProfile owner, World world, final int x, final int y, final int z) { - TileEntity tile = world.getTileEntity(x, y, z); - - IPollinatable receiver = null; - if (tile instanceof IPollinatable) - receiver = (IPollinatable) tile; - else if (!world.isAirBlock(x, y, z)) { - - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if (Blocks.leaves == block || Blocks.leaves2 == block) { - if ((meta & 4) != 0) { - // no-decay vanilla leaves. http://minecraft.gamepedia.com/Data_values#Leaves - // Treat them as decorative and don't pollinate. - return null; - } - meta = meta % 3; - } - - // Test for ersatz genomes - for (Map.Entry entry : AlleleManager.ersatzSpecimen.entrySet()) { - if (block == StackUtils.getBlock(entry.getKey()) && entry.getKey().getItemDamage() == meta) { - // We matched, replace the leaf block with ours and set the ersatz genome - PluginArboriculture.treeInterface.setLeaves(world, entry.getValue(), owner, x, y, z); - // Now let's pollinate - receiver = (IPollinatable) world.getTileEntity(x, y, z); - } - } - - } - - return receiver; - } } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index 099924a8b..b154daaa5 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -10,14 +10,10 @@ ******************************************************************************/ package forestry.lepidopterology.entities; -import forestry.api.arboriculture.ITreeRoot; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IPollinatable; import forestry.api.lepidopterology.IButterflyNursery; -import forestry.core.utils.StackUtils; -import java.util.Map; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; +import forestry.core.utils.GeneticsUtil; + import net.minecraft.tileentity.TileEntity; public class AIButterflyMate extends AIButterflyInteract { @@ -43,23 +39,13 @@ public class AIButterflyMate extends AIButterflyInteract { if (tile instanceof IButterflyNursery) nursery = (IButterflyNursery) tile; - else - for (Map.Entry entry : AlleleManager.ersatzSpecimen.entrySet()) { - - if (!StackUtils.equals(entity.worldObj.getBlock(rest.posX, rest.posY, rest.posZ), entry.getKey())) - continue; - - int meta = entity.worldObj.getBlockMetadata(rest.posX, rest.posY, rest.posZ); - if (StackUtils.equals(Blocks.leaves, entry.getKey())) - meta = meta & 3; - if (entry.getKey().getItemDamage() != meta) - continue; - - // We matched, replace the leaf block with ours and set the ersatz genome - ((ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees")).setLeaves(entity.worldObj, entry.getValue(), null, rest.posX, rest.posY, rest.posZ); - // Now let's pollinate - nursery = (IButterflyNursery) entity.worldObj.getTileEntity(rest.posX, rest.posY, rest.posZ); + else { + IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); + if (pollinatable instanceof IButterflyNursery) { + nursery = (IButterflyNursery) pollinatable; } + } + if (nursery == null) return false; diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index bf47c918f..d34c457c8 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -11,7 +11,7 @@ package forestry.lepidopterology.entities; import forestry.api.genetics.IPollinatable; -import forestry.core.utils.Utils; +import forestry.core.utils.GeneticsUtil; public class AIButterflyPollinate extends AIButterflyInteract { @@ -28,7 +28,7 @@ public class AIButterflyPollinate extends AIButterflyInteract { if (entity.cooldownPollination > 0) return false; - IPollinatable pollinatable = Utils.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); + IPollinatable pollinatable = GeneticsUtil.getOrCreatePollinatable(null, entity.worldObj, rest.posX, rest.posY, rest.posZ); if (pollinatable == null) return false; diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index b1428866f..6436d5254 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -991,6 +991,10 @@ public class PluginArboriculture extends ForestryPlugin { TreeTemplates.templateAsGenome(TreeTemplates.getBirchTemplate()))); AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves, 1, 3), new Tree( TreeTemplates.templateAsGenome(TreeTemplates.getJungleTemplate()))); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 0), new Tree( + TreeTemplates.templateAsGenome(TreeTemplates.getAcaciaTemplate()))); + AlleleManager.ersatzSpecimen.put(new ItemStack(Blocks.leaves2, 1, 1), new Tree( + TreeTemplates.templateAsGenome(TreeTemplates.getDarkOakTemplate()))); AlleleManager.ersatzSaplings.put(new ItemStack(Blocks.sapling, 1, 0), new Tree( TreeTemplates.templateAsGenome(TreeTemplates.getOakTemplate()))); From 08555326b2738b54fd8c6461649edbd365d7cf35 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 19 Dec 2014 23:16:15 -0800 Subject: [PATCH 070/175] Clean up Bee.java. Split Vect into MutableVect and (immutable) Vect. --- .../gadgets/StructureLogicAlveary.java | 2 +- .../genetics/AlleleEffectGlacial.java | 2 +- .../genetics/AlleleEffectRadioactive.java | 2 +- .../genetics/AlleleEffectSnowing.java | 2 +- .../genetics/AlleleEffectThrottled.java | 2 +- .../forestry/apiculture/genetics/Bee.java | 177 ++++++---------- .../apiculture/genetics/BeeGenome.java | 2 +- .../apiculture/genetics/JubilanceDefault.java | 2 +- .../apiculture/genetics/MutationEMC.java | 2 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 2 +- .../apiculture/items/ItemBiomefinder.java | 2 +- .../genetics/AlleleLeafEffectNone.java | 2 +- .../genetics/GrowthProvider.java | 2 +- .../worldgen/WorldGenArboriculture.java | 2 +- .../forestry/core/gadgets/StructureLogic.java | 2 +- .../forestry/core/gadgets/TileForestry.java | 2 +- .../forestry/core/genetics/AlleleArea.java | 2 +- .../java/forestry/core/utils/BlockUtil.java | 2 + .../java/forestry/core/utils/Schemata.java | 1 + src/main/java/forestry/core/utils/Utils.java | 1 + src/main/java/forestry/core/vect/IVect.java | 23 +++ .../java/forestry/core/vect/MutableVect.java | 83 ++++++++ .../forestry/core/{utils => vect}/Vect.java | 194 ++++++++++-------- .../java/forestry/farming/FarmTarget.java | 106 +++++----- .../farming/gadgets/StructureLogicFarm.java | 2 +- .../forestry/farming/gadgets/TileControl.java | 2 +- .../farming/gadgets/TileFarmPlain.java | 2 +- .../java/forestry/farming/logic/Crop.java | 2 +- .../forestry/farming/logic/CropBlock.java | 2 +- .../forestry/farming/logic/CropFruit.java | 2 +- .../java/forestry/farming/logic/CropPeat.java | 2 +- .../forestry/farming/logic/CropRubber.java | 2 +- .../forestry/farming/logic/FarmLogic.java | 34 +-- .../farming/logic/FarmLogicArboreal.java | 4 +- .../farming/logic/FarmLogicCocoa.java | 7 +- .../farming/logic/FarmLogicCrops.java | 11 +- .../farming/logic/FarmLogicGourd.java | 2 +- .../farming/logic/FarmLogicHomogeneous.java | 2 +- .../farming/logic/FarmLogicInfernal.java | 4 +- .../farming/logic/FarmLogicOrchard.java | 2 +- .../forestry/farming/logic/FarmLogicPeat.java | 2 +- .../farming/logic/FarmLogicPoale.java | 2 +- .../farming/logic/FarmLogicRubber.java | 2 +- .../farming/logic/FarmLogicSucculent.java | 2 +- .../farming/logic/FarmLogicWatered.java | 8 +- .../forestry/farming/logic/FarmableCocoa.java | 2 +- .../farming/logic/FarmableFarmCraftory.java | 2 +- .../forestry/farming/logic/FarmableGE.java | 2 +- .../farming/logic/FarmableGenericCrop.java | 2 +- .../farming/logic/FarmableGenericSapling.java | 2 +- .../forestry/farming/logic/FarmableGourd.java | 2 +- .../farming/logic/FarmableStacked.java | 2 +- .../farming/logic/FarmableVanillaShroom.java | 2 +- 53 files changed, 413 insertions(+), 320 deletions(-) create mode 100644 src/main/java/forestry/core/vect/IVect.java create mode 100644 src/main/java/forestry/core/vect/MutableVect.java rename src/main/java/forestry/core/{utils => vect}/Vect.java (50%) mode change 100755 => 100644 diff --git a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java index bc13fa17c..7294c3790 100755 --- a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java @@ -17,7 +17,7 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState; import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.HashSet; import net.minecraft.block.Block; import net.minecraft.init.Blocks; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java index af66476c2..15c4f0bfb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectGlacial.java @@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java index 4f949e6d2..a36b42ae5 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectRadioactive.java @@ -17,7 +17,7 @@ import forestry.apiculture.gadgets.BlockAlveary; import forestry.apiculture.gadgets.TileAlveary; import forestry.apiculture.items.ItemArmorApiarist; import forestry.core.utils.DamageSourceForestry; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.List; import java.util.Random; import net.minecraft.block.Block; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java index 864f9d11b..d6e13c735 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectSnowing.java @@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java index 250f86599..83d2dcf56 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectThrottled.java @@ -17,7 +17,7 @@ import forestry.api.genetics.IEffectData; import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; import forestry.core.genetics.EffectData; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; import net.minecraft.util.AxisAlignedBB; diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 43f0547ff..97adc897b 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -10,6 +10,18 @@ ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.IAlleleBeeEffect; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -31,27 +43,17 @@ import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; -import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.config.Defaults; import forestry.core.genetics.Chromosome; import forestry.core.genetics.GenericRatings; import forestry.core.genetics.IndividualLiving; import forestry.core.proxy.Proxies; +import forestry.core.utils.GeneticsUtil; import forestry.core.utils.StringUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.MutableVect; +import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class Bee extends IndividualLiving implements IBee { @@ -266,26 +268,16 @@ public class Bee extends IndividualLiving implements IBee { IFlowerProvider provider = genome.getFlowerProvider(); - Vect coords = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); - Vect posCurrent = new Vect(0, 0, 0); - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)); - - if (area.x < 1) - area.x = 1; - if (area.y < 1) - area.y = 1; - if (area.z < 1) - area.z = 1; - - Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2)); + Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); + Vect area = getArea(genome, housing); + Vect offset = new Vect(-area.x / 2, -area.y / 2, -area.z / 2); boolean hasFlower = false; - while (advancePosition(posCurrent, area)) { + MutableVect posCurrent = new MutableVect(0, 0, 0); + while (posCurrent.advancePositionInArea(area)) { - Vect posBlock = posCurrent.add(coords); - posBlock = posBlock.add(offset); + Vect posBlock = Vect.add(housingPos, posCurrent, offset); if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) { hasFlower = true; @@ -297,28 +289,6 @@ public class Bee extends IndividualLiving implements IBee { return hasFlower; } - private boolean advancePosition(Vect posCurrent, Vect area) { - // Increment z first until end reached - if (posCurrent.z < area.z - 1) - posCurrent.z++; - else { - posCurrent.z = 0; - - if (posCurrent.x < area.x - 1) - posCurrent.x++; - else { - posCurrent.x = 0; - - if (posCurrent.y < area.y - 1) - posCurrent.y++; - else - return false; - } - } - - return true; - } - @Override public ArrayList getSuitableBiomeIds() { ArrayList suitableBiomes = new ArrayList(); @@ -571,14 +541,12 @@ public class Bee extends IndividualLiving implements IBee { } for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) { - float chance = 0; - - if ((chance = mutation.getChance(housing, allele0, allele1, genome0, genome1)) > 0) - if (world.rand.nextFloat()*100 < chance) { - IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName()); - breedingTracker.registerMutation(mutation); - return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate()); - } + float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1); + if (chance > world.rand.nextFloat() * 100) { + IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName()); + breedingTracker.registerMutation(mutation); + return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate()); + } } return null; @@ -588,33 +556,24 @@ public class Bee extends IndividualLiving implements IBee { @Override public IIndividual retrievePollen(IBeeHousing housing) { - int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f)); - - // Correct speed - if (housing.getWorld().rand.nextInt(100) >= chance) - return null; - - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f); - Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2)); - - if (area.x < 1) - area.x = 1; - if (area.y < 1) - area.y = 1; - if (area.z < 1) - area.z = 1; + int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f)); World world = housing.getWorld(); Random random = world.rand; + // Correct speed + if (random.nextInt(100) >= chance) + return null; + + Vect area = getArea(genome, housing); + Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2); Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); IIndividual pollen = null; for (int i = 0; i < 20; i++) { - Vect randomPos = new Vect(random.nextInt(area.x), random.nextInt(area.y), random.nextInt(area.z)); - Vect blockPos = housingPos.add(randomPos).add(offset); + Vect randomPos = Vect.getRandomPositionInArea(random, area); + Vect blockPos = Vect.add(housingPos, randomPos, offset); TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z); if (tile instanceof IPollinatable) { @@ -637,33 +596,27 @@ public class Bee extends IndividualLiving implements IBee { int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f)); + World world = housing.getWorld(); + Random random = world.rand; + // Correct speed - if (housing.getWorld().rand.nextInt(100) >= chance) + if (random.nextInt(100) >= chance) return false; - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f); - Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2)); - - if (area.x < 1) - area.x = 1; - if (area.y < 1) - area.y = 1; - if (area.z < 1) - area.z = 1; + Vect area = getArea(genome, housing); + Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2); + Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); for (int i = 0; i < 30; i++) { - Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z)); + Vect randomPos = Vect.getRandomPositionInArea(random, area); + Vect posBlock = Vect.add(housingPos, randomPos, offset); - Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord())); - posBlock = posBlock.add(offset); - - IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z); + IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z); if(receiver == null) continue; - if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), receiver)) + if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver)) continue; if (!receiver.canMateWith(pollen)) continue; @@ -678,35 +631,33 @@ public class Bee extends IndividualLiving implements IBee { @Override public void plantFlowerRandom(IBeeHousing housing) { - int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f)); + int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f)); + + World world = housing.getWorld(); + Random random = world.rand; // Correct speed - if (housing.getWorld().rand.nextInt(100) >= chance) + if (random.nextInt(100) >= chance) return; // Gather required info IFlowerProvider provider = genome.getFlowerProvider(); - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f); - Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2)); + Vect area = getArea(genome, housing); + Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2); + Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()); - if (area.x < 1) - area.x = 1; - if (area.y < 1) - area.y = 1; - if (area.z < 1) - area.z = 1; - - // We have up to ten attempts for (int i = 0; i < 10; i++) { + Vect randomPos = Vect.getRandomPositionInArea(random, area); + Vect posBlock = Vect.add(housingPos, randomPos, offset); - Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z)); - - Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord())); - posBlock = posBlock.add(offset); - - if (provider.growFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) + if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) break; } } + + private static Vect getArea(IBeeGenome genome, IBeeHousing housing) { + int[] genomeTerritory = genome.getTerritory(); + float housingModifier = housing.getTerritoryModifier(genome, 1f); + return new Vect(genomeTerritory).multiply(housingModifier * 3.0f); + } } diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java index b41ee9b22..4912cc2ef 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java +++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java @@ -26,7 +26,7 @@ import forestry.core.genetics.AlleleArea; import forestry.core.genetics.AlleleBoolean; import forestry.core.genetics.AlleleTolerance; import forestry.core.genetics.Genome; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java index 6b6a1d2c4..2d1baf043 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceDefault.java @@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.biome.BiomeGenBase; diff --git a/src/main/java/forestry/apiculture/genetics/MutationEMC.java b/src/main/java/forestry/apiculture/genetics/MutationEMC.java index f893aea25..3a929bdc0 100755 --- a/src/main/java/forestry/apiculture/genetics/MutationEMC.java +++ b/src/main/java/forestry/apiculture/genetics/MutationEMC.java @@ -14,7 +14,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.lang.reflect.Field; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 6cd2f69ca..48e02b8a4 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -25,7 +25,7 @@ import forestry.core.genetics.AlleleArea; import forestry.core.genetics.AlleleBoolean; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java index 88301d50d..a8ac828fd 100755 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java @@ -25,7 +25,7 @@ import forestry.core.inventory.ItemInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; import java.util.ArrayList; import net.minecraft.client.renderer.texture.IIconRegister; diff --git a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java index f011cdd38..e6e8dde43 100755 --- a/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java +++ b/src/main/java/forestry/arboriculture/genetics/AlleleLeafEffectNone.java @@ -14,7 +14,7 @@ import forestry.api.arboriculture.IAlleleLeafEffect; import forestry.api.arboriculture.ITreeGenome; import forestry.api.genetics.IEffectData; import forestry.core.genetics.Allele; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java index 7047f7910..a180dce2d 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java @@ -17,7 +17,7 @@ import forestry.api.arboriculture.ITreeGenome; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.StringUtil; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index ac89f234b..e290f424d 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -14,7 +14,7 @@ import com.mojang.authlib.GameProfile; import forestry.api.world.ITreeGenData; import forestry.arboriculture.gadgets.TileSapling; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.core.worldgen.BlockType; import forestry.core.worldgen.WorldGenBase; import net.minecraft.init.Blocks; diff --git a/src/main/java/forestry/core/gadgets/StructureLogic.java b/src/main/java/forestry/core/gadgets/StructureLogic.java index bf7ec925d..96632ace4 100755 --- a/src/main/java/forestry/core/gadgets/StructureLogic.java +++ b/src/main/java/forestry/core/gadgets/StructureLogic.java @@ -16,7 +16,7 @@ import forestry.core.config.Defaults; import forestry.core.gadgets.BlockStructure.EnumStructureState; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.HashMap; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index d8c777ec9..a4bc744a3 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -30,7 +30,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/forestry/core/genetics/AlleleArea.java b/src/main/java/forestry/core/genetics/AlleleArea.java index 88d7b57f5..dfec2771f 100755 --- a/src/main/java/forestry/core/genetics/AlleleArea.java +++ b/src/main/java/forestry/core/genetics/AlleleArea.java @@ -12,7 +12,7 @@ package forestry.core.genetics; import forestry.api.genetics.IAlleleArea; import forestry.core.utils.StringUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; public class AlleleArea extends Allele implements IAlleleArea { diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index de6782603..059f9fde9 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -17,6 +17,8 @@ import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import cofh.api.energy.IEnergyHandler; import forestry.core.config.Defaults; +import forestry.core.vect.Vect; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; diff --git a/src/main/java/forestry/core/utils/Schemata.java b/src/main/java/forestry/core/utils/Schemata.java index 968d6a698..b0adbee8f 100755 --- a/src/main/java/forestry/core/utils/Schemata.java +++ b/src/main/java/forestry/core/utils/Schemata.java @@ -11,6 +11,7 @@ package forestry.core.utils; import forestry.core.config.Config; +import forestry.core.vect.Vect; public class Schemata { public enum EnumStructureBlock { diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index a05a1c523..b20588b68 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -37,6 +37,7 @@ import forestry.api.core.ForestryAPI; import forestry.api.core.ITileStructure; import forestry.core.gadgets.TileForestry; import forestry.core.proxy.Proxies; +import forestry.core.vect.Vect; import buildcraft.api.tools.IToolWrench; diff --git a/src/main/java/forestry/core/vect/IVect.java b/src/main/java/forestry/core/vect/IVect.java new file mode 100644 index 000000000..b20c33149 --- /dev/null +++ b/src/main/java/forestry/core/vect/IVect.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * 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.vect; + +/** + * Represents a position or dimensions. + */ +public interface IVect { + int getX(); + int getY(); + int getZ(); + + IVect add(IVect other); + IVect add(int x, int y, int z); +} diff --git a/src/main/java/forestry/core/vect/MutableVect.java b/src/main/java/forestry/core/vect/MutableVect.java new file mode 100644 index 000000000..7a765006e --- /dev/null +++ b/src/main/java/forestry/core/vect/MutableVect.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.vect; + +/** + * Represents changeable positions or dimensions. + */ +public class MutableVect implements IVect { + public int x; + public int y; + public int z; + + public MutableVect(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public MutableVect(IVect vect) { + this.x = vect.getX(); + this.y = vect.getY(); + this.z = vect.getZ(); + } + + public MutableVect add(IVect other) { + x += other.getX(); + y += other.getY(); + z += other.getZ(); + return this; + } + + public MutableVect add(int x, int y, int z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + public boolean advancePositionInArea(Vect area) { + // Increment z first until end reached + if (z < area.z - 1) + z++; + else { + z = 0; + + if (x < area.x - 1) + x++; + else { + x = 0; + + if (y < area.y - 1) + y++; + else + return false; + } + } + + return true; + } + + @Override + public int getX() { + return x; + } + + @Override + public int getY() { + return y; + } + + @Override + public int getZ() { + return z; + } +} diff --git a/src/main/java/forestry/core/utils/Vect.java b/src/main/java/forestry/core/vect/Vect.java old mode 100755 new mode 100644 similarity index 50% rename from src/main/java/forestry/core/utils/Vect.java rename to src/main/java/forestry/core/vect/Vect.java index 256b8c2d0..a9e0e25c3 --- a/src/main/java/forestry/core/utils/Vect.java +++ b/src/main/java/forestry/core/vect/Vect.java @@ -1,84 +1,110 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.utils; - -/** - * Generic class to represent a position or dimensions. - */ -public class Vect { - public int x; - public int y; - public int z; - - public Vect(int[] dim) { - if (dim.length != 3) - throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points."); - - this.x = dim[0]; - this.y = dim[1]; - this.z = dim[2]; - } - - public Vect(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } - - public Vect add(Vect other) { - Vect result = new Vect(x, y, z); - result.x += other.x; - result.y += other.y; - result.z += other.z; - return result; - } - - public Vect multiply(float factor) { - Vect result = new Vect(x, y, z); - result.x *= factor; - result.y *= factor; - result.z *= factor; - return result; - } - - @Override - public String toString() { - return String.format("%sx%sx%s", x, y, z); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + x; - result = prime * result + y; - result = prime * result + z; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Vect other = (Vect) obj; - if (x != other.x) - return false; - if (y != other.y) - return false; - if (z != other.z) - return false; - return true; - } -} +/******************************************************************************* + * 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.vect; + +import java.util.Random; + +/** + * Represents an unchangeable position or dimensions. + */ +public class Vect implements IVect { + public final int x; + public final int y; + public final int z; + + public Vect(int[] dim) { + if (dim.length != 3) + throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points."); + + this.x = dim[0]; + this.y = dim[1]; + this.z = dim[2]; + } + + public Vect(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public static Vect getRandomPositionInArea(Random random, IVect area) { + int x = random.nextInt(area.getX()); + int y = random.nextInt(area.getY()); + int z = random.nextInt(area.getZ()); + return new Vect(x, y, z); + } + + public static Vect add(IVect... vects) { + int x = 0; + int y = 0; + int z = 0; + for (IVect vect : vects) { + x += vect.getX(); + y += vect.getY(); + z += vect.getZ(); + } + return new Vect(x, y, z); + } + + @Override + public Vect add(IVect other) { + return new Vect(x + other.getX(), y + other.getY(), z + other.getZ()); + } + + @Override + public Vect add(int x, int y, int z) { + return new Vect(this.x + x, this.y + y, this.z + z); + } + + public Vect multiply(float factor) { + return new Vect(Math.round(x * factor), Math.round(y * factor), Math.round(z * factor)); + } + + @Override + public String toString() { + return String.format("%sx%sx%s", x, y, z); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + x; + result = prime * result + y; + result = prime * result + z; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!(obj instanceof Vect)) + return false; + Vect other = (Vect) obj; + return (x == other.x) && (y == other.y) && (z == other.z); + } + + @Override + public int getX() { + return x; + } + + @Override + public int getY() { + return y; + } + + @Override + public int getZ() { + return z; + } +} diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index b707f5d98..ba055e045 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -1,53 +1,53 @@ -/******************************************************************************* - * 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.farming; - -import forestry.core.utils.Vect; - -public class FarmTarget { - - private Vect start; - private int yOffset; - private int extent; - private int limit; - - public FarmTarget(Vect start) { - this.start = start; - } - - public void setYOffset(int yOffset) { - this.yOffset = yOffset; - } - - public void setLimit(int limit) { - this.limit = limit; - } - - public void setExtent(int extent) { - this.extent = extent; - } - - public Vect getStart() { - return start; - } - - public int getYOffset() { - return this.yOffset; - } - - public int getLimit() { - return limit; - } - - public int getExtent() { - return extent; - } -} +/******************************************************************************* + * 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.farming; + +import forestry.core.vect.Vect; + +public class FarmTarget { + + private Vect start; + private int yOffset; + private int extent; + private int limit; + + public FarmTarget(Vect start) { + this.start = start; + } + + public void setYOffset(int yOffset) { + this.yOffset = yOffset; + } + + public void setLimit(int limit) { + this.limit = limit; + } + + public void setExtent(int extent) { + this.extent = extent; + } + + public Vect getStart() { + return start; + } + + public int getYOffset() { + return this.yOffset; + } + + public int getLimit() { + return limit; + } + + public int getExtent() { + return extent; + } +} diff --git a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java index ce6371ba7..ec5acea0d 100755 --- a/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java +++ b/src/main/java/forestry/farming/gadgets/StructureLogicFarm.java @@ -16,7 +16,7 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState; import forestry.core.gadgets.StructureLogic; import forestry.core.utils.Schemata; import forestry.core.utils.Schemata.EnumStructureBlock; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.HashSet; import java.util.Set; import net.minecraft.block.Block; diff --git a/src/main/java/forestry/farming/gadgets/TileControl.java b/src/main/java/forestry/farming/gadgets/TileControl.java index 54b90f082..f5e6280d1 100755 --- a/src/main/java/forestry/farming/gadgets/TileControl.java +++ b/src/main/java/forestry/farming/gadgets/TileControl.java @@ -15,7 +15,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 884071ab9..e275ae474 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -38,7 +38,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.DelayTimer; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index 2262e944c..c227a38e2 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -12,7 +12,7 @@ package forestry.farming.logic; import forestry.api.farming.ICrop; import forestry.core.config.Defaults; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index 82e555ca9..707583b2a 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -11,7 +11,7 @@ package forestry.farming.logic; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index ffc199471..07f0e8f1a 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -14,7 +14,7 @@ import forestry.api.genetics.IFruitBearer; import forestry.api.genetics.IFruitFamily; import forestry.core.network.PacketFXSignal; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index 949deefec..af55bd49a 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -13,7 +13,7 @@ package forestry.farming.logic; import forestry.core.gadgets.BlockSoil; import forestry.core.proxy.Proxies; import forestry.core.utils.BlockUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import net.minecraft.block.Block; diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index ac7dfc885..4d7349485 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -12,7 +12,7 @@ package forestry.farming.logic; import forestry.core.config.Defaults; import forestry.core.proxy.Proxies; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginIC2; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 97e1419f4..24abcc6db 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -10,21 +10,25 @@ ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmLogic; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.render.SpriteSheet; -import forestry.core.utils.Vect; import java.util.HashSet; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmLogic; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.render.SpriteSheet; +import forestry.core.vect.IVect; +import forestry.core.vect.Vect; + public abstract class FarmLogic implements IFarmLogic { IFarmHousing housing; @@ -67,8 +71,8 @@ public abstract class FarmLogic implements IFarmLogic { return SpriteSheet.ITEMS.getLocation(); } - protected final boolean isAirBlock(Vect position) { - return getWorld().isAirBlock(position.x, position.y, position.z); + protected final boolean isAirBlock(IVect position) { + return getWorld().isAirBlock(position.getX(), position.getY(), position.getZ()); } protected final boolean isAirBlock(Block block) { @@ -80,20 +84,20 @@ public abstract class FarmLogic implements IFarmLogic { world.getBlockMetadata(position.x, position.y, position.z) == 0; } - protected final boolean isWoodBlock(Vect position) { + protected final boolean isWoodBlock(IVect position) { Block block = getBlock(position); - return block.isWood(getWorld(), position.x, position.y, position.z); + return block.isWood(getWorld(), position.getX(), position.getY(), position.getZ()); } - protected final Block getBlock(Vect position) { - return getWorld().getBlock(position.x, position.y, position.z); + protected final Block getBlock(IVect position) { + return getWorld().getBlock(position.getX(), position.getY(), position.getZ()); } - protected final int getBlockMeta(Vect position) { - return getWorld().getBlockMetadata(position.x, position.y, position.z); + protected final int getBlockMeta(IVect position) { + return getWorld().getBlockMetadata(position.getX(), position.getY(), position.getZ()); } - protected final ItemStack getAsItemStack(Vect position) { + protected final ItemStack getAsItemStack(IVect position) { return new ItemStack(getBlock(position), 1, getBlockMeta(position)); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 00352ab7c..145d70a9e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -19,7 +19,7 @@ import forestry.api.farming.IFarmable; import forestry.core.config.ForestryBlock; import forestry.core.gadgets.BlockSoil; import forestry.core.render.SpriteSheet; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -101,7 +101,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { Vect offset = new Vect(housing.getOffset()); Vect min = coords.add(offset); - Vect max = coords.add(offset).add(area); + Vect max = min.add(area); AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, getWorld().getHeight(), max.z); List list = getWorld().getEntitiesWithinAABB(Entity.class, harvestBox); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 5a1c4eedb..967fac68a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -15,7 +15,8 @@ import cpw.mods.fml.relauncher.SideOnly; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; -import forestry.core.utils.Vect; +import forestry.core.vect.MutableVect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -123,7 +124,7 @@ public class FarmLogicCocoa extends FarmLogic { World world = getWorld(); - Vect current = position; + MutableVect current = new MutableVect(position); while (isWoodBlock(current) && BlockLog.func_150165_c(getBlockMeta(current)) == 3) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { @@ -135,7 +136,7 @@ public class FarmLogicCocoa extends FarmLogic { return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z); } - current = current.add(new Vect(0, 1, 0)); + current.y++; if (current.y - position.y > 1) break; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 29e9a2b95..1e8af8cbc 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -16,7 +16,8 @@ import forestry.api.farming.IFarmable; import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.IVect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -74,7 +75,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { Vect offset = new Vect(housing.getOffset()); Vect min = coords.add(offset); - Vect max = coords.add(offset).add(area); + Vect max = min.add(area); AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z); List list = housing.getWorld().getEntitiesWithinAABB(Entity.class, harvestBox); @@ -106,7 +107,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { if (!isAirBlock(position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z)) continue; - ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0))); + ItemStack below = getAsItemStack(position.add(0, -1, 0)); if (ground.getItem() != below.getItem()) continue; if (below.getItemDamage() <= 0) @@ -118,11 +119,11 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { return false; } - private boolean trySetCrop(Vect position) { + private boolean trySetCrop(IVect position) { World world = getWorld(); for (IFarmable candidate : seeds) - if (housing.plantGermling(candidate, world, position.x, position.y, position.z)) + if (housing.plantGermling(candidate, world, position.getX(), position.getY(), position.getZ())) return true; return false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 4af434431..39a425f83 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -16,7 +16,7 @@ import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import java.util.Stack; import net.minecraft.init.Items; diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 5fa931400..cf31c5407 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -14,7 +14,7 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 2eb3af892..2a4e36a80 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -17,7 +17,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import java.util.Stack; import net.minecraft.init.Blocks; @@ -89,7 +89,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { if (!isAirBlock(position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z)) continue; - ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0))); + ItemStack below = getAsItemStack(position.add(0, -1, 0)); if (!isAcceptedGround(below)) continue; diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 642b930ed..e870ecf18 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -16,7 +16,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.genetics.IFruitBearer; import forestry.core.config.ForestryItem; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index f37cf7575..63c769da2 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -17,7 +17,7 @@ import forestry.api.farming.IFarmHousing; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockSoil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import java.util.Stack; import net.minecraft.block.Block; diff --git a/src/main/java/forestry/farming/logic/FarmLogicPoale.java b/src/main/java/forestry/farming/logic/FarmLogicPoale.java index cca789b17..b19211f5e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPoale.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPoale.java @@ -17,7 +17,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import java.util.Stack; import net.minecraft.init.Blocks; diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 53fc99782..46566329e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -16,7 +16,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginIC2; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index 68a2ec2fb..fb5c3bc68 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -17,7 +17,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.Collection; import java.util.Stack; import net.minecraft.init.Blocks; diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 7dd55ac91..979c578c5 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -15,7 +15,7 @@ import forestry.core.fluids.Fluids; import forestry.core.utils.BlockUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import java.util.ArrayList; import java.util.Collection; import net.minecraft.block.Block; @@ -154,7 +154,7 @@ public abstract class FarmLogicWatered extends FarmLogic { // don't place water close to other water for (int x = -2; x <= 2; x++) { for (int z = -2; z <= 2; z++) { - Vect offsetPosition = position.add(new Vect(x, 0, z)); + Vect offsetPosition = position.add(x, 0, z); if (isWaterSourceBlock(world, offsetPosition)) return false; } @@ -162,12 +162,12 @@ public abstract class FarmLogicWatered extends FarmLogic { // don't place water if it can flow into blocks next to it for (int x = -1; x <= 1; x++) { - Vect offsetPosition = position.add(new Vect(x, 0, 0)); + Vect offsetPosition = position.add(x, 0, 0); if (isAirBlock(offsetPosition)) return false; } for (int z = -1; z <= 1; z++) { - Vect offsetPosition = position.add(new Vect(0, 0, z)); + Vect offsetPosition = position.add(0, 0, z); if (isAirBlock(offsetPosition)) return false; } diff --git a/src/main/java/forestry/farming/logic/FarmableCocoa.java b/src/main/java/forestry/farming/logic/FarmableCocoa.java index a5874201b..d4d410279 100755 --- a/src/main/java/forestry/farming/logic/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmableCocoa.java @@ -13,7 +13,7 @@ package forestry.farming.logic; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; diff --git a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java index ce13c3ca7..83709dd1f 100755 --- a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java +++ b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java @@ -13,7 +13,7 @@ package forestry.farming.logic; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import forestry.plugins.PluginFarmCraftory; import java.util.Collection; import net.minecraft.block.Block; diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/FarmableGE.java index 556c6cb4b..358bf9465 100755 --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/FarmableGE.java @@ -15,7 +15,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.arboriculture.genetics.TreeGenome; import forestry.core.config.ForestryBlock; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 632ce5344..1309aeb47 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -12,7 +12,7 @@ package forestry.farming.logic; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index f49c16760..6834df2b0 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -13,7 +13,7 @@ package forestry.farming.logic; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 7d340265d..57136907f 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -14,7 +14,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index 50311afeb..b41fbb287 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -14,7 +14,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Defaults; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java index 0b739124b..d6c068b42 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaShroom.java @@ -15,7 +15,7 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; -import forestry.core.utils.Vect; +import forestry.core.vect.Vect; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; From 46348fca07da7ed87ee531ec8570501cebb8bc35 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 19 Dec 2014 23:25:45 -0800 Subject: [PATCH 071/175] Fix #383 Fermenter crash when opening the gui --- .../forestry/factory/gadgets/MachineFermenter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index c0089d4ad..34154f210 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -30,6 +30,7 @@ import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; +import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; import java.util.ArrayList; @@ -145,12 +146,11 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } public static boolean isResource(ItemStack resource) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); - if (recipe.resource.getItemDamage() == Defaults.WILDCARD - && recipe.resource.getItem() == resource.getItem()) - return true; - else if (recipe.resource.isItemEqual(resource)) + if (resource == null) + return false; + + for (Recipe recipe : recipes) { + if (StackUtils.isCraftingEquivalent(recipe.resource, resource)) return true; } return false; From d63377532cebc439bb097a576da8f9c9295dae25 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 19 Dec 2014 23:40:07 -0800 Subject: [PATCH 072/175] Fix #384 Client crash at forestry.farming.gadgets.TileHatch --- .../apiculture/gadgets/TileAlvearyPlain.java | 47 ++++++++++-------- src/main/java/forestry/core/utils/Utils.java | 4 +- .../forestry/farming/gadgets/TileHatch.java | 48 +++++++++++-------- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 2db92b886..b0e44b75e 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -140,8 +140,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB return; // Add swarm effects - if (worldObj.getTotalWorldTime() % 200 * 10 == 0) - onQueenChange(getStructureInventory().getStackInSlot(SLOT_QUEEN)); + if (worldObj.getTotalWorldTime() % 200 == 0) { + ISidedInventory inventory = getStructureInventory(); + if (inventory != null) + onQueenChange(inventory.getStackInSlot(SLOT_QUEEN)); + } + if (getErrorState() == EnumErrorCode.OK) queen.doFX(beekeepingLogic.getEffectData(), this); @@ -166,15 +170,18 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB if (!isMaster()) return; - if (getStructureInventory() == null) + ISidedInventory inventory = getStructureInventory(); + if (inventory == null) return; // / Multiplayer FX - if (PluginApiculture.beeInterface.isMated(getStructureInventory().getStackInSlot(SLOT_QUEEN))) + ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN); + if (PluginApiculture.beeInterface.isMated(queenStack)) { if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) { - IBee displayQueen = PluginApiculture.beeInterface.getMember(getStructureInventory().getStackInSlot(SLOT_QUEEN)); + IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack); displayQueen.doFX(beekeepingLogic.getEffectData(), this); } + } } private void equalizeTemperature() { @@ -544,37 +551,37 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public int getSizeInventory() { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getSizeInventory(); - else + if (inv == null) return 0; + + return inv.getSizeInventory(); } @Override public ItemStack getStackInSlot(int slotIndex) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getStackInSlot(slotIndex); - else + if (inv == null) return null; + + return inv.getStackInSlot(slotIndex); } @Override public ItemStack decrStackSize(int slotIndex, int amount) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.decrStackSize(slotIndex, amount); - else + if (inv == null) return null; + + return inv.decrStackSize(slotIndex, amount); } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getStackInSlotOnClosing(slotIndex); - else + if (inv == null) return null; + + return inv.getStackInSlotOnClosing(slotIndex); } @Override @@ -598,10 +605,10 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public int getInventoryStackLimit() { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getInventoryStackLimit(); - else + if (inv == null) return 0; + + return inv.getInventoryStackLimit(); } @Override diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index b20588b68..9869e0cd5 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -60,7 +60,7 @@ public class Utils { if (tile instanceof ITileStructure) { IInventory inventory = ((ITileStructure) tile).getInventory(); - if (inventory != null) + if (inventory != null) { for (int i = 0; i < inventory.getSizeInventory(); i++) { if (inventory.getStackInSlot(i) == null) continue; @@ -68,7 +68,7 @@ public class Utils { StackUtils.dropItemStackAsEntity(inventory.getStackInSlot(i), world, x, y, z); inventory.setInventorySlotContents(i, null); } - + } } else { IInventory inventory; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index dec38f7f0..5d6820471 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -13,6 +13,7 @@ package forestry.farming.gadgets; import buildcraft.api.statements.ITriggerExternal; import cpw.mods.fml.common.Optional; import forestry.api.core.ITileStructure; +import forestry.core.config.Defaults; import forestry.core.inventory.AdjacentInventoryCache; import forestry.core.inventory.ITileFilter; import forestry.core.inventory.InvTools; @@ -57,7 +58,11 @@ public class TileHatch extends TileFarm implements ISidedInventory { /* AUTO-EJECTING */ private IInventory getProductInventory() { - return new InventoryMapper(getStructureInventory(), TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION); + TileInventoryAdapter inventory = getStructureInventory(); + if (inventory == null) + return null; + + return new InventoryMapper(inventory, TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION); } protected void dumpStash() { @@ -87,37 +92,37 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public int getSizeInventory() { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getSizeInventory(); - else + if (inv == null) return 0; + + return inv.getSizeInventory(); } @Override public ItemStack getStackInSlot(int slotIndex) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getStackInSlot(slotIndex); - else + if (inv == null) return null; + + return inv.getStackInSlot(slotIndex); } @Override public ItemStack decrStackSize(int slotIndex, int amount) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.decrStackSize(slotIndex, amount); - else + if (inv == null) return null; + + return inv.decrStackSize(slotIndex, amount); } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getStackInSlotOnClosing(slotIndex); - else + if (inv == null) return null; + + return inv.getStackInSlotOnClosing(slotIndex); } @Override @@ -130,10 +135,10 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public int getInventoryStackLimit() { IInventory inv = getStructureInventory(); - if (inv != null) - return inv.getInventoryStackLimit(); - else + if (inv == null) return 0; + + return inv.getInventoryStackLimit(); } @Override @@ -171,7 +176,8 @@ public class TileHatch extends TileFarm implements ISidedInventory { if (!(struct instanceof TileFarmPlain)) return false; - if (!getStructureInventory().isItemValidForSlot(slotIndex, itemstack)) + TileInventoryAdapter inventory = getStructureInventory(); + if (inventory == null || !inventory.isItemValidForSlot(slotIndex, itemstack)) return false; TileFarmPlain housing = (TileFarmPlain) struct; @@ -196,7 +202,8 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getStructureInventory().canExtractItem(slotIndex, itemstack, side)) + TileInventoryAdapter inventory = getStructureInventory(); + if (inventory == null || !inventory.canExtractItem(slotIndex, itemstack, side)) return false; return slotIndex >= TileFarmPlain.SLOT_PRODUCTION_1 && slotIndex < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; @@ -204,7 +211,10 @@ public class TileHatch extends TileFarm implements ISidedInventory { @Override public int[] getAccessibleSlotsFromSide(int side) { - return getStructureInventory().getAccessibleSlotsFromSide(side); + TileInventoryAdapter inventory = getStructureInventory(); + if (inventory == null) + return Defaults.FACINGS_NONE; + return inventory.getAccessibleSlotsFromSide(side); } /* ITRIGGERPROVIDER */ From 71dcbdf0e45f5e9a988a01e104adb963dd5b7d8e Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 00:13:28 -0800 Subject: [PATCH 073/175] Fix #385 Server crash when opening AlvearySieve --- .../apiculture/gadgets/TileAlvearySieve.java | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index 413ada71e..8987def65 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeListener; @@ -18,11 +21,8 @@ import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.core.interfaces.ICrafter; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener { @@ -32,11 +32,10 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe public static final int SLOT_POLLEN_1 = 0; public static final int SLOTS_POLLEN_COUNT = 4; public static final int SLOT_SIEVE = 4; - - private final InventoryAdapter inventory = new InventoryAdapter(5, "Items", 1); public TileAlvearySieve() { super(BLOCK_META); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1)); } @Override @@ -44,7 +43,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe player.openGui(ForestryAPI.instance, GuiId.AlvearySieveGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); } - @Override public boolean hasFunction() { return true; @@ -61,7 +59,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe ((IAlvearyComponent)getCentralTE()).registerBeeListener(this); } - @Override protected void updateServerSide() { super.updateServerSide(); @@ -74,19 +71,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe ((IAlvearyComponent)getCentralTE()).registerBeeListener(this); } - /* SAVING & LOADING */ - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - inventory.readFromNBT(nbttagcompound); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - inventory.writeToNBT(nbttagcompound); - } - /* TEXTURES & INTERNAL */ @Override public int getIcon(int side, int metadata) { @@ -96,15 +80,19 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } private void destroySieve() { + TileInventoryAdapter inventory = getInternalInventory(); inventory.setInventorySlotContents(SLOT_SIEVE, null); } + private void destroyPollen() { + TileInventoryAdapter inventory = getInternalInventory(); for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { inventory.setInventorySlotContents(i, null); } } private boolean canStorePollen() { + TileInventoryAdapter inventory = getInternalInventory(); if(inventory.getStackInSlot(SLOT_SIEVE) == null) return false; @@ -117,6 +105,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } private void storePollenStack(ItemStack itemstack) { + TileInventoryAdapter inventory = getInternalInventory(); for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { if(inventory.getStackInSlot(i) == null) { inventory.setInventorySlotContents(i, itemstack); @@ -133,6 +122,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { + TileInventoryAdapter inventory = getInternalInventory(); if(slotIndex == SLOT_SIEVE) { destroyPollen(); return inventory.getStackInSlot(SLOT_SIEVE); @@ -157,7 +147,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) { if(isHandled) - return isHandled; + return true; if(!canStorePollen()) return false; From 483a21cd7d83e5b7ad437c6b8c505bcd4b00f2f8 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 01:07:36 -0800 Subject: [PATCH 074/175] Remove unused imports --- api | 2 +- .../java/forestry/core/gadgets/BlockBase.java | 22 +++++----- .../factory/gadgets/MachineCentrifuge.java | 40 ++++++++++--------- .../factory/gadgets/MachineFabricator.java | 33 +++++++-------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/api b/api index 8799e138d..32e4fa061 160000 --- a/api +++ b/api @@ -1 +1 @@ -Subproject commit 8799e138dab95de6504ecdbe158aef9a12ec9c35 +Subproject commit 32e4fa061c31ac225274070937e1c37e91fac046 diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 8a9c30e26..d131f8f15 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -10,18 +10,9 @@ ******************************************************************************/ package forestry.core.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.fluids.FluidHelper; -import forestry.core.interfaces.IOwnable; -import forestry.core.items.ItemNBTTile; -import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumAccess; -import forestry.core.utils.PlayerUtil; -import forestry.core.utils.StringUtil; -import forestry.core.utils.Utils; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -35,10 +26,21 @@ import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.fluids.FluidHelper; +import forestry.core.interfaces.IOwnable; +import forestry.core.items.ItemNBTTile; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; +import forestry.core.utils.Utils; + public class BlockBase extends BlockForestry { private final List definitions = new ArrayList(); diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 33944549f..7cf7509ce 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -10,8 +10,27 @@ ******************************************************************************/ package forestry.factory.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICentrifugeManager; import forestry.core.EnumErrorCode; @@ -21,24 +40,9 @@ import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; -import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.ITriggerExternal; public class MachineCentrifuge extends TilePowered implements ISidedInventory { diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 19813a7a1..e097856ee 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -10,6 +10,23 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; import forestry.api.core.ForestryAPI; import forestry.api.recipes.IFabricatorManager; @@ -31,22 +48,6 @@ import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class MachineFabricator extends TilePowered implements ICrafter, ILiquidTankContainer, ISidedInventory { From 09df969bcf4895c8faf1c99ca7f174466aa2e363 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 03:21:00 -0800 Subject: [PATCH 075/175] Fix drawing bee icons in the Imprinter --- .../forestry/apiculture/gui/GuiImprinter.java | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java index 0d677d7c1..8fbd9c2c9 100755 --- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java +++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java @@ -10,6 +10,15 @@ ******************************************************************************/ package forestry.apiculture.gui; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.apiculture.genetics.BeeGenome; import forestry.apiculture.items.ItemBeeGE; @@ -20,10 +29,6 @@ import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import java.util.ArrayList; -import java.util.HashMap; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; public class GuiImprinter extends GuiForestry { @@ -33,7 +38,7 @@ public class GuiImprinter extends GuiForestry { private int startX; private int startY; - private final HashMap iconStacks = new HashMap(); + private final Map iconStacks = new HashMap(); public GuiImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) { super(Defaults.TEXTURE_PATH_GUI + "/imprinter.png", new ContainerImprinter(inventoryplayer, inventory), inventory); @@ -44,7 +49,7 @@ public class GuiImprinter extends GuiForestry { xSize = 176; ySize = 185; - ArrayList beeList = new ArrayList(); + List beeList = new ArrayList(); ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); for (ItemStack beeStack : beeList) iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack); @@ -74,21 +79,9 @@ public class GuiImprinter extends GuiForestry { } private void drawBeeSpeciesIcon(IAlleleBeeSpecies bee, int x, int y) { - - /* - * GL11.glDisable(GL11.GL_LIGHTING); mc.renderEngine.func_98187_b(Defaults.TEXTURE_BEES); - * - * for (int i = 0; i < ForestryItem.beeDroneGE.getRenderPasses(0); ++i) { - * - * int iconIndex = ForestryItem.beeDroneGE.getIconIndex(iconStacks.get(bee.getUID()), i); int color = ((ItemGE) - * ForestryItem.beeDroneGE).getColorFromItemStack(iconStacks.get(bee.getUID()), i); float colorR = (color >> 16 & 255) / 255.0F; float colorG = (color - * >> 8 & 255) / 255.0F; float colorB = (color & 255) / 255.0F; - * - * GL11.glColor4f(colorR, colorG, colorB, 1.0F); drawTexturedModalRect(x, y, iconIndex % 16 * 16, iconIndex / 16 * 16, 16, 16); - * - * } GL11.glEnable(GL11.GL_LIGHTING); - */ - + RenderHelper.enableStandardItemLighting(); + drawItemStack(iconStacks.get(bee.getUID()), x, y); + RenderHelper.disableStandardItemLighting(); } private int getHabitatSlotAtPosition(int i, int j) { From e2fff11ea81e8d2a519b18deff2f0343b60cc53a Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 03:59:31 -0800 Subject: [PATCH 076/175] Simple Cleanup --- .../apiculture/FlowerProviderCacti.java | 5 +- .../apiculture/FlowerProviderJungle.java | 5 +- .../apiculture/FlowerProviderMushroom.java | 5 +- .../apiculture/FlowerProviderVanilla.java | 5 +- .../apiculture/gadgets/BlockCandle.java | 2 +- .../apiculture/gadgets/TileBeehouse.java | 3 - .../apiculture/genetics/AlleleBeeSpecies.java | 2 +- .../genetics/AlleleEffectCreeper.java | 4 +- .../genetics/AlleleEffectFungification.java | 2 +- .../genetics/AlleleEffectIgnition.java | 4 +- .../genetics/AlleleEffectMiasmic.java | 2 +- .../apiculture/genetics/BeeHelper.java | 30 +++---- .../apiculture/genetics/BeekeepingMode.java | 5 +- .../genetics/JubilanceProviderHermit.java | 5 +- .../apiculture/genetics/JubilanceReqRes.java | 12 +-- .../apiculture/gui/ContainerAlveary.java | 22 ++--- .../gui/ContainerAlvearyHygroregulator.java | 9 +- .../apiculture/gui/ContainerAlvearySieve.java | 26 +++--- .../gui/ContainerAlvearySwarmer.java | 12 +-- .../apiculture/gui/ContainerApiary.java | 28 +++--- .../gui/ContainerHabitatLocator.java | 6 +- .../apiculture/gui/ContainerImprinter.java | 8 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 2 - .../forestry/apiculture/gui/GuiImprinter.java | 4 +- .../apiculture/render/BeeItemRenderer.java | 2 +- .../apiculture/render/TextureBiomefinder.java | 2 +- .../worldgen/ComponentVillageBeeHouse.java | 11 +-- .../arboriculture/FruitProviderNone.java | 4 +- .../arboriculture/FruitProviderPod.java | 2 +- .../arboriculture/gadgets/BlockArbFence.java | 5 +- .../arboriculture/gadgets/TileLeaves.java | 4 +- .../forestry/arboriculture/genetics/Tree.java | 18 ++-- .../arboriculture/genetics/TreeHelper.java | 33 +++---- .../gui/ContainerTreealyzer.java | 11 +-- .../render/LeavesRenderingHandler.java | 6 +- .../render/SaplingRenderHandler.java | 4 +- .../java/forestry/core/EnumErrorCode.java | 4 +- src/main/java/forestry/core/GameMode.java | 24 ++--- .../core/circuits/ContainerSolderingIron.java | 14 +-- .../core/commands/CommandHelpers.java | 13 ++- .../java/forestry/core/config/Config.java | 90 +++++++++---------- .../forestry/core/config/Configuration.java | 31 +++---- .../java/forestry/core/config/Property.java | 10 +-- .../java/forestry/core/config/Version.java | 6 +- .../core/fluids/tanks/FilteredTank.java | 7 +- .../gadgets/BlockResourceStorageBlock.java | 2 +- .../java/forestry/core/gadgets/BlockSoil.java | 30 ++----- .../java/forestry/core/gadgets/Engine.java | 14 +-- .../core/gadgets/MachineDefinition.java | 3 - .../forestry/core/gui/ContainerAlyzer.java | 14 +-- .../forestry/core/gui/ContainerAnalyzer.java | 23 +++-- .../core/gui/ContainerEscritoire.java | 10 +-- .../forestry/core/gui/ContainerForestry.java | 10 --- .../core/gui/ContainerItemInventory.java | 4 +- .../gui/ContainerNaturalistInventory.java | 8 +- .../forestry/core/gui/ContainerSocketed.java | 2 +- .../java/forestry/core/gui/ErrorLedger.java | 2 +- .../java/forestry/core/gui/GuiAlyzer.java | 6 +- .../java/forestry/core/gui/GuiForestry.java | 48 +--------- .../core/gui/GuiNaturalistInventory.java | 6 +- .../java/forestry/core/gui/GuiTextBox.java | 5 +- src/main/java/forestry/core/gui/Ledger.java | 6 +- .../java/forestry/core/gui/OwnerLedger.java | 4 +- .../core/gui/widgets/ReservoirWidget.java | 2 +- .../forestry/core/gui/widgets/TankWidget.java | 2 +- .../forestry/core/inventory/InvTools.java | 2 +- .../java/forestry/core/items/ItemPipette.java | 2 +- .../forestry/core/network/ForestryPacket.java | 2 +- .../core/proxy/ClientProxyCommon.java | 8 -- .../forestry/core/render/EntitySnowFX.java | 2 +- .../java/forestry/core/utils/BlockUtil.java | 68 ++++---------- .../java/forestry/core/utils/StackUtils.java | 4 - .../java/forestry/energy/EnergyManager.java | 11 +-- .../forestry/energy/gadgets/EngineBronze.java | 25 +----- .../forestry/energy/gadgets/EngineCopper.java | 14 --- .../forestry/energy/gadgets/EngineTin.java | 2 +- .../energy/gui/ContainerEngineBronze.java | 6 +- .../energy/gui/ContainerEngineCopper.java | 14 +-- .../energy/gui/ContainerEngineTin.java | 6 +- .../energy/gui/ContainerGenerator.java | 6 +- .../forestry/energy/gui/GuiEngineBronze.java | 7 +- .../factory/gadgets/MachineFermenter.java | 3 +- .../factory/gadgets/MachineMoistener.java | 3 +- .../factory/gadgets/MachineRaintank.java | 2 +- .../factory/gadgets/MachineSqueezer.java | 5 +- .../factory/gadgets/MachineStill.java | 11 +-- .../factory/gui/ContainerBottler.java | 10 +-- .../factory/gui/ContainerCarpenter.java | 25 ++---- .../factory/gui/ContainerCentrifuge.java | 8 +- .../factory/gui/ContainerFabricator.java | 24 +++-- .../factory/gui/ContainerFermenter.java | 14 +-- .../factory/gui/ContainerMoistener.java | 14 +-- .../factory/gui/ContainerRaintank.java | 11 +-- .../factory/gui/ContainerSqueezer.java | 21 ++--- .../forestry/factory/gui/ContainerStill.java | 20 ++--- .../factory/gui/ContainerWorktable.java | 39 ++++---- .../java/forestry/farming/FarmTarget.java | 2 +- .../forestry/farming/gadgets/BlockFarm.java | 5 +- .../forestry/farming/gui/ContainerFarm.java | 16 ++-- .../java/forestry/farming/logic/Crop.java | 12 +-- .../forestry/farming/logic/CropBlock.java | 4 +- .../forestry/farming/logic/CropFruit.java | 2 +- .../forestry/farming/logic/FarmLogic.java | 6 +- .../farming/logic/FarmLogicArboreal.java | 4 +- .../farming/logic/FarmLogicCocoa.java | 4 +- .../farming/logic/FarmLogicCrops.java | 2 +- .../farming/logic/FarmLogicOrchard.java | 4 +- .../farming/logic/FarmLogicPoale.java | 2 +- .../farming/logic/FarmLogicRubber.java | 3 +- .../farming/logic/FarmLogicSucculent.java | 2 +- .../farming/logic/FarmLogicWatered.java | 2 +- .../farming/logic/FarmableFarmCraftory.java | 5 +- .../farming/logic/FarmableGenericCrop.java | 9 +- .../farming/logic/FarmableGenericSapling.java | 7 +- .../forestry/farming/logic/FarmableGourd.java | 18 ++-- .../farming/logic/FarmableStacked.java | 4 +- .../forestry/food/gui/ContainerInfuser.java | 16 ++-- .../forestry/food/items/ItemBeverage.java | 2 +- .../entities/AIButterflyMate.java | 1 - .../entities/AIButterflyPollinate.java | 1 - .../lepidopterology/genetics/Butterfly.java | 10 +-- src/main/java/forestry/mail/Letter.java | 9 +- src/main/java/forestry/mail/PostOffice.java | 2 +- src/main/java/forestry/mail/PostRegistry.java | 2 +- .../java/forestry/mail/PostalCarrier.java | 6 +- src/main/java/forestry/mail/TradeStation.java | 2 +- .../forestry/mail/gui/ContainerLetter.java | 10 +-- .../forestry/mail/gui/ContainerMailbox.java | 6 +- .../mail/gui/ContainerPhilatelist.java | 8 +- .../forestry/mail/gui/ContainerTradeName.java | 4 +- .../forestry/mail/gui/ContainerTrader.java | 16 ++-- .../java/forestry/mail/gui/GuiCatalogue.java | 15 ++-- .../java/forestry/mail/items/ItemLetter.java | 4 - .../pipes/gui/ContainerPropolisPipe.java | 8 +- .../forestry/plugins/PluginApiculture.java | 20 ++--- .../plugins/PluginLepidopterology.java | 8 +- .../java/forestry/plugins/PluginStorage.java | 24 ++--- .../storage/PickupHandlerStorage.java | 6 +- .../forestry/storage/ResupplyHandler.java | 6 -- .../storage/gui/ContainerBackpack.java | 2 +- .../gui/ContainerNaturalistBackpack.java | 4 +- 141 files changed, 545 insertions(+), 859 deletions(-) diff --git a/src/main/java/forestry/apiculture/FlowerProviderCacti.java b/src/main/java/forestry/apiculture/FlowerProviderCacti.java index 251f45f10..8d718419b 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderCacti.java +++ b/src/main/java/forestry/apiculture/FlowerProviderCacti.java @@ -40,10 +40,7 @@ public class FlowerProviderCacti implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 9) - return true; - else - return false; + return meta == 9; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderJungle.java b/src/main/java/forestry/apiculture/FlowerProviderJungle.java index 2f4c651e6..cedada411 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderJungle.java +++ b/src/main/java/forestry/apiculture/FlowerProviderJungle.java @@ -43,10 +43,7 @@ public class FlowerProviderJungle implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 11) - return true; - else - return false; + return meta == 11; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java index 91a030535..9b6465529 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderMushroom.java +++ b/src/main/java/forestry/apiculture/FlowerProviderMushroom.java @@ -42,10 +42,7 @@ public class FlowerProviderMushroom implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 7 || meta == 8) - return true; - else - return false; + return meta == 7 || meta == 8; } @Override diff --git a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java index 11abee91e..29007add9 100755 --- a/src/main/java/forestry/apiculture/FlowerProviderVanilla.java +++ b/src/main/java/forestry/apiculture/FlowerProviderVanilla.java @@ -53,10 +53,7 @@ public class FlowerProviderVanilla implements IFlowerProvider { } private boolean checkFlowerPot(int meta) { - if (meta == 1 || meta == 2) - return true; - else - return false; + return meta == 1 || meta == 2; } @Override diff --git a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java index 76d59c2b4..30ddd761f 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java @@ -107,7 +107,7 @@ public class BlockCandle extends BlockTorch { @SideOnly(Side.CLIENT) public IIcon getTextureFromPassAndMeta(int meta, int pass) { - IIcon i = this.unlitStump; + IIcon i; if (pass == 0) { if (isLit(meta)) { i = this.litTip; diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 178b18ca8..59dc13288 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -221,9 +221,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, /** * Returns scaled queen health or breeding progress - * - * @param i - * @return */ public int getHealthScaled(int i) { if (getMaxHealthDisplay() == 0) diff --git a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java index b960f7bff..071545876 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleBeeSpecies.java @@ -51,7 +51,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies private final int primaryColour; private final int secondaryColour; - private final String iconType = "default"; + private static final String iconType = "default"; public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) { this(uid, dominant, name, branch, null, primaryColor, secondaryColor); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java index 1b0612f0e..7177a271d 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectCreeper.java @@ -22,8 +22,8 @@ import net.minecraft.world.World; public class AlleleEffectCreeper extends AlleleEffectThrottled { - private final int explosionChance = 50; - private final byte defaultForce = 12; + private static final int explosionChance = 50; + private static final byte defaultForce = 12; private final byte indexExplosionTimer = 1; private final byte indexExplosionForce = 2; diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java index 9de179817..6cc5bc5d9 100644 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectFungification.java @@ -114,7 +114,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { } private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) { - WorldGenBigMushroom giantMushroomGenerator = null; + WorldGenBigMushroom giantMushroomGenerator; if (block == Blocks.brown_mushroom) { giantMushroomGenerator = new WorldGenBigMushroom(0); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java index 05029e58d..e51aa6edb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectIgnition.java @@ -23,8 +23,8 @@ import net.minecraft.world.World; public class AlleleEffectIgnition extends AlleleEffectThrottled { - private final int ignitionChance = 50; - private final int fireDuration = 500; + private static final int ignitionChance = 50; + private static final int fireDuration = 500; public AlleleEffectIgnition(String uid) { super(uid, "ignition", false, 20, false, true); diff --git a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java index 8ce97f3a8..8e61a26cb 100755 --- a/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java +++ b/src/main/java/forestry/apiculture/genetics/AlleleEffectMiasmic.java @@ -24,7 +24,7 @@ import net.minecraft.world.World; public class AlleleEffectMiasmic extends AlleleEffectThrottled { - private final int infectionChance = 50; + private static final int infectionChance = 50; public AlleleEffectMiasmic(String uid) { super(uid, "misasmic", false, 50, false, false); diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index 9eb3963ba..6e5e03962 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -10,8 +10,21 @@ ******************************************************************************/ package forestry.apiculture.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Locale; +import java.util.Map.Entry; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.common.FMLCommonHandler; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlleleBeeSpecies; @@ -35,16 +48,6 @@ import forestry.apiculture.gadgets.StructureLogicAlveary; import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map.Entry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class BeeHelper extends SpeciesRoot implements IBeeRoot { @@ -65,9 +68,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { public int getSpeciesCount() { if (beeSpeciesCount < 0) { beeSpeciesCount = 0; - Iterator > it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { if (entry.getValue() instanceof IAlleleBeeSpecies) if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) beeSpeciesCount++; @@ -97,7 +98,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { if (!isMember(bee)) return null; - Item beeItem = null; + Item beeItem; switch (EnumBeeType.VALUES[type]) { case QUEEN: beeItem = ForestryItem.beeQueenGE.item(); @@ -113,7 +114,6 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { break; default: throw new RuntimeException("Cannot instantiate a bee of type " + type); - } NBTTagCompound nbttagcompound = new NBTTagCompound(); diff --git a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java index efc5c64d1..d731fa7d1 100755 --- a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java +++ b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java @@ -141,10 +141,7 @@ public class BeekeepingMode implements IBeekeepingMode { @Override public boolean isNaturalOffspring(IBee queen) { - if (!queen.isNatural()) - return false; - - return true; + return queen.isNatural(); } @Override diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java index 56c37976a..2758ff16c 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceProviderHermit.java @@ -28,10 +28,7 @@ public class JubilanceProviderHermit extends JubilanceDefault { @SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding); - if (list.size() > 0) - return false; - - return true; + return list.size() <= 0; } } diff --git a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java index 5eb1fc8dc..3e11a8411 100755 --- a/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java +++ b/src/main/java/forestry/apiculture/genetics/JubilanceReqRes.java @@ -16,6 +16,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.core.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; public class JubilanceReqRes implements IJubilanceProvider { @@ -31,12 +32,11 @@ public class JubilanceReqRes implements IJubilanceProvider { if (blockRequired == null) return true; - Block block = housing.getWorld().getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); - int meta = housing.getWorld().getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); - if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) - return true; - else - return false; + World world = housing.getWorld(); + + Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); + int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord()); + return StackUtils.equals(block, meta, blockRequired); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java index 5c1f90caf..3b54fba52 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java @@ -30,27 +30,27 @@ public class ContainerAlveary extends ContainerForestry { tile.sendNetworkUpdate(); // Queen/Princess - this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); // Drone - this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); // Product Inventory - this.addSlot(new SlotClosed(tile, 2, 116, 52)); - this.addSlot(new SlotClosed(tile, 3, 137, 39)); - this.addSlot(new SlotClosed(tile, 4, 137, 65)); - this.addSlot(new SlotClosed(tile, 5, 116, 78)); - this.addSlot(new SlotClosed(tile, 6, 95, 65)); - this.addSlot(new SlotClosed(tile, 7, 95, 39)); - this.addSlot(new SlotClosed(tile, 8, 116, 26)); + this.addSlotToContainer(new SlotClosed(tile, 2, 116, 52)); + this.addSlotToContainer(new SlotClosed(tile, 3, 137, 39)); + this.addSlotToContainer(new SlotClosed(tile, 4, 137, 65)); + this.addSlotToContainer(new SlotClosed(tile, 5, 116, 78)); + this.addSlotToContainer(new SlotClosed(tile, 6, 95, 65)); + this.addSlotToContainer(new SlotClosed(tile, 7, 95, 39)); + this.addSlotToContainer(new SlotClosed(tile, 8, 116, 26)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 166)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 166)); } @Override diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java index dfe03c829..2a46f2e8a 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java @@ -18,20 +18,17 @@ import net.minecraft.inventory.Slot; public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks { - private final TileAlvearyHygroregulator tile; - public ContainerAlvearyHygroregulator(IInventory inventory, TileAlvearyHygroregulator tile) { super(inventory, tile); - this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, 0, 56, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, 0, 56, 38)); for (int i = 0; i < 3; ++i) for (int var4 = 0; var4 < 9; ++var4) - this.addSlot(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); for (int i = 0; i < 9; ++i) - this.addSlot(new Slot(inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index a67f45819..8b36b55dc 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -10,40 +10,38 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.gadgets.TileAlvearySieve; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -public class ContainerAlvearySieve extends ContainerForestry { +import forestry.apiculture.gadgets.TileAlvearySieve; +import forestry.core.config.ForestryItem; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotCustom; - private final TileAlvearySieve tile; +public class ContainerAlvearySieve extends ContainerForestry { public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) { super(tile.getInternalInventory()); - this.tile = tile; IInventory inventory = tile.getInternalInventory(); - addSlot(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile)); - addSlot(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile)); - addSlot(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile)); + addSlotToContainer(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile)); // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(player, i, 8 + i * 18, 145)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 145)); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java index f4caf8a85..fcd304f79 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java @@ -24,18 +24,18 @@ public class ContainerAlvearySwarmer extends ContainerForestry { public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) { super(tile); - this.addSlot(new SlotCustom(tile, 0, 79, 52, getInducerItems())); - this.addSlot(new SlotCustom(tile, 1, 100, 39, getInducerItems())); - this.addSlot(new SlotCustom(tile, 2, 58, 39, getInducerItems())); - this.addSlot(new SlotCustom(tile, 3, 79, 26, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 0, 79, 52, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 1, 100, 39, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 2, 58, 39, getInducerItems())); + this.addSlotToContainer(new SlotCustom(tile, 3, 79, 26, getInducerItems())); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 145)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 145)); } diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index ac13523f9..6d1eed40a 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -33,36 +33,36 @@ public class ContainerApiary extends ContainerForestry { IInventory inv = tile.getInternalInventory(); // Queen/Princess - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); // Drone - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); // Frames if (hasFrames) { - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); - this.addSlot(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); + this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); } // Product Inventory - this.addSlot(new SlotClosed(inv, 2, 116, 52)); - this.addSlot(new SlotClosed(inv, 3, 137, 39)); - this.addSlot(new SlotClosed(inv, 4, 137, 65)); - this.addSlot(new SlotClosed(inv, 5, 116, 78)); - this.addSlot(new SlotClosed(inv, 6, 95, 65)); - this.addSlot(new SlotClosed(inv, 7, 95, 39)); - this.addSlot(new SlotClosed(inv, 8, 116, 26)); + this.addSlotToContainer(new SlotClosed(inv, 2, 116, 52)); + this.addSlotToContainer(new SlotClosed(inv, 3, 137, 39)); + this.addSlotToContainer(new SlotClosed(inv, 4, 137, 65)); + this.addSlotToContainer(new SlotClosed(inv, 5, 116, 78)); + this.addSlotToContainer(new SlotClosed(inv, 6, 95, 65)); + this.addSlotToContainer(new SlotClosed(inv, 7, 95, 39)); + this.addSlotToContainer(new SlotClosed(inv, 8, 116, 26)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player, j1, 8 + j1 * 18, 166)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 166)); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index 62eef0741..2123148ad 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -31,12 +31,12 @@ public class ContainerHabitatLocator extends ContainerItemInventory { this.inventory = inventory; // Energy - this.addSlot(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop)); + this.addSlotToContainer(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop)); // Bee to analyze - this.addSlot(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class)); // Analyzed bee - this.addSlot(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index a280a9a05..44313e457 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -35,17 +35,17 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class)); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); } @Override diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 48e02b8a4..4e9d06193 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -40,8 +40,6 @@ public class GuiBeealyzer extends GuiAlyzer { ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); for (ItemStack beeStack : beeList) iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack); - - breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()); } @Override diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java index 8fbd9c2c9..40a714296 100755 --- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java +++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java @@ -102,8 +102,8 @@ public class GuiImprinter extends GuiForestry { int cornerX = (width - xSize) / 2; int cornerY = (height - ySize) / 2; - int slot = 0; - if ((slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY)) < 0) + int slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY); + if (slot < 0) return; if (k == 0) diff --git a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java index c8ba2b5d5..9da52204e 100755 --- a/src/main/java/forestry/apiculture/render/BeeItemRenderer.java +++ b/src/main/java/forestry/apiculture/render/BeeItemRenderer.java @@ -44,7 +44,7 @@ public class BeeItemRenderer implements IItemRenderer { public static float getIrregularWingYaw(long flapping, float flap) { long irregular = flapping / 1000; - float wingYaw = 1f; + float wingYaw; if(irregular % 11 == 0) { wingYaw = 0.75f; diff --git a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java b/src/main/java/forestry/apiculture/render/TextureBiomefinder.java index 65c909ef9..548bd9116 100755 --- a/src/main/java/forestry/apiculture/render/TextureBiomefinder.java +++ b/src/main/java/forestry/apiculture/render/TextureBiomefinder.java @@ -47,7 +47,7 @@ public class TextureBiomefinder extends TextureAtlasSprite { public void updateCompass(World world, double playerX, double playerZ, double playerYaw, boolean par8, boolean hasSpin) { - double targetAngle = 0.0d; + double targetAngle; if(world == null || targetBiome == null) { // No target has the locator spinning wildly. diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index 93cf2872b..a730f1d6e 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -322,11 +322,8 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { EnumTolerance temperatureTolerance = genome.getToleranceTemp(); Collection toleratedTemperatures = AlleleManager.climateHelper.getToleratedTemperature(beeTemperature, temperatureTolerance); - boolean validTemp = false; - validTemp = toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature)); - - if (!validTemp) + if (!toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature))) return false; EnumHumidity beeHumidity = genome.getPrimary().getHumidity(); @@ -334,11 +331,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { Collection toleratedHumidity = AlleleManager.climateHelper.getToleratedHumidity(beeHumidity, humidityTolerance); - boolean validHumidity = false; - - validHumidity = toleratedHumidity.contains(EnumHumidity.getFromValue(humidity)); - - return validHumidity; + return toleratedHumidity.contains(EnumHumidity.getFromValue(humidity)); } protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, ItemStack buildingBlock, diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java index 47804f0c8..1e2a5832b 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderNone.java +++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java @@ -43,8 +43,8 @@ public class FruitProviderNone implements IFruitProvider { overlayTypes.put("plums", new OverlayType("plums", (short) 1004)); } - String key; - IFruitFamily family = null; + private final String key; + private final IFruitFamily family; int ripeningPeriod = 10; diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java index f94e05a75..15aa29c52 100755 --- a/src/main/java/forestry/arboriculture/FruitProviderPod.java +++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java @@ -39,7 +39,7 @@ public class FruitProviderPod extends FruitProviderNone { } } - private static ItemStack[] DUMMY = new ItemStack[0]; + private static final ItemStack[] DUMMY = new ItemStack[0]; private final EnumPodType type; private final ItemStack[] drop; diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index 48233a27c..aeee54181 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -93,10 +93,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { public boolean isFence(IBlockAccess world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (PluginArboriculture.validFences.contains(block)) - return true; - - return false; + return PluginArboriculture.validFences.contains(block); } /* PROPERTIES */ diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 8034eef4a..153aa33f6 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -341,9 +341,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru **/ @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { - if (!Block.isEqualTo(oldBlock, newBlock)) - return true; - return false; + return !Block.isEqualTo(oldBlock, newBlock); } /* IFRUITBEARER */ diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index b8ab72fff..a8335c0a6 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -218,10 +218,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable return false; Collection suitable = genome.getPrimary().getSuitableFruit(); - if (!suitable.contains(provider.getFamily())) - return false; - - return true; + return suitable.contains(provider.getFamily()); } @Override @@ -360,18 +357,17 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable } for (ITreeMutation mutation : PluginArboriculture.treeInterface.getMutations(true)) { - float chance = 0; // Stop blacklisted species. // if (BeeManager.breedingManager.isBlacklisted(mutation.getTemplate()[0].getUID())) { // continue; // } - - if ((chance = mutation.getChance(world, x, y, z, allele0, allele1, genome0, genome1)) > 0) - if (world.rand.nextFloat()*100 < chance) - // IApiaristTracker breedingTracker = BeeManager.breedingManager.getApiaristTracker(world); - // breedingTracker.registerMutation(mutation); - return PluginArboriculture.treeInterface.templateAsChromosomes(mutation.getTemplate()); + float chance = mutation.getChance(world, x, y, z, allele0, allele1, genome0, genome1); + if (chance > world.rand.nextFloat() * 100) { + // IApiaristTracker breedingTracker = BeeManager.breedingManager.getApiaristTracker(world); + // breedingTracker.registerMutation(mutation); + return PluginArboriculture.treeInterface.templateAsChromosomes(mutation.getTemplate()); + } } return null; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index c615a6ea0..d5d7bc2d4 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -10,8 +10,24 @@ ******************************************************************************/ package forestry.arboriculture.genetics; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map.Entry; + +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + import cpw.mods.fml.common.FMLCommonHandler; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; @@ -38,19 +54,6 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.SpeciesRoot; import forestry.core.utils.BlockUtil; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Locale; -import java.util.Map.Entry; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class TreeHelper extends SpeciesRoot implements ITreeRoot { @@ -79,9 +82,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { public int getSpeciesCount() { if (treeSpeciesCount < 0) { treeSpeciesCount = 0; - Iterator> it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { if (entry.getValue() instanceof IAlleleTreeSpecies) if (((IAlleleTreeSpecies) entry.getValue()).isCounted()) treeSpeciesCount++; diff --git a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java index 25dc69b6d..da83ef01b 100755 --- a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java @@ -10,19 +10,20 @@ ******************************************************************************/ package forestry.arboriculture.gui; +import net.minecraft.entity.player.InventoryPlayer; + +import org.apache.commons.lang3.ArrayUtils; + import forestry.api.genetics.AlleleManager; import forestry.arboriculture.items.ItemGermlingGE; import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerAlyzer; -import net.minecraft.entity.player.InventoryPlayer; -import org.apache.commons.lang3.ArrayUtils; public class ContainerTreealyzer extends ContainerAlyzer { - TreealyzerInventory inventory; - private static Object[] acceptedEnergy = new Object[] {ForestryItem.honeydew, ForestryItem.honeyDrop}; - private static Object[] acceptedSpecimens = ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(), ItemGermlingGE.class); + private static final Object[] acceptedEnergy = new Object[] {ForestryItem.honeydew, ForestryItem.honeyDrop}; + private static final Object[] acceptedSpecimens = ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(), ItemGermlingGE.class); public ContainerTreealyzer(InventoryPlayer inventoryplayer, TreealyzerInventory inventory) { super(inventoryplayer, inventory, acceptedEnergy, acceptedSpecimens); diff --git a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java index 95d5bb74d..e11b1e4c9 100755 --- a/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java +++ b/src/main/java/forestry/arboriculture/render/LeavesRenderingHandler.java @@ -50,10 +50,8 @@ public class LeavesRenderingHandler extends OverlayRenderingHandler implements I renderer.renderStandardBlock(block, x, y, z); // Render overlay for fruit leaves. - IIcon fruitIcon = null; - int fruitColor = 0xffffff; - fruitIcon = tile.getFruitTexture(); - fruitColor = tile.getFruitColour(); + IIcon fruitIcon = tile.getFruitTexture(); + int fruitColor = tile.getFruitColour(); if (fruitIcon != null) renderFruitOverlay(world, block, x, y, z, renderer, fruitIcon, fruitColor); diff --git a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java index a77201f72..fb71c1f9e 100755 --- a/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java +++ b/src/main/java/forestry/arboriculture/render/SaplingRenderHandler.java @@ -39,10 +39,10 @@ public class SaplingRenderHandler implements ISimpleBlockRenderingHandler { TileSapling tile = BlockSapling.getSaplingTile(world, x, y, z); - IAlleleTreeSpecies species = (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[0]; if (tile == null || tile.getTree() == null) return true; - species = tile.getTree().getGenome().getPrimary(); + + IAlleleTreeSpecies species = tile.getTree().getGenome().getPrimary(); renderCrossedSquares(species, world, block, x, y, z); renderLayer = 1; diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index 4faceb025..c6d2b3820 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -56,8 +56,8 @@ public enum EnumErrorCode implements IErrorState { NOTRADE("noTrade", "noResource"), NOPOWER("noPower"); - private String name; - private String iconName; + private final String name; + private final String iconName; @SideOnly(Side.CLIENT) private IIcon icon; diff --git a/src/main/java/forestry/core/GameMode.java b/src/main/java/forestry/core/GameMode.java index 6ca77066a..a278b7798 100755 --- a/src/main/java/forestry/core/GameMode.java +++ b/src/main/java/forestry/core/GameMode.java @@ -127,20 +127,20 @@ public class GameMode implements IGameMode { private void initSetting(String ident, ItemStack def, String comment) { Property property = Config.config.get(ident, category, def.stackSize); - property.Comment = comment; + property.comment = comment; ItemStack changed = def.copy(); - changed.stackSize = Integer.parseInt(property.Value); + changed.stackSize = Integer.parseInt(property.value); stackSettings.put(ident, changed); } private void initSetting(String ident, int def, int max, String comment) { Property property = Config.config.get(ident, category, def); if (max < 0) { - property.Comment = comment; - integerSettings.put(ident, Integer.parseInt(property.Value)); + property.comment = comment; + integerSettings.put(ident, Integer.parseInt(property.value)); } else { - property.Comment = comment + " (max: " + max + ")"; - integerSettings.put(ident, Math.min(Integer.parseInt(property.Value), max)); + property.comment = comment + " (max: " + max + ")"; + integerSettings.put(ident, Math.min(Integer.parseInt(property.value), max)); } Config.config.set(ident, category, integerSettings.get(ident)); @@ -149,19 +149,19 @@ public class GameMode implements IGameMode { private void initSetting(String ident, float def, float max, String comment) { Property property = Config.config.get(ident, category, def); if (max < 0) { - property.Comment = comment; - floatSettings.put(ident, Float.parseFloat(property.Value)); + property.comment = comment; + floatSettings.put(ident, Float.parseFloat(property.value)); } else { - property.Comment = comment + " (max: " + max + ")"; - floatSettings.put(ident, Math.min(Float.parseFloat(property.Value), max)); + property.comment = comment + " (max: " + max + ")"; + floatSettings.put(ident, Math.min(Float.parseFloat(property.value), max)); } Config.config.set(ident, category, floatSettings.get(ident)); } private void initSetting(String ident, boolean def, String comment) { Property property = Config.config.get(ident, category, def); - property.Comment = comment; - booleanSettings.put(ident, Boolean.parseBoolean(property.Value)); + property.comment = comment; + booleanSettings.put(ident, Boolean.parseBoolean(property.value)); Config.config.set(ident, category, booleanSettings.get(ident)); } diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index 43845eaa0..8b723d63b 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -27,23 +27,23 @@ import net.minecraft.world.World; public class ContainerSolderingIron extends ContainerItemInventory implements IGuiSelectable { - SolderingInventory inventory; + private final SolderingInventory inventory; public ContainerSolderingIron(InventoryPlayer inventoryplayer, SolderingInventory inventory) { super(inventory, inventoryplayer.player); this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemCircuitBoard.class)); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 92, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 92, ItemCircuitBoard.class)); // Ingredients - this.addSlot(new Slot(inventory, 2, 12, 32)); - this.addSlot(new Slot(inventory, 3, 12, 52)); - this.addSlot(new Slot(inventory, 4, 12, 72)); - this.addSlot(new Slot(inventory, 5, 12, 92)); + this.addSlotToContainer(new Slot(inventory, 2, 12, 32)); + this.addSlotToContainer(new Slot(inventory, 3, 12, 52)); + this.addSlotToContainer(new Slot(inventory, 4, 12, 72)); + this.addSlotToContainer(new Slot(inventory, 5, 12, 92)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/core/commands/CommandHelpers.java b/src/main/java/forestry/core/commands/CommandHelpers.java index f2f5100fa..d1ff93265 100644 --- a/src/main/java/forestry/core/commands/CommandHelpers.java +++ b/src/main/java/forestry/core/commands/CommandHelpers.java @@ -69,14 +69,11 @@ public class CommandHelpers { } /** - Avoid using this function if at all possible. Commands are processed on the server, - which has no localization information. - - StringUtil.localize() is NOT a valid alternative for sendLocalizedChatMessage(). - Messages will not be localized properly if you use StringUtil.localize(). - - @param sender - @param message + * Avoid using this function if at all possible. Commands are processed on the server, + * which has no localization information. + * + * StringUtil.localize() is NOT a valid alternative for sendLocalizedChatMessage(). + * Messages will not be localized properly if you use StringUtil.localize(). */ public static void sendChatMessage(ICommandSender sender, String message) { sender.addChatMessage(new ChatComponentText(message)); diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 99aa51e59..b022d4804 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -97,12 +97,12 @@ public class Config { config.addPurge("power.framework"); Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); - property.Comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; - gameMode = property.Value; + property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; + gameMode = property.value; property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); - property.Comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; - boolean recreate = Boolean.parseBoolean(property.Value); + property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; + boolean recreate = Boolean.parseBoolean(property.value); if (recreate) Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); @@ -127,88 +127,88 @@ public class Config { config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); Property particleFX = config.get("performance.particleFX.enabled", CATEGORY_COMMON, true); - particleFX.Comment = "set to false to disable particle fx on slower machines"; - enableParticleFX = Boolean.parseBoolean(particleFX.Value); + particleFX.comment = "set to false to disable particle fx on slower machines"; + enableParticleFX = Boolean.parseBoolean(particleFX.value); Property genApatiteOre = config.get("world.generate.apatite", CATEGORY_COMMON, true); - genApatiteOre.Comment = "set to false to force forestry to skip generating own apatite ore blocks in the world"; - generateApatiteOre = Boolean.parseBoolean(genApatiteOre.Value); + genApatiteOre.comment = "set to false to force forestry to skip generating own apatite ore blocks in the world"; + generateApatiteOre = Boolean.parseBoolean(genApatiteOre.value); Property genBeehives = config.get("world.generate.beehives", CATEGORY_COMMON, true); - genBeehives.Comment = "set to false to force forestry to skip generating beehives in the world"; - generateBeehives = Boolean.parseBoolean(genBeehives.Value); + genBeehives.comment = "set to false to force forestry to skip generating beehives in the world"; + generateBeehives = Boolean.parseBoolean(genBeehives.value); Property genDebugBeehives = config.get("world.generate.beehives.debug", CATEGORY_DEBUG, false); - genDebugBeehives.Comment = "Set to true to force Forestry to try to generate a beehive at every possible location."; - generateBeehivesDebug = Boolean.parseBoolean(genDebugBeehives.Value); + genDebugBeehives.comment = "Set to true to force Forestry to try to generate a beehive at every possible location."; + generateBeehivesDebug = Boolean.parseBoolean(genDebugBeehives.value); Property genCopperOre = config.get("world.generate.copper", CATEGORY_COMMON, true); - genCopperOre.Comment = "set to false to force forestry to skip generating own copper ore blocks in the world"; - generateCopperOre = Boolean.parseBoolean(genCopperOre.Value); + genCopperOre.comment = "set to false to force forestry to skip generating own copper ore blocks in the world"; + generateCopperOre = Boolean.parseBoolean(genCopperOre.value); Property genTinOre = config.get("world.generate.tin", CATEGORY_COMMON, true); - genTinOre.Comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; - generateTinOre = Boolean.parseBoolean(genTinOre.Value); + genTinOre.comment = "set to false to force forestry to skip generating own tin ore blocks in the world"; + generateTinOre = Boolean.parseBoolean(genTinOre.value); Property bronzeRecipe = config.get("crafting.bronze.enabled", CATEGORY_COMMON, true); - bronzeRecipe.Comment = "set to false to disable crafting recipe for bronze"; - craftingBronzeEnabled = Boolean.parseBoolean(bronzeRecipe.Value); + bronzeRecipe.comment = "set to false to disable crafting recipe for bronze"; + craftingBronzeEnabled = Boolean.parseBoolean(bronzeRecipe.value); property = config.get("crafting.stamps.enabled", CATEGORY_COMMON, true); - property.Comment = "set to false to disable crafting recipes for all types of stamps."; - craftingStampsEnabled = Boolean.parseBoolean(property.Value); + property.comment = "set to false to disable crafting recipes for all types of stamps."; + craftingStampsEnabled = Boolean.parseBoolean(property.value); String defaultCollectors = "20n;50n;100n;200n"; property = config.get("crafting.stamps.collector", CATEGORY_COMMON, defaultCollectors); - property.Comment = "if crafting of stamps is generally allowed, these stamps are still excluded from crafting."; + property.comment = "if crafting of stamps is generally allowed, these stamps are still excluded from crafting."; try { - collectorStamps.addAll(Arrays.asList(parseStamps(property.Value))); + collectorStamps.addAll(Arrays.asList(parseStamps(property.value))); } catch(Exception ex) { config.set("crafting.stamps.collector", CATEGORY_COMMON, defaultCollectors); collectorStamps.addAll(Arrays.asList(parseStamps(defaultCollectors))); } Property indicatorEnable = config.get("tweaks.mailalert.enabled", CATEGORY_COMMON, true); - indicatorEnable.Comment = "set to false to disable the mail alert box"; - mailAlertEnabled = Boolean.parseBoolean(indicatorEnable.Value); + indicatorEnable.comment = "set to false to disable the mail alert box"; + mailAlertEnabled = Boolean.parseBoolean(indicatorEnable.value); Property clearGenome = config.get("genetics.clear.invalid.chromosomes", CATEGORY_COMMON, clearInvalidChromosomes); - clearGenome.Comment = "set to true to clear chromosomes which contain invalid alleles. might rescue your save if it is crashing after the removal of a bee addon."; - clearInvalidChromosomes = Boolean.parseBoolean(clearGenome.Value); + clearGenome.comment = "set to true to clear chromosomes which contain invalid alleles. might rescue your save if it is crashing after the removal of a bee addon."; + clearInvalidChromosomes = Boolean.parseBoolean(clearGenome.value); Property dungeonLootRarity = config.get("difficulty.dungeonloot.rare", CATEGORY_COMMON, false); - dungeonLootRarity.Comment = "set to true to make dungeon loot generated by forestry rarer"; - dungeonLootRare = Boolean.parseBoolean(dungeonLootRarity.Value); + dungeonLootRarity.comment = "set to true to make dungeon loot generated by forestry rarer"; + dungeonLootRare = Boolean.parseBoolean(dungeonLootRarity.value); Property resupplyEnable = config.get("performance.backpacks.resupply", CATEGORY_COMMON, true); - resupplyEnable.Comment = "leaving this enabled will cycle the list of active players PER INGAME TICK to check for resupply via backpack. you want to set this to false on busy servers."; - Config.enableBackpackResupply = Boolean.parseBoolean(resupplyEnable.Value); + resupplyEnable.comment = "leaving this enabled will cycle the list of active players PER INGAME TICK to check for resupply via backpack. you want to set this to false on busy servers."; + Config.enableBackpackResupply = Boolean.parseBoolean(resupplyEnable.value); property = config.get("tweaks.hints.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable hints on machine and engine guis."; - Config.disableHints = Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable hints on machine and engine guis."; + Config.disableHints = Boolean.parseBoolean(property.value); property = config.get("tweaks.energystat.disabled", CATEGORY_COMMON, true); - property.Comment = "set to true to disable energy statistics on energy consumers."; - Config.disableEnergyStat = !isDebug && Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable energy statistics on energy consumers."; + Config.disableEnergyStat = !isDebug && Boolean.parseBoolean(property.value); property = config.get("tweaks.tooltip.liquidamount.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable displaying liquid amounts in tank tooltips."; - Config.tooltipLiquidAmount = isDebug || !Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable displaying liquid amounts in tank tooltips."; + Config.tooltipLiquidAmount = isDebug || !Boolean.parseBoolean(property.value); property = config.get("tweaks.permissions.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable access restrictions on forestry machines."; - Config.disablePermissions = Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable access restrictions on forestry machines."; + Config.disablePermissions = Boolean.parseBoolean(property.value); property = config.get("tweaks.upgradenotice.disabled", CATEGORY_COMMON, false); - property.Comment = "set to true to disable update and version check notice."; - Config.disableVersionCheck = isDebug || Boolean.parseBoolean(property.Value); + property.comment = "set to true to disable update and version check notice."; + Config.disableVersionCheck = isDebug || Boolean.parseBoolean(property.value); property = config.get("tweaks.farms.squared", CATEGORY_COMMON, false); - property.Comment = "set to true to have farms use a square layout instead of a diamond one."; - Config.squareFarms = Boolean.parseBoolean(property.Value); + property.comment = "set to true to have farms use a square layout instead of a diamond one."; + Config.squareFarms = Boolean.parseBoolean(property.value); property = config.get("structures.schemata.disabled", CATEGORY_COMMON, ""); - property.Comment = "add schemata keys to disable them. current keys: alveary3x3;farm3x3;farm3x4;farm3x5;farm4x4;farm5x5"; - disabledStructures.addAll(Arrays.asList(parseStructureKeys(property.Value))); + property.comment = "add schemata keys to disable them. current keys: alveary3x3;farm3x3;farm3x4;farm3x5;farm4x4;farm5x5"; + disabledStructures.addAll(Arrays.asList(parseStructureKeys(property.value))); for (String str : disabledStructures) Proxies.log.finer("Disabled structure '%s'.", str); @@ -281,7 +281,7 @@ public class Config { } public static boolean getOrCreateBooleanProperty(String key, String kind, boolean defaults) { - return Boolean.parseBoolean(config.get(key, kind, defaults).Value); + return Boolean.parseBoolean(config.get(key, kind, defaults).value); } } diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index 4c6f105b2..e9e6269e3 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -18,7 +18,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -89,7 +88,7 @@ public class Configuration { public void set(String key, String category, boolean val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Boolean.toString(val); + existing.value = Boolean.toString(val); return; } @@ -102,7 +101,7 @@ public class Configuration { public void set(String key, String category, String val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = val; + existing.value = val; return; } @@ -115,7 +114,7 @@ public class Configuration { public void set(String key, String category, int val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Integer.toString(val); + existing.value = Integer.toString(val); return; } @@ -128,7 +127,7 @@ public class Configuration { public void set(String key, String category, float val) { Property existing = getExisting(key, category); if (existing != null) { - existing.Value = Float.toString(val); + existing.value = Float.toString(val); return; } @@ -143,7 +142,7 @@ public class Configuration { loadCategory(category); for (Property property : categorized.get(category)) - if (property.Key.equals(key)) + if (property.key.equals(key)) return property; return null; @@ -200,7 +199,7 @@ public class Configuration { property = new Property(tokens[0], ""); if (lastComment != null) { - property.Comment = lastComment; + property.comment = lastComment; lastComment = null; } categorized.get(category).add(property); @@ -214,9 +213,7 @@ public class Configuration { } public void save() { - Iterator>> it = categorized.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); + for (Map.Entry> entry : categorized.entrySet()) { saveFile(getCategoryFile(entry.getKey()), entry.getValue()); } } @@ -248,18 +245,16 @@ public class Configuration { writer.write("# gamemodes/\t\t-\t Configures available gamemodes"); TreeMap> subsectioned = getSubsectioned(properties); - Iterator>> it = subsectioned.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); + for (Map.Entry> entry : subsectioned.entrySet()) { writer.write(newLine + newLine + "#####################" + newLine + "# " + entry.getKey().toUpperCase() + newLine + "#####################" + newLine); for (Property property : entry.getValue()) { - if(purge.contains(property.Key)) + if (purge.contains(property.key)) continue; - if (property.Comment != null) - writer.write("# " + property.Comment + newLine); - writer.write(property.Key + "=" + property.Value + newLine); + if (property.comment != null) + writer.write("# " + property.comment + newLine); + writer.write(property.key + "=" + property.value + newLine); } } @@ -275,7 +270,7 @@ public class Configuration { TreeMap> subsectioned = new TreeMap>(); for (Property property : properties) { - String subsection = property.Key.split("\\.")[0]; + String subsection = property.key.split("\\.")[0]; if (!subsectioned.containsKey(subsection)) subsectioned.put(subsection, new ArrayList()); subsectioned.get(subsection).add(property); diff --git a/src/main/java/forestry/core/config/Property.java b/src/main/java/forestry/core/config/Property.java index 1630ffb21..01ade1cfc 100755 --- a/src/main/java/forestry/core/config/Property.java +++ b/src/main/java/forestry/core/config/Property.java @@ -11,12 +11,12 @@ package forestry.core.config; public class Property { - public String Key; - public String Value; - public String Comment; + public final String key; + public String value; + public String comment; public Property(String key, String value) { - Key = key; - Value = value; + this.key = key; + this.value = value; } } diff --git a/src/main/java/forestry/core/config/Version.java b/src/main/java/forestry/core/config/Version.java index 464813d01..0f5c7b6df 100755 --- a/src/main/java/forestry/core/config/Version.java +++ b/src/main/java/forestry/core/config/Version.java @@ -62,13 +62,13 @@ public class Version { return false; Property property = Config.config.get("vars.version.seen", Config.CATEGORY_COMMON, VERSION); - property.Comment = "indicates the last version the user has been informed about and will suppress further notices on it."; - String seenVersion = property.Value; + property.comment = "indicates the last version the user has been informed about and will suppress further notices on it."; + String seenVersion = property.value; if (recommendedVersion == null || recommendedVersion.equals(seenVersion)) return false; - property.Value = recommendedVersion; + property.value = recommendedVersion; Config.config.save(); return true; } diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index 5766aa800..4fbb44b62 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -10,23 +10,26 @@ ******************************************************************************/ package forestry.core.fluids.tanks; -import forestry.core.gui.tooltips.ToolTipLine; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; + 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 forestry.core.gui.tooltips.ToolTipLine; + /** * * @author CovertJaguar */ public class FilteredTank extends StandardTank { - private HashSet filters; + private final HashSet filters; public FilteredTank(int capacity, Fluid... filters) { this(capacity, Arrays.asList(filters), null); diff --git a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java index 816a34681..622f5e933 100644 --- a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java +++ b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java @@ -52,7 +52,7 @@ public class BlockResourceStorageBlock extends Block { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int i, int meta) { - IIcon icon = null; + IIcon icon; if (meta == 0) { icon = iconApatite; } else if (meta == 1) { diff --git a/src/main/java/forestry/core/gadgets/BlockSoil.java b/src/main/java/forestry/core/gadgets/BlockSoil.java index 6f1740e42..b3fbcd797 100755 --- a/src/main/java/forestry/core/gadgets/BlockSoil.java +++ b/src/main/java/forestry/core/gadgets/BlockSoil.java @@ -107,14 +107,6 @@ public class BlockSoil extends Block implements IItemTyped { matureBog(world, i, j, k); } - /** - * - * @param world - * @param x - * @param y - * @param z - * @return - */ private boolean isEnrooted(World world, int x, int y, int z) { for (int i = -1; i < 2; i++) @@ -123,10 +115,7 @@ public class BlockSoil extends Block implements IItemTyped { if (block == Blocks.log || block == Blocks.sapling || block == ForestryBlock.saplingGE.block()) // We are not returning true if we are the base of a // sapling. - if (i == 0 && j == 0) - return false; - else - return true; + return !(i == 0 && j == 0); } return false; @@ -134,18 +123,13 @@ public class BlockSoil extends Block implements IItemTyped { /** * If a tree or sapling is in the vicinity, there is a chance, that the soil will degrade. - * - * @param world - * @param i - * @param j - * @param k */ - private void degradeSoil(World world, int i, int j, int k) { + private void degradeSoil(World world, int x, int y, int z) { if (world.rand.nextInt(140) != 0) return; - int meta = world.getBlockMetadata(i, j, k); + int meta = world.getBlockMetadata(x, y, z); // Unpack first int type = meta & 0x03; @@ -158,10 +142,10 @@ public class BlockSoil extends Block implements IItemTyped { meta = (grade << 2 | type); if (grade >= degradeDelimiter) - world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH); + world.setBlock(x, y, z, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH); else - world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH); - world.markBlockForUpdate(i, j, k); + world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH); + world.markBlockForUpdate(x, y, z); } public static boolean isMoistened(World world, int x, int y, int z) { @@ -188,7 +172,7 @@ public class BlockSoil extends Block implements IItemTyped { int type = meta & 0x03; int maturity = meta >> 2; - if (maturity >= this.degradeDelimiter) + if (maturity >= degradeDelimiter) return; // Increment (de)gradation diff --git a/src/main/java/forestry/core/gadgets/Engine.java b/src/main/java/forestry/core/gadgets/Engine.java index 8c48940d4..7ef6a7d84 100755 --- a/src/main/java/forestry/core/gadgets/Engine.java +++ b/src/main/java/forestry/core/gadgets/Engine.java @@ -68,7 +68,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection { protected final int maxHeat; protected boolean forceCooldown = false; public float progress; - protected EnergyManager energyManager; + protected final EnergyManager energyManager; public Engine(int maxHeat, int maxEnergy, int maxEnergyExtracted) { this.maxHeat = maxHeat; @@ -85,11 +85,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { rotateEngine(); } - /** - * Adds heat - * - * @param i - */ protected void addHeat(int i) { heat += i; @@ -227,8 +222,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { /** * Returns the current energy state of the engine - * - * @return */ public TemperatureState getTemperatureState() { // double scaledStorage = (double)storedEnergy / (double)maxEnergy; @@ -248,11 +241,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection { return TemperatureState.MELTING; } - /** - * Piston speed - * - * @return - */ public float getPistonSpeed() { switch (getTemperatureState()) { case COOL: diff --git a/src/main/java/forestry/core/gadgets/MachineDefinition.java b/src/main/java/forestry/core/gadgets/MachineDefinition.java index de0c5a9a7..1461c10a4 100755 --- a/src/main/java/forestry/core/gadgets/MachineDefinition.java +++ b/src/main/java/forestry/core/gadgets/MachineDefinition.java @@ -33,9 +33,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -/** - * This will replace the whole {@link Gadget}-nonsense at some point, using the proper Forge hook. Will hopefully sort out any issues with interfaces. - */ public class MachineDefinition { public final Class teClass; diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index 360a13805..e9a7dc8ac 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -19,17 +19,17 @@ public class ContainerAlyzer extends ContainerItemInventory { final int xPosLeftSlots = 223; // Energy - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy)); // Bee to analyze - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens)); // Analyzed bee - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens)); - this.addSlot(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens)); + this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens)); final int xPosPlayerInv = 43; final int xSpacePlayerInv = 18; diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index 43c99f5ee..ff01abcb3 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gadgets.TileAnalyzer; @@ -17,29 +21,22 @@ import forestry.core.genetics.ItemGE; import forestry.core.gui.slots.SlotCustom; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.core.gui.slots.SlotOutput; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerAnalyzer extends ContainerLiquidTanks { - private final TileAnalyzer tile; - public ContainerAnalyzer(InventoryPlayer player, TileAnalyzer tile) { super(tile, tile); - this.tile = tile; - // Input buffer for (int i = 0; i < 3; i++) for (int k = 0; k < 2; k++) - addSlot(new SlotCustom(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18, ItemGE.class)); + addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18, ItemGE.class)); // Analyze slot - addSlot(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); + addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); // Can slot - addSlot(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.get()) { + addSlotToContainer(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.get()) { @Override public boolean isItemValid(ItemStack stack) { @@ -53,15 +50,15 @@ public class ContainerAnalyzer extends ContainerLiquidTanks { // Output buffer for (int i = 0; i < 2; i++) for (int k = 0; k < 2; k++) - addSlot(new SlotOutput(tile, TileAnalyzer.SLOT_OUTPUT_1 + i * 2 + k, 134 + k * 18, 48 + i * 18)); + addSlotToContainer(new SlotOutput(tile, TileAnalyzer.SLOT_OUTPUT_1 + i * 2 + k, 134 + k * 18, 48 + i * 18)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 94 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 152)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 152)); } diff --git a/src/main/java/forestry/core/gui/ContainerEscritoire.java b/src/main/java/forestry/core/gui/ContainerEscritoire.java index 11ae103ac..8a56349db 100755 --- a/src/main/java/forestry/core/gui/ContainerEscritoire.java +++ b/src/main/java/forestry/core/gui/ContainerEscritoire.java @@ -41,24 +41,24 @@ public class ContainerEscritoire extends ContainerForestry implements IGuiSelect filters.add(Blocks.sapling); filters.addAll(AlleleManager.alleleRegistry.getSpeciesRoot().values()); // Analyze slot - addSlot(new SlotCustom(tile, TileEscritoire.SLOT_ANALYZE, 97, 67, filters.toArray()).setCrafter(tile)); + addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_ANALYZE, 97, 67, filters.toArray()).setCrafter(tile)); for (int i = 0; i < TileEscritoire.SLOTS_INPUT_COUNT; i++) { - addSlot(new SlotCustom(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setExclusion(true).setBlockedTexture("slots/blocked_2")); + addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setExclusion(true).setBlockedTexture("slots/blocked_2")); } for(int i = 0; i < 3; i++) for(int j = 0; j < 2; j++) { - addSlot(new SlotClosed(tile, TileEscritoire.SLOT_RESULTS_1 + (i*2) + j, 177 + j*18, 85 + i*18)); + addSlotToContainer(new SlotClosed(tile, TileEscritoire.SLOT_RESULTS_1 + (i * 2) + j, 177 + j * 18, 85 + i * 18)); } // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player.inventory, j + i * 9 + 9, 34 + j * 18, 153 + i * 18)); + addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 34 + j * 18, 153 + i * 18)); // Player hotbar for (int k = 0; k < 9; k++) - addSlot(new Slot(player.inventory, k, 34 + k * 18, 211)); + addSlotToContainer(new Slot(player.inventory, k, 34 + k * 18, 211)); } @Override diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index ad6a4881f..67f487444 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -34,16 +34,6 @@ public class ContainerForestry extends Container { this.inventoryForestry = null; } - /** - * Adds a slot to the container, shortcut for addSlotToContainer(slot). - * - * @param slot - * @return - */ - protected Slot addSlot(Slot slot) { - return addSlotToContainer(slot); - } - @Override public ItemStack slotClick(int slotIndex, int button, int modifier, EntityPlayer player) { if (player == null) diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index 0cee5c7c5..4c043a8b6 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -35,9 +35,9 @@ public abstract class ContainerItemInventory extends ContainerForestry { protected void addSecuredSlot(IInventory other, int slot, int x, int y) { if (other.getStackInSlot(slot) != null && inventory.itemClass.isAssignableFrom(other.getStackInSlot(slot).getItem().getClass())) - addSlot(new SlotLocked(other, slot, x, y)); + addSlotToContainer(new SlotLocked(other, slot, x, y)); else - addSlot(new SlotItemInventory(this, other, player, slot, x, y)); + addSlotToContainer(new SlotItemInventory(this, other, player, slot, x, y)); } protected abstract boolean isAcceptedItem(EntityPlayer player, ItemStack stack); diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index 0eaa91cac..a103c04c2 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -22,7 +22,7 @@ import net.minecraft.item.ItemStack; public class ContainerNaturalistInventory extends ContainerForestry implements IGuiSelectable { private final IPagedInventory inv; - private ISpeciesRoot speciesRoot; + private final ISpeciesRoot speciesRoot; public ContainerNaturalistInventory(ISpeciesRoot speciesRoot, InventoryPlayer player, IPagedInventory inventory, int page, int pageSize) { super(inventory); @@ -32,19 +32,19 @@ public class ContainerNaturalistInventory extends ContainerForestry implements I // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlot(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); } } // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player, l1 + i1 * 9 + 9, 18 + l1 * 18, 120 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 18 + l1 * 18, 120 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player, j1, 18 + j1 * 18, 178)); + addSlotToContainer(new Slot(player, j1, 18 + j1 * 18, 178)); } } diff --git a/src/main/java/forestry/core/gui/ContainerSocketed.java b/src/main/java/forestry/core/gui/ContainerSocketed.java index 90ad17791..672905d56 100755 --- a/src/main/java/forestry/core/gui/ContainerSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerSocketed.java @@ -24,7 +24,7 @@ import net.minecraft.tileentity.TileEntity; public class ContainerSocketed extends ContainerForestry { - ISocketable tile; + private final ISocketable tile; public ContainerSocketed(IInventory inventory, ISocketable tile) { super(inventory); diff --git a/src/main/java/forestry/core/gui/ErrorLedger.java b/src/main/java/forestry/core/gui/ErrorLedger.java index 9e5fda8e8..035a233e1 100755 --- a/src/main/java/forestry/core/gui/ErrorLedger.java +++ b/src/main/java/forestry/core/gui/ErrorLedger.java @@ -20,7 +20,7 @@ import forestry.core.utils.StringUtil; */ public class ErrorLedger extends Ledger { - IErrorSource tile; + private final IErrorSource tile; public ErrorLedger(LedgerManager manager, IErrorSource tile) { super(manager); diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index d7bfc4090..6c11ff0c8 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -45,9 +45,9 @@ public abstract class GuiAlyzer extends GuiForestry { protected static final int COLUMN_1 = 85; protected static final int COLUMN_2 = 150; - protected IInventory inventory; - protected ISpeciesRoot speciesRoot; - protected IBreedingTracker breedingTracker; + protected final IInventory inventory; + protected final ISpeciesRoot speciesRoot; + protected final IBreedingTracker breedingTracker; protected final String guiName; diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 7f4e0dffb..169960341 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -406,53 +406,7 @@ public abstract class GuiForestry extends GuiContainer i public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { super.drawGradientRect(par1, par2, par3, par4, par5, par6); } - // - // protected void drawGuiContainerForegroundLayer() { - // } - /** - * Draws the basic background texture centered on the screen. - */ - // protected void drawBackground() { - // drawBackground((this.width - this.xSize) / 2, (this.height - this.ySize) / 2, this.xSize, this.ySize); - // } - // protected void drawBackground(int x, int y, int w, int h) { - // bindTexture(); - // this.drawTexturedModalRect(x, y, 0, 0, w, h); - // } - // protected void bindTexture() { - // bindTexture(textureFile); - // } - // - // protected void drawSlotInventory(Slot slot) { - // - // int xPos = slot.xDisplayPosition; - // int yPos = slot.yDisplayPosition; - // ItemStack slotStack = slot.getStack(); - // boolean backgroundDrawn = false; - // - // this.zLevel = 100.0F; - // itemRenderer.zLevel = 100.0F; - // - // if (slotStack == null) { - // IIcon icon = slot.getBackgroundIconIndex(); - // - // if (icon != null) { - // GL11.glDisable(GL11.GL_LIGHTING); - // GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); - // Proxies.common.bindTexture(SpriteSheet.ITEMS); - // this.drawTexturedModelRectFromIcon(xPos, yPos, icon, 16, 16); - // GL11.glEnable(GL11.GL_LIGHTING); - // backgroundDrawn = true; - // } - // } - // - // if (!backgroundDrawn && slotStack != null) - // drawItemStack(slotStack, xPos, yPos); - // - // this.zLevel = 0.0F; - // itemRenderer.zLevel = 0.0F; - // } public void drawItemStack(ItemStack stack, int xPos, int yPos) { GL11.glTranslatef(0.0F, 0.0F, 32.0F); this.zLevel = 100.0F; @@ -469,7 +423,7 @@ public abstract class GuiForestry extends GuiContainer i } protected class ItemStackWidget extends Widget { - ItemStack itemStack; + private final ItemStack itemStack; public ItemStackWidget(int xPos, int yPos, ItemStack itemStack) { super(widgetManager, xPos, yPos); diff --git a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java index 643c2d80c..bbdf0184c 100755 --- a/src/main/java/forestry/core/gui/GuiNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/GuiNaturalistInventory.java @@ -192,7 +192,7 @@ public class GuiNaturalistInventory extends GuiForestry { RenderHelper.disableStandardItemLighting(); int line = 48; - int column = 0; + int column; EnumMutateChance chance = EnumMutateChance.rateChance(combination.getBaseChance()); if (chance == EnumMutateChance.HIGHEST) { line += 16; @@ -223,8 +223,8 @@ public class GuiNaturalistInventory extends GuiForestry { float chance = mutation.getBaseChance(); - int line = 0; - int column = 0; + int line; + int column; if (chance >= 20) { line = 16; column = 228; diff --git a/src/main/java/forestry/core/gui/GuiTextBox.java b/src/main/java/forestry/core/gui/GuiTextBox.java index 174330634..79ccee1cb 100755 --- a/src/main/java/forestry/core/gui/GuiTextBox.java +++ b/src/main/java/forestry/core/gui/GuiTextBox.java @@ -15,12 +15,11 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiTextField; public class GuiTextBox extends GuiTextField { + private static final int enabledColor = 14737632; + private static final int disabledColor = 7368816; private final FontRenderer fontRendererObj; - private final int startX, startY, width, height; - private final int enabledColor = 14737632; - private final int disabledColor = 7368816; private int lineScroll = 0; private int maxLines = 0; diff --git a/src/main/java/forestry/core/gui/Ledger.java b/src/main/java/forestry/core/gui/Ledger.java index 8621d3f4f..b2ac970b6 100755 --- a/src/main/java/forestry/core/gui/Ledger.java +++ b/src/main/java/forestry/core/gui/Ledger.java @@ -79,11 +79,7 @@ public abstract class Ledger { } public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) { - - if (mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight()) - return true; - - return false; + return mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight(); } public void setFullyOpen() { diff --git a/src/main/java/forestry/core/gui/OwnerLedger.java b/src/main/java/forestry/core/gui/OwnerLedger.java index e501a585a..8c6303cc0 100755 --- a/src/main/java/forestry/core/gui/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/OwnerLedger.java @@ -38,9 +38,7 @@ public class OwnerLedger extends Ledger { int shiftX = currentShiftX; int shiftY = currentShiftY + 44; - if (mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12) - return true; - return false; + return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12; } public boolean isOwnerChangeButton(int mouseX, int mouseY) { diff --git a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java index 1660c9a1a..fba887aea 100755 --- a/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java +++ b/src/main/java/forestry/core/gui/widgets/ReservoirWidget.java @@ -43,7 +43,7 @@ public class ReservoirWidget extends TankWidget { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index d74db7e4c..459ef0ab3 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -76,7 +76,7 @@ public class TankWidget extends Widget { GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 3996b923c..8685a9b73 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -810,7 +810,7 @@ public abstract class InvTools { if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { - pipes.add(new AbstractMap.SimpleEntry(side, pipe)); + pipes.add(new AbstractMap.SimpleEntry(side, pipe)); foundPipe = true; } } diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index a284f834e..7d011cc13 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -92,7 +92,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette { PipetteContents contained = new PipetteContents(itemstack.getTagCompound()); int limit = getCapacity(itemstack); - int filled = 0; + int filled; if (contained.contents == null) { diff --git a/src/main/java/forestry/core/network/ForestryPacket.java b/src/main/java/forestry/core/network/ForestryPacket.java index 7e741ea0a..907ee744d 100755 --- a/src/main/java/forestry/core/network/ForestryPacket.java +++ b/src/main/java/forestry/core/network/ForestryPacket.java @@ -26,8 +26,8 @@ import net.minecraft.nbt.NBTTagCompound; public class ForestryPacket { + protected static final String channel = "FOR"; protected int id; - protected static String channel = "FOR"; public ForestryPacket() { } diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index c98a7a3c8..e87f55154 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -157,14 +157,6 @@ public class ClientProxyCommon extends ProxyCommon { /** * Renders a EntityBiodustFX on client. - * - * @param world - * @param d1 - * @param d2 - * @param d3 - * @param f1 - * @param f2 - * @param f3 */ // FIXME: This is causing crashes. @Override diff --git a/src/main/java/forestry/core/render/EntitySnowFX.java b/src/main/java/forestry/core/render/EntitySnowFX.java index 65926c336..71446379c 100755 --- a/src/main/java/forestry/core/render/EntitySnowFX.java +++ b/src/main/java/forestry/core/render/EntitySnowFX.java @@ -19,7 +19,7 @@ import net.minecraft.world.World; public class EntitySnowFX extends EntityFX { public static IIcon icons[]; - private Random spreadRand = new Random(); + private static final Random spreadRand = new Random(); public EntitySnowFX(World world, double x, double y, double z, float motionScaleX, float motionScaleY, float motionScaleZ) { super(world, x, y, z, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index 059f9fde9..d45c7accc 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -10,29 +10,30 @@ ******************************************************************************/ package forestry.core.utils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockLog; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +import forestry.core.config.Defaults; +import forestry.core.vect.Vect; + import buildcraft.api.core.Position; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeConnection.ConnectOverride; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import cofh.api.energy.IEnergyHandler; -import forestry.core.config.Defaults; -import forestry.core.vect.Vect; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import net.minecraft.block.Block; -import net.minecraft.block.BlockCocoa; -import net.minecraft.block.BlockLog; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityHopper; -import net.minecraft.util.Direction; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class BlockUtil { @@ -44,41 +45,8 @@ public class BlockUtil { } - /** - * Searches for inventories adjacent to block, excludes IPowerReceptor - * - * @param world - * @param blockPos - * @param from - * @return - * @deprecated Use AdjacentInventoryCache instead - */ - @Deprecated - public static IInventory[] getAdjacentInventories(World world, Vect blockPos, ForgeDirection from) { - ArrayList inventories = new ArrayList(); - - // WTF is this? A loop that only picks the opposite direction? -CovertJaguar - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if (from != ForgeDirection.UNKNOWN && from != dir.getOpposite()) - continue; - - TileEntity entity = world.getTileEntity(blockPos.x + dir.offsetX, blockPos.y + dir.offsetY, blockPos.z + dir.offsetZ); - if (entity != null) - if (entity instanceof IInventory) - if (!(entity instanceof TileEntityHopper)) - inventories.add((IInventory) entity); - } - - return inventories.toArray(new IInventory[inventories.size()]); - } - /** * Returns a list of adjacent pipes. - * - * @param world - * @param blockPos - * @param from - * @return */ public static ForgeDirection[] getPipeDirections(World world, Vect blockPos, ForgeDirection from) { LinkedList possiblePipes = new LinkedList(); diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index f3dd2d587..89110b8ae 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -185,10 +185,6 @@ public class StackUtils { /** * Creates a split stack of the specified amount, preserving NBT data, * without decreasing the source stack. - * - * @param stack - * @param amount - * @return */ public static ItemStack createSplitStack(ItemStack stack, int amount) { ItemStack split = new ItemStack(stack.getItem(), amount, stack.getItemDamage()); diff --git a/src/main/java/forestry/energy/EnergyManager.java b/src/main/java/forestry/energy/EnergyManager.java index ca366191c..6de21acb2 100644 --- a/src/main/java/forestry/energy/EnergyManager.java +++ b/src/main/java/forestry/energy/EnergyManager.java @@ -14,12 +14,12 @@ public class EnergyManager implements IEnergyHandler { } private final int energyPerWork; - protected EnergyStorage energyStorage; + private final EnergyStorage energyStorage; private EnergyTransferMode mode = EnergyTransferMode.BOTH; public EnergyManager(int maxTransfer, int energyPerWork, int capacity) { this.energyPerWork = scaleForDifficulty(energyPerWork); - energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer)); + this.energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer)); } private static int scaleForDifficulty(int energyPerUse) { @@ -143,8 +143,6 @@ public class EnergyManager implements IEnergyHandler { /** * Sends as much energy as it can to the tile at orientation. * For power sources. Ignores canExtract() - * @param orientation - * @param tile * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile) { @@ -154,9 +152,6 @@ public class EnergyManager implements IEnergyHandler { /** * Sends amount of energy to the tile at orientation. * For power sources. Ignores canExtract() - * @param orientation - * @param tile - * @param amount * @return amount sent */ public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) { @@ -175,7 +170,6 @@ public class EnergyManager implements IEnergyHandler { /** * Drains an amount of energy, due to decay from lack of work or other factors - * @param amount */ public void drainEnergy(int amount) { energyStorage.modifyEnergyStored(-amount); @@ -183,7 +177,6 @@ public class EnergyManager implements IEnergyHandler { /** * Creates an amount of energy, generated by engines - * @param amount */ public void generateEnergy(int amount) { energyStorage.modifyEnergyStored(amount); diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 0a2bc5105..7af2eb3b0 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -62,13 +62,10 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank public void fromPacketPayload(PacketPayload payload) { super.fromPacketPayload(payload); - if (payload.intPayload[3] > 0) - shutdown = true; - else - shutdown = false; + shutdown = payload.intPayload[3] > 0; } - public FilteredTank fuelTank; - public FilteredTank heatingTank; + private final FilteredTank fuelTank; + private final FilteredTank heatingTank; private final TankManager tankManager; public int burnTime; public int totalTime; @@ -214,11 +211,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } /** - * Returns the fuel value (power per cycle) an item of the passed ItemStack - * provides - * - * @param fluid - * @return + * Returns the fuel value (power per cycle) an item of the passed fluid */ private int determineFuelValue(Fluid fluid) { if (FuelManager.bronzeEngineFuel.containsKey(fluid)) @@ -228,8 +221,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } /** - * - * @param fluid * @return Duration of burn cycle of one bucket */ private int determineBurnTime(Fluid fluid) { @@ -280,10 +271,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank return (heatingTank.getFluidAmount() * i) / Defaults.ENGINE_TANK_CAPACITY; } - /** - * Reads saved data - * @param nbt - */ @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); @@ -301,10 +288,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank } - /** - * Writes data to save - * @param nbt - */ @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index cc58dfaec..2d805666f 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -199,9 +199,6 @@ public class EngineCopper extends Engine implements ISidedInventory { /** * Returns the fuel value (power per cycle) an item of the passed ItemStack provides - * - * @param fuel - * @return */ private int determineFuelValue(ItemStack fuel) { if (FuelManager.copperEngineFuel.containsKey(fuel)) @@ -212,9 +209,6 @@ public class EngineCopper extends Engine implements ISidedInventory { /** * Returns the fuel value (power per cycle) an item of the passed ItemStack provides - * - * @param fuel - * @return */ private int determineBurnDuration(ItemStack fuel) { if (FuelManager.copperEngineFuel.containsKey(fuel)) @@ -275,10 +269,6 @@ public class EngineCopper extends Engine implements ISidedInventory { } // / LOADING AND SAVING - /** - * Reads saved data - * @param nbttagcompound - */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); @@ -295,10 +285,6 @@ public class EngineCopper extends Engine implements ISidedInventory { ashProduction = nbttagcompound.getInteger("AshProduction"); } - /** - * Writes data to save - * @param nbttagcompound - */ @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index fe5e76bb1..47e9d0c57 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -50,7 +50,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } } - private final short batterySlot = 0; + private static final short batterySlot = 0; private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(Defaults.ENGINE_TIN_EU_FOR_CYCLE, Defaults.ENGINE_TIN_ENERGY_PER_CYCLE, Defaults.ENGINE_TIN_MAX_EU_STORED); diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index d8fdcffce..dc964ac24 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -24,17 +24,17 @@ public class ContainerEngineBronze extends ContainerLiquidTanks { super(engine, engine); this.engine = engine; - this.addSlot(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); + this.addSlotToContainer(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); int i; for (i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index ecb09027c..0d75f1d80 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -25,21 +25,21 @@ public class ContainerEngineCopper extends ContainerForestry { super(tile); this.engine = tile; - this.addSlot(new Slot(tile, 0, 44, 46)); + this.addSlotToContainer(new Slot(tile, 0, 44, 46)); - this.addSlot(new SlotClosed(tile, 1, 98, 35)); - this.addSlot(new SlotClosed(tile, 2, 98, 53)); - this.addSlot(new SlotClosed(tile, 3, 116, 35)); - this.addSlot(new SlotClosed(tile, 4, 116, 53)); + this.addSlotToContainer(new SlotClosed(tile, 1, 98, 35)); + this.addSlotToContainer(new SlotClosed(tile, 2, 98, 53)); + this.addSlotToContainer(new SlotClosed(tile, 3, 116, 35)); + this.addSlotToContainer(new SlotClosed(tile, 4, 116, 53)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/ContainerEngineTin.java b/src/main/java/forestry/energy/gui/ContainerEngineTin.java index f2887abdb..4ffdcc26c 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineTin.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineTin.java @@ -24,15 +24,15 @@ public class ContainerEngineTin extends ContainerSocketed { super(tile, tile); this.tile = tile; - this.addSlot(new Slot(tile, 0, 84, 53)); + this.addSlotToContainer(new Slot(tile, 0, 84, 53)); int i; for (i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); for (i = 0; i < 9; ++i) - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } @Override diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index a02e15d65..7b5cd5b19 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -24,16 +24,16 @@ public class ContainerGenerator extends ContainerLiquidTanks { super(tile, tile); this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/energy/gui/GuiEngineBronze.java b/src/main/java/forestry/energy/gui/GuiEngineBronze.java index b867fe27c..6a40bab32 100755 --- a/src/main/java/forestry/energy/gui/GuiEngineBronze.java +++ b/src/main/java/forestry/energy/gui/GuiEngineBronze.java @@ -30,7 +30,7 @@ public class GuiEngineBronze extends GuiEngine { protected class BiogasSlot extends Widget { - EngineBronze engine; + private final EngineBronze engine; public BiogasSlot(WidgetManager manager, int xPos, int yPos, EngineBronze engine) { super(manager, xPos, yPos); @@ -60,7 +60,7 @@ public class GuiEngineBronze extends GuiEngine { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); while (true) { - int x = 0; + int x; if (squaled > 16) { x = 16; @@ -87,8 +87,7 @@ public class GuiEngineBronze extends GuiEngine { if (fluid == null) return StringUtil.localize("gui.empty"); - String tooltip = fluid.getLocalizedName(new FluidStack(fluid, 1)); - return tooltip; + return fluid.getLocalizedName(new FluidStack(fluid, 1)); } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 34154f210..50bc1ca8a 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -137,8 +137,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(res, liqu)) return recipe; } diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 28338d621..47cc42913 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -99,8 +99,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public static Recipe findMatchingRecipe(ItemStack item) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(item)) return recipe; } diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 74e987486..81680d09c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -46,7 +46,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private static final FluidStack STACK_WATER = Fluids.WATER.get(Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ - public FilteredTank resourceTank; + private final FilteredTank resourceTank; private final TankManager tankManager; private boolean isValidBiome = true; private int fillingTime; diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 3b2eb8cf8..e5110b2b2 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -337,10 +337,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi private boolean addProduct(FluidStack stack) { stack.amount -= productTank.fill(stack, true); - if (stack.amount <= 0) - return true; - else - return false; + return stack.amount <= 0; } private boolean addRemnant(ItemStack stack) { diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index e4b22ddff..dea14c65b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -65,12 +65,10 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } public boolean matches(FluidStack res) { - if (res == null && input == null) - return true; - else if (res == null || input == null) + if (res == null) return false; - else - return input.isFluidEqual(res); + + return input.isFluidEqual(res); } } @@ -90,8 +88,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui } public static Recipe findMatchingRecipe(FluidStack item) { - for (int i = 0; i < recipes.size(); i++) { - Recipe recipe = recipes.get(i); + for (Recipe recipe : recipes) { if (recipe.matches(item)) return recipe; } diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index d842a3a2b..8a2026287 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -25,19 +25,19 @@ public class ContainerBottler extends ContainerLiquidTanks { super(tile, tile); this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineBottler.SLOT_RESOURCE, 116, 19, true)); - this.addSlot(new SlotClosed(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); - this.addSlot(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_RESOURCE, 116, 19, true)); + this.addSlotToContainer(new SlotClosed(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + this.addSlotToContainer(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { - this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + this.addSlotToContainer(new Slot(player, var3, 8 + var3 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index 41c5db9f4..a036ba011 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -40,7 +40,6 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain } private MachineCarpenter machine; private final IInventory craftingInventory; - private IInventory internalInventory; public final InventoryCraftingAuto craftMatrix; public final InventoryCraftResult craftResult; @@ -50,7 +49,7 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain machine = tile; machine.activeContainer = this; craftingInventory = machine.getCraftingInventory(); - internalInventory = machine.getInternalInventory(); + IInventory internalInventory = machine.getInternalInventory(); craftMatrix = new InventoryCraftingAuto(this, 3, 3); craftResult = new InventoryCraftResult(); @@ -58,36 +57,36 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain // Internal inventory for (int i = 0; i < 2; i++) { for (int k = 0; k < 9; k++) { - addSlot(new Slot(internalInventory, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); + addSlotToContainer(new Slot(internalInventory, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); } } // Liquid Input - this.addSlot(new SlotLiquidContainer(internalInventory, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); + this.addSlotToContainer(new SlotLiquidContainer(internalInventory, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); // Boxes - this.addSlot(new SlotCrate(this, internalInventory, MachineCarpenter.SLOT_BOX, 83, 20)); + this.addSlotToContainer(new SlotCrate(this, internalInventory, MachineCarpenter.SLOT_BOX, 83, 20)); // Product - this.addSlot(new SlotOutput(internalInventory, MachineCarpenter.SLOT_PRODUCT, 120, 56)); + this.addSlotToContainer(new SlotOutput(internalInventory, MachineCarpenter.SLOT_PRODUCT, 120, 56)); // CraftResult display - addSlot(new SlotLocked(craftResult, 0, 80, 51)); + addSlotToContainer(new SlotLocked(craftResult, 0, 80, 51)); // Crafting matrix for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 10 + k1 * 18, 20 + l * 18)); + addSlotToContainer(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 10 + k1 * 18, 20 + l * 18)); } } // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 194)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 194)); } // Update crafting matrix with current contents of tileentity. @@ -114,12 +113,6 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain updateProductSlot(); } - /** - * Replaces the original onCraftMatrixChanged - * - * @param iinventory - * @param slot - */ @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { craftingInventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot)); diff --git a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java index dcbfbcdc8..c522a0c9f 100755 --- a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java +++ b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java @@ -27,20 +27,20 @@ public class ContainerCentrifuge extends ContainerForestry { this.tile = tile; // Resource - this.addSlot(new Slot(tile, 0, 34, 37)); + this.addSlotToContainer(new Slot(tile, 0, 34, 37)); // Product Inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new SlotClosed(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); + addSlotToContainer(new SlotClosed(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 142)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 142)); } @Override diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 1fa32ba2a..12eb4c7eb 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -10,46 +10,44 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCrafter; -import forestry.factory.gadgets.MachineFabricator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -public class ContainerFabricator extends ContainerLiquidTanks { +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotCrafter; +import forestry.factory.gadgets.MachineFabricator; - private final MachineFabricator tile; +public class ContainerFabricator extends ContainerLiquidTanks { public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) { super(tile, tile); - this.tile = tile; // Internal inventory for (int i = 0; i < 2; i++) for (int k = 0; k < 9; k++) - addSlot(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); + addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); // Molten resource - this.addSlot(new Slot(tile, MachineFabricator.SLOT_METAL, 26, 21)); + this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_METAL, 26, 21)); // Plan - this.addSlot(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); + this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); // Result - this.addSlot(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); + this.addSlotToContainer(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); // Crafting matrix for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); + addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_CRAFTING_1 + k + l * 3, 67 + k * 18, 17 + l * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int k = 0; k < 9; k++) - addSlot(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); + addSlotToContainer(new Slot(playerInventory, k + i * 9 + 9, 8 + k * 18, 129 + i * 18)); // Player hotbar for (int j = 0; j < 9; j++) - addSlot(new Slot(playerInventory, j, 8 + j * 18, 187)); + addSlotToContainer(new Slot(playerInventory, j, 8 + j * 18, 187)); } diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index c467b7710..a31643f90 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -26,20 +26,20 @@ public class ContainerFermenter extends ContainerLiquidTanks { super(fermenter, fermenter); this.fermenter = fermenter; - this.addSlot(new SlotCustom(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23).setExclusion(true)); - this.addSlot(new SlotCustom(fermenter, MachineFermenter.SLOT_FUEL, 75, 57).setExclusion(true)); - this.addSlot(new SlotOutput(fermenter, MachineFermenter.SLOT_CAN_OUTPUT, 150, 58)); - this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); - this.addSlot(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); + this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23).setExclusion(true)); + this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_FUEL, 75, 57).setExclusion(true)); + this.addSlotToContainer(new SlotOutput(fermenter, MachineFermenter.SLOT_CAN_OUTPUT, 150, 58)); + this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); + this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 5070b8b26..716503826 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -30,32 +30,32 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain // Stash for (int l = 0; l < 2; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); + addSlotToContainer(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); } } // Reservoir for (int k1 = 0; k1 < 3; k1++) { - addSlot(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); + addSlotToContainer(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); } // Working slot - this.addSlot(new SlotWorking(tile, 9, 105, 37)); + this.addSlotToContainer(new SlotWorking(tile, 9, 105, 37)); // Product slot - this.addSlot(new Slot(tile, 10, 143, 55)); + this.addSlotToContainer(new Slot(tile, 10, 143, 55)); // Boxes - this.addSlot(new SlotCraftAuto(this, tile, 11, 143, 19)); + this.addSlotToContainer(new SlotCraftAuto(this, tile, 11, 143, 19)); // Player inventory int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { - this.addSlot(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + this.addSlotToContainer(new Slot(player, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { - this.addSlot(new Slot(player, var3, 8 + var3 * 18, 142)); + this.addSlotToContainer(new Slot(player, var3, 8 + var3 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index e21be8b92..f0408977c 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -19,23 +19,20 @@ import net.minecraft.inventory.Slot; public class ContainerRaintank extends ContainerLiquidTanks { - protected MachineRaintank tile; - public ContainerRaintank(InventoryPlayer player, MachineRaintank tile) { super(tile, tile); - this.tile = tile; - this.addSlot(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); - this.addSlot(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); + this.addSlotToContainer(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerSqueezer.java b/src/main/java/forestry/factory/gui/ContainerSqueezer.java index b542da864..5e30fde2e 100755 --- a/src/main/java/forestry/factory/gui/ContainerSqueezer.java +++ b/src/main/java/forestry/factory/gui/ContainerSqueezer.java @@ -10,42 +10,39 @@ ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotClosed; import forestry.core.gui.slots.SlotLiquidContainer; import forestry.factory.gadgets.MachineSqueezer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; public class ContainerSqueezer extends ContainerLiquidTanks { - protected MachineSqueezer tile; - public ContainerSqueezer(InventoryPlayer player, MachineSqueezer tile) { super(tile, tile); - this.tile = tile; - // Resource inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlot(new Slot(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); + addSlotToContainer(new Slot(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); // Remnants slot - this.addSlot(new SlotClosed(tile, 9, 123, 19)); + this.addSlotToContainer(new SlotClosed(tile, 9, 123, 19)); // Can slot - this.addSlot(new SlotLiquidContainer(tile, 10, 106, 55, true)); + this.addSlotToContainer(new SlotLiquidContainer(tile, 10, 106, 55, true)); // Output slot - this.addSlot(new SlotClosed(tile, 11, 140, 55)); + this.addSlotToContainer(new SlotClosed(tile, 11, 140, 55)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); + addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(player, j1, 8 + j1 * 18, 142)); + addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerStill.java b/src/main/java/forestry/factory/gui/ContainerStill.java index 19f47f3fd..6984eae12 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -10,32 +10,30 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.factory.gadgets.MachineStill; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -public class ContainerStill extends ContainerLiquidTanks { +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotLiquidContainer; +import forestry.factory.gadgets.MachineStill; - protected MachineStill processor; +public class ContainerStill extends ContainerLiquidTanks { public ContainerStill(InventoryPlayer player, MachineStill tile) { super(tile, tile); - this.processor = tile; - this.addSlot(new Slot(tile, MachineStill.SLOT_PRODUCT, 150, 54)); - this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); - this.addSlot(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); + this.addSlotToContainer(new Slot(tile, MachineStill.SLOT_PRODUCT, 150, 54)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); + this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { - this.addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { - this.addSlot(new Slot(player, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142)); } } diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index 1395912f3..ccf249c46 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.factory.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.core.gui.ContainerForestry; import forestry.core.gui.IGuiSelectable; import forestry.core.gui.slots.SlotCrafter; @@ -20,56 +26,47 @@ import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; import forestry.factory.gadgets.TileWorktable; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCraftResult; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerWorktable extends ContainerForestry implements IContainerCrafting, IGuiSelectable { - EntityPlayer player; - TileWorktable tile; - IInventory craftingInventory; - IInventory internalInventory; - InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); - InventoryCraftResult craftResult = new InventoryCraftResult(); - long lastUpdate; + private final EntityPlayer player; + private final TileWorktable tile; + private final InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + private long lastUpdate; public ContainerWorktable(EntityPlayer player, TileWorktable tile) { super(tile.getInternalInventory()); this.tile = tile; - craftingInventory = tile.getCraftingInventory(); - internalInventory = tile.getInternalInventory(); + IInventory craftingInventory = tile.getCraftingInventory(); + IInventory internalInventory = tile.getInternalInventory(); // Internal inventory for (int i = 0; i < 2; i++) { for (int k = 0; k < 9; k++) { - addSlot(new Slot(internalInventory, TileWorktable.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); + addSlotToContainer(new Slot(internalInventory, TileWorktable.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); } } // Crafting matrix for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlot(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 11 + k1 * 18, 20 + l * 18)); + addSlotToContainer(new SlotCraftMatrix(this, craftingInventory, k1 + l * 3, 11 + k1 * 18, 20 + l * 18)); } } // CraftResult display - addSlot(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); + addSlotToContainer(new SlotCrafter(player, craftingInventory, tile, TileWorktable.SLOT_CRAFTING_RESULT, 77, 38)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { - addSlot(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); + addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 136 + i1 * 18)); } } // Player hotbar for (int j1 = 0; j1 < 9; j1++) { - addSlot(new Slot(player.inventory, j1, 8 + j1 * 18, 194)); + addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 194)); } // Update crafting matrix with current contents of tileentity. @@ -106,7 +103,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC private void updateMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - craftMatrix.setInventorySlotContents(i, craftingInventory.getStackInSlot(i)); + craftMatrix.setInventorySlotContents(i, tile.getCraftingInventory().getStackInSlot(i)); } } diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index ba055e045..0d2853b61 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -14,7 +14,7 @@ import forestry.core.vect.Vect; public class FarmTarget { - private Vect start; + private final Vect start; private int yOffset; private int extent; private int limit; diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index b0e368b97..fbad70e8d 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -182,10 +182,7 @@ public class BlockFarm extends BlockStructure { @Override public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - if (world.getBlockMetadata(x, y, z) == 5) - return true; - else - return false; + return world.getBlockMetadata(x, y, z) == 5; } @Override diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 1f1c30d41..2db4c6b84 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -40,45 +40,45 @@ public class ContainerFarm extends ContainerSocketed { // Resources for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); } } // Germlings for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); } } // Production 1 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); } } // Production 2 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); } } // Fertilizer - addSlot(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer)); + addSlotToContainer(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer)); // Can Slot - addSlot(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95)); + addSlotToContainer(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95)); // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(playerinventory, j + i * 9 + 9, 28 + j * 18, 138 + i * 18)); + addSlotToContainer(new Slot(playerinventory, j + i * 9 + 9, 28 + j * 18, 138 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(playerinventory, i, 28 + i * 18, 196)); + addSlotToContainer(new Slot(playerinventory, i, 28 + i * 18, 196)); } } diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index c227a38e2..26fc1f203 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -10,18 +10,20 @@ ******************************************************************************/ package forestry.farming.logic; -import forestry.api.farming.ICrop; -import forestry.core.config.Defaults; -import forestry.core.vect.Vect; import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.core.config.Defaults; +import forestry.core.vect.Vect; + public abstract class Crop implements ICrop { - protected World world; - protected Vect position; + protected final World world; + protected final Vect position; public Crop(World world, Vect position) { this.world = world; diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index 707583b2a..3ba012417 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -19,8 +19,8 @@ import net.minecraft.world.World; public class CropBlock extends Crop { - Block block; - int meta; + protected final Block block; + protected final int meta; public CropBlock(World world, Block block, int meta, Vect position) { super(world, position); diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index 07f0e8f1a..a65c0c4f6 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -23,7 +23,7 @@ import net.minecraft.world.World; public class CropFruit extends Crop { - IFruitFamily family; + private final IFruitFamily family; public CropFruit(World world, Vect position, IFruitFamily family) { super(world, position); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 24abcc6db..7ad6160a7 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -31,11 +31,11 @@ import forestry.core.vect.Vect; public abstract class FarmLogic implements IFarmLogic { - IFarmHousing housing; + protected final IFarmHousing housing; - boolean isManual; + protected boolean isManual; - static HashSet breakable = new HashSet(); + private static final HashSet breakable = new HashSet(); public FarmLogic(IFarmHousing housing) { this.housing = housing; diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 145d70a9e..b4df54aa0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -127,8 +127,6 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtentsHarvest.containsKey(start)) lastExtentsHarvest.put(start, 0); @@ -138,7 +136,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtentsHarvest.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 967fac68a..59cf78c51 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -102,8 +102,6 @@ public class FarmLogicCocoa extends FarmLogic { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtentsHarvest.containsKey(start)) lastExtentsHarvest.put(start, 0); @@ -113,7 +111,7 @@ public class FarmLogicCocoa extends FarmLogic { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtentsHarvest.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 1e8af8cbc..c80ed7bb4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -33,7 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection; public abstract class FarmLogicCrops extends FarmLogicWatered { private final IFarmable[] seeds; - private static ItemStack farmland = new ItemStack(Blocks.farmland, 1, Defaults.WILDCARD); + private static final ItemStack farmland = new ItemStack(Blocks.farmland, 1, Defaults.WILDCARD); public FarmLogicCrops(IFarmHousing housing, IFarmable[] seeds) { super(housing, diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index e870ecf18..462a7e3bd 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -82,8 +82,6 @@ public class FarmLogicOrchard extends FarmLogic { @Override public Collection harvest(int x, int y, int z, ForgeDirection direction, int extent) { - Collection crops = null; - Vect start = new Vect(x, y, z); if (!lastExtents.containsKey(start)) lastExtents.put(start, 0); @@ -95,7 +93,7 @@ public class FarmLogicOrchard extends FarmLogic { // Proxies.log.finest("Logic %s is searching in direction %s at %s/%s/%s with extension %s.", getClass(), direction, x, y, z, lastExtent); Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtents.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicPoale.java b/src/main/java/forestry/farming/logic/FarmLogicPoale.java index b19211f5e..be2972b46 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPoale.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPoale.java @@ -29,7 +29,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicPoale extends FarmLogic { - IFarmable[] germlings; + private final IFarmable[] germlings; public FarmLogicPoale(IFarmHousing housing) { super(housing); diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 46566329e..deda9bb20 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -94,7 +94,6 @@ public class FarmLogicRubber extends FarmLogic { if (inActive) return null; - Collection crops = null; Vect start = new Vect(x, y, z); if (!lastExtents.containsKey(start)) lastExtents.put(start, 0); @@ -104,7 +103,7 @@ public class FarmLogicRubber extends FarmLogic { lastExtent = 0; Vect position = translateWithOffset(x, y + 1, z, direction, lastExtent); - crops = getHarvestBlocks(position); + Collection crops = getHarvestBlocks(position); lastExtent++; lastExtents.put(start, lastExtent); diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index fb5c3bc68..5a58bd316 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -29,7 +29,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class FarmLogicSucculent extends FarmLogic { - IFarmable[] germlings; + private final IFarmable[] germlings; public FarmLogicSucculent(IFarmHousing housing) { super(housing); diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 979c578c5..526dab75f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -27,7 +27,7 @@ import net.minecraftforge.fluids.FluidStack; public abstract class FarmLogicWatered extends FarmLogic { - protected ItemStack ground; + protected final ItemStack ground; private final ItemStack[] resource; private static final FluidStack STACK_WATER = Fluids.WATER.get(1000); diff --git a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java index 83709dd1f..77df32c42 100755 --- a/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java +++ b/src/main/java/forestry/farming/logic/FarmableFarmCraftory.java @@ -39,10 +39,7 @@ public class FarmableFarmCraftory implements IFarmable { return false; Block block = world.getBlock(x, y, z); - if (block != PluginFarmCraftory.blockSingle && block != PluginFarmCraftory.blockMulti) - return false; - else - return true; + return block == PluginFarmCraftory.blockSingle || block == PluginFarmCraftory.blockMulti; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 1309aeb47..db5c8f8ae 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -32,14 +32,7 @@ public class FarmableGenericCrop implements IFarmable { @Override public boolean isSaplingAt(World world, int x, int y, int z) { - - if (world.isAirBlock(x, y, z)) - return false; - - if (world.getBlock(x, y, z) != block) - return false; - else - return true; + return world.getBlock(x, y, z) == block; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index 6834df2b0..0be2d42b2 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -21,10 +21,9 @@ import net.minecraft.world.World; public class FarmableGenericSapling implements IFarmable { - final Block sapling; - final int saplingMeta; - - ItemStack[] windfall; + private final Block sapling; + private final int saplingMeta; + private final ItemStack[] windfall; public FarmableGenericSapling(Block sapling, int saplingMeta, ItemStack... windfall) { this.sapling = sapling; diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 57136907f..9841a90ab 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -10,20 +10,21 @@ ******************************************************************************/ package forestry.farming.logic; +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.config.Defaults; import forestry.core.utils.StackUtils; import forestry.core.vect.Vect; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class FarmableGourd implements IFarmable { - public ItemStack seed; - public ItemStack stem; - public ItemStack fruit; + private final ItemStack seed; + private final ItemStack stem; + private final ItemStack fruit; public FarmableGourd(ItemStack seed, ItemStack stem, ItemStack fruit) { this.seed = seed; @@ -36,10 +37,7 @@ public class FarmableGourd implements IFarmable { if (world.isAirBlock(x, y, z)) return false; - if (!StackUtils.equals(world.getBlock(x, y, z), stem)) - return false; - - return true; + return StackUtils.equals(world.getBlock(x, y, z), stem); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index b41fbb287..626cd0776 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -22,8 +22,8 @@ import net.minecraft.world.World; public class FarmableStacked implements IFarmable { - Block block; - int matureHeight; + private final Block block; + private final int matureHeight; public FarmableStacked(Block block, int matureHeight) { this.block = block; diff --git a/src/main/java/forestry/food/gui/ContainerInfuser.java b/src/main/java/forestry/food/gui/ContainerInfuser.java index 70991252e..6a7ec5a61 100755 --- a/src/main/java/forestry/food/gui/ContainerInfuser.java +++ b/src/main/java/forestry/food/gui/ContainerInfuser.java @@ -30,24 +30,24 @@ public class ContainerInfuser extends ContainerForestry { this.inventory = inventory; // Input - this.addSlot(new SlotCustom(inventory, 0, 152, 12, ForestryItem.beverage.getItemStack())); + this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ForestryItem.beverage.getItemStack())); // Output - this.addSlot(new SlotCustom(inventory, 1, 152, 72, ItemBeverage.class)); + this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeverage.class)); // Ingredients - this.addSlot(new Slot(inventory, 2, 12, 12)); - this.addSlot(new Slot(inventory, 3, 12, 32)); - this.addSlot(new Slot(inventory, 4, 12, 52)); - this.addSlot(new Slot(inventory, 5, 12, 72)); + this.addSlotToContainer(new Slot(inventory, 2, 12, 12)); + this.addSlotToContainer(new Slot(inventory, 3, 12, 32)); + this.addSlotToContainer(new Slot(inventory, 4, 12, 52)); + this.addSlotToContainer(new Slot(inventory, 5, 12, 72)); // Player inventory for (int i1 = 0; i1 < 3; i1++) for (int l1 = 0; l1 < 9; l1++) - addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); + addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18)); // Player hotbar for (int j1 = 0; j1 < 9; j1++) - addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); + addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161)); } @Override diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index c5c965164..acaf1804c 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -107,7 +107,7 @@ public class ItemBeverage extends ItemForestryFood { } - public BeverageInfo[] beverages; + public final BeverageInfo[] beverages; public ItemBeverage(BeverageInfo... beverages) { super(1, 0.2f); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java index b154daaa5..6772956f4 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyMate.java @@ -24,7 +24,6 @@ public class AIButterflyMate extends AIButterflyInteract { /** * Should lay egg? - * @return */ @Override protected boolean canInteract() { diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java index d34c457c8..f4248f92a 100644 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyPollinate.java @@ -21,7 +21,6 @@ public class AIButterflyPollinate extends AIButterflyInteract { /** * Should pollinate? - * @return */ @Override protected boolean canInteract() { diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index b4a5c4959..e440e9484 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -230,12 +230,10 @@ public class Butterfly extends IndividualLiving implements IButterfly { } for (IButterflyMutation mutation : PluginLepidopterology.butterflyInterface.getMutations(true)) { - float chance = 0; - - if ((chance = mutation.getChance(nursery, allele0, allele1, genome0, genome1)) > 0) - if (world.rand.nextFloat()*100 < chance) { - return PluginLepidopterology.butterflyInterface.templateAsChromosomes(mutation.getTemplate()); - } + float chance = mutation.getChance(nursery, allele0, allele1, genome0, genome1); + if (chance > world.rand.nextFloat() * 100) { + return PluginLepidopterology.butterflyInterface.templateAsChromosomes(mutation.getTemplate()); + } } return null; diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index 803a02127..f296ed577 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -135,16 +135,9 @@ public class Letter implements ILetter, INBTTagable { @Override public boolean isMailable() { - // Can't resend an already sent letter - if (this.isProcessed) - return false; - // Requires at least one recipient - if (this.recipient != null && this.recipient.length > 0) - return true; - - return false; + return !isProcessed && recipient != null && recipient.length > 0; } @Override diff --git a/src/main/java/forestry/mail/PostOffice.java b/src/main/java/forestry/mail/PostOffice.java index a89507cc6..ab62ba76f 100755 --- a/src/main/java/forestry/mail/PostOffice.java +++ b/src/main/java/forestry/mail/PostOffice.java @@ -122,7 +122,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice { for (EnumPostage postage : postages) { - int collected = 0; + int collected; if (collectedPostage[postage.ordinal()] <= 0) continue; diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 0b814ea80..6571fc46a 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -161,7 +161,7 @@ public class PostRegistry implements IPostRegistry { } public IMailAddress getValidMailAddress(World world, GameProfile gameProfile) { - IMailAddress address = new MailAddress(gameProfile);; + IMailAddress address = new MailAddress(gameProfile); if (getPOBox(world, address) != null) return address; return null; diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index dddc710e4..65178a60b 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -61,15 +61,11 @@ public class PostalCarrier implements IPostalCarrier { } private IPostalState handleTradeLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { - IPostalState state = EnumDeliveryState.NOT_MAILABLE; - ITradeStation trade = PostManager.postRegistry.getTradeStation(world, recipient); if (trade == null) return EnumDeliveryState.NO_MAILBOX; - state = trade.handleLetter(world, recipient, letterstack, doLodge); - - return state; + return trade.handleLetter(world, recipient, letterstack, doLodge); } private EnumDeliveryState storeInPOBox(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doLodge) { diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index f7a5b7d3a..4ce4df494 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -585,7 +585,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide int[] slotsInt = new int[slots.size()]; for (int i = 0; i < slots.size(); i++) - slotsInt[i] = slots.get(i).intValue(); + slotsInt[i] = slots.get(i); return slotsInt; } diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index f5798f318..f97dffc88 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -61,17 +61,17 @@ public class ContainerLetter extends ContainerItemInventory { // Stamps for (int i = 0; i < 4; i++) - addSlot(new SlotCustom(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19, validStamps).setStackLimit(1)); + addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19, validStamps).setStackLimit(1)); // Attachments if (!letterInventory.getLetter().isProcessed()) for (int i = 0; i < 2; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotCustom(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18, ItemLetter.class).setExclusion(true)); + addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18, ItemLetter.class).setExclusion(true)); else for (int i = 0; i < 2; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotClosed(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); + addSlotToContainer(new SlotClosed(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) @@ -126,7 +126,7 @@ public class ContainerLetter extends ContainerItemInventory { break; } - IPostalCarrier postal = null; + IPostalCarrier postal; if(it.hasNext()) postal = it.next(); else @@ -153,7 +153,7 @@ public class ContainerLetter extends ContainerItemInventory { String typeName = packet.payload.stringPayload[1]; EnumAddressee type = EnumAddressee.fromString(typeName); - IMailAddress recipient = null; + IMailAddress recipient; if (type == EnumAddressee.PLAYER) { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); if (gameProfile == null) diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index c8c443360..78c24b5d5 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -44,15 +44,15 @@ public class ContainerMailbox extends ContainerForestry { for (int i = 0; i < 7; i++) for (int j = 0; j < 12; j++) - addSlot(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); + addSlotToContainer(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 35 + j * 18, 145 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 35 + j * 18, 145 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 35 + i * 18, 203)); + addSlotToContainer(new Slot(player, i, 35 + i * 18, 203)); } diff --git a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java index 155d708b6..6ab9b9972 100755 --- a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java +++ b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java @@ -24,20 +24,20 @@ public class ContainerPhilatelist extends ContainerForestry { super(tile); // Filter - addSlot(new SlotCustom(tile, MachinePhilatelist.SLOT_FILTER, 80, 19, ItemStamps.class)); + addSlotToContainer(new SlotCustom(tile, MachinePhilatelist.SLOT_FILTER, 80, 19, ItemStamps.class)); // Collected Stamps for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new SlotClosed(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); + addSlotToContainer(new SlotClosed(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 111 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 111 + i * 18)); // Player hotbar for (int i = 0; i < 9; i++) - addSlot(new Slot(player, i, 8 + i * 18, 169)); + addSlotToContainer(new Slot(player, i, 8 + i * 18, 169)); } diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index da5b8db84..6ccc21e62 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -24,13 +24,11 @@ import org.apache.commons.lang3.StringUtils; public class ContainerTradeName extends ContainerForestry { - boolean isLinked; - MachineTrader machine; + protected final MachineTrader machine; public ContainerTradeName(InventoryPlayer player, MachineTrader tile) { super(new InventoryAdapter(0, "Empty")); machine = tile; - isLinked = machine.isLinked(); } public IMailAddress getAddress() { diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 8401aaba0..7f67f748c 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -32,26 +32,26 @@ public class ContainerTrader extends ContainerForestry { IInventory inventory = machine.getOrCreateTradeInventory(); // Trade good - this.addSlot(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); + this.addSlotToContainer(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); // Exchange for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); } } // Stamps for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); } } // Letters for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); } } @@ -59,25 +59,25 @@ public class ContainerTrader extends ContainerForestry { final int bufCols = 5; for (int i = 0; i < 3; i++) { for (int j = 0; j < bufCols; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); } } for (int i = 0; i < 2; i++) { for (int j = 0; j < bufCols; j++) { - addSlot(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); } } // Player inventory for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { - addSlot(new Slot(player, j + i * 9 + 9, 33 + j * 18, 138 + i * 18)); + addSlotToContainer(new Slot(player, j + i * 9 + 9, 33 + j * 18, 138 + i * 18)); } } // Player hotbar for (int i = 0; i < 9; i++) { - addSlot(new Slot(player, i, 33 + i * 18, 196)); + addSlotToContainer(new Slot(player, i, 33 + i * 18, 196)); } } diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 40ea3a7bb..983369f27 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -24,13 +24,13 @@ import org.lwjgl.opengl.GL11; public class GuiCatalogue extends GuiForestry { - GuiButton buttonTrade; - GuiButton buttonClose; +// GuiButton buttonTrade; +// GuiButton buttonClose; - GuiButton buttonFilter; - GuiButton buttonCopy; + private GuiButton buttonFilter; + private GuiButton buttonCopy; - ContainerCatalogue container; + private final ContainerCatalogue container; public GuiCatalogue(EntityPlayer player) { super(new ResourceLocation("textures/gui/book.png"), new ContainerCatalogue(player)); @@ -76,10 +76,7 @@ public class GuiCatalogue extends GuiForestry { drawNoTrade(guiLeft + 38, guiTop + 30); buttonFilter.displayString = StringUtil.localize("gui.mail.filter." + container.getFilterIdent()); - if(container.getTradeInfo() == null || !container.getTradeInfo().state.isOk()) - buttonCopy.enabled = false; - else - buttonCopy.enabled = true; + buttonCopy.enabled = container.getTradeInfo() != null && container.getTradeInfo().state.isOk(); } private void drawNoTrade(int x, int y) { diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index 26f8a6686..b155adb12 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -228,10 +228,6 @@ public class ItemLetter extends ItemInventoried { public static int encodeMeta(int state, int size) { int meta = size << 4; meta |= state; - - size = getSize(meta); - state = getState(meta); - return meta; } diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index a071a9583..6d8f847ef 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -17,22 +17,20 @@ import net.minecraft.inventory.Slot; public class ContainerPropolisPipe extends ContainerForestry { - IInventory playerIInventory; - public PipeLogicPropolis pipeLogic; + public final PipeLogicPropolis pipeLogic; public ContainerPropolisPipe(IInventory playerInventory, PipeItemsPropolis pipe) { super(new InventoryAdapter(0, "Empty")); - this.playerIInventory = playerInventory; this.pipeLogic = pipe.pipeLogic; for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 9; k1++) { - addSlot(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18)); + addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 140 + l * 18)); } } for (int i1 = 0; i1 < 9; i1++) { - addSlot(new Slot(playerInventory, i1, 8 + i1 * 18, 198)); + addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 198)); } } diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index d660a22d2..1c6c44c03 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -282,25 +282,25 @@ public class PluginApiculture extends ForestryPlugin { apicultureConfig = new Configuration(); Property property = apicultureConfig.get("apiary.sidesensitive", CONFIG_CATEGORY, apiarySideSensitive); - property.Comment = "set to false if apiaries should output all items regardless of side a pipe is attached to"; - apiarySideSensitive = Boolean.parseBoolean(property.Value); + property.comment = "set to false if apiaries should output all items regardless of side a pipe is attached to"; + apiarySideSensitive = Boolean.parseBoolean(property.value); property = apicultureConfig.get("render.bees.fancy", CONFIG_CATEGORY, fancyRenderedBees); - property.Comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; - fancyRenderedBees = Boolean.parseBoolean(property.Value); + property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; + fancyRenderedBees = Boolean.parseBoolean(property.value); property = apicultureConfig.get("beekeeping.mode", CONFIG_CATEGORY, "NORMAL"); - property.Comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; - beekeepingMode = property.Value.trim(); + property.comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; + beekeepingMode = property.value.trim(); Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode); property = apicultureConfig.get("beekeeping.flowers.custom", CONFIG_CATEGORY, ""); - property.Comment = "add additional flower blocks for apiaries here in the format id:meta. separate blocks using ';'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; - parseAdditionalFlowers(property.Value, FlowerManager.plainFlowers); + property.comment = "add additional flower blocks for apiaries here in the format id:meta. separate blocks using ';'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; + parseAdditionalFlowers(property.value, FlowerManager.plainFlowers); property = apicultureConfig.get("species.blacklist", CONFIG_CATEGORY, ""); - property.Comment = "add species to blacklist identified by their uid and seperated with ';'."; - parseBeeBlacklist(property.Value); + property.comment = "add species to blacklist identified by their uid and seperated with ';'."; + parseBeeBlacklist(property.value); apicultureConfig.save(); diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index e5df08f22..b61184225 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -99,12 +99,12 @@ public class PluginLepidopterology extends ForestryPlugin { config = new Configuration(); Property property = config.get("entities.spawn.limit", CONFIG_CATEGORY, spawnConstraint); - property.Comment = "determines the global butterfly entity count above which natural spawning of butterflies ceases."; - spawnConstraint = Integer.parseInt(property.Value); + property.comment = "determines the global butterfly entity count above which natural spawning of butterflies ceases."; + spawnConstraint = Integer.parseInt(property.value); property = config.get("entities.maximum.allowed", CONFIG_CATEGORY, entityConstraint); - property.Comment = "determines the global butterfly entity count above which butterflies will stay in item form and will not take flight anymore."; - entityConstraint = Integer.parseInt(property.Value); + property.comment = "determines the global butterfly entity count above which butterflies will stay in item form and will not take flight anymore."; + entityConstraint = Integer.parseInt(property.value); config.save(); diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 9f9a99262..6ffdc76aa 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -106,23 +106,23 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl config = new Configuration(); Property backpackConf = config.get("backpacks.miner.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the miner's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Miner's Backpack", backpackConf.Value, BackpackManager.definitions.get("miner")); + backpackConf.comment = "add additional blocks and items for the miner's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Miner's Backpack", backpackConf.value, BackpackManager.definitions.get("miner")); backpackConf = config.get("backpacks.digger.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the digger's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Digger's Backpack", backpackConf.Value, BackpackManager.definitions.get("digger")); + backpackConf.comment = "add additional blocks and items for the digger's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Digger's Backpack", backpackConf.value, BackpackManager.definitions.get("digger")); backpackConf = config.get("backpacks.forester.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the forester's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Forester's Backpack", backpackConf.Value, BackpackManager.definitions.get("forester")); + backpackConf.comment = "add additional blocks and items for the forester's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Forester's Backpack", backpackConf.value, BackpackManager.definitions.get("forester")); backpackConf = config.get("backpacks.hunter.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add additional blocks and items for the hunter's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Hunter's Backpack", backpackConf.Value, BackpackManager.definitions.get("hunter")); + backpackConf.comment = "add additional blocks and items for the hunter's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Hunter's Backpack", backpackConf.value, BackpackManager.definitions.get("hunter")); backpackConf = config.get("backpacks.adventurer.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add blocks and items for the adventurer's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Adventurer's Backpack", backpackConf.Value, BackpackManager.definitions.get("adventurer")); + backpackConf.comment = "add blocks and items for the adventurer's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Adventurer's Backpack", backpackConf.value, BackpackManager.definitions.get("adventurer")); backpackConf = config.get("backpacks.builder.items", CONFIG_CATEGORY, ""); - backpackConf.Comment = "add blocks and items for the builder's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; - parseBackpackItems("Builder's Backpack", backpackConf.Value, BackpackManager.definitions.get("builder")); + backpackConf.comment = "add blocks and items for the builder's backpack here in the format id:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; + parseBackpackItems("Builder's Backpack", backpackConf.value, BackpackManager.definitions.get("builder")); config.save(); diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index f63b1d2e8..67d37cfe5 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -51,10 +51,7 @@ public class PickupHandlerStorage implements IPickupHandler { backpack.tryStowing(player, pack, itemstack); } - if (itemstack.stackSize <= 0) - return false; - else - return true; + return itemstack.stackSize > 0; } /** @@ -85,7 +82,6 @@ public class PickupHandlerStorage implements IPickupHandler { if (space > itemstack.stackSize) { inventoryStack.stackSize += itemstack.stackSize; itemstack.stackSize = 0; - itemstack = null; break; // Only part can be added } else { diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index b94471da8..ee44c5c30 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -93,9 +93,6 @@ public class ResupplyHandler implements IResupplyHandler { /** * This tops off existing stacks in the player's inventory. - * - * @param player - * @param itemstack */ private boolean topOffPlayerInventory(EntityPlayer player, ItemStack itemstack) { @@ -112,11 +109,8 @@ public class ResupplyHandler implements IResupplyHandler { continue; if (inventoryStack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(inventoryStack, itemstack)) { - inventoryStack.stackSize++; itemstack.stackSize--; - if (itemstack.stackSize <= 0) - itemstack = null; return true; } } diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index f64acf725..727d0e92d 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -43,7 +43,7 @@ public class ContainerBackpack extends ContainerItemInventory { for (int j = 0; j < lines; j++) for (int k = 0; k < columns; k++) { int slot = k + j * columns; - addSlot(new SlotForestry(inventory, slot, startX + k * 18, startY + j * 18) { + addSlotToContainer(new SlotForestry(inventory, slot, startX + k * 18, startY + j * 18) { @Override public boolean isItemValid(ItemStack stack) { diff --git a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java index 8f140a334..e93141cdc 100755 --- a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java @@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack; public class ContainerNaturalistBackpack extends ContainerItemInventory implements IGuiSelectable { private final PagedInventory inv; - private ISpeciesRoot speciesRoot; + private final ISpeciesRoot speciesRoot; public ContainerNaturalistBackpack(ISpeciesRoot speciesRoot, InventoryPlayer player, PagedInventory inventory, int page, int pageSize) { super(inventory, player.player); @@ -35,7 +35,7 @@ public class ContainerNaturalistBackpack extends ContainerItemInventory implemen // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlot(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); } } From 4cfa8f733871c9faf625cacd770391f0d4652431 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 03:59:47 -0800 Subject: [PATCH 077/175] Minor bugfixes --- src/main/java/forestry/apiculture/gadgets/BlockCandle.java | 1 + src/main/java/forestry/farming/logic/FarmLogicPeat.java | 2 +- src/main/java/forestry/lepidopterology/MatingRecipe.java | 2 ++ .../forestry/lepidopterology/entities/AIButterflyFlee.java | 4 +--- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java index 30ddd761f..649c3379a 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockCandle.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockCandle.java @@ -176,6 +176,7 @@ public class BlockCandle extends BlockTorch { TileCandle te = (TileCandle)world.getTileEntity(x, y, z); if (te == null) { world.setTileEntity(x, y, z, this.createTileEntity(world, meta)); + te = (TileCandle)world.getTileEntity(x, y, z); } if (StackUtils.equals(this, held)) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 63c769da2..71f29440a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -73,7 +73,7 @@ public class FarmLogicPeat extends FarmLogicWatered { Vect position = translateWithOffset(x, y, z, direction, i); ItemStack occupant = getAsItemStack(position); - if (occupant == null) + if (occupant.getItem() == null) continue; Block block = BlockSoil.getBlockFromItem(occupant.getItem()); diff --git a/src/main/java/forestry/lepidopterology/MatingRecipe.java b/src/main/java/forestry/lepidopterology/MatingRecipe.java index 518f42678..3edb71581 100755 --- a/src/main/java/forestry/lepidopterology/MatingRecipe.java +++ b/src/main/java/forestry/lepidopterology/MatingRecipe.java @@ -64,6 +64,8 @@ public class MatingRecipe implements IRecipe { } else if(PluginLepidopterology.butterflyInterface.isMember(crafting.getStackInSlot(i), EnumFlutterType.SERUM.ordinal())) serum = PluginLepidopterology.butterflyInterface.getMember(crafting.getStackInSlot(i)); } + if (butterfly == null || serum == null) + return null; IButterfly mated = butterfly.copy(); mated.mate(serum); diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java index bc3db0eb0..483db22cd 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyFlee.java @@ -15,8 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; public class AIButterflyFlee extends AIButterflyMovement { - private EntityPlayer player; - public AIButterflyFlee(EntityButterfly entity) { super(entity); setMutexBits(3); @@ -25,7 +23,7 @@ public class AIButterflyFlee extends AIButterflyMovement { @Override public boolean shouldExecute() { - player = entity.worldObj.getClosestPlayerToEntity(entity, entity.getButterfly().getGenome().getPrimary().getFlightDistance()); + EntityPlayer player = entity.worldObj.getClosestPlayerToEntity(entity, entity.getButterfly().getGenome().getPrimary().getFlightDistance()); if (player == null || player.isSneaking()) return false; From 26ff21f4467178b8a30ef3a79fbc13971ddd8283 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 04:06:07 -0800 Subject: [PATCH 078/175] Fix #387 bee tooltip shows wrong humidity tolerance --- src/main/java/forestry/apiculture/genetics/Bee.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 97adc897b..505140fda 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -336,7 +336,7 @@ public class Bee extends IndividualLiving implements IBee { IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); - IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); list.add(genome.getFlowerProvider().getDescription()); From 2f6969e1411cea93ffa2b65fe00e346929586a89 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 04:18:52 -0800 Subject: [PATCH 079/175] Cleanup --- .../forestry/core/gadgets/TileForestry.java | 1 - .../java/forestry/core/gui/GuiTextBox.java | 2 +- .../java/forestry/core/gui/LedgerManager.java | 2 - .../forestry/core/inventory/InvTools.java | 55 ------------------- .../core/inventory/InventoryAdapter.java | 15 ----- .../manipulators/InventoryManipulator.java | 5 -- .../core/utils/ShapedRecipeCustom.java | 1 - .../java/forestry/core/utils/StackUtils.java | 26 +-------- .../factory/gadgets/MachineBottler.java | 6 -- .../factory/gadgets/MachineCentrifuge.java | 1 - .../factory/gadgets/MachineFermenter.java | 3 - .../factory/gadgets/MachineSqueezer.java | 1 - .../factory/gadgets/MachineStill.java | 1 - .../storage/PickupHandlerStorage.java | 3 - 14 files changed, 2 insertions(+), 120 deletions(-) diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index a4bc744a3..00c9f53a1 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -311,7 +311,6 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit /* NAME */ /** * Gets the tile's unlocalized name, based on the block at the location of this entity (client-only). - * @return */ public String getUnlocalizedName() { String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.", ""); diff --git a/src/main/java/forestry/core/gui/GuiTextBox.java b/src/main/java/forestry/core/gui/GuiTextBox.java index 79ccee1cb..afc00161d 100755 --- a/src/main/java/forestry/core/gui/GuiTextBox.java +++ b/src/main/java/forestry/core/gui/GuiTextBox.java @@ -97,7 +97,7 @@ public class GuiTextBox extends GuiTextField { drawRect(startX, startY, startX + this.width, startY + this.height, -16777216); } - int textColour = isFocused() ? this.enabledColor : this.disabledColor; + int textColour = isFocused() ? enabledColor : disabledColor; drawScrolledSplitString(getCursoredText(), startX + 2, startY + 2, width - 4, textColour); } diff --git a/src/main/java/forestry/core/gui/LedgerManager.java b/src/main/java/forestry/core/gui/LedgerManager.java index 53f9d9f78..1e5e742fe 100755 --- a/src/main/java/forestry/core/gui/LedgerManager.java +++ b/src/main/java/forestry/core/gui/LedgerManager.java @@ -37,8 +37,6 @@ public class LedgerManager { /** * Inserts a ledger into the next-to-last position. - * - * @param ledger */ public void insert(Ledger ledger) { this.ledgers.add(ledgers.size() - 1, ledger); diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 8685a9b73..b1e35ae12 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -250,9 +250,6 @@ public abstract class InvTools { /** * Counts the number of items. - * - * @param inv - * @return */ public static int countItems(IInventory inv) { int count = 0; @@ -290,10 +287,6 @@ public abstract class InvTools { * Counts the number of items that match the filter. Ignores * ISpecialInventory and ISidedInventory, and bypasses InventoryMapper to * count from the base IInventory. - * - * @param inv - * @param filters - * @return */ public static int countItems(IInventory inv, ItemStack... filters) { if (inv instanceof InventoryMapper) @@ -369,9 +362,6 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. - * - * @param source - * @param dest * @return null if nothing was moved, the stack moved otherwise */ public static ItemStack moveOneItem(IInventory source, IInventory dest) { @@ -380,9 +370,6 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. - * - * @param source - * @param dest * @param filters an ItemStack[] to match against * @return null if nothing was moved, the stack moved otherwise */ @@ -392,9 +379,6 @@ public abstract class InvTools { /** * Attempts to move a single item from one inventory to another. - * - * @param source - * @param dest * @param filter an IItemType to match against * @return null if nothing was moved, the stack moved otherwise */ @@ -405,11 +389,6 @@ public abstract class InvTools { /** * Attempts to move one item from a collection of inventories. - * - * @param sources - * @param dest - * @param filters - * @return */ public static ItemStack moveOneItem(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { @@ -422,11 +401,6 @@ public abstract class InvTools { /** * Attempts to move one item from a collection of inventories. - * - * @param sources - * @param dest - * @param filter - * @return */ public static ItemStack moveOneItem(Iterable sources, IInventory dest, IStackFilter filter) { for (IInventory inv : sources) { @@ -439,11 +413,6 @@ public abstract class InvTools { /** * Attempts to move one item to a collection of inventories. - * - * @param source - * @param destinations - * @param filters - * @return */ public static ItemStack moveOneItem(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { @@ -459,8 +428,6 @@ public abstract class InvTools { * * Will not move any items in the filter. * - * @param source - * @param dest * @param filters an ItemStack[] to exclude * @return null if nothing was moved, the stack moved otherwise */ @@ -470,11 +437,6 @@ public abstract class InvTools { /** * Attempts to move one item from a collection of inventories. - * - * @param sources - * @param dest - * @param filters - * @return */ public static ItemStack moveOneItemExcept(Iterable sources, IInventory dest, ItemStack... filters) { for (IInventory inv : sources) { @@ -487,11 +449,6 @@ public abstract class InvTools { /** * Attempts to move one item to a collection of inventories. - * - * @param source - * @param destinations - * @param filters - * @return */ public static ItemStack moveOneItemExcept(IInventory source, Iterable destinations, ItemStack... filters) { for (IInventory dest : destinations) { @@ -610,10 +567,6 @@ public abstract class InvTools { /** * Returns true if the item is equal to any one of several possible matches. - * - * @param stack - * @param matches - * @return */ public static boolean isItemEqual(ItemStack stack, ItemStack... matches) { for (ItemStack match : matches) { @@ -625,10 +578,6 @@ public abstract class InvTools { /** * Returns true if the item is equal to any one of several possible matches. - * - * @param stack - * @param matches - * @return */ public static boolean isItemEqual(ItemStack stack, Collection matches) { for (ItemStack match : matches) { @@ -704,10 +653,6 @@ public abstract class InvTools { /** * Removes a up to numItems worth of items from the inventory, not caring * about what the items are. - * - * @param inv - * @param numItems - * @return */ public static ItemStack[] removeItems(IInventory inv, int numItems) { PlainInventory output = new PlainInventory(27, "temp"); diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index 3966f48ce..1cdbf5359 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -113,12 +113,6 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl /** * Tries to add a stack to the specified slot range. - * - * @param stack - * @param startSlot - * @param slots - * @param all - * @return */ public boolean tryAddStack(ItemStack stack, int startSlot, int slots, boolean all) { return tryAddStack(stack, startSlot, slots, all, true); @@ -237,15 +231,6 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl * Removes the exact items first if they exist, and then removes crafting equivalents. * If the inventory doesn't have all the required items, returns false without removing anything. * If stowContainer is true, items with containers will have their container stowed. - * @param count - * @param set - * @param firstSlotIndex - * @param slotCount - * @param player - * @param stowContainer - * @param oreDictionary - * @param craftingTools - * @return */ public boolean removeSets(int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { diff --git a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java index f3651041a..f0d611b80 100755 --- a/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java +++ b/src/main/java/forestry/core/inventory/manipulators/InventoryManipulator.java @@ -48,8 +48,6 @@ public class InventoryManipulator { /** * Attempt to add the stack to the inventory. - * - * @param stack * @return The remainder */ public ItemStack addStack(ItemStack stack) { @@ -103,10 +101,7 @@ public class InventoryManipulator { } /** - * @param slot - * @param stack * @param available Amount we can move - * @param doAdd * @return Return the number of items moved. */ private int addToSlot(IInvSlot slot, ItemStack stack, int available, boolean doAdd) { diff --git a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java index 2e72e78d6..eaf71a8a6 100755 --- a/src/main/java/forestry/core/utils/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/utils/ShapedRecipeCustom.java @@ -167,7 +167,6 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { } /** - * @param resource * @return true if resource is a valid ingredient in this recipe. */ @SuppressWarnings("unchecked") diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 89110b8ae..93a5d0215 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -33,10 +33,6 @@ public class StackUtils { /** * Compares item id, damage and NBT. Accepts wildcard damage. - * - * @param lhs - * @param rhs - * @return */ public static boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) { if (lhs == null || rhs == null) @@ -150,9 +146,6 @@ public class StackUtils { /** * Merges the giving stack into the receiving stack as far as possible - * - * @param giver - * @param receptor */ public static void mergeStacks(ItemStack giver, ItemStack receptor) { if (receptor.stackSize >= 64) @@ -200,11 +193,7 @@ public class StackUtils { } /** - * - * @param stacks - * @param maxCountedPerStack The maximum stacksize counted in a single - * stack. -1 for unlimited. - * @return + * @param maxCountedPerStack The maximum stacksize counted in a single stack. -1 for unlimited. */ public static ItemStack[] condenseStacks(ItemStack[] stacks, int maxCountedPerStack, boolean craftingEquivalency) { ArrayList condensed = new ArrayList(); @@ -238,10 +227,6 @@ public class StackUtils { /** * Counts how many full sets are contained in the passed stock - * - * @param set - * @param stock - * @return */ public static int containsSets(ItemStack[] set, ItemStack[] stock) { return containsSets(set, stock, false, false); @@ -249,10 +234,6 @@ public class StackUtils { /** * Counts how many full sets are contained in the passed stock - * - * @param set - * @param stock - * @return */ public static int containsSets(ItemStack[] set, ItemStack[] stock, boolean oreDictionary, boolean craftingTools) { int count = 0; @@ -307,11 +288,6 @@ public class StackUtils { /** * Compare two item stacks for crafting equivalency. - * - * @param base - * @param comparison - * @param oreDictionary - * @return */ public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) { if (isCraftingEquivalent(base, comparison)) diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 0745981bd..221f58457 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -87,9 +87,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public static final ArrayList recipes = new ArrayList(); /** - * - * @param res - * @param empty * @return Recipe matching both res and empty, null if none */ public static Recipe findMatchingRecipe(FluidStack res, ItemStack empty) { @@ -116,8 +113,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } /** - * - * @param res * @return true if any recipe has a matching input */ public static boolean isInput(FluidStack res) { @@ -228,7 +223,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - return; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index 7cf7509ce..c02a9734c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -210,7 +210,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - return; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index 50bc1ca8a..a5c70bd59 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -357,9 +357,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL /** * Returns the burnTime an item of the passed ItemStack provides - * - * @param item - * @return */ private int determineFuelValue(ItemStack item) { if (item == null) diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index e5110b2b2..600edd4c6 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -242,7 +242,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - return; } } diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index dea14c65b..92fff756a 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -188,7 +188,6 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui if (energyManager.getTotalEnergyStored() == 0) { setErrorState(EnumErrorCode.NOPOWER); - return; } } diff --git a/src/main/java/forestry/storage/PickupHandlerStorage.java b/src/main/java/forestry/storage/PickupHandlerStorage.java index 67d37cfe5..e45ef050e 100755 --- a/src/main/java/forestry/storage/PickupHandlerStorage.java +++ b/src/main/java/forestry/storage/PickupHandlerStorage.java @@ -57,9 +57,6 @@ public class PickupHandlerStorage implements IPickupHandler { /** * This tops off existing stacks in the player's inventory. That way you can keep f.e. a stack of dirt or cobblestone in your inventory which gets refreshed * constantly by picked up items. - * - * @param player - * @param itemstack */ private void topOffPlayerInventory(EntityPlayer player, ItemStack itemstack) { From d705f4f4dbd0ba9fdeeea9697d1c9a6885c35371 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 15:52:48 -0800 Subject: [PATCH 080/175] Move EnumFarmBlock to its own file --- .../forestry/farming/gadgets/BlockFarm.java | 22 +++-- .../farming/gadgets/EnumFarmBlock.java | 91 +++++++++++++++++++ .../forestry/farming/gadgets/TileFarm.java | 86 ++---------------- .../forestry/farming/items/ItemFarmBlock.java | 6 +- .../farming/render/FarmItemRenderer.java | 9 +- .../java/forestry/plugins/PluginFarming.java | 25 ++--- 6 files changed, 135 insertions(+), 104 deletions(-) create mode 100644 src/main/java/forestry/farming/gadgets/EnumFarmBlock.java diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index fbad70e8d..2028e48a2 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -10,15 +10,9 @@ ******************************************************************************/ package forestry.farming.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.gadgets.BlockStructure; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StackUtils; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; -import forestry.plugins.PluginFarming; import java.util.ArrayList; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -33,6 +27,14 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.gadgets.BlockStructure; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StackUtils; +import forestry.plugins.PluginFarming; + public class BlockFarm extends BlockStructure { public BlockFarm() { @@ -152,7 +154,7 @@ public class BlockFarm extends BlockStructure { @SideOnly(Side.CLIENT) public IIcon getBlockTextureFromSideAndMetadata(EnumFarmBlock type, int side, int metadata) { - return StackUtils.getBlock(type.base).getIcon(side, type.base.getItemDamage()); + return StackUtils.getBlock(type.getBase()).getIcon(side, type.getBase().getItemDamage()); } @SideOnly(Side.CLIENT) @@ -189,10 +191,10 @@ public class BlockFarm extends BlockStructure { @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { TileEntity tile = world.getTileEntity(x, y, z); - ItemStack base = EnumFarmBlock.BRICK_STONE.base; + ItemStack base = EnumFarmBlock.BRICK_STONE.getBase(); if (tile instanceof TileFarm) - base = ((TileFarm) tile).farmBlock.base; + base = ((TileFarm) tile).farmBlock.getBase(); return StackUtils.getBlock(base).getIcon(side, base.getItemDamage()); } diff --git a/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java b/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java new file mode 100644 index 000000000..2a3e538e1 --- /dev/null +++ b/src/main/java/forestry/farming/gadgets/EnumFarmBlock.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * 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.farming.gadgets; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.render.TextureManager; + +public enum EnumFarmBlock { + BRICK_STONE(new ItemStack(Blocks.stonebrick, 1, 0)), + BRICK_MOSSY(new ItemStack(Blocks.stonebrick, 1, 1)), + BRICK_CRACKED(new ItemStack(Blocks.stonebrick, 1, 2)), + BRICK(new ItemStack(Blocks.brick_block)), + SANDSTONE_SMOOTH(new ItemStack(Blocks.sandstone, 1, 2)), + SANDSTONE_CHISELED(new ItemStack(Blocks.sandstone, 1, 1)), + BRICK_NETHER(new ItemStack(Blocks.nether_brick)), + BRICK_CHISELED(new ItemStack(Blocks.stonebrick, 1, 3)), + QUARTZ(new ItemStack(Blocks.quartz_block, 1, 0)), + QUARTZ_CHISELED(new ItemStack(Blocks.quartz_block, 1, 1)), + QUARTZ_LINES(new ItemStack(Blocks.quartz_block, 1, 2)); + + @SideOnly(Side.CLIENT) + private static List icons; + + @SideOnly(Side.CLIENT) + public static void registerIcons(IIconRegister register) { + TextureManager textureManager = TextureManager.getInstance(); + icons = Arrays.asList( + textureManager.registerTex(register, "farm/plain"), + textureManager.registerTex(register, "farm/reverse"), + textureManager.registerTex(register, "farm/top"), + textureManager.registerTex(register, "farm/band"), + textureManager.registerTex(register, "farm/gears"), + textureManager.registerTex(register, "farm/hatch"), + textureManager.registerTex(register, "farm/valve"), + textureManager.registerTex(register, "farm/control") + ); + } + + private final ItemStack base; + + private EnumFarmBlock(ItemStack base) { + this.base = base; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int type) { + return icons.get(type); + } + + public void saveToCompound(NBTTagCompound compound) { + compound.setInteger("FarmBlock", this.ordinal()); + } + + public String getName() { + return base.getItem().getItemStackDisplayName(base); + } + + public ItemStack getBase() { + return base; + } + + public static EnumFarmBlock getFromCompound(NBTTagCompound compound) { + + if (compound != null) { + int farmBlockOrdinal = compound.getInteger("FarmBlock"); + if (farmBlockOrdinal < EnumFarmBlock.values().length) + return EnumFarmBlock.values()[farmBlockOrdinal]; + } + + return EnumFarmBlock.BRICK_STONE; + } +} diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 448e669ae..c25af5085 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -10,8 +10,16 @@ ******************************************************************************/ package forestry.farming.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ForestryAPI; import forestry.api.core.IStructureLogic; import forestry.api.core.ITileStructure; @@ -22,16 +30,6 @@ import forestry.core.gadgets.TileForestry; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; public abstract class TileFarm extends TileForestry implements IFarmComponent { @@ -44,74 +42,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { public static final int TYPE_VALVE = 6; public static final int TYPE_CONTROL = 7; - public enum EnumFarmBlock { - - BRICK_STONE(new ItemStack(Blocks.stonebrick, 1, 0)), - BRICK_MOSSY(new ItemStack(Blocks.stonebrick, 1, 1)), - BRICK_CRACKED(new ItemStack(Blocks.stonebrick, 1, 2)), - BRICK(new ItemStack(Blocks.brick_block)), - SANDSTONE_SMOOTH(new ItemStack(Blocks.sandstone, 1, 2)), - SANDSTONE_CHISELED(new ItemStack(Blocks.sandstone, 1, 1)), - BRICK_NETHER(new ItemStack(Blocks.nether_brick)), - BRICK_CHISELED(new ItemStack(Blocks.stonebrick, 1, 3)), - QUARTZ(new ItemStack(Blocks.quartz_block, 1, 0)), - QUARTZ_CHISELED(new ItemStack(Blocks.quartz_block, 1, 1)), - QUARTZ_LINES(new ItemStack(Blocks.quartz_block, 1, 2)); - public final ItemStack base; - - private EnumFarmBlock(ItemStack base) { - this.base = base; - } - @SideOnly(Side.CLIENT) - private static IIcon[] icons; - - @SideOnly(Side.CLIENT) - public static void registerIcons(IIconRegister register) { - - icons = new IIcon[8]; - // for(int i = 0; i < values().length; i++) { - // generateTexturesIfNeeded(values()[i]); - - icons[0] = TextureManager.getInstance().registerTex(register, "farm/plain"); - icons[1] = TextureManager.getInstance().registerTex(register, "farm/reverse"); - icons[2] = TextureManager.getInstance().registerTex(register, "farm/top"); - icons[3] = TextureManager.getInstance().registerTex(register, "farm/band"); - icons[4] = TextureManager.getInstance().registerTex(register, "farm/gears"); - icons[5] = TextureManager.getInstance().registerTex(register, "farm/hatch"); - icons[6] = TextureManager.getInstance().registerTex(register, "farm/valve"); - icons[7] = TextureManager.getInstance().registerTex(register, "farm/control"); - // } - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int type) { - return icons[type]; - } - - public void saveToCompound(NBTTagCompound compound) { - compound.setInteger("FarmBlock", this.ordinal()); - } - - public String getName() { - return base.getItem().getItemStackDisplayName(base); - } - - public ItemStack getCraftingIngredient() { - return base; - } - - public static EnumFarmBlock getFromCompound(NBTTagCompound compound) { - - if (compound != null) { - int farmBlockOrdinal = compound.getInteger("FarmBlock"); - if (farmBlockOrdinal < EnumFarmBlock.values().length) - return EnumFarmBlock.values()[farmBlockOrdinal]; - } - - return EnumFarmBlock.BRICK_STONE; - } - } - public TileFarm() { this.structureLogic = Farmables.farmInterface.createFarmStructureLogic(this); } diff --git a/src/main/java/forestry/farming/items/ItemFarmBlock.java b/src/main/java/forestry/farming/items/ItemFarmBlock.java index 09ceb6b7b..c3919e267 100755 --- a/src/main/java/forestry/farming/items/ItemFarmBlock.java +++ b/src/main/java/forestry/farming/items/ItemFarmBlock.java @@ -10,14 +10,16 @@ ******************************************************************************/ package forestry.farming.items; -import forestry.core.gadgets.IStructureBlockItem; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import forestry.core.gadgets.IStructureBlockItem; +import forestry.farming.gadgets.EnumFarmBlock; + public class ItemFarmBlock extends ItemBlock implements IStructureBlockItem { public ItemFarmBlock(Block block) { diff --git a/src/main/java/forestry/farming/render/FarmItemRenderer.java b/src/main/java/forestry/farming/render/FarmItemRenderer.java index 215a346a2..f5b8898e0 100755 --- a/src/main/java/forestry/farming/render/FarmItemRenderer.java +++ b/src/main/java/forestry/farming/render/FarmItemRenderer.java @@ -10,15 +10,18 @@ ******************************************************************************/ package forestry.farming.render; -import forestry.core.utils.StackUtils; -import forestry.farming.gadgets.BlockFarm; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; + import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import forestry.core.utils.StackUtils; +import forestry.farming.gadgets.BlockFarm; +import forestry.farming.gadgets.EnumFarmBlock; + public class FarmItemRenderer implements IItemRenderer { private void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 12c8782c2..885eedc0b 100755 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -10,11 +10,23 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.MinecraftForge; + import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitLayout; import forestry.api.farming.Farmables; @@ -35,8 +47,8 @@ import forestry.farming.GuiHandlerFarming; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.gadgets.BlockFarm; import forestry.farming.gadgets.BlockMushroom; +import forestry.farming.gadgets.EnumFarmBlock; import forestry.farming.gadgets.TileControl; -import forestry.farming.gadgets.TileFarm.EnumFarmBlock; import forestry.farming.gadgets.TileFarmPlain; import forestry.farming.gadgets.TileGearbox; import forestry.farming.gadgets.TileHatch; @@ -62,14 +74,6 @@ import forestry.farming.logic.FarmableVanillaSapling; import forestry.farming.logic.FarmableVanillaShroom; import forestry.farming.proxy.ProxyFarming; import forestry.farming.triggers.FarmingTriggers; -import java.util.ArrayList; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.MinecraftForge; @Plugin(pluginID = "Farming", name = "Farming", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.farming.description") public class PluginFarming extends ForestryPlugin { @@ -294,8 +298,7 @@ public class PluginFarming extends ForestryPlugin { block.saveToCompound(compound); basic.setTagCompound((NBTTagCompound) compound.copy()); - ShapedRecipeCustom.buildRecipe(basic.copy(), "I#I", "WCW", '#', block.getCraftingIngredient(), 'W', "slabWood", 'C', ForestryItem.tubes.getItemStack(1, 1), 'I', "ingotCopper"); - + ShapedRecipeCustom.buildRecipe(basic.copy(), "I#I", "WCW", '#', block.getBase(), 'W', "slabWood", 'C', ForestryItem.tubes.getItemStack(1, 1), 'I', "ingotCopper"); } ItemStack gearbox = ForestryBlock.farm.getItemStack(1, 2); From 8d5b19787e7f8d250a4d3190cd2b7fe2db6b4800 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 15:56:51 -0800 Subject: [PATCH 081/175] Fix #388 Multifarm not loading its inventory --- src/main/java/forestry/farming/gadgets/TileFarm.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index c25af5085..00af4add6 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -58,8 +58,6 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - this.isMaster = nbttagcompound.getBoolean("IsMaster"); this.masterX = nbttagcompound.getInteger("MasterX"); this.masterY = nbttagcompound.getInteger("MasterY"); @@ -72,6 +70,8 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { makeMaster(); structureLogic.readFromNBT(nbttagcompound); + + super.readFromNBT(nbttagcompound); } @Override From 4432b0dac4744acb2131bec1df107165f5b6f20e Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 21:16:55 -0800 Subject: [PATCH 082/175] Fix #395 Crashes without BuildCraft --- src/main/java/buildcraft/LICENSE-API | 21 +++++ .../buildcraft/api/tools/IToolWrench.java | 40 +++++++++ .../buildcraft/api/tools/package-info.java | 11 +++ .../inventory/AdjacentInventoryCache.java | 16 +++- .../forestry/core/inventory/InvTools.java | 71 ++++++++++------ .../java/forestry/core/utils/BlockUtil.java | 81 ------------------- .../forestry/energy/gadgets/EngineCopper.java | 73 ++++++++--------- .../energy/gadgets/EngineDefinition.java | 2 +- .../forestry/farming/gadgets/TileHatch.java | 10 +-- 9 files changed, 173 insertions(+), 152 deletions(-) create mode 100644 src/main/java/buildcraft/LICENSE-API create mode 100644 src/main/java/buildcraft/api/tools/IToolWrench.java create mode 100644 src/main/java/buildcraft/api/tools/package-info.java diff --git a/src/main/java/buildcraft/LICENSE-API b/src/main/java/buildcraft/LICENSE-API new file mode 100644 index 000000000..95f750db0 --- /dev/null +++ b/src/main/java/buildcraft/LICENSE-API @@ -0,0 +1,21 @@ +BuildCraft API License + +Copyright (c) 2011-2014 SpaceToad and the BuildCraft team + +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. diff --git a/src/main/java/buildcraft/api/tools/IToolWrench.java b/src/main/java/buildcraft/api/tools/IToolWrench.java new file mode 100644 index 000000000..517f3e79b --- /dev/null +++ b/src/main/java/buildcraft/api/tools/IToolWrench.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. + * Please check the contents of the license, which should be located + * as "LICENSE.API" in the BuildCraft source code distribution. + */ +package buildcraft.api.tools; + +import net.minecraft.entity.player.EntityPlayer; + +/*** + * Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft + */ +public interface IToolWrench { + + /*** + * Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem() + * + * @param player + * - The player doing the wrenching + * @param x + * ,y,z - The coordinates for the block being wrenched + * + * @return true if wrenching is allowed, false if not + */ + boolean canWrench(EntityPlayer player, int x, int y, int z); + + /*** + * Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get the ItemStack that was used, check + * player.inventory.getCurrentItem() + * + * @param player + * - The player doing the wrenching + * @param x + * ,y,z - The coordinates of the block being wrenched + */ + void wrenchUsed(EntityPlayer player, int x, int y, int z); +} diff --git a/src/main/java/buildcraft/api/tools/package-info.java b/src/main/java/buildcraft/api/tools/package-info.java new file mode 100644 index 000000000..9c131641e --- /dev/null +++ b/src/main/java/buildcraft/api/tools/package-info.java @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. + * Please check the contents of the license, which should be located + * as "LICENSE.API" in the BuildCraft source code distribution. + */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools") +package buildcraft.api.tools; +import cpw.mods.fml.common.API; diff --git a/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java index d77b7695f..da1a14afb 100644 --- a/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java +++ b/src/main/java/forestry/core/inventory/AdjacentInventoryCache.java @@ -10,12 +10,20 @@ ******************************************************************************/ package forestry.core.inventory; -import forestry.core.utils.AdjacentTileCache; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; +import forestry.core.utils.AdjacentTileCache; + /** * * @author CovertJaguar @@ -40,12 +48,12 @@ public final class AdjacentInventoryCache implements AdjacentTileCache.ICacheLis cache.addListener(this); } - public IInventory getAdjecentInventory(ForgeDirection side) { + public IInventory getAdjacentInventory(ForgeDirection side) { checkChanged(); return sides[side.ordinal()]; } - public Collection getAdjecentInventories() { + public Collection getAdjacentInventories() { checkChanged(); return invs; } diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index b1e35ae12..5cdad4e87 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -10,8 +10,31 @@ ******************************************************************************/ package forestry.core.inventory; -import buildcraft.api.transport.IPipeTile; -import buildcraft.api.transport.PipeManager; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.oredict.OreDictionary; + +import cpw.mods.fml.common.Optional; + import forestry.core.inventory.filters.ArrayStackFilter; import forestry.core.inventory.filters.IStackFilter; import forestry.core.inventory.filters.InvertedStackFilter; @@ -25,26 +48,10 @@ import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.PlainInventory; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.oredict.OreDictionary; +import forestry.plugins.PluginManager; + +import buildcraft.api.transport.IPipeTile; +import buildcraft.api.transport.PipeManager; public abstract class InvTools { @@ -144,8 +151,10 @@ public abstract class InvTools { if (tile == null || !(tile instanceof IInventory)) return null; - if (!PipeManager.canExtractItems(null, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)) - return null; + if (PluginManager.Module.BUILDCRAFT_TRANSPORT.isEnabled()) { + if(!internal_canExtractFromBuildCraftPipe(tile)) + return null; + } if (tile instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) tile; @@ -154,6 +163,11 @@ public abstract class InvTools { return getInventory((IInventory) tile, side); } + @Optional.Method(modid = "BuildCraftAPI|transport") + private static boolean internal_canExtractFromBuildCraftPipe(TileEntity tile) { + return PipeManager.canExtractItems(null, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); + } + public static IInventory getInventory(IInventory inv, ForgeDirection side) { if (inv == null) return null; @@ -741,6 +755,15 @@ public abstract class InvTools { * @return true if an item was inserted, otherwise false. */ public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + if (PluginManager.Module.BUILDCRAFT_TRANSPORT.isEnabled()) { + return internal_moveOneItemToPipe(source, tileCache); + } + + return false; + } + + @Optional.Method(modid = "BuildCraftAPI|transport") + private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { IInventory invClone = new InventoryCopy(source); ItemStack stackToMove = removeOneItem(invClone); if (stackToMove == null) diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index d45c7accc..a4971a0e5 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -11,8 +11,6 @@ package forestry.core.utils; import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; @@ -28,11 +26,6 @@ import net.minecraftforge.common.util.ForgeDirection; import forestry.core.config.Defaults; import forestry.core.vect.Vect; -import buildcraft.api.core.Position; -import buildcraft.api.transport.IPipeConnection; -import buildcraft.api.transport.IPipeConnection.ConnectOverride; -import buildcraft.api.transport.IPipeTile; -import buildcraft.api.transport.IPipeTile.PipeType; import cofh.api.energy.IEnergyHandler; public class BlockUtil { @@ -45,80 +38,6 @@ public class BlockUtil { } - /** - * Returns a list of adjacent pipes. - */ - public static ForgeDirection[] getPipeDirections(World world, Vect blockPos, ForgeDirection from) { - LinkedList possiblePipes = new LinkedList(); - - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if (from != ForgeDirection.UNKNOWN && from != dir.getOpposite()) - continue; - - Position posPipe = new Position(blockPos.x, blockPos.y, blockPos.z, dir); - posPipe.moveForwards(1.0); - - TileEntity pipeEntry = world.getTileEntity((int) posPipe.x, (int) posPipe.y, (int) posPipe.z); - - if (pipeEntry instanceof IPipeTile) { - IPipeTile pipe = (IPipeTile) pipeEntry; - - if (from != ForgeDirection.UNKNOWN && pipeEntry instanceof IPipeConnection) { - if (((IPipeConnection) pipeEntry).overridePipeConnection(PipeType.ITEM, from) != ConnectOverride.DISCONNECT) - possiblePipes.add(dir); - } else if (pipe.getPipeType() == PipeType.ITEM && pipe.isPipeConnected(dir.getOpposite())) - possiblePipes.add(dir); - } - } - - return possiblePipes.toArray(new ForgeDirection[possiblePipes.size()]); - - } - - public static ArrayList filterPipeDirections(ForgeDirection[] allDirections, ForgeDirection[] exclude) { - ArrayList filtered = new ArrayList(); - ArrayList excludeList = new ArrayList(Arrays.asList(exclude)); - - for (ForgeDirection direction : allDirections) { - if (!excludeList.contains(direction)) - filtered.add(direction); - } - - return filtered; - - } - - public static boolean putFromStackIntoPipe(TileEntity tile, ArrayList pipes, ItemStack stack) { - - if (stack == null) - return false; - if (stack.stackSize <= 0) - return false; - if (pipes.size() <= 0) - return false; - - int choice = tile.getWorldObj().rand.nextInt(pipes.size()); - Position itemPos = new Position(tile.xCoord, tile.yCoord, tile.zCoord, pipes.get(choice)); - - itemPos.x += 0.5; - itemPos.y += 0.25; - itemPos.z += 0.5; - itemPos.moveForwards(0.5); - - Position pipePos = new Position(tile.xCoord, tile.yCoord, tile.zCoord, pipes.get(choice)); - pipePos.moveForwards(1.0); - - IPipeTile pipe = (IPipeTile) tile.getWorldObj().getTileEntity((int) pipePos.x, (int) pipePos.y, (int) pipePos.z); - - ItemStack payload = stack.splitStack(1); - if (pipe.injectItem(payload, true, itemPos.orientation.getOpposite()) > 0) - return true; - else - pipes.remove(choice); - - return false; - } - public static boolean isRFTile(ForgeDirection side, TileEntity tile) { if (tile == null) return false; diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 2d805666f..2afdfc453 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -10,9 +10,24 @@ ******************************************************************************/ package forestry.energy.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.registry.GameData; + import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.core.EnumErrorCode; @@ -22,22 +37,14 @@ import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; +import forestry.core.inventory.AdjacentInventoryCache; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; -import forestry.core.utils.BlockUtil; import forestry.factory.triggers.FactoryTriggers; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.ITriggerExternal; public class EngineCopper extends Engine implements ISidedInventory { @@ -53,6 +60,7 @@ public class EngineCopper extends Engine implements ISidedInventory { private int totalBurnTime; private int ashProduction; private final int ashForItem; + private final AdjacentInventoryCache inventoryCache = new AdjacentInventoryCache(this, getTileCache()); public EngineCopper() { super(Defaults.ENGINE_COPPER_HEAT_MAX, 200000, 4000); @@ -97,9 +105,11 @@ public class EngineCopper extends Engine implements ISidedInventory { public void updateServerSide() { super.updateServerSide(); - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 40 != 0) return; + dumpStash(); + if (mayBurn() && burnTime > 0) { setErrorState(EnumErrorCode.OK); return; @@ -217,31 +227,22 @@ public class EngineCopper extends Engine implements ISidedInventory { return 0; } - private void dumpStash() { - ForgeDirection[] pipes = BlockUtil.getPipeDirections(worldObj, Coords(), ForgeDirection.UNKNOWN); + /* AUTO-EJECTING */ + private IInventory getWasteInventory() { + TileInventoryAdapter inventory = getInternalInventory(); + if (inventory == null) + return null; - if (pipes.length > 0) - dumpToPipe(pipes); + return new InventoryMapper(inventory, SLOT_WASTE_1, SLOT_WASTE_COUNT); } - private void dumpToPipe(ForgeDirection[] pipes) { - TileInventoryAdapter inventory = getInternalInventory(); - for (int i = SLOT_WASTE_1; i < SLOT_WASTE_1 + SLOT_WASTE_COUNT; i++) { - if (inventory.getStackInSlot(i) == null) - continue; - if (inventory.getStackInSlot(i).stackSize <= 0) - continue; + private void dumpStash() { + IInventory wasteInventory = getWasteInventory(); + if (wasteInventory == null) + return; - ArrayList filtered; - filtered = BlockUtil.filterPipeDirections(pipes, new ForgeDirection[]{getOrientation()}); - - while (inventory.getStackInSlot(i).stackSize > 0 && filtered.size() > 0) { - BlockUtil.putFromStackIntoPipe(this, filtered, inventory.getStackInSlot(i)); - } - - if (inventory.getStackInSlot(i).stackSize <= 0) - inventory.setInventorySlotContents(i, null); - } + if (!InvTools.moveOneItemToPipe(wasteInventory, tileCache)) + InvTools.moveItemStack(wasteInventory, inventoryCache.getAdjacentInventories()); } // / STATE INFORMATION diff --git a/src/main/java/forestry/energy/gadgets/EngineDefinition.java b/src/main/java/forestry/energy/gadgets/EngineDefinition.java index f91f18890..db9f4f0fa 100755 --- a/src/main/java/forestry/energy/gadgets/EngineDefinition.java +++ b/src/main/java/forestry/energy/gadgets/EngineDefinition.java @@ -42,7 +42,7 @@ public class EngineDefinition extends MachineDefinition { return false; Engine tile = (Engine) world.getTileEntity(x, y, z); - if (player.getCurrentEquippedItem() != null && Utils.canWrench(player, x, y, z)) { + if (Utils.canWrench(player, x, y, z)) { tile.rotateEngine(); Utils.useWrench(player, x, y, z); return true; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 5d6820471..52a456e57 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -66,14 +66,12 @@ public class TileHatch extends TileFarm implements ISidedInventory { } protected void dumpStash() { - - if (!hasMaster()) + IInventory productInventory = getProductInventory(); + if (productInventory == null) return; - if (!InvTools.moveOneItemToPipe(getProductInventory(), tileCache)) { - IInventory struct = getStructureInventory(); - if (struct != null) - InvTools.moveItemStack(getProductInventory(), inventoryCache.getAdjecentInventories()); + if (!InvTools.moveOneItemToPipe(productInventory, tileCache)) { + InvTools.moveItemStack(productInventory, inventoryCache.getAdjacentInventories()); } } From eb20049b6d21a2493a4bff962a49ca7d5403a302 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Dec 2014 21:39:32 -0800 Subject: [PATCH 083/175] Fix #391 Some inventory slots have Xs when they're empty --- src/main/java/forestry/core/gui/slots/SlotCustom.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/core/gui/slots/SlotCustom.java b/src/main/java/forestry/core/gui/slots/SlotCustom.java index 50ce36767..24fc06233 100755 --- a/src/main/java/forestry/core/gui/slots/SlotCustom.java +++ b/src/main/java/forestry/core/gui/slots/SlotCustom.java @@ -129,7 +129,8 @@ public class SlotCustom extends SlotForestry { @SideOnly(Side.CLIENT) @Override public IIcon getBackgroundIconIndex() { - if (!inventory.isItemValidForSlot(getSlotIndex(), null)) + ItemStack stack = getStack(); + if (stack != null && !inventory.isItemValidForSlot(getSlotIndex(), stack)) return TextureManager.getInstance().getDefault(blockedTexture); else return null; From 43bd2763899286767177441dcd96b1b7465ab9d7 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 23 Dec 2014 01:16:29 -0800 Subject: [PATCH 084/175] Close #390 Forestry Fluids should have FluidBlocks --- lang | 2 +- src/main/java/forestry/Forestry.java | 40 ++- .../java/forestry/core/EventHandlerCore.java | 20 +- src/main/java/forestry/core/ForestryCore.java | 80 +---- .../java/forestry/core/config/Config.java | 111 +++--- .../forestry/core/config/Configuration.java | 2 +- .../forestry/core/config/ForestryItem.java | 34 +- .../core/fluids/BlockForestryFluid.java | 250 ++++++++++++++ .../java/forestry/core/fluids/Fluids.java | 27 +- .../forestry/core/fluids/ForestryFluids.java | 317 ++++++++++++++++++ .../core/items/ItemLiquidContainer.java | 135 +++++++- .../java/forestry/core/proxy/ProxyCommon.java | 6 + .../render/EntityColoredDropParticleFX.java | 84 +++++ .../forestry/core/render/TextureManager.java | 11 +- .../forestry/core/utils/LiquidHelper.java | 36 +- .../java/forestry/core/utils/Schemata.java | 2 +- .../plugins/PluginBuildCraftFuels.java | 55 ++- .../java/forestry/plugins/PluginCore.java | 113 ++++--- .../java/forestry/plugins/PluginFood.java | 1 - .../{bioethanol.png => bioethanol_still.png} | Bin ...png.mcmeta => bioethanol_still.png.mcmeta} | 0 .../textures/blocks/liquid/biomass.png | Bin 4876 -> 0 bytes .../textures/blocks/liquid/biomass_still.png | Bin 0 -> 9753 bytes ...ss.png.mcmeta => biomass_still.png.mcmeta} | 0 .../blocks/liquid/for.honey_still.png | Bin 0 -> 3816 bytes ....png.mcmeta => for.honey_still.png.mcmeta} | 0 .../liquid/{glass.png => glass_still.png} | Bin ...oney.png.mcmeta => glass_still.png.mcmeta} | 0 .../forestry/textures/blocks/liquid/honey.png | Bin 4047 -> 0 bytes .../forestry/textures/blocks/liquid/ice.png | Bin 4982 -> 0 bytes .../textures/blocks/liquid/ice_still.png | Bin 0 -> 3792 bytes .../{ice.png.mcmeta => ice_still.png.mcmeta} | 0 .../forestry/textures/blocks/liquid/juice.png | Bin 4859 -> 0 bytes .../textures/blocks/liquid/juice_still.png | Bin 0 -> 3282 bytes ...uice.png.mcmeta => juice_still.png.mcmeta} | 0 .../liquid/{milk.png => milk_still.png} | Bin .../liquid/{seedoil.png => seedoil_still.png} | Bin ...il.png.mcmeta => seedoil_still.png.mcmeta} | 0 .../textures/blocks/liquid/short.mead.png | Bin 5000 -> 0 bytes .../blocks/liquid/short.mead_still.png | Bin 0 -> 6923 bytes ...png.mcmeta => short.mead_still.png.mcmeta} | 0 41 files changed, 1090 insertions(+), 236 deletions(-) create mode 100644 src/main/java/forestry/core/fluids/BlockForestryFluid.java create mode 100644 src/main/java/forestry/core/fluids/ForestryFluids.java create mode 100644 src/main/java/forestry/core/render/EntityColoredDropParticleFX.java rename src/main/resources/assets/forestry/textures/blocks/liquid/{bioethanol.png => bioethanol_still.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{bioethanol.png.mcmeta => bioethanol_still.png.mcmeta} (100%) mode change 100755 => 100644 delete mode 100755 src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png rename src/main/resources/assets/forestry/textures/blocks/liquid/{biomass.png.mcmeta => biomass_still.png.mcmeta} (100%) mode change 100755 => 100644 create mode 100644 src/main/resources/assets/forestry/textures/blocks/liquid/for.honey_still.png rename src/main/resources/assets/forestry/textures/blocks/liquid/{glass.png.mcmeta => for.honey_still.png.mcmeta} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{glass.png => glass_still.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{honey.png.mcmeta => glass_still.png.mcmeta} (100%) mode change 100755 => 100644 delete mode 100755 src/main/resources/assets/forestry/textures/blocks/liquid/honey.png delete mode 100755 src/main/resources/assets/forestry/textures/blocks/liquid/ice.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png rename src/main/resources/assets/forestry/textures/blocks/liquid/{ice.png.mcmeta => ice_still.png.mcmeta} (100%) mode change 100755 => 100644 delete mode 100755 src/main/resources/assets/forestry/textures/blocks/liquid/juice.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png rename src/main/resources/assets/forestry/textures/blocks/liquid/{juice.png.mcmeta => juice_still.png.mcmeta} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{milk.png => milk_still.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{seedoil.png => seedoil_still.png} (100%) mode change 100755 => 100644 rename src/main/resources/assets/forestry/textures/blocks/liquid/{seedoil.png.mcmeta => seedoil_still.png.mcmeta} (100%) mode change 100755 => 100644 delete mode 100755 src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png rename src/main/resources/assets/forestry/textures/blocks/liquid/{short.mead.png.mcmeta => short.mead_still.png.mcmeta} (100%) mode change 100755 => 100644 diff --git a/lang b/lang index ab16b1a2e..05bee96e8 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit ab16b1a2efc80aa48e70d81c8859fd83e143a98f +Subproject commit 05bee96e8aa617756ab7445cf32163a901c82028 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 9661e460e..9d42c573b 100755 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -39,6 +39,9 @@ import forestry.core.utils.FluidMap; import forestry.core.utils.ItemStackMap; import forestry.core.utils.StringUtil; import java.io.File; +import java.util.HashMap; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -63,6 +66,22 @@ public class Forestry { public static Forestry instance; private File configFolder; + private static final Map mappedItems = new HashMap(); + + static { + mappedItems.put("Forestry:builderBackpack", ForestryItem.builderBackpack); + mappedItems.put("Forestry:builderBackpackT2", ForestryItem.builderBackpackT2); + mappedItems.put("Forestry:adventurerBackpack", ForestryItem.adventurerBackpack); + mappedItems.put("Forestry:adventurerBackpackT2", ForestryItem.adventurerBackpackT2); + mappedItems.put("Forestry:shortMead", ForestryItem.beverage); + mappedItems.put("Forestry:waterCan", ForestryItem.canWater); + mappedItems.put("Forestry:biofuelCan", ForestryItem.canEthanol); + mappedItems.put("Forestry:biomassCan", ForestryItem.canBiomass); + mappedItems.put("Forestry:bucketBiofuel", ForestryItem.bucketEthanol); + mappedItems.put("Forestry:refractoryBiofuel", ForestryItem.refractoryEthanol); + mappedItems.put("Forestry:waxCapsuleBiofuel", ForestryItem.waxCapsuleEthanol); + } + public Forestry() { FuelManager.fermenterFuel = new ItemStackMap(); FuelManager.moistenerResource = new ItemStackMap(); @@ -129,21 +148,12 @@ public class Forestry { if (block != null) { mapping.remap(Item.getItemFromBlock(block)); Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block)); - } else if (mapping.name.equals("Forestry:builderBackpack")) { - mapping.remap(ForestryItem.builderBackpack.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpack.name()); - } else if (mapping.name.equals("Forestry:builderBackpackT2")) { - mapping.remap(ForestryItem.builderBackpackT2.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpackT2.name()); - } else if (mapping.name.equals("Forestry:adventurerBackpack")) { - mapping.remap(ForestryItem.adventurerBackpack.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpack.name()); - } else if (mapping.name.equals("Forestry:adventurerBackpackT2")) { - mapping.remap(ForestryItem.adventurerBackpackT2.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpackT2.name()); - } else if (mapping.name.equals("Forestry:shortMead")) { - mapping.remap(ForestryItem.beverage.item()); - Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.beverage.name()); + } else { + ForestryItem mappedItem = mappedItems.get(mapping.name); + if (mappedItem != null) { + mapping.remap(mappedItem.item()); + Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name()); + } } } } diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index dd5caadce..465fb4752 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -10,22 +10,25 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ErrorStateRegistry; -import forestry.core.fluids.Fluids; +import forestry.core.fluids.ForestryFluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.render.TextureManager; import forestry.plugins.PluginManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.oredict.OreDictionary; public class EventHandlerCore { @@ -86,8 +89,9 @@ public class EventHandlerCore { if(event.map.getTextureType() == 1) { ErrorStateRegistry.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); - } else if(event.map.getTextureType() == 0) - Fluids.resetFluidIcons(event.map); + } else if(event.map.getTextureType() == 0) { + ForestryFluids.resetFluidIcons(event.map); + } } @SubscribeEvent diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index 12da31df3..bec6868b0 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -11,10 +11,21 @@ package forestry.core; import com.google.common.collect.ImmutableList; + +import java.io.File; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; + +import net.minecraftforge.common.MinecraftForge; + import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; + import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; @@ -34,12 +45,6 @@ import forestry.core.gadgets.TileMill; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; import forestry.plugins.PluginManager; -import java.io.File; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraftforge.common.MinecraftForge; public class ForestryCore { @@ -61,7 +66,6 @@ public class ForestryCore { public void init(Object basemod) { - // Register Liquids & Containers registerLiquidContainers(); // Register world generator @@ -123,7 +127,6 @@ public class ForestryCore { } public void postInit() { - PluginManager.runPostInit(); Proxies.common.registerTickHandlers(); @@ -144,61 +147,14 @@ public class ForestryCore { return "after:mod_IC2;after:mod_BuildCraftCore;after:mod_BuildCraftEnergy;after:mod_BuildCraftFactory;after:mod_BuildCraftSilicon;after:mod_BuildCraftTransport;after:mod_RedPowerWorld"; } + /** Set containers for vanilla liquids */ private void registerLiquidContainers() { - // Add lava and water buckets to the API in case this has not been done yet. - if (LiquidHelper.isEmptyLiquidData()) { - LiquidHelper.injectLiquidContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, new ItemStack(Items.lava_bucket), new ItemStack(Items.bucket)); - LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.water_bucket), new ItemStack(Items.bucket)); - } - - // Glass - Fluids.GLASS.register(); - - // Set default lava, water and biofuel buckets - Fluids.MILK.register(); - LiquidHelper.injectLiquidContainer(Fluids.MILK, Defaults.BUCKET_VOLUME, new ItemStack(Items.milk_bucket), new ItemStack(Items.bucket)); - - // Lava - LiquidHelper.injectTinContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.canLava.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.LAVA, Defaults.BUCKET_VOLUME, ForestryItem.refractoryLava.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - // Water - LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.glass_bottle)); - LiquidHelper.injectTinContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.canWater.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleWater.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, ForestryItem.refractoryWater.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.BIOMASS.register(); - LiquidHelper.injectLiquidContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiomass.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.canBiomass.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiomass.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.BIOMASS, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiomass.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.BIOETHANOL.register(); - LiquidHelper.injectLiquidContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.bucketBiofuel.getItemStack(), new ItemStack(Items.bucket)); - LiquidHelper.injectTinContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.canBiofuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleBiofuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.BIOETHANOL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryBiofuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.SEEDOIL.register(); - LiquidHelper.injectTinContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.canSeedOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleSeedOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.SEEDOIL, Defaults.BUCKET_VOLUME, ForestryItem.refractorySeedOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.HONEY.register(); - LiquidHelper.injectTinContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.canHoney.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleHoney.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.HONEY, Defaults.BUCKET_VOLUME, ForestryItem.refractoryHoney.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.JUICE.register(); - LiquidHelper.injectTinContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.canJuice.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleJuice.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.JUICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryJuice.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - - Fluids.ICE.register(); - LiquidHelper.injectTinContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.canIce.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleIce.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.ICE, Defaults.BUCKET_VOLUME, ForestryItem.refractoryIce.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.canLava.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.refractoryLava.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem), new ItemStack(Items.glass_bottle)); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.canWater.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.waxCapsuleWater.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.refractoryWater.getItemStack()); } } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index b022d4804..e66da0a98 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -19,20 +19,26 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import java.util.Properties; +import java.util.Set; +import forestry.core.fluids.ForestryFluids; import forestry.core.proxy.Proxies; public class Config { public static final String CATEGORY_COMMON = "common"; + public static final String CATEGORY_FLUIDS = "fluids"; public static final String CATEGORY_DEBUG = "debug"; public static Configuration config; public static String gameMode; - public static final HashSet disabledStructures = new HashSet(); + private static final Set disabledStructures = new HashSet(); + private static final Set disabledFluids = new HashSet(); + private static final Set disabledBlocks = new HashSet(); public static boolean isDebug = false; @@ -65,10 +71,6 @@ public class Config { private static boolean craftingBronzeEnabled = true; - public static boolean getCraftingBronzeEnabled() { - return craftingBronzeEnabled; - } - public static boolean craftingStampsEnabled = true; public static final ArrayList collectorStamps = new ArrayList(); @@ -82,6 +84,22 @@ public class Config { public static final HashMap hints = new HashMap(); public static boolean disableEnergyStat = false; + public static boolean isStructureEnabled(String uid) { + return !Config.disabledStructures.contains(uid); + } + + public static boolean isFluidEnabled(ForestryFluids fluids) { + return !Config.disabledFluids.contains(fluids.tag); + } + + public static boolean isBlockEnabled(String tag) { + return !Config.disabledBlocks.contains(tag); + } + + public static boolean isCraftingBronzeEnabled() { + return craftingBronzeEnabled; + } + public static void load() { setDebugMode(); @@ -96,35 +114,10 @@ public class Config { config.addPurge("buildcraft.ignore"); config.addPurge("power.framework"); - Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); - property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; - gameMode = property.value; + loadModes(); + loadFluids(); - property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); - property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; - boolean recreate = Boolean.parseBoolean(property.value); - - if (recreate) - Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); - - // Make sure the default mode files are there. - File easyMode = config.getCategoryFile("gamemodes/EASY"); - if (recreate) - CopyFileToFS(easyMode, "/config/forestry/gamemodes/EASY.conf"); - - File opMode = config.getCategoryFile("gamemodes/OP"); - if (!opMode.exists() || recreate) - CopyFileToFS(opMode, "/config/forestry/gamemodes/OP.conf"); - - File normalMode = config.getCategoryFile("gamemodes/NORMAL"); - if (!normalMode.exists() || recreate) - CopyFileToFS(normalMode, "/config/forestry/gamemodes/NORMAL.conf"); - - File hardMode = config.getCategoryFile("gamemodes/HARD"); - if (!hardMode.exists() || recreate) - CopyFileToFS(hardMode, "/config/forestry/gamemodes/HARD.conf"); - - config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); + Property property; Property particleFX = config.get("performance.particleFX.enabled", CATEGORY_COMMON, true); particleFX.comment = "set to false to disable particle fx on slower machines"; @@ -217,6 +210,53 @@ public class Config { loadHints(); } + private static void loadModes() { + Property property = config.get("difficulty.gamemode", CATEGORY_COMMON, "EASY"); + property.comment = "set to your preferred game mode. available modes are OP, EASY, NORMAL, HARD. mismatch with the server may cause visual glitches with recipes. setting an unavailable mode will create a new mode definition file."; + gameMode = property.value; + + property = config.get("difficulty.recreate.definitions", CATEGORY_COMMON, true); + property.comment = "set to true to force recreation of the game mode definitions in config/forestry/gamemodes"; + boolean recreate = Boolean.parseBoolean(property.value); + + if (recreate) + Proxies.log.info("Recreating all gamemode definitions from the defaults. This may be caused by an upgrade"); + + // Make sure the default mode files are there. + File easyMode = config.getCategoryFile("gamemodes/EASY"); + if (recreate) + CopyFileToFS(easyMode, "/config/forestry/gamemodes/EASY.conf"); + + File opMode = config.getCategoryFile("gamemodes/OP"); + if (!opMode.exists() || recreate) + CopyFileToFS(opMode, "/config/forestry/gamemodes/OP.conf"); + + File normalMode = config.getCategoryFile("gamemodes/NORMAL"); + if (!normalMode.exists() || recreate) + CopyFileToFS(normalMode, "/config/forestry/gamemodes/NORMAL.conf"); + + File hardMode = config.getCategoryFile("gamemodes/HARD"); + if (!hardMode.exists() || recreate) + CopyFileToFS(hardMode, "/config/forestry/gamemodes/HARD.conf"); + + config.set("difficulty.recreate.definitions", CATEGORY_COMMON, false); + } + + private static void loadFluids() { + Property property; + for (ForestryFluids fluid : ForestryFluids.values()) { + property = config.get("disable.fluid." + fluid.tag, CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the fluid for " + fluid.tag; + if (Boolean.parseBoolean(property.value)) + Config.disabledFluids.add(fluid.tag); + + property = config.get("disable.fluidBlock." + fluid.tag, CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the in-world FluidBlock for " + fluid.tag; + if (Boolean.parseBoolean(property.value)) + Config.disabledBlocks.add(fluid.tag); + } + } + private static void setDebugMode() { File debug = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/DEBUG.ON"); isDebug = debug.exists(); @@ -279,9 +319,4 @@ public class Config { else return list.split("[;]+"); } - - public static boolean getOrCreateBooleanProperty(String key, String kind, boolean defaults) { - return Boolean.parseBoolean(config.get(key, kind, defaults).value); - } - } diff --git a/src/main/java/forestry/core/config/Configuration.java b/src/main/java/forestry/core/config/Configuration.java index e9e6269e3..40d60d5b1 100755 --- a/src/main/java/forestry/core/config/Configuration.java +++ b/src/main/java/forestry/core/config/Configuration.java @@ -237,8 +237,8 @@ public class Configuration { writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine); writer.write("#" + newLine + "# Config files:" + newLine); - writer.write("# base.conf\t\t-\t Contains Forge configuration for block and item ids" + newLine); writer.write("# common.conf\t\t-\t Contains all options common to Forestry" + newLine); + writer.write("# fluids.conf\t\t-\t Contains all options for fluids" + newLine); writer.write("# apiculture.conf\t-\t Contains all options for bee breeding" + newLine); writer.write("# backpacks.conf\t-\t Contains custom configurations for backpacks" + newLine); writer.write("# pipes.conf\t\t-\t Configures item id for the apiarist's pipe" + newLine); diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 46465d42c..4e839aae8 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -10,10 +10,16 @@ ******************************************************************************/ package forestry.core.config; +import forestry.core.fluids.ForestryFluids; +import forestry.core.items.ItemLiquidContainer; import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; import forestry.plugins.PluginManager.Stage; + +import java.awt.Color; import java.util.EnumSet; + +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -42,7 +48,13 @@ public enum ForestryItem { wrench, pipette, bucketBiomass, - bucketBiofuel, + bucketEthanol, + bucketGlass, + bucketHoney, + bucketIce, + bucketJuice, + bucketSeedoil, + bucketShortMead, // Crafting impregnatedCasing, sturdyCasing, @@ -156,7 +168,7 @@ public enum ForestryItem { waxCapsule, waxCapsuleWater, waxCapsuleBiomass, - waxCapsuleBiofuel, + waxCapsuleEthanol, waxCapsuleOil, waxCapsuleFuel, waxCapsuleSeedOil, @@ -167,7 +179,7 @@ public enum ForestryItem { refractoryEmpty, refractoryWater, refractoryBiomass, - refractoryBiofuel, + refractoryEthanol, refractoryOil, refractoryFuel, refractoryLava, @@ -179,7 +191,7 @@ public enum ForestryItem { canWater, canEmpty, canBiomass, - canBiofuel, + canEthanol, canOil, canFuel, canLava, @@ -283,4 +295,18 @@ public enum ForestryItem { return null; return new ItemStack(item, qty, meta); } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid, int healAmount, float saturationModifier) { + ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()); + liquidContainer.setDrink(healAmount, saturationModifier); + registerItem(liquidContainer, toString()); + } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid) { + registerItem(new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()), toString()); + } + + public void registerContainer(ItemLiquidContainer.EnumContainerType type, Block block, Color color) { + registerItem(new ItemLiquidContainer(type, block, color), toString()); + } } diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java new file mode 100644 index 000000000..794459ff3 --- /dev/null +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -0,0 +1,250 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.awt.Color; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Defaults; +import forestry.core.render.EntityColoredDropParticleFX; +import forestry.core.render.TextureManager; + +public class BlockForestryFluid extends BlockFluidClassic { + + private final boolean flammable; + private final int flammability; + private final Color color; + + @SideOnly(Side.CLIENT) + private List icons; + + public BlockForestryFluid(ForestryFluids forestryFluid) { + this(forestryFluid, 0, false); + } + + public BlockForestryFluid(ForestryFluids forestryFluid, int flammability, boolean flammable) { + this(forestryFluid.standardFluid.get(), flammability, flammable, forestryFluid.getColor()); + } + + private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) { + super(fluid, Material.water); + + setDensity(fluid.getDensity()); + + this.flammability = flammability; + this.flammable = flammable; + + this.color = color; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) { + return true; + } + + @Override + public Fluid getFluid() { + return FluidRegistry.getFluid(fluidName); + } + + @Override + public IIcon getIcon(int side, int meta) { + if (side == 0 || side == 1 || this.icons.size() == 1) { + return this.icons.get(0); + } else { + return this.icons.get(1); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + + this.icons = new ArrayList(2); + + String still = "liquid/" + fluidName + "_still"; + this.icons.add(TextureManager.getInstance().registerTex(iconRegister, still)); + + if(flowTextureExists()) { + String flow = "liquid/" + fluidName + "_flow"; + this.icons.add(TextureManager.getInstance().registerTex(iconRegister, flow)); + } + } + + @SideOnly(Side.CLIENT) + public boolean flowTextureExists() { + try { + ResourceLocation resourceLocation = new ResourceLocation(Defaults.ID, "textures/blocks/liquid/" + fluidName + "_flow.png"); + IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); + return resourceManager.getResource(resourceLocation) != null; + } catch (java.lang.Exception e) { + return false; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand) { + if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { + double px = (double) ((float) x + rand.nextFloat()); + double py = (double) y - 1.05D; + double pz = (double) ((float) z + rand.nextFloat()); + + EntityFX fx = new EntityColoredDropParticleFX(world, px, py, pz, color.getRed(), color.getGreen(), color.getBlue()); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); + } + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 30 : 0; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammability; + } + + public boolean isFlammable(IBlockAccess world, int x, int y, int z) { + return flammable; + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable; + } + + @Override + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { + return flammable && flammability == 0; + } + + public Color getColor() { + return color; + } + + @Override + public Material getMaterial() { + // Fahrenheit 451 = 505.928 Kelvin + // The temperature at which book-paper catches fire, and burns. + if (temperature > 505) + return Material.lava; + else + return super.getMaterial(); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + super.updateTick(world, x, y, z, rand); + + // Start fires if the fluid is lava-like + if (getMaterial() == Material.lava) { + int rangeUp = rand.nextInt(3); + + for (int i = 0; i < rangeUp; ++i) { + x += rand.nextInt(3) - 1; + ++y; + z += rand.nextInt(3) - 1; + Block block = world.getBlock(x, y, z); + + if (block.getMaterial() == Material.air) { + if (isNeighborFlammable(world, x, y, z)) { + world.setBlock(x, y, z, Blocks.fire); + return; + } + } else if (block.getMaterial().blocksMovement()) { + return; + } + } + + if (rangeUp == 0) { + int startX = x; + int startZ = z; + + for (int i = 0; i < 3; ++i) { + x = startX + rand.nextInt(3) - 1; + z = startZ + rand.nextInt(3) - 1; + + if (world.isAirBlock(x, y + 1, z) && this.isFlammable(world, x, y, z)) { + world.setBlock(x, y + 1, z, Blocks.fire); + } + } + } + } + + // explode if very flammable and near fire + int flammability = getFlammability(world, x, y, z, ForgeDirection.UNKNOWN); + if (flammability > 0) { + // Explosion size is determined by flammability, up to size 4. + float explosionSize = 4F * flammability / 300F; + if (explosionSize > 1.0 && isNearFire(world, x, y, z)) { + world.setBlock(x, y, z, Blocks.fire); + world.newExplosion(null, x, y, z, explosionSize, true, true); + } + } + } + + private boolean isNeighborFlammable(World world, int x, int y, int z) { + return isFlammable(world, x - 1, y, z) || + isFlammable(world, x + 1, y, z) || + isFlammable(world, x, y, z - 1) || + isFlammable(world, x, y, z + 1) || + isFlammable(world, x, y - 1, z) || + isFlammable(world, x, y + 1, z); + } + + private boolean isNearFire(World world, int x, int y, int z) { + AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1); + return world.func_147470_e(boundingBox); + } +} diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 12040b03a..dcf17563a 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -10,13 +10,10 @@ ******************************************************************************/ package forestry.core.fluids; -import forestry.core.render.TextureManager; -import java.util.ArrayList; -import java.util.List; import java.util.Locale; -import net.minecraft.client.renderer.texture.IIconRegister; + import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -28,9 +25,7 @@ import net.minecraftforge.fluids.FluidStack; public enum Fluids { WATER, LAVA, FUEL, BIOMASS, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, - COAL, PYROTHEUM, HONEY, MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); - - private static final List myLiquids = new ArrayList(values().length); + COAL, PYROTHEUM, HONEY("for.honey"), MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); private final String tag; @@ -50,15 +45,6 @@ public enum Fluids { return FluidRegistry.getFluid(tag); } - public void register() { - Fluid fluid = get(); - if (fluid == null) { - fluid = new Fluid(tag); - FluidRegistry.registerFluid(fluid); - myLiquids.add(tag); - } - } - /** * Gets a FluidStack filled with mb milliBuckets worth of Fluid. */ @@ -84,12 +70,5 @@ public enum Fluids { return fluid == null && fluidStack == null; } - public static void resetFluidIcons(IIconRegister register) { - for (String fluidString : myLiquids) { - Fluid fluid = FluidRegistry.getFluid(fluidString); - IIcon icon = TextureManager.getInstance().registerTex(register, "liquid/" + fluid.getName()); - fluid.setIcons(icon); - } - } } diff --git a/src/main/java/forestry/core/fluids/ForestryFluids.java b/src/main/java/forestry/core/fluids/ForestryFluids.java new file mode 100644 index 000000000..aa0c0d31e --- /dev/null +++ b/src/main/java/forestry/core/fluids/ForestryFluids.java @@ -0,0 +1,317 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.awt.Color; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Config; +import forestry.core.config.ForestryItem; +import forestry.core.items.ItemLiquidContainer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.LiquidHelper; + +public enum ForestryFluids { + + ETHANOL(Fluids.BIOETHANOL, new Color(255, 111, 0), 790, 1000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 300, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketEthanol.getItemStack(), + ForestryItem.canEthanol.getItemStack(), + ForestryItem.waxCapsuleEthanol.getItemStack(), + ForestryItem.refractoryEthanol.getItemStack() + ); + } + }, + BIOMASS(Fluids.BIOMASS, new Color(100, 132, 41), 400, 6560) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 100, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketBiomass.getItemStack(), + ForestryItem.canBiomass.getItemStack(), + ForestryItem.waxCapsuleBiomass.getItemStack(), + ForestryItem.refractoryBiomass.getItemStack() + ); + } + }, + LIQUID_GLASS(Fluids.GLASS, new Color(164, 164, 164), 2400, 10000, 1200) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 0, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketGlass.getItemStack() + ); + } + }, + HONEY(Fluids.HONEY, new Color(255, 173, 31), 1420, 73600) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketHoney.getItemStack(), + ForestryItem.canHoney.getItemStack(), + ForestryItem.waxCapsuleHoney.getItemStack(), + ForestryItem.refractoryHoney.getItemStack() + ); + } + }, + ICE(Fluids.ICE, new Color(175, 242, 255), 920, 1000, 265) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketIce.getItemStack(), + ForestryItem.canIce.getItemStack(), + ForestryItem.waxCapsuleIce.getItemStack(), + ForestryItem.refractoryIce.getItemStack() + ); + } + }, + JUICE(Fluids.JUICE, new Color(168, 201, 114), 1000, 1000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketJuice.getItemStack(), + ForestryItem.canJuice.getItemStack(), + ForestryItem.waxCapsuleJuice.getItemStack(), + ForestryItem.refractoryJuice.getItemStack() + ); + } + }, + MILK(Fluids.MILK, new Color(255, 255, 255), 1030, 3000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + new ItemStack(Items.milk_bucket) + ); + } + }, + SEEDOIL(Fluids.SEEDOIL, new Color(255, 255, 168), 885, 5000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 2, true); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketSeedoil.getItemStack(), + ForestryItem.canSeedOil.getItemStack(), + ForestryItem.waxCapsuleSeedOil.getItemStack(), + ForestryItem.refractorySeedOil.getItemStack() + ); + } + }, + SHORT_MEAD(Fluids.SHORT_MEAD, new Color(239, 153, 0), 1000, 1200) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + @Override + List getFilledContainers() { + return Arrays.asList( + ForestryItem.bucketShortMead.getItemStack() + ); + } + }; + + public static final ForestryFluids[] VALUES = values(); + public final String tag; + public final Fluids standardFluid; + public final int density, viscosity, temperature; + private final Color color; + protected Fluid fluid; + protected Block fluidBlock; + + private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity) { + this(standardFluid, color, density, viscosity, 295); + } + + private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity, int temperature) { + this.tag = "fluid." + standardFluid.getTag(); + this.standardFluid = standardFluid; + this.color = color; + this.density = density; + this.viscosity = viscosity; + this.temperature = temperature; + } + + private void initFluid() { + if (fluid == null && Config.isFluidEnabled(this)) { + fluid = new Fluid(standardFluid.getTag()).setDensity(density).setViscosity(viscosity).setTemperature(temperature); + FluidRegistry.registerFluid(fluid); + initBlock(); + } + } + + List getFilledContainers() { + return Collections.emptyList(); + } + + abstract Block makeBlock(); + + private void initBlock() { + if (fluidBlock != null) + return; + + Fluid fluid = standardFluid.get(); + if (fluid == null) + return; + + fluidBlock = fluid.getBlock(); + + if (Config.isBlockEnabled(tag)) + if (fluidBlock == null) { + fluidBlock = makeBlock(); + fluidBlock.setBlockName("forestry." + tag); + Proxies.common.registerBlock(fluidBlock, ItemBlock.class); + } else { + GameRegistry.UniqueIdentifier blockID = GameRegistry.findUniqueIdentifierFor(fluidBlock); + Proxies.log.severe("Pre-existing {0} fluid block detected, deferring to {1}:{2}, " + + "this may cause issues if the server/client have different mod load orders, " + + "recommended that you disable all but one instance of {0} fluid blocks via your configs.", fluid.getName(), blockID.modId, blockID.name); + } + } + + public static void resetFluidIcons(IIconRegister register) { + for (ForestryFluids fluid : VALUES) { + fluid.getBlock().registerBlockIcons(register); + } + } + + public Block getBlock() { + return fluidBlock; + } + + public Color getColor() { + return color; + } + + public static class MissingFluidException extends RuntimeException { + + public MissingFluidException(String tag) { + super("Fluid '" + tag + "' was not found. Please check your configs."); + } + + } + + public static void preInit() { + for (ForestryFluids fluidType : VALUES) { + fluidType.initFluid(); + } + } + + public static void init() { + for (ForestryFluids fluidType : VALUES) { + if (fluidType.standardFluid.get() == null) + continue; + + for (ItemStack filledContainer : fluidType.getFilledContainers()) { + LiquidHelper.injectLiquidContainer(fluidType.standardFluid, filledContainer); + } + } + } + + public static void postInit() { + for (ForestryFluids fluidType : VALUES) { + fluidType.initBlock(); + if (fluidType.standardFluid.get() == null) + throw new MissingFluidException(fluidType.standardFluid.getTag()); + } + } + + public static class TextureHook { + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void textureHook(TextureStitchEvent.Post event) { + if (event.map.getTextureType() == 0) { + for (ForestryFluids fluidType : VALUES) { + if (fluidType.fluid != null) + fluidType.fluid.setIcons(fluidType.fluidBlock.getBlockTextureFromSide(1), fluidType.fluidBlock.getBlockTextureFromSide(2)); + } + } + } + + } + + public static Object getTextureHook() { + return new TextureHook(); + } + + public static class FillBucketHook { + @SubscribeEvent + public void fillBucket(FillBucketEvent event) { + MovingObjectPosition movingObjectPosition = event.target; + int x = movingObjectPosition.blockX; + int y = movingObjectPosition.blockY; + int z = movingObjectPosition.blockZ; + Block targetedBlock = event.world.getBlock(x, y, z); + if (targetedBlock instanceof BlockForestryFluid) { + Item filledBucket = ItemLiquidContainer.getExistingBucket(targetedBlock); + if (filledBucket != null) { + event.result = new ItemStack(filledBucket); + event.setResult(Event.Result.ALLOW); + } + } + } + } + + public static Object getFillBucketHook() { + return new FillBucketHook(); + } +} \ No newline at end of file diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 0b2056840..9007cb4e0 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -10,17 +10,18 @@ ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.CreativeTabForestry; -import forestry.core.fluids.FluidHelper; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; +import java.awt.Color; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; +import java.util.Random; + import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -28,17 +29,29 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.CreativeTabForestry; +import forestry.core.fluids.BlockForestryFluid; +import forestry.core.fluids.FluidHelper; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; + public class ItemLiquidContainer extends Item { public static enum EnumContainerType { - - GLASS, JAR, CAN, CAPSULE, REFRACTORY + GLASS, JAR, CAN, CAPSULE, REFRACTORY, BUCKET } + private static final Map buckets = new HashMap(); + private boolean isDrink = false; private boolean isAlwaysEdible = false; @@ -46,14 +59,25 @@ public class ItemLiquidContainer extends Item { private float saturationModifier = 0.0f; private final EnumContainerType type; - private final int colour; + private final Block contents; + private final Color color; - public ItemLiquidContainer(EnumContainerType type, int colour) { + public ItemLiquidContainer(EnumContainerType type, Block contents, Color color) { super(); this.type = type; - this.colour = colour; + this.contents = contents; + this.color = color; setCreativeTab(CreativeTabForestry.tabForestry); setMaxStackSize(16); + if (type == EnumContainerType.BUCKET) { + setContainerItem(Items.bucket); + this.maxStackSize = 1; + buckets.put(contents, this); + } + } + + public static ItemLiquidContainer getExistingBucket(Block contents) { + return buckets.get(contents); } private int getMatchingSlot(EntityPlayer player, ItemStack stack) { @@ -141,8 +165,8 @@ public class ItemLiquidContainer extends Item { } } - if (fluid == null || fluid.amount <= 0) - return itemstack; + if (fluid == null || fluid.amount <= 0 && this.type == EnumContainerType.BUCKET) + return tryPlaceLiquid(itemstack, world, entityplayer, movingobjectposition); ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemstack); if (filledContainer == null) @@ -179,6 +203,81 @@ public class ItemLiquidContainer extends Item { } + private ItemStack tryPlaceLiquid(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) { + + if (this.type != EnumContainerType.BUCKET) { + return itemstack; + } + + if (this.contents == Blocks.air) { + return new ItemStack(Items.bucket); + } + + int x = movingobjectposition.blockX; + int y = movingobjectposition.blockY; + int z = movingobjectposition.blockZ; + + switch (movingobjectposition.sideHit) { + case 0: --y; break; + case 1: ++y; break; + case 2: --z; break; + case 3: ++z; break; + case 4: --x; break; + case 5: ++x; break; + } + + if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, itemstack)) { + return itemstack; + } + + if (this.tryPlaceLiquidAtPosition(world, x, y, z) && !player.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + + return itemstack; + } + + private boolean tryPlaceLiquidAtPosition(World world, int x, int y, int z) { + if (this.contents == Blocks.air) { + return false; + } else { + Material material = world.getBlock(x, y, z).getMaterial(); + boolean isLiquid = !material.isSolid(); + + if (!world.isAirBlock(x, y, z) && !isLiquid) { + return false; + } else { + // Can't put down liquids in the nether. + // Explode if it's flammable, evaporate otherwise. + if (world.provider.isHellWorld && this.contents != Blocks.flowing_lava) { + int flammability = contents.getFlammability(world, x, y, z, ForgeDirection.UNKNOWN); + if (contents instanceof BlockForestryFluid && flammability > 0) { + // Explosion size is determined by flammability, up to size 4. + float explosionSize = 4F * flammability / 300F; + world.newExplosion(null, x, y, z, explosionSize, true, true); + return true; + } else { + Random random = world.rand; + world.playSoundEffect(x + 0.5, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F + (random.nextFloat() - random.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) { + world.spawnParticle("largesmoke", x + random.nextDouble(), y + random.nextDouble(), z + random.nextDouble(), 0.0, 0.0, 0.0); + } + } + } else { + if (!world.isRemote && isLiquid && !material.isLiquid()) { + world.func_147480_a(x, y, z, true); + } + + world.setBlock(x, y, z, this.contents, 0, 3); + } + + return true; + } + } + } + + public int getHealAmount() { return healAmount; } @@ -218,7 +317,7 @@ public class ItemLiquidContainer extends Item { @SideOnly(Side.CLIENT) @Override public IIcon getIconFromDamageForRenderPass(int i, int j) { - if (j > 0 && colour >= 0) + if (j > 0 && color != null) return icons[1]; else return icons[0]; @@ -232,9 +331,13 @@ public class ItemLiquidContainer extends Item { @Override public int getColorFromItemStack(ItemStack itemstack, int j) { - if (j > 0 && colour >= 0) - return colour; + if (j > 0 && color != null) + return color.getRGB() & 0xffffff; // remove alpha else return 0xffffff; } + + public EnumContainerType getType() { + return type; + } } diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index cfad6e3ac..e41783504 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -31,7 +31,11 @@ import forestry.core.network.PacketFXSignal; import forestry.core.network.PacketIds; import forestry.core.render.SpriteSheet; import forestry.core.utils.StringUtil; +import forestry.plugins.PluginManager; + import java.io.File; +import java.util.EnumSet; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResourceManager; @@ -62,6 +66,8 @@ public class ProxyCommon { } public void registerBlock(Block block, Class itemClass) { + if (!EnumSet.of(PluginManager.Stage.PRE_INIT).contains(PluginManager.getStage())) + throw new RuntimeException("Tried to register Block outside of Pre-Init"); GameRegistry.registerBlock(block, itemClass, StringUtil.cleanBlockName(block)); } diff --git a/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java b/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java new file mode 100644 index 000000000..bccc400b6 --- /dev/null +++ b/src/main/java/forestry/core/render/EntityColoredDropParticleFX.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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.render; + +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityColoredDropParticleFX extends EntityFX { + + /** + * The height of the current bob + */ + private int bobTimer; + + public EntityColoredDropParticleFX(World world, double x, double y, double z, float red, float green, float blue) { + super(world, x, y, z); + this.particleRed = red; + this.particleGreen = green; + this.particleBlue = blue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.bobTimer = 40; + this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D)); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= (double) this.particleGravity; + + if (this.bobTimer-- > 0) { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setDead(); + } + + if (this.onGround) { + this.setParticleTextureIndex(114); + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) { + double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + + if (this.posY < d0) { + this.setDead(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/forestry/core/render/TextureManager.java b/src/main/java/forestry/core/render/TextureManager.java index a47334ddf..66b5e09dc 100755 --- a/src/main/java/forestry/core/render/TextureManager.java +++ b/src/main/java/forestry/core/render/TextureManager.java @@ -10,15 +10,18 @@ ******************************************************************************/ package forestry.core.render; +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ForestryAPI; import forestry.api.core.IIconProvider; import forestry.api.core.ITextureManager; -import java.util.ArrayList; -import java.util.HashMap; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; @SideOnly(Side.CLIENT) public class TextureManager implements ITextureManager { diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index fda0feff9..56d42c337 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -10,18 +10,44 @@ ******************************************************************************/ package forestry.core.utils; -import forestry.api.recipes.RecipeManagers; -import forestry.core.config.ForestryItem; -import forestry.core.fluids.Fluids; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidStack; +import forestry.api.recipes.RecipeManagers; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.fluids.Fluids; +import forestry.core.items.ItemLiquidContainer; +import forestry.core.proxy.Proxies; + public class LiquidHelper { - public static boolean isEmptyLiquidData() { - return FluidContainerRegistry.getRegisteredFluidContainerData().length <= 0; + public static void injectLiquidContainer(Fluids fluid, ItemStack filled) { + Item item = filled.getItem(); + if (item.getContainerItem() instanceof ItemBucket) { + LiquidHelper.injectLiquidContainer(fluid, Defaults.BUCKET_VOLUME, filled, new ItemStack(Items.bucket)); + return; + } else if (item instanceof ItemLiquidContainer) { + ItemLiquidContainer liquidContainer = (ItemLiquidContainer)item; + switch (liquidContainer.getType()) { + case CAN: + LiquidHelper.injectTinContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.canEmpty.getItemStack()); + return; + case CAPSULE: + LiquidHelper.injectWaxContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.waxCapsule.getItemStack()); + return; + case REFRACTORY: + LiquidHelper.injectRefractoryContainer(fluid, Defaults.BUCKET_VOLUME, filled, ForestryItem.refractoryEmpty.getItemStack()); + return; + } + } + Proxies.log.warning("Unable to inject liquid container: " + filled); } public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) { diff --git a/src/main/java/forestry/core/utils/Schemata.java b/src/main/java/forestry/core/utils/Schemata.java index b0adbee8f..f36670e38 100755 --- a/src/main/java/forestry/core/utils/Schemata.java +++ b/src/main/java/forestry/core/utils/Schemata.java @@ -97,7 +97,7 @@ public class Schemata { } public boolean isEnabled() { - return !Config.disabledStructures.contains(uid); + return Config.isStructureEnabled(uid); } /** diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index eacab05c8..87798e991 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -10,15 +10,23 @@ ******************************************************************************/ package forestry.plugins; -import buildcraft.api.fuels.BuildcraftFuelRegistry; +import java.awt.Color; + +import net.minecraft.block.Block; + +import net.minecraftforge.fluids.Fluid; + import cpw.mods.fml.common.Optional; + import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; -import net.minecraftforge.fluids.Fluid; + +import buildcraft.api.fuels.BuildcraftFuelRegistry; +import forestry.core.items.ItemLiquidContainer.EnumContainerType; @Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends ForestryPlugin { @@ -39,16 +47,41 @@ public class PluginBuildCraftFuels extends ForestryPlugin { BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.get(), 10.0f); Fluid ethanol = Fluids.BIOETHANOL.get(); - int ethanolPower = 40; - int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); - BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); + if (ethanol != null) { + int ethanolPower = 40; + int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); + BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); + } - LiquidHelper.injectWaxContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleOil.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectWaxContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.waxCapsuleFuel.getItemStack(), ForestryItem.waxCapsule.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryOil.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectRefractoryContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.refractoryFuel.getItemStack(), ForestryItem.refractoryEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Fluids.OIL, Defaults.BUCKET_VOLUME, ForestryItem.canOil.getItemStack(), ForestryItem.canEmpty.getItemStack()); - LiquidHelper.injectTinContainer(Fluids.FUEL, Defaults.BUCKET_VOLUME, ForestryItem.canFuel.getItemStack(), ForestryItem.canEmpty.getItemStack()); + Fluid oil = Fluids.OIL.get(); + if (oil != null) { + Block oilBlock = oil.getBlock(); + if (oilBlock != null) { + Color oilColor = new Color(0x404040); + ForestryItem.waxCapsuleOil.registerContainer(EnumContainerType.CAPSULE, oilBlock, oilColor); + ForestryItem.canOil.registerContainer(EnumContainerType.CAN, oilBlock, oilColor); + ForestryItem.refractoryOil.registerContainer(EnumContainerType.REFRACTORY, oilBlock, oilColor); + + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.waxCapsuleOil.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.refractoryOil.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.canOil.getItemStack()); + } + } + + Fluid fuel = Fluids.FUEL.get(); + if (fuel != null) { + Block fuelBlock = fuel.getBlock(); + if (fuelBlock != null) { + Color fuelColor = new Color(0xffff00); + ForestryItem.waxCapsuleFuel.registerContainer(EnumContainerType.CAPSULE, fuelBlock, fuelColor); + ForestryItem.canFuel.registerContainer(EnumContainerType.CAN, fuelBlock, fuelColor); + ForestryItem.refractoryFuel.registerContainer(EnumContainerType.REFRACTORY, fuelBlock, fuelColor); + + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.waxCapsuleFuel.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.refractoryFuel.getItemStack()); + LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.canFuel.getItemStack()); + } + } } } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index ba033a27e..30a62f5af 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -10,8 +10,22 @@ ******************************************************************************/ package forestry.plugins; +import java.awt.Color; +import java.util.ArrayList; + +import net.minecraft.block.material.Material; +import net.minecraft.command.ICommand; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.RecipeSorter; + import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.network.IGuiHandler; + import forestry.api.circuits.ChipsetManager; import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; @@ -29,6 +43,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; +import forestry.core.fluids.ForestryFluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.BlockResource; import forestry.core.gadgets.BlockResourceStorageBlock; @@ -51,7 +66,6 @@ import forestry.core.items.ItemForestryPickaxe; import forestry.core.items.ItemForestryShovel; import forestry.core.items.ItemFruit; import forestry.core.items.ItemLiquidContainer; -import forestry.core.items.ItemLiquidContainer.EnumContainerType; import forestry.core.items.ItemMisc; import forestry.core.items.ItemOverlay; import forestry.core.items.ItemOverlay.OverlayInfo; @@ -61,15 +75,11 @@ import forestry.core.items.ItemWrench; import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryModEnvWarningCallable; import forestry.core.utils.ShapedRecipeCustom; -import java.util.ArrayList; -import net.minecraft.block.material.Material; -import net.minecraft.command.ICommand; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.RecipeSorter; + +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.BUCKET; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAN; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAPSULE; +import static forestry.core.items.ItemLiquidContainer.EnumContainerType.REFRACTORY; @Plugin(pluginID = "Core", name = "Core", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.core.description") public class PluginCore extends ForestryPlugin { @@ -86,6 +96,10 @@ public class PluginCore extends ForestryPlugin { rootCommand.addChildCommand(new CommandVersion()); rootCommand.addChildCommand(new CommandPlugins()); + ForestryFluids.preInit(); + MinecraftForge.EVENT_BUS.register(ForestryFluids.getTextureHook()); + MinecraftForge.EVENT_BUS.register(ForestryFluids.getFillBucketHook()); + ChipsetManager.solderManager = new ItemSolderingIron.SolderManager(); CircuitRegistry circuitRegistry = new CircuitRegistry(); @@ -135,6 +149,8 @@ public class PluginCore extends ForestryPlugin { public void doInit() { super.doInit(); + ForestryFluids.init(); + definitionEscritoire.register(); crashCallable = new ForestryModEnvWarningCallable(); @@ -264,49 +280,56 @@ public class PluginCore extends ForestryPlugin { ForestryItem.fruits.registerItem(new ItemFruit(), "fruits"); // / EMPTY LIQUID CONTAINERS - ForestryItem.waxCapsule.registerItem(new ItemLiquidContainer(EnumContainerType.CAPSULE, -1).setMaxStackSize(64), "waxCapsule"); - ForestryItem.canEmpty.registerItem(new ItemLiquidContainer(EnumContainerType.CAN, -1).setMaxStackSize(64), "canEmpty"); - ForestryItem.refractoryEmpty.registerItem(new ItemLiquidContainer(EnumContainerType.REFRACTORY, -1).setMaxStackSize(64), "refractoryEmpty"); + ForestryItem.waxCapsule.registerItem(new ItemLiquidContainer(CAPSULE, Blocks.air, null).setMaxStackSize(64), "waxCapsule"); + ForestryItem.canEmpty.registerItem(new ItemLiquidContainer(CAN, Blocks.air, null).setMaxStackSize(64), "canEmpty"); + ForestryItem.refractoryEmpty.registerItem(new ItemLiquidContainer(REFRACTORY, Blocks.air, null).setMaxStackSize(64), "refractoryEmpty"); // / BUCKETS - ForestryItem.bucketBiomass.registerItem(new ItemForestry().setContainerItem(Items.bucket).setMaxStackSize(1), "bucketBiomass"); - ForestryItem.bucketBiofuel.registerItem(new ItemForestry().setContainerItem(Items.bucket).setMaxStackSize(1), "bucketBiofuel"); + ForestryItem.bucketBiomass.registerContainer(BUCKET, ForestryFluids.BIOMASS); + ForestryItem.bucketEthanol.registerContainer(BUCKET, ForestryFluids.ETHANOL); + ForestryItem.bucketGlass.registerContainer(BUCKET, ForestryFluids.LIQUID_GLASS); + ForestryItem.bucketHoney.registerContainer(BUCKET, ForestryFluids.HONEY); + ForestryItem.bucketIce.registerContainer(BUCKET, ForestryFluids.ICE); + ForestryItem.bucketJuice.registerContainer(BUCKET, ForestryFluids.JUICE); + ForestryItem.bucketSeedoil.registerContainer(BUCKET, ForestryFluids.SEEDOIL); + ForestryItem.bucketShortMead.registerContainer(BUCKET, ForestryFluids.SHORT_MEAD); + + Color colorWater = new Color(0x2432ec); + Color colorLava = new Color(0xfd461f); // / WAX CAPSULES - ForestryItem.waxCapsuleWater.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x2432ec)), "waxCapsuleWater"); - ForestryItem.waxCapsuleBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x83d41c)), "waxCapsuleBiomass"); - ForestryItem.waxCapsuleBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xff7909)), "waxCapsuleBiofuel"); - ForestryItem.waxCapsuleOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x404040)), "waxCapsuleOil"); - ForestryItem.waxCapsuleFuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffff00)), "waxCapsuleFuel"); - ForestryItem.waxCapsuleSeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffffa9)), "waxCapsuleSeedOil"); - ForestryItem.waxCapsuleHoney.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "waxCapsuleHoney"); - ForestryItem.waxCapsuleJuice.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "waxCapsuleJuice"); - ForestryItem.waxCapsuleIce.registerItem((new ItemLiquidContainer(EnumContainerType.CAPSULE, 0xdcffff)), "waxCapsuleIce"); + ForestryItem.waxCapsuleBiomass.registerContainer(CAPSULE, ForestryFluids.BIOMASS); + ForestryItem.waxCapsuleEthanol.registerContainer(CAPSULE, ForestryFluids.ETHANOL); + ForestryItem.waxCapsuleHoney.registerContainer(CAPSULE, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.waxCapsuleIce.registerContainer(CAPSULE, ForestryFluids.ICE); + ForestryItem.waxCapsuleJuice.registerContainer(CAPSULE, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.waxCapsuleSeedOil.registerContainer(CAPSULE, ForestryFluids.SEEDOIL); + ForestryItem.waxCapsuleWater.registerContainer(CAPSULE, Blocks.flowing_water, colorWater); // / CANS - ForestryItem.canWater.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x2432ec)), "waterCan"); - ForestryItem.canBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x83d41c)), "biomassCan"); - ForestryItem.canBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xff7909)), "biofuelCan"); - ForestryItem.canOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x404040)), "canOil"); - ForestryItem.canFuel.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffff00)), "canFuel"); - ForestryItem.canLava.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xfd461f)), "canLava"); - ForestryItem.canSeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffffa9)), "canSeedOil"); - ForestryItem.canHoney.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "canHoney"); - ForestryItem.canJuice.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "canJuice"); - ForestryItem.canIce.registerItem((new ItemLiquidContainer(EnumContainerType.CAN, 0xdcffff)), "canIce"); + ForestryItem.canBiomass.registerContainer(CAN, ForestryFluids.BIOMASS); + ForestryItem.canEthanol.registerContainer(CAN, ForestryFluids.ETHANOL); + ForestryItem.canLava.registerContainer(CAN, Blocks.flowing_lava, colorLava); + ForestryItem.canHoney.registerContainer(CAN, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.canIce.registerContainer(CAN, ForestryFluids.ICE); + ForestryItem.canJuice.registerContainer(CAN, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.canSeedOil.registerContainer(CAN, ForestryFluids.SEEDOIL); + ForestryItem.canWater.registerContainer(CAN, Blocks.flowing_water, colorWater); // / REFRACTORY CAPSULES - ForestryItem.refractoryWater.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x2432ec)), "refractoryWater"); - ForestryItem.refractoryBiomass.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x83d41c)), "refractoryBiomass"); - ForestryItem.refractoryBiofuel.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xff7909)), "refractoryBiofuel"); - ForestryItem.refractoryOil.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x404040)), "refractoryOil"); - ForestryItem.refractoryFuel.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffff00)), "refractoryFuel"); - ForestryItem.refractoryLava.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xfd461f)), "refractoryLava"); - ForestryItem.refractorySeedOil.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffffa9)), "refractorySeedOil"); - ForestryItem.refractoryHoney.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xffda47)).setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION), "refractoryHoney"); - ForestryItem.refractoryJuice.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0x99d04e)).setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION), "refractoryJuice"); - ForestryItem.refractoryIce.registerItem((new ItemLiquidContainer(EnumContainerType.REFRACTORY, 0xdcffff)), "refractoryIce"); + ForestryItem.refractoryBiomass.registerContainer(REFRACTORY, ForestryFluids.BIOMASS); + ForestryItem.refractoryEthanol.registerContainer(REFRACTORY, ForestryFluids.ETHANOL); + ForestryItem.refractoryLava.registerContainer(REFRACTORY, Blocks.flowing_lava, colorLava); + ForestryItem.refractoryHoney.registerContainer(REFRACTORY, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + ForestryItem.refractoryIce.registerContainer(REFRACTORY, ForestryFluids.ICE); + ForestryItem.refractoryJuice.registerContainer(REFRACTORY, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + ForestryItem.refractorySeedOil.registerContainer(REFRACTORY, ForestryFluids.SEEDOIL); + ForestryItem.refractoryWater.registerContainer(REFRACTORY, Blocks.flowing_water, colorWater); + } + @Override + public void postInit() { + ForestryFluids.postInit(); } @Override @@ -365,7 +388,7 @@ public class PluginCore extends ForestryPlugin { Proxies.common.addSmelting(ForestryBlock.resources.getItemStack(1, 2), ForestryItem.ingotTin.getItemStack(), 0.5f); /* BRONZE INGOTS */ - if (Config.getCraftingBronzeEnabled()) + if (Config.isCraftingBronzeEnabled()) Proxies.common.addShapelessRecipe(ForestryItem.ingotBronze.getItemStack(4), "ingotTin", "ingotCopper", "ingotCopper", "ingotCopper"); /* STURDY MACHINE */ diff --git a/src/main/java/forestry/plugins/PluginFood.java b/src/main/java/forestry/plugins/PluginFood.java index 5bf4f5b29..dc4cd9a21 100755 --- a/src/main/java/forestry/plugins/PluginFood.java +++ b/src/main/java/forestry/plugins/PluginFood.java @@ -67,7 +67,6 @@ public class PluginFood extends ForestryPlugin { ItemStack meadBottle = ForestryItem.beverage.getItemStack(); ((ItemBeverage) ForestryItem.beverage.item()).beverages[0].saveEffects(meadBottle, new IBeverageEffect[] { BeverageEffect.weakAlcoholic }); - Fluids.SHORT_MEAD.register(); LiquidHelper.injectLiquidContainer(Fluids.SHORT_MEAD, Defaults.BUCKET_VOLUME, meadBottle, new ItemStack(Items.glass_bottle)); } diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png b/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/bioethanol_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass.png deleted file mode 100755 index 3f226d8c5462ba5381b5e63996be661858db247c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4876 zcmX|_c{Eh-AIC={jHR)Cv!qL7DZ4>Jw~;N|h$u<2?^|OjgOnu=Stg7%TSSNmDPk;x zk$uZ9gecqCnZj@S{(k58Iq&m&UZ2mo|2*fO=iKMqDC6roY|Q-35D0`#Pgl!?wz5MY zCm>8vn$$)@&|B@EH z#{cnpBjo=vB0+AFApfOV3q)PdNS(I3YknrzO$&>QOH0ej-qWgzR@K#?YU}Fih_q^G zY9f(Ht+XPO+dI0ty1To3d;9wO`v-=GzJ47U9UB{;n4J1HJu@@=-6w}t3IgHC)6-JF ziM6_w1`nE3@@adO-#Gh^jg#}$CYY}03gLZ*;Z5@5WLDz0dx4%?hYco+XI&D3QZiom zg%E{w`8cO9^(Pj*CicDJc(WG+0;iDiXK|zr49Jk{l5&dNQp`Wc-Y#SMwaes8ugaKk zyie8fQk3#D67p0$bMz2*DM={m0%tcuVM@(Paq@UGR9HGqD*#GCeNmas=Xk^Dri@LH0J2N@j^g>`^hJ6= z%R~4q!lDH$u##3Y-xZPjo)x_$m%!9ttLCcQP%2R5-E+-L9+h==pqM)Hw zff+?kDU*yyY8+Z+5qn{f71bEdTgJdeBrKK#ZXe~YHNT%UXd`{ygLhjh!H`(ehYIJp2;{v$NXBJAx?&!QV0?3>(iOu&1N~P zX_veOPiYR+X_jUE}p(gJS!8}7}~K#GZY-Mw_#P(Md|kzaa&a#y zsuCIVn9*FBJ)Hd+uR7EK0%$IB%xM+zA1$#gTyh@%eTkA2A(^q~;iHDMzfH*bb zet>h2xEv7j561?`x8s6k*ZH$hkq@+s2V+jtF)LLpKZm z`S4@k*p7)ApMekoQiZnX#FS1Wq4du+lc0hb1=3Xk#1@6 zOqN??g8lrB_<1l++0Mi@`#A@m+qr0b{A4b77)ofY+Ec?)?GU=F@xY)@XYWl#d#uh^ z7H1^zkq*Li<73K_Ro9V0qFke{kD(&}rFp-}fET}F8J%-$GFs0LZogu%y#u79#goW* z1C^6XttVM+3c7CbKRSnv3D)2Y|5$tBej1%Yi-CO8P7TV$Iy>~(5<~KPtLDX+;^GJqpG+UXO#!c%2-B>kx}1}SWF}YdQtQIfk;#RiTh|Gew0ZY-V5{Da{wZ6vhoi3}u7w*7 z2GDk3hgyk<6#Ky9lJKK>C&N0D0{j9|GELI=p1(M!07w%+Z}t8cuUB{K_=R{bpkH9c zgCduf8J?Qw3RAp|jc%QIP6(wpQ_v_0eKNw>t-!U32Py;NsfbI*@r0Dl<=)ca$u0Qv zfP3SJz`#HsfG4`SEpOTWw-*m0_26(fa9FxztjBBaIT*FU8`?6+iEz5B|1kx`%WRy1 z|DulW8o&|DVN?bE1N)Q4+! zn~XVee&#v-{ePyizkkcJ8hYEN+4z7{M(xk`-qufgK$P@jEv5ANw<}=k@c95L2B9?s z#a1on71#>kwpR~4M=q|&LoZ`d(ITh2+m#C!_8&5q|GOtYk89ifD#^r z7;AUb^SrJ99)TLg&OqSqKSBQIVZ*87cEgds>vMz|IiXea;A!#Sv5dW43sh?FZ<81u zPmP%yf<3iDYoy=chil%SHq5PwWs?Cb4Uaq)F{P}bwbpj_ywB*mUOkJ7@e68LeVi zcy*ErA08QK#RPD>J_H{6T#X)ozv&E&Ve9@pEK7*hNn*wK?=lwU@|W|cSbT{V-XGi{ zzmZ_#J*YTd4Y-UOF>HjUmACu2y~3Rq`<%ZOvX{xpmHbo8((cE~L7-<3DQh=0u-<~C zGAJdZk1$)x8(6C36NXK5?mrf&-M=SQKhH)7`lNA42oi!1a|W}r2L!2@pmVp>t7k!n z0?T(J(`ylf0;d>uyr-V{%^`)@T=Y;r7?`9Ws^ zY+IND2Q!TO#zUJ^mw>1=(>q66Z)$aC#xmrJtr-*a&3*MR0lo=`6FEI37RQ7x|DL?% z#$aabB={?mVSZVo4O@RRz9-LFlH;q0@nyI}>`YU7qcCSLVf%nO!D#N+SB%y}y~_@W zdB24FtZLtle2F>QH}5}g?8QHMGG>AOEUP)9Gc=yQ!5cV#5l|ra*h6B~uv#6>3F~V| ziZ4;hav*2^k_7D@k?OlUsGB&M9j^GxRWSL*9S@%#C~DX}qHiG#+t2b@PCIUwH1#*H`gOW+v%CvtKLaS)N*$~-)%Y0=7_ZxwBYgQZ&;DJ8$`AB#ftK*Mos-9 z`l?33DsdxMIUqahad0vJk!7oS(Z!fW5>bZ0u}oPj4xdCC8PfEkRH zC4+0NQiluI(HuMn^LK-pwCA~ukTXcHBy+ilKS@J4Q?9qjTH0w${|&G3-d^z(5O?$e zgh^Jpn=8q&`P&)P-ri$Nz7WM;tvaw2Zb)dLstPQ%xPi5owSy-d;>`8tHt_YjSPAeU zIrGDFv%Iy5P~9I;pHMUVwt~G4UaWQ< zMA3>ePmcIq_PDC@VmteW2^JouFmI87VCqD@&uG%;MZ8pWxhj0GLAX036Gs=_V^4{{ zj;x>zKU{pzVy1R&k*>329m-p%ajx=$!ZcQh4%xBGxX5H0)v%m*KBDmE%&o!(C6j|s za{j@en#(aZU86o{Yo`a$b$(C{uyf%jbuXQ()i|MaS;YFItV(^#DpJ5sulV~WCRilx zySEa!xw$_q5@DEdaaOZrJ&|{3W4c{b;hNq$xlh~Be&zRM9-9Xmarf{v*n{WXHfSz> z5X8U5-4ZA3j=@mKUW14>-MI43wwWC zODtmSp2^K>)Yyoh`}t^s%;hvF{tK6S<#D6nGwvvDL&2}VQgG2vD=KicbXT-P1@yR)D%|6SAEXuozk;fbc0h!=T8qp5S$0{;S=1`*b{PLuq#QjJ zkub;88fz<}K9}~Ktwf&XX}$LFcWs(t9M9_g01@u@!#Cc+Z#y!p-kJK9B^xFGe!?KG zzN$k?lNT>+mN}^w$9<#6X=!ejQ26Z(zV-}@$#WU&*&K^)(z|tWu{({Vm){O0;g2S{ zGjUH;{s08={Q$IeCChyb5Qh=Em&&!4+7ClkuJweskGrX?PfK>AUpX0xX}4bQoO4%Z z=Q7w#AFCATVE10pD-mJV(1m*Im@E*U93P(kZlGtk{qa9Xja3p=Tt=GD|jxQWG07`%>7y3H~T324kECB*t&ycUtgV0L$o{* znKUX%Fwy9v{s|hos&|bdcM_IQ?;eAcyRrEQ9ZM!9K3xsai)Ze3us|f0SG%2g(@k-* zN`2{G()(4?{OUt%Zn`Na!AzY?h-^g_`1UoeO!A~*w6XePS_W=9BjB!@guG5c)uXN0 z>gq7Yh;+FrVI;yh=;-A}Bq`&SAMG=KfoCG(z*16Gl-0N;i4B;tQpM}GtbO3f=5ik8 z$956K%*+hE!;eR;&S23n&4OIpCoZ*W*`mHqj_>I1<1Vjg(N0_eFYMb0-GQz2j5p;n zf<(+&q!EuEak{^<%&i}vTDKU+Y!^&?a`hzDZp#eb|F psQuZi@gq;ZGm^-KiIR`$a%9a!AwDa6v>!kaJ?-mS?=)<}{sZieFb4nt diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/biomass_still.png new file mode 100644 index 0000000000000000000000000000000000000000..79660a1b6c2d87199a6f74aa5ff00517317a8e95 GIT binary patch literal 9753 zcmWlfcRbXOAIIscqteGnMs>&62+1b&amGnFyCj=3B812t&aN}E$zIunY_j(r*?X^y z+&TM&JC*1tV z$T$|1IC5KiJK04ef?B2nXq}82YebVME+qI zWsh4NYH1LMHKp66Pr4Y8($_*pnGS*uo|_fboZv=nFmnfFk! zroQ4>GfnK4H+(_$iCn5R>wB1T;->OY^Q!FUu5*#0xRdwNXW&C;%zvvnS~{W<7%0lG zf3eI=CMnxuAdg()E35u)OqSB7w#SAWGM!3PH)6%;Wpr|nYM|URW!%(5?T4ba)wQ)5 zsznts{6$5$!k!Ug$K{_Mi3}^o5&wj>rQk=d2dAT=tBawkatLKH$KGLEOK|Y%W=Afk za<26{JB*Xk)fuMM71PHVDhskSj&xyUOu~~a(K*&4#ci4QOZ!%h`;Nr{@;?KrR$P?e zNPX6I0)Uwn2Q+_tc>(*9mV#kSrz|I$V1*DpNZap1DvL1SelCY}r|*K2Y+a@GZP5L= z&c&#fAh%?gP8|H9w_&g+!`af?a@tlAN@q!Y%`Zn<)BjLm>(-2nMAa^{UUW5(-s5F* zGcryk$p?7gn2nQcwtio`<6%!?{tLR?M77cw`QYzmA?5Ms{ID$L>n>mvx*rmz@;KGg z0!C)DmZqk>76sKx!g%#^09Jwh5S$8=%Nrv%&PShO>4EC5guXBHGiRFz@6iZN3-UU4gM)xF5YJ^2OWq zRBKubEN}pfhSVPu&gUovnW7TvAJuUy)jh9g5T&`rcGQ^qU)%MQndTNo z=%6TU%KtCLEEYC|1jT1NKd`apKS?6kA1qzN{Mn=wVmmZlOZyv)(*$$eMM#_0rTGu= zjVBGyiw%!r3;GNH$d-B7^vP-iy50*{v;TRUFy3vW{}6 zS(w8|aJ~KRXzz1S1Ybjo|o!I@-Y1pOK`rm+06!At~_kGy@G;u{#`rhqXevP zZI<6#N;%)}iF69^D8YSqv$7L%fr-bXKEb;0NYeqQHi}KQ=3PR1KY^R_eOiEzv}09_ny=r^&iUp+Gs@5kFa{hQXA}PB;nQ^ z>x}pCOWo%jIbM$FcUcBn$r#1)@o`e|G;nUWfd>$$8|hoqEQ{Jj34(`6p&PUH8QpfdRY>Q?;hP|3i?)#wAZ^X!yeoMY28B z%X<;34!a3z6Lyt`^KZ+@@2WWRx_~0)*y_dG>rJLr9_P#)H-X$JaiTz+fFwW$B{T47 zZs9D?K4dM@-}?yT9H8T?x)waLwm?q07f=e6xa9rOyo3@dmx{FnLnFaSqXXU$|YHI1O%G52sjvuaG zA9UT(7Oaq>rN5yv=HA}2&kpz*WIb4>1nzu|Pu%l*Km6JIMq^7*i8r(o(7h`l0Wc&K z5WOBc;A5g3aP%({W=a7PtHZe7>0Kek4Q`mCylv5o=I5vHyL_1s5x|V)5=|mhRH2pb z81gKz9jUiR9h7)U2aEV>%dLFfyYX4^M~_mQm)!XWuH{CetOJCW7odNQ9x9#d&6@Yy z@V_=DQY+duzg(9$Z>S=_b8^$-3NI%grg%LCR}hG92)4}miF*@cj0@t6t@qt=>3M=#p ze0sfF544MK-GM~`&4f%3(#s`19Snd&5{ z?!WdpNtpL^shgx=CT90z!X%52$zO;Q2Yqegu7C!HMps%QaLzV-6%4|FP$2TYx77x2 zw(oCN&5o~R^AvkCkF+=~)qAV`A}mQ&O-4#2Ql-o;4#N`30sM4b@V?5?6+Upx0z?L7 zgiS>xYSDME405@SSw>!yEt$0eaf_PCWCHg6I}jzu8MeS79(3oQcW^my-TSS_w{}t7 zmuX`I!v{OaJDW}0Mp1}?-ygoi4dw?Sc!6o$*$&)8c3JtZ-EBw9Ft|W)M5C;d+%q9q zp%?>0exEnadI-M#RyDDN+GcANkJof9dn~2+6Q;6 zez_B~kuLa=$Nuh6goGn?7WLSYvEH*Cq(&4^x1rBpaDm^@&`|eTYZ}ph@<$R>QulCC z{jwz{OKTRR{sy>)Vqwh4Xe%H9(RmnG(w{`e( zso}z+VQUtF26qlwUj$kgs!RVHLu1KRa*a-GmoJX`IgIgj?qtRl##5TV6BaNox}RBh zlAxsr%?#^0nM-PT*3meqf99?wY$A}ja1o*Z32pD$CCRU>D*;rKd0tEb2tdjX&K2jb zed~EZDc1ks9bEB!6EaeETbMwNQYaz2i%>_$9zRqufnkol~h=y z_3)I}{Lan}5uC_8NQ7S9h5_cYLqF7sVGRTq4{pvBPwH=YmLw|$O(PpNbI;#}pFP6` zC04x)9bik;Gl*2h55H!YL3wlVF9Cz#CO&GOfjg&a> z8~siVoud?fA^|w3(hm1R9*Zk1vzAR_OlqA=^&HBHVIRd{Vmi~0(2OcJq7mY81#2Hmpf0yWwNWHHmTppHrpxr z1YoJ;o_TS0;V0gPsbf03W>J$L(6PPIo`Fz~xTtjE&)r`yV9o41|EfJ9UwqI<1s-qT z1X+F;puhB#srFYIWK{re{wTS!UG=_o>#0qwagEp^B{Pdf$AnSxOVwkqUGWl%Y zjqx~W8PC{-V_ni;bSM1mqDIEw`0;;1fYW$qk*tq^-g}cZaLU9j44V6Gg+oc=wXW7T zZ+9=;kTtq_2l-%=2+H^cK-jtaP8k8Z>^JUHh{l#EIU0aliSi>?SN>E~}a&^b}>qC*c^#|+2A%g{g5LLfkx%TIuV*yi~FV{-3N*Ws*& z3e}&VGM$Ap01=oNj-R0jg{sEF7Fo3soXbsJIY;Om-|HHFtDyaV zDSKWXt%#ZRw0p1>+1y7-%3lKSa10Z;VNM^*=M1KBMIO6563N$JI{h97SAfg48s*%_ z=A(+I7yA{vbi+P^ANIw+iJ)}B|cfV*_{$usTkNw+k_ObwbZ(Nz( z%X2}Iq%eeEli0%b!oU3Hk}u6a=|%|u$qhp}aj2C%1Wm#t&N4sL$@U8a+lXoVZpeR~ z56)j-4>2pDP{#{|lyct6#J>I5jHKbzW^e^}y4E{CEs&pWqF0)5`i-pqxD{|jV?aVINbm{ z=_T+Bi{)sFK5=5IUitJv>XiNClml7VlJq6qnAMq&k;$gO=)j%G`3`J>hSZxw}rBiDf0`X{8Ykm9!d z?QMK6fgXX+mKVq;+?!0k#xSP|dAc8dg%V~Wm+4?<&C7C{ex4%f3( zi-N^YtD$P=A*oKi3=^i}p(@+F zbZ;7Em>|?tiLR=fj7vZu+98xDiIQLx1hD^MA*eKfsQ|dE8d@rU%KM4ludjj|cE%4Y@k<)MJ6SpVLttuw_{XfYK^jt-8aPG5^31XQmicQCsEe&<%P0 zTTB>OsH!M_)a`V>IogYyp~@_7y2!+)=FAkcg-z^sh4#CUesX8FYf&6w!x^@PuZXKG zkvn6Xk@Fcz1dTD?YrRxSr8V_+9vIcSP~xx{yrYdFp>NA{{gCxy()02$$RZlG?JHU? z{!<_?L%BZEB5769KaK0ia>ChEBVu&q2FMi!K`~iS)*V$nnZm+&KhXgR0VzjluW7?e zUCcY3K)Cz4))^tiGrSpl7Zx8Mg?!zV_rnq9OB4ts{aR_-k7k!>eF|e~#6_*Tm@BPC z;Hr2cC5*~S2tUgJnPk`kxla;q5;1X20m^*ehxjkH z-}_I*=k(xBXGrm_qL#X zop?}n03UW2TuJ2mLX?r45hiMwO`b}f@$EqDUs##{Z5q5&kZ_Q|T2yIO1I4_XTDlne zRLVMw@t6{Nkgxuh#Yo1BzM-mW!j6B=L;uAg$sz9F5p$g-gS_D33p&|^NLLu>{{bvt1&8BYqe8U+trb6I{Oazd5kgib%p(c zY%ay?M#a-xVlLde$_P=>oSjaIV<`dSg6k4-YCW_E3=F!P8naGifU4Y$O&d5LKcCe{ zAAfaeZ1ptj#_#p)@_Nx*8TsN<%g|-hV9o({LGD*@ayOFEVpZzvxlrmB~X=mW#@56j!kVNHh3>H+jfNzEYcRQoMGO>c1P*!1Q>SbCg>T4} zzj({T$^l+SSHeHX>P*c8J>Dl&&ohs+ zj1zG_?H*pZo}Fii#YN~PUdO1x^_&ry9eE0LN^X}#hh7XkpNNHG7G#8e*q&2*e0ELG ziMCF{P>j7v(~k9%ZOoKfl|3(6@!pktn2495BOw3LrP%=;<7vq`0?W}!B973AG=L=W z#bE7WS-)1uS%!UZXHE0yheh<3lCS7*1*%_Mr@LxvWmt7bxJNr^9p1jFMMQ)h2zrdnWgRvJQcKJWYbp>JMN`3SSK4_Vzn%{__ds7yU*ax?Q$2&^PlCh zW<;#Q=NvK@a6e;XF#$cecA=%+mxzPGmLi}j+lW1l6_g~9eMqj=HMIk=w2${VELHz9 zYviw$VVKfDsGNIr6Lu^_Y^*~gd%Gn7MRtmrWp6^J2e`N3t3V_IYi^l7i9h&t6u164 zmYV9O!vTWRiyPqn6SpgNSGp5sAM38nlb$!6p00}Cy%+Q5Yc{yu5u(m@jn^2Wak1oi z*%poy>jM>;9-|v|BS%_YS6Ic)N(E!>yr5Cry-4_Til4uOZEn7iumCewX5UW@B|g@v z(zAmM(&EtfjeQK03N(oh+6hI*Hwx4y?HSMS@1kXLYLvwCs2+kNSl)bE0rq@RcZU9E zBvco1iK@BF(dZJ89`M43Xak3>HGNU&O;sWIK_{X3{6f?8;`T8ejv4z-l(_CasD2UQ zd2g+l`$w3v{$RU&A&<%(0Fk%_Qp9?m4fD5Y%JA(VMPUD&oxOdtFTb3@9?R#2M^XJd zzCx;9I}ldCX&f~xVxw72$h!JZ+Lg3U`_|>N{ZcTDHM)@5@;^i0Vh!ayhE%Lka))5R!Ue!d&ndJUjB?L~4=V*a6|Zj6l2B5Nr> zhK1=fCjSaBawZFNr;O^8wh_~NvzaBOf`ZMt6Z^n+hJIw-vZ-h3JwZSQmhZlO4G_1F zf^}?Z!n7oo$%Wn?pP*xXz7JcX$u=et8z+CL;j83IV!sP}4hlrN(!rnF(46Z>F;Uct zg+lYNbyoaSvt?G_kg0!e3Ky16LUl$EP2x`ket%pcuTMow%rRTSw5S19KL!GIo40)! z_O)nC!cC_%FxmJkRKkh$8}swFY%4U{CM3Hw08^^R-F0>%$e$@MB|`V?VPw;o*HgH4%EZS!~4i%=oe&ksUQ{vZU$ zigI3qPL+nD@0SRWdl;X(g0&ga6&jBdigL6#2)yK|L(ECe-VTJrN`bC%x0n@Bqq$=V zI(5_u!K#GF>a5YhD7+G(?=;UA22`!%ALKzDU&_l=FOH4BuUanpoqc~tv-rL(qDHs-t%fn z?5z`DW!?8dfz*75%)(AE`v*zfzCD%$VNVBk*+vCU@iA@mwdx%LBG`P)4s=H#m` zFzPE!woH-$v#}ga5`KYzwCRC>EVS#OjGk_}Fc6E6!+j6(+4dEuo=0py0F&3ew?d^a zbju0y+HaqfXzgIDXimfufnnSUZuT)|PYKs;@=Ya0 zC|Yivu=_?z54;;zzk8apN6qd;kcFAaJA$jSQiIBDR?c>6!a%~OBvp>YQ`Fw~c&EyG z(cZ1P+}Muc`nhQ*X+;+?Ws%d0X#FA<3cc(y= z=ccFCje-Af-uHE0T}hV&x@zm*Wvhhk1;)=zLW?c$O7`TxBcOaJy8b~S)wO4xKzc|s z@}3!QwyE@-B*3>RWH8y9ttJK^*AdTONZX;tM}$w#2PE3MW4|ISgoz7x#ats=fr>g} z|2oPlhvC*e;Kdn1yQ@RPtm zZ82o6*|>XXs{76#UGrI9!+ifce_JwwOxA2JynQ*{8T~@S3rz=i@()01Y{gtndk4C6 zA%4rD&gJJZ>yMA4YoN-a9YRg7?8Yb*O%dScSKBeXd4J3N-@soAJYHM2sdEv>z;fbU zt`{~^0Fn(0-jU9moaVr54YQ-!W%4@~Fn5pB&CQ4i{Lw9-d@-hMB)djk!Vu*M+oOo? zrmDZGGc3r?ab6VFYkUJo;9%A{D#I+y2#mculr`D+jZ%Ie+Nl& zCS$zcNhmy-Ie5u(9PxvT3@iJClG&gfnfI3;1MVyr2u+L?2W-?>%5E1jKsJN)3JiXu z{`)aQPT8cOKcZak5%56hnp<%CSC8Bzf!vK;k?IEa)eCaEsZPCw1C?txVE8VnFyWkos(g4K(mNvsUq4KHK>HZ^<>6r(`}T{VFFF_2M>Pj? zvaCw*an7;}F3^SIJ_>UE#V;A<|xvE0z0qP5H~I&8f+Dv1%fv&XvZB(;~hCZ(Uhk* z_*JOnA^o6m&f)xcfeKsF=4y|}crJ%lAwpW})3PJ>Q8PI(7k%ah{kvi#+~&hG8;Z?a zYO2%EH!xrHE;7!WC18b102J)op{d7SPlrB}VO~2V6^^F3;;JxWG#XV;fi8mFZ*L+r z!`~p#+|OZER}1ByjA`%X_x%bk@ygh}q5R(S^{$~rE}JzKW!&cWp{(xKr_z|R-#>o> z+$h7|Lvr^P9{wH3t4B3hjaQmhePC*U(y=Lth3)&v%sW%PjPYWCd6P)Ubh3cA7vi8_ z_h09x;lxZUfb#g+4-!G`BBTYP!&z8wMcGHke?a}^SdY4Nbf$w>%^w)BqWGrXLx_oT zjbBx%V~A6|cU%1*?K%q2G~kSD6_|$Nlh@%Is=aC-b@)nBFUCIS)maDJ zz9&BPhJ~CAPsWXWLiWw<>H0FsVnQo?;v`)kCVi`pCoIUhVQG+H0%zCPtOX=x zeQ|&pGoMW6D|K@@ol;-(?Zvlke%el6lKr`sclWu&0k-Zh^-wk%zn&esr9Xg{K~$e% zU^B)`ksG5?iq}=pT&9sL&Sv-MRK~1FS{1s(s)sm*zeVaL_ul+-mqoxzaHl=SG?lOJ zls!<3`4{1j+dXIKs;jgv8x|aj)RJAd?eli?i-8lghQ`$$e4Ed$|POglmIAA>mRt8KKWv6ix-M=m+Za8 zfWBK07Xp|W2Nv*kYcb85FK&smu;m|tEN`)jQZ95JgCWkdM2nxSfe>@ zfmH_Q>9@Pafrz)4+Qb-n_1GDNqJCv?$&F&GA8B7Tj$%}ZROvOD8KyooxuF!VB2lJ# zwP7c)ZPl+I0-#T1)A;5ehVjxN;xuKp!U~IyUI~_Qq6Y6{!dkc^>zA-sYCCqKaFIup zVVhl~6Rship@&@Z&fg?8$J`xT+?;SlhKch7 zIyDd=J^!i8`v^elQ_GqA{TMa6GI8Ka+V0iy9FJE|eY#(Ot%7@h9xQ=jO+Gm7eg1AKzn#@1x9sLxqIj_Acz-ZC)nt_yls(3+Ic-6 zn+`tLsT~^IzH}Pe?(>1leP^8r?9Zj_8dIR8y(dC@u?_5bku@VjXC`yL5$(~^aPXzu zjUEh(c8+=^A_>0Kc&N;WHWb9~0A16-g$h9%)aJ z^jms;2S~+z;9!(6@cBraZ+_Phr|;R&UU%e{PZQbqJ|r8I7p}E?oQNCx=C=Fcym78b zu%T#Z2f3X;jaw!0oP4GEef)>PHXx)&f!a>{;q2IRI_PZVK3i)W>1)bDnx6>Kp7Dc} z=Y=6~1nE+%4+-o57!E=4O7CeM;gCGh@ zitQ|j?!@FYVPboKFDhE#aIwz>Go4%lQ_91=os46k7rH4E8Q+hX(t|{vh@Is0u7Fnq zJ|xXQ^s2dUo8{=yP`TY=ttbp2@LqnWXDw$Q^?Q4(J#kR?ztifZ+~B6iyQcNqoscVg zout3#%o!X{-pJ~qYC|I%2GC8A1R{&MHf@S9;KaL+==Ei9&Ui%96rwmVh20v=cp=d8 zYOjm*7XW$Zbtt3zAu&s4-?aGt&dqmQ)eXeXY4Kkoq*$06adU`rfIuK_6JtZGKjr~}7(r}I ze_Go;u`hpQX<>>&o>oEsrTV|Df}H+8h@V#dU&Q_!7C)^NJFOD?H~;1QfBahnw@QWo zEI%J=Wqx~^M*X(Bw*LLc#?Q^2t!?_=m)(Q?{a;6ihsPm~3r8T(S$PvfJrvf#J~t(p zs&y90;3`vA^?aG0e|kDDfmqpO>wFEfHKUz02Gk~Qp;b!o;Q8yFH;E0Tw(dSFRj z=Li5&BzSJbP#>Ii&ReIX%-c+8`OvO6V^z--?zQo1LwCqJ0Xc2IJoiFxaL^xK<~~A_ zT5Z{*bYvpbq3#bp#Ga9AGVO!9xZi(VCu*- zQ5agfT-TuDd5Rve(nzBiYZdqaosCKr*7(;(Tfdkf$1DB$Dz!~YZER?8q?5YEIH%K& z=N%z%hjaJw&Y`jMB*Jl4WUa8WupW~Lfmf3{I!?OzmA}YhzUDGGAheOCxP*%G*C`Er zT<}sQ%CXhk7n`SmEH+Y+&%QtYuE*pKdgoB1hZ2&j=*yQ;TkF8@2$#jeTh8CuS=uL- zkowsUg>MUAYw_|Q`?)0H-{9ym7XVT1GV62Sa`JqU5+K8|Lv}S*W(mFXI4dS*P+Z1P ztw>wCFfOqxK5=zsPykWmTzNH=4Khd(!j=-;PWTj2YvW<}hhv(tfdtRQmrQtqdOGWq zSdb9Ga&cl}X6%R5aHD%i!C1Ypqz$0&(<*q`h1!ZMbqyZQPEF!@bFV*X@nWSc`dXL4 zOR(__D?Cxhu%3z}CZeTpK#jIEl2SL=Y-U922W)5ezg+52+ed~s0mP!P>5sl5av@uw zjFTy0TZTY}NA;F)lB=+a*!^!kOn~9YY(sH&OkUEo^q5@uDPhncSzFZY$f$VY#vvT? z4(!4l6R{qD6IwG)FJo5!$AT+@2kYqp%WlS>$xuM~s*mJkKh>Q5w!c9N0(ynIq0uJ@ zFrUn!xN>FJL`GB~zv7pYzOT_+L{r=AQN3TI{YtBnY5Y_1*j&^_ns7!-fB8iMuk;rt>MlRW6UX|2W zyWL{rkyO~*oC`Mx7zuT06DYfX;BoAW&YON)p3%QIc{b(neM;v(i}T-?!Sw-Sh|M83 zE7^qMSJ;Fzam$~&PTjW}_^X`-H246RxaG}o=kBgiXh&cNTU!5!aswHzzrqHBh7i$F z$BFA9Lj)Z-7hrtd-~IYTVRzL>^9DMyi+|V-sujKC@{efnl3Ny zQU8^Jmg?j}{iK^_bF&=uEjk0f@>A4kD=}p%>mE%c2ZeDg;zaF$;#oQEc3=%DPmZex z|GGPEa8J8t-fxS@V7;m%R~710eg^X7*rqXgZH4*Be4Dh#@w%lO|HR_5jnKYoaU5qw z^SmPdQ3>HEe?t3oe~^7{CvGHLbZ7lMkSQ2kqm@}!sc~i?Tg_7`kODlqy!b80F(Ti8 zn0dhy65GRYK)qq5Hz92GHPxu}L!h;_?h8$!13ZbNB6Ds13vj=(IuMAae$tP4KQ3DrAPow21|x6o7Pt-u~Y zS>`0{%PqJhc*ALe@*nJ=q*Sx|^WD^`X7N(zgX2S@tLH4VrzN<==*0yruz#<`x^a}; zZIDTSJ4mA6mgmgZ$kO^HQ6TKXy+x|369PBWw@i7*gP!G;`dG<1)s|(bW@b=UEH5sR z4Wil?%bF<%PZzR7GbfFhgGFLl;pc9z=AE@&+jha+zdVf(8s0hjto;UClyff=)9Wh6 zs+>~rfMe?>Y-gTPCei~Z*W@+eqdWVgFSs4|SWTIqb80+}b$0vU;hfsuYHo-`xb7@Z2d;8VMZlkuN%)2i&3Ss2->fCHyaW@O&T_`;AIEtsSzkc_ zMXP09D*hrs6hl}uzwazZ#u*g^%INF^#-#yWVE0B$a>Z+$sYH$@Ibou^<`BhlP1u%^ zuuE|OOv&4ahu=U1W&1AboRrj=x-reyO20RSXMhGm$VMo){P&@oIht3c(XGdB{#Q{3 z`K+-?Wo6j%QSIkk=iDcO$Z@M8;fsF`v7{Xo1;F?0SS*nLWV8Tfe&MVK7P5DTO`8*t zk#+;5#jP$hEjigu9sIUU=QJdtVp6y|TbUO2Ym*I2)qKda?_FOVqQSgLIcc9UcO3qy zKh}=pQ8OwcGkv&j#%w5oQGQcBJID-{6z14a^Soo3B!`6GfHEQ2Q)XLYIzK9$==$~B zr+Qv`vtcCM5U~S$48_A7qneVo#l_|w70QE8VQoqVUjA8ROb+QWY^OMS->2$^aEq>>G zC%yZ9;0KQ8_4`6D_G7V>sqRUnW#^MP*7q4~jUceJUB>CwoIO(RI&mcc@>eaPa36Q; zsG0kzRG8msRJ94zsAIQVnTAmyOtR*S#s)nSoFDnzZ)619Iy(IHN;aEbBQgQlLQnvImgFQyh{(fD7O>F7FF2k}1sSo`G}F9{ zxGxD&cC`ufh3qu<@mQhOOyKs} zg&9QJ)D`s~^44}wA{k|4h(uL_|48E-e@J_Pr{B?h0Axk}3YkfSaEbZ0#Anha8=#~5 zba%Mn!Futo@^l^UD}T$_blvB7cTVspA>@}o-P&(WV#F0qe{=XQk^DGf2MI|d2p8_` zW*dI6ELU+BVG427FU5M$my+t2m#Uh%00g2Gbv`xirA%)7-~tT{z*u2<_t>QL`Ff>K zCUBja=$W*na?ck>4IZ{JNgihz=6fJ2ruDdEZKLsTn`)V=9(~f^87)u-*+&Cpsu5JG zn~FB4X~acHmQ5(BGi$ydGTwgbcxX|z#s%alb+j_Bo-Gj~&^13b$2U;RZiQ_+#pm?a zOSK*vE&$1-r>?ka*NC~fRf$BmX|z7-*KSnwMTni&b1%hCA1=Z~g&@c(NVS8r9twH) z-9JR^cCq=D;Acw`8Ri+2+LWeYn~)0xDCE-kV7u-nwoR8@W^Ta~+^112qH_~6^_$PLV0 z7U{&Ims&h4Xt>{3ufdPV-UYqWk$$_2(`?bKatuYhPon*yQ`s~2HBZn)EwOPcr-wR9 zjj*oh{&@7KSr7pq(iTxW*Xkr0zOT$rsV&V@sx#m;`@Fnz72lJ5rOpS-0OO5rxx~j< zD&PRO!x|>=sKPtD?7Z$}e&DvXptr97x4Vp+>0$+dI!2Fk^XiW`2oo{&U*_tSj zxqyf*Q7$n5dAC@1r19MmSF&I72zB-8aNsmu-ywJiGc2*-EXpR!vv{RB{NsD?F$VBM z$B5xc_5OxEc9re`Zdf~&iD%l(j}CjxOWQjZn+Gfy-CD{I!`@?p)KB^iVA#F&rk(`- z`nT*}X{w?dcjQ%n@`}c$SgP9FLXFDPmz33nvOr3L>ZwC>jem<0`uDs617r_xE}k4uma zotdNVDQ?1q?w9qZp3E2xU-ySdNa71?uEIZjs1vXTX0%?7s7?Tx#1H{+;jBiiD~+zm zHq#!CyEE^}{@oa>WKJpkPGjKfjz^~Fakb{P#BjfZa;8~06cgyG-Ar#};u~BC!hWa@ z_V`-p{vIThy+$0x^d*1GPXquUwx6y?r4Ul_B>YiOx)yu1HX;ARQ!`;}CX63n| zFH|zev`2y#MjaLR33h_ln18-ggoMus%yDX>9vmm@p(E?>wAQAtuYC?k`p`BS2zFCD aP~08HhnOrnv;FxlK_*CZ!)kq}xc>nP5Sc%fr)U&L>turA{~WSW7ydi#F7@0%&#RnBJLsK)Ut-X`n)!oxK@a5a! z&@g3md}4BH`umTW*}3@z;A$2N2y}M&fu=eJYxOuQ_UWQ>t(L8X3Fv~1S#71|X#YCy z=%ih_jX&v^z(fIC3S%;Wd&XeYoaH`ktov!_-_fJVhSJgs35iFKrbilhlMj8?TnzCs z=8Y2Y(&Crdjh+?e4OMZ*fu7S+#{DD4jR==bu9f__%KN%(X1i zr#-&y{<{Bc_elf!>{%iG#wrTCYNL5&bIgNDY^?QSI7^0td_i!|)xg>c^NZQ;FRnKA z8UFfptV-nj<+-@W=PGW5>X%PrharUMbTFa$c9>o+Po51p+8IkR$1jL!Flb(aKr3xR zuUhqkhdf3w#8-!%wV88KM&GqQ;}UAyA(f0dV&kBOI&W`Hj_Xljr2cOD(QX1T-^+7x$)r9(<% zI{n}7FvI3pU_YcZwL)?5k=)V}xFF|jJg^jtQPXzwmFp5xmgyOnc-HKDBl4*Qyle%8u^J@S+c_^Ie@@)9VYb?K7B|O{ z82Zy|5PTh??cHji?z`>GSQ44Y9m*UDe0r~xX&O;qP>PEoP)}M74UYHxu?VnWQT+01`mUeb^eYG>}NbQ zSAsGT&_FedUF}g0K)J%+M|7VPx2Q^qfy^U}bg@k0kgP+{c`rA!2i&i>C5U~-TJLr4 zZ0a8p%U8eJR81Ad-}rpAGLJy&?duyiiP4xJY0gS`{|)5@?nl6x4H^Weo--sRfjRj- zzPJ__!9HwZ!4T-~c3_FRT57aSic`mrJ12&D4wbO9_);Vf(gAc@uX<$R2r4s#+c>^> zS?wqDJXL8aBk#t}U{)CB@Ia{ec66LN96j8VGTFUO_@TAf6iK)n^6DBc^D;J23pJYX z9;v|!l-bX{e&xEI^$b&g$)H2$)}VHLmqry~s1TwLkqJmCXhaWbBGb%oUv)`}zWiMQ zw^3s5ei!Wb*F@*>-b*}v@Y?qEaEHPb(F)hdKIPd$s<+W>LQR>Z&b{^h@y$Y<71<&z zwSc=!!}6{B8xj@`ci4UmH?SSQ2@@xQf|zk=FEOe@Fbgh*ICHJrcFXuyieGQKF|kzx zPP|uyl;^ga>tqy)0BlT_(8Vd@{CZ-LBCk&S!*zUg5|{@4q8aFCKuPYBJnVlcge5s> z4mI|&SZk;~hq$1QQV3krpx=Z^s}&|!z=7JPavcD>VfL}e zI#E8EMAEDeA256asj4V9GtSFFe_GuzvdchY-^`%Vz=Wnu|JV;OR^$9_gRCyss+m@IwsTsf0gSc# zPEt%4*)-Sp(yd7gpIv}kHv5}gmf4^bpTL{KF_I#`EQ~u)hSW?`cjIb2e^3I+MGmtm znzEyE^2TQCYO!&S^*$|HN@-7yH!`Lbzh`kuC|Oiz*yus z3e^j!!+|&4=vd^jDA54b8?mRgPMv2(;lYQ$X@B@2FzCU*KXo#&jhMtSa_y`YhkxZR z+uz{3o8QQqnSVaF2FL~7mcnHM*bX*iakBPaTO|Gn&o-9ayLgd9^2f*$lORdoplcX| zY0dY5Q&d=`8wTpoEF3YJCK7K%uUVv>(|vEPMnS*rLhgxINNwDa?^zr*IUamZA|0(& zU7(n}`<)y}&AG_kO|oS_ZbhO_J{l6T)&O;y_0gB5FzdD`QE3|Q zi$7#m#eCmc>dp_4!v1&nns(yyP+}29_h0j+!m%5N$SpJ7P7Rj2dVP4f1}_(;eSvMVoUjJPce|SPGJ!!Sr^9%q z9RV+c%!@!T2CK)Mk-TDFzfOrx>fY;~l^m&$XNCDTv<66cCb!5HJqX$ocqdo>d=dAr zxn92-HO;A&I;mpo%mS|rXXJcPTJ^Pz4=If+quE0~_eX-|Cv{Bbqre{%16c`X^J2(- zATBT+SS5GZ|Dwg_X2D;F&wPo*MI9IMqLB$9(fFEL5M`}HKmZZHdOZC}EE~ED# z$7gI;E)kxjb|27-e=m)3PGn_p7TfUQc*nxcOGPURcJ90PIT`^*^gOG0=#y(WtOhr` zG{Y&sd(s|tlI_3_XaBrqg#BG)^~znD<`X1y;&^-k>B_>nFl+%;LL%xmwruIw-mIi0 zv3@x&e&`$dHTcu-U>C0Kk1c6F?Ket6vMccYnvBNzN*>QmYMB0z{AJu=TA`Hp$hqpw z$&GP~OAwTPIn}dj1JOr0%fWQ${NIQ9_-WUADX#52i)yDK3(XizUtFDncshDcLW>PH7{q4##B)nUT$?$If~AWZy6CIofpU5nT) z>ufqT?7%&4IqwxPcs)Ft1t&l0`rYefGiLRi42ojihNZ-}UN0U|4+_C~o>lP;Io^Fi z+X6#$xelFOZ{ZxAzDhwRytdL#nvQ3yv=3rYngy?i00e9&P5@UtmKVtvZ)03d~nx z!34RW`crIT6`amwpT9{Qegi2Nb7NHnmR=(<{UaFWGjgyFb>Uv;ZGm^W2O3h4HFeBO zphCajRz*^HT(e^_-xkD!PF#8+@`F5OmB(zFZSz2-qvhLCKbX+|mG)HEB6wWwJh;aQ z1Ukwx4^ncr26&A6RT}Pw>llA$0URV%h$)-%#!l0&n_Y`|Fv=mcnoGnZK$E=i>FLLD z&V5hWt0B^2b|roOZqxq6%Hwj#r|zTQwqj8fF}{`6pPNUQg|V6)9*S1d9_d#@T8@1p z(-h;!8(i}|)nUy(;@5X z#7gUJiD#3DgOn$R@O(dzy&pBdD)D-jr_u$6L@LBc6j zp2vs(W*+xrY3r{|#aPG;hU`QGcn-c^?<5S|Yz0pM{y1r0e>sj6E?L-|$xc!A?6a#8 z;tU;q=SxdQx-iF6ixJHAvDPACJ)pvm;zk_T!;)S_qXWki0I@u5TiZ=+tJ3)`q1%`* z1h>fx9U4eKmIc=RaiRTPZABTEKNA}k*@C#$&*GkQVIPc6PxjQpm~eq3cZs7WY_F|1 zc{p0*Y?i%p*EFiAO!l{NCMhqy%kHZtI>_>C#CCa-K&jf#D180xs*1Se>tv? zQ_EagBL1Xy@?9R`4H~R+Us&+m6NZ#;z1W-f;YdAKm^K+c%qQvalFz$OB)FV*I6&a8 zMg@tK4|f#h%D!d}GxE6#6{HJB$w^_ihEKLS?l>iZ?_7c)>bEl6*93Z!z);U~E+yA+ zYU59Qs)HX(SZuC5jLGJ?{|d7F{U#~xl7fOZj|{95pQHO$V~X)$QCP@!Hn{yF{~kNc zeQvUi{0xi2=LN_H(cGLzDP81;`1svEmDQi=r0%$w=H%}2^}D8ZX?>DAYUs78oA*t! zV#|9BFlo+g65K_zl&1DBa{1@BZh=y~z@pX-kZsln693;39s+RHvs@=gE#^qRocoRh zT2uN>ML2J%_Sox6v%trggcqfmF|}}xttNlLeG1|VEh;i&$O75^+|ZHRcgwV!)97&bYE1ca zM7^3YwOaMO6;xnV&+!pVDH*7U@o+>;jb`FInPltUvsE!23U~$WnBGau*j@FR@f)a- zcXO<2i%IHE(dOMU4OM2-VHaf^$CS^~!rmuH8Kv7=ZXX;Z0G3sc^Cj!dv`92FT4d}7 z_Jrf630&72+!#s=nEcl#(t{S>32zj=3v^0y9AOn&_3)BKN3ep1YSP)tVu)l(k*d-dPs zFaMiZj8aa0TK~f2KmUV!lay1RPEOPMKhIEXW~rz3G_C)!-7NK#Pt$JxFF4HqkN?8_ z-|F4BfQ}KIt7qo&B^aGt?=~$SM;I-K6cilA9p_ghoV$snDZw z>xre@()=WZxlcKDkCOER)0-xX8}>8Jdoop9Ee9E7#+|X+;68fau5eLKw)B^Gqat^v zq&kU40Lq4Rx?&RP?z{hoY9>fFQT|H6vL?{;Yoc=QkUWKs847Nmw77MvI&TGG4w_or z5z{63ey8JShVVGc$`p+)9{1E7R7Z7heFGZ5c3;Yb4G*idMDb_)(8e@WWQp{ z2F=Yj(I`a)m$Q%zCk<;<#j4QSp4BLUZSXmnvPv0(GzrfaLc1Jd3DXvr;38?ZeSqiL z49n?2m@xnn0u+Bmoco!k-iV{Ey?tx_xTXMhmdk4VVCFVlg+&h8K5G#s6&1PiK^2=) z_aRYsZdrRH6Hd*6Hfsz=V+|~6E`pX1jKvUz!%|yW5n1Cg@$cAyx*2ZAJ0=qWFilek zlWYX8%F_0bv@p&-KT-Lf=e}e2nS;JDoDw8FBa@BFWL>+uWcBCHLaQee(c{U8zym)$ z-&fs-)=4X!D6>u4!=pG1%Q@|At2X5HL5`>i>PQ41zUTG%aKKYV&tc+mzm1sVat0b& zdsMRA5?GK2QgGx_(Z~qT7xD_}$(ded&^Ly7c`H5>y#jg`jRZo1UhpnMv#A0k8gzST z6jcH)kME1_6e3{NeqV$JNeOvUTH^N2sG%Z}k0xJXcY2S2dKgI%&hTL`P=x*-WY65* zry~k_5xb_wx+N!};cTs6G>(_jShHj?MBlU&la^^vHb56x<~}8q$|4&9M0}T_M@EI) zV3CdpA6H5-{LR}MSaXf|QWH{>Uf`$xet-$2%{5+cA+dWVVz*8A&Gw8f{9PvoD+J_n z8=F+;kHKcO(gubCRM|Uy%we3)j@$62=!e(cBw+U#TyY-~a@b=DAuT}Nm4#U#eT=Au zH5T-s;~IF2rUPQz*}A>?%Sp!EHUw6q)-CFYGT(2Mlf=3M0WUs|$0*6Smc3cKw6dQ6(@HBXX`Skh0QM|U-fd)3ll zV^MLKrQ7k*9%r$L{aaO4w3E*S0M~f2;PcOj5hEUdhBo_!_T6D`Yx6}r?hV0?Oi(OH zzB7e9II8&hNuS8iJ7qGT^fx1SUaz!SbvMl};%~jKD_;y}8so|NEoH9>rq52Xi;8B1 zDmN`Rk*=NG*=9SEfG~)Td?yf0V|A9H@kN@}AJoDL&;9j=YbYQ6-8VXw4ThF;y`FM} zFLHzfRY9`G3Vy7+9jW)G@h;{4Cw07=PtMAk;V;*Y{nzU;B)_Xtz?_L#8g541L51 zho4~6Tu)Z6*bR3kPz9zu&%h_<2}Qec-S*P&1V6hym5jS?Kx(3gMDBm#5_;Dreg2WM zm|f>S8+a_MhlKFHzf|pF>Ow?3745N8Ha@>p^~20eUCcN|z*{11^W)077gi|oFy0m5 zws{-;wY+KA4+EA@B$_}Wh-l>F(0p_x3hpN}XiUErTXND|(-1jBf-z_?~2 zZUu*Ka1~0~e;f$Y^}V`0`qeRG;WJcBptRyeBmy&}Wzr6}K6-c{fM5VI9lbaT2Mp;awTy0sHn)-w zjT$P@aI!Z5G{u~cxZ?WQb4yT7QS_LIyLoJ!ox3=`Y6SXPt&lTulcDzws2J0j$ErTEW~k;vO^D*tPAulj>OCOJ$E6eQ(=bHCH{W*M0gRK#x#RmAl39DL1 zcP)_gf{vO=1Y$a2XOpl!C!Hi{ys7{B{G@W2%8+cr!0IuB2`$o!KnvDkPE<#A*ou7K6dZRF}XB- z!dHJf)Id46OsxiDld|=;hi=NB*&rqFlUGzKj=b`8@-nay_mq9J_eZ+W)ecSFR$8?A zI}gPK>g))8y?b`duhxO&S|z1vaA%k?>axcsFn#AJF=!Ao$`mEy!iyKa%HBz)t~{Rq zQsoRCsJ`jpdhLO_&@QnhR(*SUjC9+zZF!%x<7iY=oh)X|%pEy2_MRLoER*6T_V`S= zT_0oY3{hCtSA1D*=c_oj4a6n^qGOGAmwO?J6`fmEy^KeEnVD+`lHfN&uxGaKm7Zri z_o_rV`P^#O{19r(qbE8LjwUDV*xg|CBb{9zTYND{=BYjJ7X0-+l+r9k*h6@M_iS>XxnKtE+{vD1%2ZLTju|P*C?Fvsl`R$yRxq@q$xx->qD)`OpyucJsdzkWRYeO*ljYcpeBvT~m)kcGQ42mnM* zG&*bnu#Bo{Z*2;L*?uY^xsB~yw~V&o&_#f-pxvUO!8Rqh8#%|GsIyP0NY{gphU;9( zW$mMFNU%UM6^X@_*&Vet&zZ zg*G|laI3$u*k`t$@{r-dLen!XbtmT%1Xp4*XsET}q#%j*-;^?@d zNu&!@>}4HtrcH|1%uQwc1LS0iJ48fU)2`<(S8_8ZVZ1*>3zeyB6`}8L1HEsGI(jVG zk8(?+pH?{ZSd~SBH@ETTRQBz3!s28YU)V^%x1hU`F4CeJcf>Zh>!{)q`WjSu z@MXgQ;B}c|XtTlZ5Ssiw8V)6Osl7V6NA)sk%?DLJLgmSngGS9RJr~nFk55vJ>}5-I z@%%fKJ$(cVTjkZ)MVIu6ZgswN9Gu+KihhAJ&3b)Ci5b1Y)f~^#ympT=e08PpEl2B` zOgf~j###z@QGWUE`>LWe%FnXSh*~Acm(P35E5}l_5mMGEqq$ES=@=tThxwItQld|? zu^H@!vRucwsn7Y;Qdxg=O0(3g&r6j;lwX7B>ncAw4QLGc`M!HxXzk#q!L5>|3QOko z0sghgo@9YvA{Bc(MTe8NTm!!`T9lmp!{lpcb}{V5GB+d1_ILEq2TJlC2CxYKgq7^P zj$QOxN55=DqRlZg)Nr>0ZN^wWyy_NRt{*VO!!QvM{J{>XGibZJvuevWR`C%wwYFt& zx-@z2apiw#8Heu%G9l)?RE2hv~Xc#ODzS!5l7k_s585ba7U>$8mm(uJs zRhMvhf-KNftd9PoPQ_R_Px~F#@!rY4lilQBU8B-aK4~O_9nUBBucitbR2fUB=-s*D zuuEZ8IKtQzV>#8PLG~N1*5>@%lH2^C(IhtKJI!Im}gt5HaxBVMROIXc^+tUNV*&&huZU zTJ_))ZR^H?h2MxcPh!}M+76|1HVJA_g8$rY>1nvulRv2hFY-(r20e;qB+mVwz_6ul zXp`U!I&Yf!ya-`>k*Tf<5Y4T-1>}lj@e0{$o~x+_Z?-BX)V^Pm^FBA#P>;=K00-(j ztIerPg9p?nz?#afGV4zS>qF9OAxanTKT$=-CjmQc3|;d$pu^=-K@y!wIzATB9t%V! zE#=(VS20^l7D9O36D|$o#khD^pe&wF4&iM>TjQR&mNGHHkqgbuFB;i3 z5spv{#at0LVfdoGe#y4pfqI2VT6=FFDAi<^6=AL~(((1{GJdHLDIDu{EpEGX>>TH- zZZ4GiNdI9Esq;|J2v7GFY_d=~-Jr5#O47i$c*akR>D-!cXD5F9MGWwWVmM&nUQ_22 z&)KHP5L>YNin*lzl|wxbF1%UM$Hcy-_w5*SR%A+@A0#8P+g%t2jQ?_N!%DpC=t2zr zuQixBc7X#r?}b)btNd#nv@p99bZ6BGu7C2_XY#{yGf zPL-w)jD(SXO83^*Kg8+8+x706>bZgft#1SLqrF_d$(*bn{80dlheir7yU?yPou2}C zZNIubT}Exjhc`#sY{cbDV!OK93cVRQUb2YF=#Q_pef{u``l|6(1p7`K`lQ9g^TdzU z&`a;RA3EnwIQ+ukkdlH_AyACJmX5a(ApbM5rMlzR_PM93Y;;?9tKWRv2(ajyp{T7M m+bPSIB$wxiGzI3J0NLz@$=cc%icf!)0J>U+n#CGUVgCnxoBcch diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png new file mode 100644 index 0000000000000000000000000000000000000000..cbb2d11a227dd44edea10ffdcdfbbe8e34721090 GIT binary patch literal 3792 zcmb_f`8(7P16(0uS#paH7L|KhN3!JDbrV{V`z%LpYAHwVdy#WRxk^G2{%`F>+ z*u`$FbJrEc+aK{h&pgk}Pcy&FGtVXU~M z;UAe;n4(c{sb~K$;7mv-|7-<9t;}z&l9tJ9>y(Ynt?eD!E_MHaaJcvT==kK%={$2C z2*iHL2&sd{I5`%jnZoC>1jimy9d~uuQK}4DjrUIFEQ7*1N`T7}a|EEz~`NgUbYWQcZ>g^SE+` z*{FZ8nb`fAA&F1F6Dr|2Q#wa8457JxC=m97#SSC?h~2%-C-p{g`m0Y&1mH?{13<=l z*2pTZz-O@ow1`(qYoYezGSj-Yrrt#?d=Q?D&ls3yDm%PcaU}k-ATVNTR|1w3{eh^w z+GIp*&Pq|XmP<&hGV&WD$~S(1dqpd_OFcvROO(7-ak^n&h_CPXT7mgP5B&KxS`2S! zfqi1Og*`26|R$uv#Y?Z*lAla3P}dQ|gJ`weYpD+VIa<*r5Z7br9(;RIBF4 znS7yxx0kIdeD|UGtw}eA$aE>N=z{XcnVY*DYIASl8){hG(q*^z7?|>S-^YuL!aMv{ zrgRI|l@g*$K?WDH*}Ne})h^;YF0O6+L5!om{1kTK*g?fZMqu5&=q!UzI?SuR&9ln^ z(Q>az7Z%en$Ttx8pLR^z;ME;|FADi!j9OQ;O_q^MOy_@rFJ z0Wh_?vhMx?oZE_t(LeJB*MV9}++wD^-D0K~<^sn~OuWmBJ*sXlS8$D!quD0`=HRp{$Z9%~KMPBT|j59!8?sHF2B{WZRSyTM@E@M*t{rUp^HJZXq; z)_gjTmh=Z6Sz$(II4|eCg}YgJmPQ+ke5rXIPW~?uI#A-Wl?$r>lCJG=k$9I!qeEmy``_UzgKMV$+RRkfIdtAx)Z;T$KB`V zXq|Gs)v;gS5E8`R-aw5__TWZHFbyH?@B(Y9Bv!MxYhigw>&XeJdp&*9UgX+G`~zs` zUfHI228@di@=Nb4Nh6!-j;wnvC6!+~v}HOrvd%(eTy3x6!O5e=e$)AU3HbQCO5(AY z;|m-UKf-nv$JAgpzw%I%G*S*gDPef;v_WvS@u7})mHjQ1ox+umZ78(CmDzwCzUG_P z@bp_r@xcv=Eho7w^0g$N&OIHRR+JUTfmO+Jn^H8bP)3DBV?t!|25(=_d|lgeejrcP z3l=z!$dX?o=Q~Ff`wuhx^a7sr(EVOEw$hp8w^~UxsQw;kZGFQ@o$q&K1C*xwyt)fWZ1j*`VP8`?#|$vqYc}110Pe3X3#eg}=Sy!ale$MD(gpHq5#=9#WLCds z3-=#JW*vM}iJbZ)#Dy^R2Rs?fQ<(a+0ti||D2KwT@MlKJp*I!S3e>Jz%bKC^WYq)4 zI-55s`K_GjiHtsJr_&0MMx_Z)su+?uHt!~RvaW{?N`Bx@3-o95vF#|`R!@BJSFBd% zUc^dx?4a+>m-bm#*yTZpiOG4&P)xzr0AyP#xALCnmFfTG#QZ zE?t_LUv1F+6@9ER=fCDs7;lcQj=kEes|?B2f@TdfBV1Anjb}n9tP1#+YaW%ArrDR? zh&~u0X4~bc2eV;=g!&|+wxs$*o{adi=5n`fZp-odv2Uo{e$;=(mZ8NO)g~0DWe0db zF$oRaMRSRBO_=IwY2k?^v<<4l{{}VKnG&aY4$&bggF(OQiVkN;rSjKcdL(Sc%exdT zU{ERj^!NK>YS=t)<2MH!a|2qMA@VC*GlD&8*nPw;!oVh`bD;cv<$RgfRMjn&Rie8r zEX(+GDqo54ZmCQOtI46j_O@%~#cOEwskPii#Brj`ZYxS zA#G&2Y*GtaH!axw{tep8m&DiC4?~rZg+{a;9g}Rg%4FN!`@YRdFyM6*`v4iv>MdHx>1w<3(&mw2Nv3twyfxS4DoWN^gkJeV z%1m2K=bYSW)M8~j_ayr60v0B;Ptt)#??1t0GaEGPfC)ZMGiSp7HMvU!a)h6HHdw;# z5`Ee*V^jUiJE9-?AgUg<%`<=Pnp-+b81}NC;m#-a*Ra?QL{p4M>dIBXQ1r*`#>;Z} z;-s1at**F0A)8B```!2nzl8byHr9sv8SSk#m$mZhMWgPxb)9(o7^a-MfoQ}78_rbD z%g4n`_cq*rMJ|4g@~2--cAR@o#_efQD zO^=tHzSSemO)uj(L!I*wLyD?Cl&g;YXf2Cx%uO(-E3^)ORlxH zjDXVmL{I3I28`2LJp^Jsi8%BdZvsKah0Zl4Xx=UKq8)`~z98?YW~$ullX!N{00tY->(xiH#6@Jqc4|P{)rLQgfY;E$Y^5Bg|UDLm8*&O+^5T`a)~mhvnA+ z4|ZJQ@_U=a+Xs*xh~)BI_wai6h}qdSu>{X)2VL~hUR1OcV1K>DTcpz$jGb)f1z82D zobq}(179}$LxgTs`6~q%5XCagGp01>TZV6kT)}oC&@ZqjkC%3jqHwp8fb20}94qpe z5qh^~X#6%<0zKV%tgZF;eb(2W_=!?W;yJRjbGA7}oC&!$CAg-~A{Nde zxF4n2(U#VgA;fPG`%XXaorm}U{i3>**GWZxi8|6OPadovtyk<1WBsR`hjZ@X znzcGKxZQ;c(r+MSCl!9wggZr_PxkD*vl&u|dz%3~6C^BxBxBHSRPsS-ebZJ%Nng)2 zAtwJEeD6s!Bi*SC(6`=k9512EYQEr|rXsjyBcrl?QSeF1on{9+5rdj^qM|Ba4hY7pmO3>1@g1(PpI+~* zH%~p5e+k4=9KBftL5&W_@C*pAj~LO@*yw0}&e7)9mj~pkQ`GNeh$a!o^2T zkJ?L5{w}`i!IQVbEWZhWUz+l4u2C(yO~5vc5=Uli+aJTO;b#wReM6+udqtJQ9N=%& zs4o^2HX*W!TE@vVZN?#8D_Va!Iw9Z>CVr(iF2xaDw=K+NIqhzVFn<+R)mYhe>7u!B z=KPp<4RgUWb(>v| z;}NcFcb%fO-<3uVw@>MtxES=r1rgaj)gXn;fUMiJ$1HxD@xH~Wt!+G2I!I z{kdUsGixaG@VQ&e#I{_6<5SCFWS2>T@7j1U4yRiC?TUOxaZ-_Iz%8FxWydf-`-unz z&kHECnxfEBcqSPjwFHpg7Mu*qv5Lk%T;;=RP*^q+glaTTQ*~?~H`%l|q*K-x1CqXf g8ViJYs{W4d4~k^n9)6Pb?@NM=Q0B;bU6SssI20 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/ice.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/ice.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/ice_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png b/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png deleted file mode 100755 index 1ccbd8b94f8d6cfc93a7fe9a001dd6b6c0d9f544..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4859 zcmX|_byySXlbnu{?(UEf2^r#~89hLdkWf;PQY3|uf^@4i zV@O;=UcF4n0#pb7-3R`_fAs<`j2Z^0|LY4t|GWID zga3|$0L_s@)>% zn*#ioZj%7*=sDwyOR4!A=or2!FR!euu6}o+4;QMhZ)|R9X(3#wt)ru>tLxK+dV4?j z4-O6ujf{?tjg3!EO?~|~Jv}o!H@~pBv_xFKf4{2^0AR_}K&cpEY>cxKACqKLqh6P^ zJ8;;Qzg6yFP!HI;>4-?;!%s})=4NdTdM}*6uJ=~S-5Qlw6i^9o$61ExxefXwA%bj= zrbB+a!XY4B=I5j?A_fit>VMF}IXW08KB9NZD0|>imbjL)m7QQ$e z#C@?(MzP1bq-5~kZz@W)a~ zFeVm5ctM|cFmCLV;|Fw);AJFu+oERg5^NQbYQnP&!;mF=j23O4S+8>WvMtzDXPb+$ zj@Xm5S&*#GcS58fvcaRVxt;u6;Z*Z_1~3S05N<9b`XYOc27>YwyeeSPjp5tMYFZhL zDtLEEdtEY>eymx^9UfwVFd*e5&N(6TBs^N5&ZTp=_D^RLf{(=E_`T3+>YErok`Q}V z4p-)}E8KybZ0BVEo|@@E!$ z!#Jba$YK-_v+~|nF}zo3aBcIs6vpYkefml*m`gi2LeYvmw&MKYFOcIz&`kpd?RkP7 zb<;`~Ju+tRfh18OfjvWJqC1%zgNjpId$(=Myj|=&=vuPTL;Cf2!KPhM%i4U-CZ`vc zEkCYIsDDLujN+bD0DavX4FW)3DgW)bv`$ThXWXS?#vXW`Tdi}k*5-sXvwu+#pata? zY9wEgH9wyTa*BN<)0ynS)gF=LC`3we*>C6`T)CP|epLl>lv1aBRfT@ZY;OHl(dUz_ z3SDgD!k2#3?s23onUwJin0SXGw!GOHC4qWLd93sZBHEVeb@2WHga=DpkOdgstQ}o&PvSK|? zCrmos-Dfu?T(eRaY>i|a;{*9=NU(OxcCCQ;jyOYYHMp{}9K?;G%5iBk%^`Wm&!ykX zKF->pv9rKqO(k}=*~DvBCVuZ&&(2@JTtt)URP57rEq`u#P=D=E2^sFE6SfDah>2P2 zdxP$ZfG_D2+qLo_DfdZ3^B;(}gG7Rv zgyT(0H*67m0-Zo7SXe{73H*LZF#F-Vro)Iv_5!H8P7hE#DY^

gWJN+XXNCsO6$% zAuGsNpjJl#1QUm&x(7qSOkRjQtk^k3yxcyicj+w6LE!!ai@=qLbHDSjFQi1Ap=gVQ zh!Bk&1oFgf^=_m90>7i=B#ljoPBybF3s}rD7Mr`#>0VJOwYR^~5L#?o9=OrPP;m(& z8Tww@PtR5~xNcKcfc3Jp_E*@3h&8lq=-$aXQi>Y9Rs8f0FP=5Bb_@nt7sHx`$JGxU z^~>DKaGm;??2e>acT7Uu3JPm&1So)#I(ojUZE<2TH3HdI7SR&yso;Vq+YFv* zJ(p}(_q{K}Be&u|7nJ-@BAshNQ_iQW69=zp?ad+C+G6RwYsER#FPEulB@I{qW+s4< zJ&OFX9hTN<4TGV=%feYpCsxq1YJC&uyw5?6iU!2PG88DUJN^shiE-sLhCZu%m0a(h zdUE)7)A3F%*$3+;?Zk%p@LlvfE2IBx7+`V*Nh=BG;`ClVn;t?`ch2Bdb;s+Q0?8mBiZLZ}oe}5+kH~m&WKgx4e>lcl}xJgJbL& zg?UAG?ZT!M@Rn!%6wYHqWb)Pu@w>D6nG(J}y<&S?5TgyU{(OfpiF>h(SAVg!Z6e*?vub)0LGksSs;wPgn}+Zg*R-o97sW9Ysp>pRdDSa+X#5lA#(wO)XgOy4Ac8y}`|Kj++%fp0p`q5>e(3RIUegtggkE}~ycb~DtU+_@N|1l-B1Z3PZ@sN%W=;})nDdOq zsCGq`fM}Hm_L!fZmjaf@J0RbXd^ja*!3Qi>CCNY?%_v276Os!%oXS)P^LG7={pj$Z zz~(lDy6U;l&y9?>d|lDq>)f(|ZJx#lJH(C;ihUC}HvR%gd!aS-HZuuc1Rc(QY~3X; zT@yifG7iShDBjjoU%GSE4|{M*cepHkDWm$$_D9-C2Zufsy-r<}VL_i(sMw7HTX3f5 zS2X+7Fpz=4fPO8EE%ZDB_hnjdeID7{K~Wh7LpY8Ze$r97O_m4hT0_%1NWHetEOnVm zYv#k~egv+G6o0sN3D)O)d)yY|S*>)-W@zpA8M(NM$Y8Joi4;x$II3nR#VGwqh{jI+ z3DMGpohUAZz*m>e=XZ2jL#z1TmAy8v&7#Fz{29EB(Gsb3mRC7Ts($w83P8Jn|8KeS+wI)*Sb7QPwY2>L;u}+gUR0VKPSSJ@Z zSwqDgbUJL6fP1kX%nQWSw51B#PT04X3| z-Q70($%OYr+Jv;3_VpBMM)$h?iZIe=HcQm1T=~Rux^Y4_yh4-kbo%`8eQwvR$WoZL znG>RJRE_ER{CH6NFP&J10e?1enBU>kR@pUs-CxSBHkHI2cMeWrmKz89?g!HeDUlBu zo+@3oJ{5mqvmXtBG!4?HgZc^2M%_nrH*~R$t;yxrW_=)1hT>m0e;jqXUydgymu|n$ zSRD>Ef+nJ?(cv4U?*`K~_ns}BZw6R)l^Vb1lhmsWV9t}ijCAbCqK~49yRIOK(5?E0x$o+TNete9V}ybj=`)?v|yO z>n_|MlA0VwCor;CDs4Bz?6Sl|;}=1~Kg6S5HfkR?ELS}=uZM`Fm!X?F}QaK#4y{0)r2#r(*zd5zC* z@`n_s)KX6Uf0=N32)7}BH@pKukNnL|9hjDuJQ^#}ia@(FXJ7pE3dr zce(CEYp|X^>TZ&ygxQFkR#hmysF}?&>WBV91c056Z;6VN+Gz>q;5uQbMSjTmixxx| z_cmeA{NZo}Au0td?l0Q@ij&LnG5 zGJ32EkHD#!qC}rg;L1RyA|{Uhq;~|_Bd8N;eR>vd(7%Gb7u|~bK7ETCwK;2& z0=VbJVuCE7+1EpUS;I$Tr!fA3aVPbCeD6|wNYLPvT_em^l7h#T%6sz-z?AnXLOXjL zz<-d@TrQ|v-jvta`!P-`k>FGYWV9PHE`~8RBgM>2h+bC08##{R3niMgQ{G+W=Xe@! z7~krtxn2A&d3L}j*iOhrP>Scy;on+p!jG`+dtHh)&t|#0)391jwzC2P+x&d)_Qs!j zo;7fad(x29_YV&mg1^_?2poZ$bJzz!c0$nE2n7(3Be!=+FxSC}Sh+py$XW3$VHo%# zeUVO5FG|%#--WQJOzn`i4H{-CVLcy3>oV$>wZGL1@haMHkqpE(cGmdV4Sw^z+PpZf z-Qo{aMGk!5I62B@`=pmzxhb?*_YmHiu?^#M&?sNt_rVHfEkBY)?w=f&X)wMN^612w zEsDbaA%!Gsxg?}6;9tjQ_k25QLi2vhMAe@FF*#7-b-766%|n@0v6!oilc=St9HFA4 zZ{UBXJc}OnnC1}gJcfffnI2f;%P+61`=+Gz6!MO;{Jc}tpS{?X4@u3}j4KnCjOu6! zsmAN(6Zi{YMv;GwSGw!mJW|S5lzGb-WDLM+?=J)@6%w}EjE0Hbm+U*Ed^-$O$A8x2 zMF&d^Cqb~_(@>>LVyyAmise%hAWjBnXHWp}NgOpI?R{k`_;d&Ep&m;s3b4J8t#1cx zsE~(&?g-S1joc+Sfd%3D{dbcouh(x0uq}IacGdbU=jGoMp!aKQdG=ByuBXfBUenFg zWIF3aoVLKF;0>hub%)AAD`-_eyZ`&^6tv{x(yJ80~a3|{PD@BIEW8M;KS(ql!(egfq9_a_Pr{9{`wOQ1VMXim2x)j)OhWIuRPS>xWW z$@_%TrNwV|KCQZv%SwBFxt|vAEs={BayXia8HttlWJbDZvfX%F(%2E=`H&e|63K5k zR-+^{Z#$fdsFnH}+R%0Nu|O^^*f4?S$7bkh4aYA0_-cy1?Qnz@RMN82u!suT{PG4K z|8Q7M>T4xZ=VR4Kmc-=!gugmY~g&1$)b)Da*WzgB5hE1r=pPEAmZAuVbGxh~;V?@0FGug&=Ndu|_GLXfH;2!${xc zq><&KC7BKY-gbc0H>38Z0jj2J0?F}ICn9C+cUl(M{f>Moi)-Uo{XQy|#fYTwozn%b X89g!0qRzee_yK6#)j?IM+J*lguH`BA diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png new file mode 100644 index 0000000000000000000000000000000000000000..853306a2f46a3b3ff5485e37955c27a797147761 GIT binary patch literal 3282 zcmV;@3@!7CP);5xtR>D>)?U<0IxE z=Wmx~0U4i{<(I&(StJX{+X}!AP*EUJWr68^f36)uCAa&|oJg0A1g3|99Mi)`Upz_) zq_|1?9IT{~%5Im(Qr&BI^ zBRz5!*5K1CXf(2yuO0`q?v!!g2-`x~v`PIOx<5ZT4LA4rkdIjcDX!tG@d1AI2rm?I zzOx(+W`ODe;PPOr)jbYQj~X7N$)F)N13YHj3- z^ypXw{Nh0ZQ`zHM!eaqes&%+JNWf9Pc@%1R6f^@YJPzl`eEc;%>gpbSGMQ2~-L}7< z58A=4lAC+n(gOtEW6%MEi@kaHOs57;yYK)G*jJB2^5Gsh$gS3us~+hAU&ZPk&p$nR zO#L~XtGSlxK}!!D06NVVyrhS?N6-GZ8fN95>!qNR2Cet$K?6th=VNQ4t8VxE;9-2Y z2d2mE_931tSgtvHB&_88-U@K9%g#NVkGg)#2S<3osADK~JNoo^GpfsxPcO|UVN~$0mssJ4X zgCeQJ|5uNK1?9WP^i*CROL%NgA{VQwZ9GV_PY;v@O_ku~p^--SAnD5m+Vo(k!^^rM zT3j~o0&WzP^e8B&2ManbkI3WTyt3G6LQ?lSJ=VH6Qaa=o{R0Nt1iDm@w&_n-eEwN;Xrdhy(PK1xpzga@X9c9ccVeo7Q{ zHtSox`|`VcOhbFD?ot0DajbPGS0NU;&3tswR<0)n-aT&eULnir$>~7xJUe%*`jzTsD>pMkscr~51_YfUdKa) zLCxq;U1;DJo1^X=0ukV(8&X%{=JHin#O+NL#2__Mk8C@ zbyeX}vVXb95Xh@Q#&(KPL^<<80`5_y@y&x@&L7l!dN|JKzOU=Mhi;9h$MHFc%R@ia z(2FeCbYH2WC>Jyg6igT?FOOK|7D4)!4~)8p2dF+r*igxHdMEi=RX3rXv4>IlQ_6Rb zkC(^H$}RJ8c|geJ^f>Iz1Mb1ogVcJztA>XYJygl2``tO~gGGS!sPR~oKDNL0y9eDv zfV1%*Wc*0|=7C>4+RLNyV55OXtvZH~9?(p5tG~;~?RI+j$)1W59>pDmS3b~tc$Dy1 zUmo4awcekqn&%IIW7Tys)%0k%Jhr`_+kCqZZZe2Bk7If)P7>Utl=SG!Z#=eIn;bDp zk4=U2p?eJd{3&Fa|LhWQ-#mKe_3+;mS51KH~R#|V!`0DP>Q z&W`peCaDUil!y!w)1Pi+kh%mj|_bn0iNXk8}YM_3p9O^x*W^r^iZ@ZFP^j4rOb)NrABr z1x}CcURS4NeLSm94@wpfat-rh5a}Q;kCg}zxQDriK_6p!%%b_#Xzl@a;E4Fv$cNl~ zRb+cy9v@deW_|UT%Bm#r?qT+e$I5njbocn<(Hc!u!$Us@S6>{+stT0!824S%qds>X zvMbM5Jx)U@<$TXS(j(rK?D8;xq)m^mLn#ELfCvw&Y-fag_0yv{fE4%O$W_NC0f^Z% zZs{>KA|D0Yp!ebhf)XA8`kTiBk{n+>{_jDC2i>E7Qc0$VOPBEYyDI&GQR~0^HsrpY z9)(<0MNW^x^e7^S5tm0~p7H*o?h!AZm&YJF5k*c9&26~2hh84Jhmc{JU~;>;N9#Zz zpCq%zpQnOf@oIi*~3h$=}A<^2`?VE?49#=wdFONpmvwvh*QJjw95u@I@>E+?n z$K^3q1WPK&7Y|HL*8BL4hXn`1LuuiI0s{TbgEa8UM+=XpNOuw4ntRLi*p>3!xQGX} zw@r16)&+xrAi8^GKwdK>? z6M7NQ*bP!JjqtsnY8%tzb7VfcKL!NF(!&Kol1lFiPVr0E>I1SbEq2o&s-m4sM|quT7@=%Oe37Pp9uPUV&rI z(&x7CKQ@|s!~<^VN>V>XqS-)}Garq>fd#zRe;=e&rU%HC4DntZyOZv5rZ-xP9PY7c zb&pD6^AM*OP3UC+`n$(GfE0tlQec66ttDX)9}Bd7Jv|VhQgA*`N=T95YTv*kn?%eNRBOf5VCGuHb2 z2h&rD0&r8($j2V{l8`g52Mw?SaIbeIMd`;g0gUa;2TN=XzqR1{5-0LuS3VBtXQi}3 z07NNqlaQ@#!#^rQXND3QnY1hfNQ@DoNsqFe9+?jdqEf&{9ymQZY1jD_Bw6dd*#S%s zEMQw{-B{h@i2aftAP}d-{c|TFJo+MWjv|TlKunzzYneAMjCCxp{Sy7-Q7Kx9;$k95 z4?gOfM;u;$?*W&HAF@I$-j?aJDVGNdxMn~+XF+gztlCE1iO%ql*!G>R-hKVCk+Xfl z#Sn*B8iYWB*?H!C^Nd_?+LTX?@9VZp2=>epNhKF_I*tm^KAU%q}$O%=SA~;~gYdSE`M**u20^;NB!!)zW zaOR`HxJ-}5J&Y&_4zz20 zQrVgkJw0+$7$46c|LgxdXd@8wz?9%rXLwkC7{KN9c>8|e0GN^N{rrC402*x(m^Rs~ z^6}sFu=GffY#NK40g%NA7~ICuQtTzOBnYm>P}3-d)_srfZ&y;!@3TStKXIdGsjkjf QiU0rr07*qoM6N<$g3otb#sB~S literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/juice.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/juice.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/juice_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/milk.png b/src/main/resources/assets/forestry/textures/blocks/liquid/milk_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/milk.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/milk_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png b/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png rename to src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/seedoil.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/seedoil_still.png.mcmeta diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png deleted file mode 100755 index 49cdec0cfbe70f51f8745d28f07b1c591e1c624f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5000 zcmXY#c{J2r9L6yi3S-Gq={J^WY#|95Ms|@k*@sNF6wzXAk)@$zh_RFTNrYDO7wW|SXFAXu zy4Okk)n90k`j-h(G&<0ot{S=jy+V%mNuKtf(}AEwt5EviE0kAnGCI)z+Vp{?snv%M z1@tK{E-oo4qfaG$s;a81YisN48ylONT3XuLzR-tABzAOkb&*Jo%_%0hBMaEnqhABdk*Q=al=8b7r{vJ}usn zcxExPWPj5KwRM64)D^klg2b`lXT`PMi?)4z1l;jdjbA*6{ae&e54BJGP5V;ZvO;Bb zO?;k9H~dr%S|%WU(+RNZmLF>Qhw1g$&ZLX4{tVmgTs-K{f`%1z)>XT&n+e9sF2pAN z5blgLcmpE}F6QKd&mdrTGQ`sQIas8++UlYrr4{daDY9&exUQ`%SXdWw0MHwKwZVyhW#6*Zjf3^g1Fl`egA^?uF1p>dp&Fnu?HIa|Cf%J{_LK z1L8Z#tV&}AJz(*KGeik8K};m1{d_*oARiay!KIgvep|SvkRxGOVXtvg9#nL1IqdS? zK%Ka0-+oOrI#dY#%`#R}uvzD-p{ULKQY~oKi|C{1XR)uU_=beu=B+pf%05sHD}*0S zrfY*C8*TPehj*RjCo!z+)w^w&}4vG)G1nOdARVb@gM2$~tG;#e+mR zTC5xdO%@*|OAY@zJhy3k>=$KA#4*_*nHg=SaNPRwMATD!$X3jrj{Mggcbe7+Tz@yhZ`b$90;7Ha=+?m3V9K1%aR7q%a<*a~q+ zlO;EFE4CWOs&VK^(K8Y^WZ`mD~3_Tco8yMS-p zz?tPprWWPv-J-1i1BJYv0~Jyj20&?>af@6gN%+FJ7HP*G!i~?AylNRS-knsvi)5lC z##YjdOMGk~hbtHqG9p9MaOIw0iLZ}OGLhMrQC?Y=RmoJ-#0SLa6!@k+J^qQW`4*ld zI|+uzbwZ40IXqS(!7RvN-|}4v{zXbv>-P{ZUfA{DR$GnNeJ@-DP9*JlZL0cn#QTAY zVqym0eruS!B3y<^1@vKWSQFX?z$Ktfsn`&s!#}e4U0zGg@-f%%LE7W96tA8W1=NX2 zVG=)=^+D1HZW)M<=KDzlnmpWm{>`WK_cLg=99OYt*W$pvefE4fBGwfivxliFJp62N z)jz+WnABKx=Ab%k-+2hL_tgaI-gw@BThoPPO=ie6YH?tffLYUVz zY$>cpE$@d%k-I?Id=hwxq;vC%e+-^#y6YLrdf#396K@waX~bNv9Yi^t!GMw;e_%r?6AQZ$TOa=XO^%N(FCgXhGYuQ|$5ZS0QBEWa1|f zgZ9OrUtS9i()P_KnZ;w}`imwL1}Wq#Vm5$qtfhv)eUt8q_u>8x8p#q-L3?GxnJDW? z&dUif|8DSa?aee|czM7L@3-~ttQi^rFFU?(o2Ok^k7p@54znVD9qC*^AR9Tp+v(QJ z(_6GKlt_thFovz|pBpqllv5N!JFXk%advGnq zliF`Y2B0Te?xt=G-UMO;ZYI}xO0J$2=zK^Lv%~P)9kHpzV4wj*i;xCC| z3D^eUcFI&+B&B);Rs?^lNhK_6GbmUADBAQ}L zvb%mf=w4t1VQb0EZ_QACT<=f&ESw)dbGS*E_W=XStxKk#2(kwg4nx$J(CKwHo`)a+ z)14XRm6gBQLs=|>_o^|fqnW#8dnZcodY(vVcDS4}(!xoJj=jU)wsZV)M&DdScC$FI zsOqQ42^RZ1?4`P1Yax$VB-OWPD>}$eqL`(0=S;Z33^W;tmytz>rUW8gvqPx0jR_%2 z6Jgl-dW+^l)pA>+u0arcPHu~3V2I`h7UTG1d}=|bX5%VV3465d^djYLwi#lYunveU z&R#($mIsJ4v%X7+(GX?O`HCw^PsG%9w4g(bFoQgB(hkd}R!BhM4P!BTOP7xUUAZPP z_fE4ZF9(%>S+%8TLyO?%%{tz!SX}Z}?S&-b2cA7*L_9}KK>th1hj&@O$Stuo$Sj&) z0eN89WK(Eu7sl^5b6^W_$?UJ#05d9=fQ?>6s3Ug$s}PfN)90@KYkX-soX4f62C&=` z;h2ZA+{r4NXk9GXt_j@7Bw4QEYHojVGG2 z+_yu#q&ZeI)nM2$2P7M?AaxR=G5SWo^1%^FTpFA2Z2B^H%TuBiRkYz_+%486o(d^W zl#3^u9YCS>`pq$W%T1cQxxwov;R)=^jsaj5?c+(v3+U#9^H10ZAMl@7yk8m8P+a$u z0bL&NdQ?+`%1geMtSj4ZkUOTYBqQG_xtV+C>F;Z@sLtT~AfQY#s>|W#YsB{l3;Elx zHAzUrv*Hs9fSN^7YPWoTt7y$__?Au+Vq_?TF}B_YaAz*C8G&w`mbuXfojDw_+E{;g zJQ>6)R{YRIZT>SmUvHjSiwK`rix3{pq=YFrLX8w`8Lmbd1qvmYJ7Gl~1M|##XH*pd zhtsC9^(w%7(62H8jt3s$wC=(alq0~#3=p#nSjYTgD&d~9 z=_`fkKV>sbr{V6-i))P%BsKl{c<78uC4w?PHIqecX~*c+oMyCseN{CG1> zYhDG&a$VxxJCL_j|2e7%=VkGg-p+%kp(=IEjMdIK*|DD~O|wpW&ee-Wgw}T`*#xyDYieZwhwO&HulBUbRpn>u;l^S zm-`&}ZWo-{jo3!XK1sjuu53sBBvw%;(tvwq&DcIzFx8Hz%UFfwjQ@EfZE$q$O7FBI zl6{tW&{+8U3lJNJ10oy*_i>T8Z$?e4VtGwhXP9?60T`J_=+G)u2r}Mg$ad~2pH=7| zXB9vKylBycXjC8WDhFX5y~W?KJU&;r$t$@?S(#nNNUob*JN!6y}s5PEWVPDmh)2|wrns%uXtw)5eWSN$cPztw?CUGC{^MsYW;>I`9Y z_zN%8Zhbey#0?uAD3%if-*b1ONgTnH)=t^eR$gj5*#K?eWcXQ0F+9XcFtzm{ccMRD zFOVakfZE}03MhSqA06S{_sj!n9wfalInNbqde)&9QZZ0J!C z?<0@d*?o=FS9Woj{h4%LgZZ51dP-VR{`0+zni7wBzw`L(Thr*~^10JRd(YWUynLom z(e3;M%**|*2yri7fuB~Wsc)&;=D3Y*M`;XUae?34PPp@=9w%A!pnl86epcoHlC_H< zsZF1RI@C4P`;0a5FWO%J!R-0Wdnc4!$ojpCJD8FY+?pd8Q5N#|s_h5(h0OmXQv?eNOUn2vhcn#eHM_6%%6)?6 z3T0!)+bA!7H8Y>--n54oXsSs>|4U0>C)UoJt4m=Y-4HmtaIG;q(-24S2-ML`J_g*_ zp*jbWM@$CLqp3Y5SJE@i9NfFbH+>7vF{^8t4#FFHMy1*HwnxS^78C=0Gsh()N8U;# z*_8vsbshv!$=;TOzKvX%_UGxBqY#ON?x>60Hq1O+l#x9Gw{x@Ubj)jx3c?vUu`AN8 zm{{9?4EPawHv4w%RtMe)_e*D9m&f$uFO(1x=K zl#jB%xnTm#+3@Izxk`yLGZ)i8QSw+IE5zFTJ-5q?Y4xg*h7{{$;+l@%VHv9#j`w4V zVfhd5!VLuenMy00&ETj|VX+J2SV$uH!A6n_&=zy2{}#Oe6b~oBPU|Tf5#T!ssZ;ge zfU=~ETYYd2llzh5A@*I|rP^UmOSA+VW(_>PI*=UiP_iLY<|KqI&au!28%sj{d&oC; zFQCz4mr7pz7FKN?ZWgz&{VgNF-Z=Bv9O#ol%g$2$Co_F*)DXb^g^t$A3=JnG{FTq> zxT#y)%zdZBi@u*jldZfIe|Do2RzU7DcPSU25bxdJIh?AXz!E3gGQW+FwjqbPn_r3v zkF6{=O^t?0GD&dz=|-B6ouXURBWl)-*&J<5@4#Uuo-8xy#w{4hvG`=_fD4<&)vJdg z=kT;q9EO=oITt2*B1(dX zWWKGLaP+I-^nvr}6J`fQTIJsTn|<|2;H(Gxw9+BsTV1Ei_M;>v`XdvAk)Ek8UfU(& EAKjzMp8x;= diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png new file mode 100644 index 0000000000000000000000000000000000000000..f4c8026727fd7cc53f0048c3210cc5d31d242c0d GIT binary patch literal 6923 zcmYjW2Q=GZ_ohayN{bpTv10Gh)`%Tiw5YvDt+rHcQKdE^1R?gG(W13VsoK=0_Nu*C z?NRy<`u)G}oO|B9@BKaZd7gXUoRi-duY>mqOG`{fO8p%SL^lu|5t1h8%h7OUL&vb*RbotYs?jRCmHvDORkUqO(x=8 z?yngBC9ipsF7ua}Yl(z^$1BVg9-GIiB>mg(q+Ee76|r)cirCC$?G?`@@`~Yq`?>`D zC;zYf>UdqUlZs`=y~13uKZly(Z9Hw(!YUU@?6apo4f{G5?(iQbp=m5 ze;H!G*_*DKYFc54(8#D5R2(`Y42}p7Pe7s~lR~2t!{AW}L?k*QF)}tRDkeTAHYoy` zmmU)xmll^29)%1`&yGeU1V^AVBBSEMv*J-nALEmAGV)Og1+mBkR3RFUKt{zR$Ax64 zCd1=X5{mOr0Z9!0 zO{;o$Rh4(HzuRaaDqP0dI*eTthm2BZ93D2_>BA=EqCIg9=k1B%ja`?LNnvMA8)2URbQB;CBV2b6R`2K=X|Hl9OOh6P zUaxRu`;gm`BIQ{YrJl~*PT!oR1uyJ)GtB01<^2jls}p)yPFQuOlGH|It+)Xc{lwu& z?djr_nf`{3N1iQ}aNSu~J7zkuW9b6(ksS{y<&omKLGylpp|u?_ZJ3(>j-DwGv42zP z?dEjFI~9ugA%Oi)rGYyJ6lG$*P((wfoC3```|*c$rD0)WW!OyLyD^<5Ya#M}vW&sR z9)&_Oh<0m04=BhvNJSeLl+uAC8!QtG0LXwHa8F~vL`|f(nT!&tVJ3&fw{c?GbIYrr zy=?md9t<<++~sRFC-E6xh;FslA2m)8)WknNJ;7*w8?veJSl|3Et<;JnFm?ND7U5ds zp*}VB8e`=x`r_MZk-%#`Y8qtihNmB`U8^8sf0mNe;9;V1YQoo4sXxa?I_X)`J4~4U z#%xmR-8CLrf71nC2AGBw{;A-Ekx?D(qrag;xd$bzz{CJ*NfDB>_mCMiaub_=xlAC7 zh&j_iItR0XJz^+to>gllVF6dxb>?UJ+Tyi;6IBkDFg1H+(JD&WdjjuIjm*Yr$BZY(F@DmI8QU6N z>^zf6R@d>qlApr199!Zo3W#qpIDVuH1Vg|XzG7qy+G+_*Of4;I=X+G1`->K(HljCA zah@Z7|CUGJzV-zqV z^Bdk!p{2lIMWE=de+zX&fWxAyO=i!8>c|<{f_j6+W*)t1DyL;qfjb5&byZDGac2OTfcsiiNCiuIyk)e%|0hX~^=?&!W@B@7{On~YIAblh<2 zednWe@j*#9?)-k7yRDTMTMvC4Eq;#~O~2a}A@ML5ZEc2EaIkNk$7xNWjBR`s0-B>! zPj`UZe7^`zWkC;Z5M48HVEU+Awxe=}#pzc`w`F{8C6+KmWB=4zfKkxh-FnSE?|pp6_s*d`ozMQaxV5ER$rvt(`kcSngkFqvv~|GFrshrHr7HaK)kog5~pIJYU$kA8GhE zhogEkpDkI2;wZRx6J@}vYxYP%EDY>85vl^o~gF01@<5p@m`%-bW2!jTzi0=2i1@88`(2dV$jZ zPQj37IaxJdB2VZVCYPeYoFPuUIhumr8${;CO%YX`{YP63 zs@Q6nW|!S7mv2``Rya_e{6PNu!O#acic=h`jf+iFI+l#HE^2W#y5u+R507L-KOlc1+^5XRzH1QzIt{{KT4 zgetaC5f;#9_Yzki-L979@AY@ED;w%QSFb>;eD~xzDKen{6wM#Mx0wy#|E0D|*bHTC zUua9`MjZi-JyJObj4d5EPs`<~03w9TdFa#|Op1*!G|k&g-CXvf*2C3EWr|Ab&fA{y z{RWa`nY~{)GR)QFT?5*a4r(^s)3UX}N4j-2p6^5b6D{~*?b!_tPHapKH5J0etW|<; z4ZuA_SAs8rpF)F%TP9m?d^MTusQwC|X`S22o4Cq_-ws{WA_u1jdgu9uytT+JpRcWg z>PmUx@X2>Bo0MpnvFNNT{q93pk7kaz!lQ8m6bxSJ5^_ahsf4K5WM?VI!^8h07k^ndmuKF}(z z5aEH>Hgq@#GMnaWLj2kUX-1;~K4^c@Tk)UlRQk<@e*ET~CA1eb?Gpm$o%)DEK1TIH zw;*Vfh+At=t9eh^VD|MM>ZR0|GyS59?-qXP57#z2%~<3MX4BS8ClgAV6j87eh!O73 z8G}4?ep)@DTC~g+9OM-fpfI!2chvvY{p;JnFi}bsa-*2!89djvyg7hPm+U`)OHl7x&hc()ymCsNRUDfCgvDYOar?6CEMiGd^#(8&aV z1VjKL&tIYKA8>U^o8Zh*M;M}w~!&%PK9n=`S)!Q`%X^~%?fN||b? z*yBMpApb&m%i);92eyWJCCd?hJgG_&RBGdC`=@$e=Mfpd6ZG?qws`^S+GtG5(6V3V zx~|u^(xrJ3#oFVb#Z2(joO|3BCT#95 z?V|An-d7q=`9ru@0$RJ3>ocn(TE}urcVvETuo)L!{1B<4?)dKcr<9Q{Fjb~+ zMbU0E(;QQ5XLC-GOKwX`=@5`QHXu2DJS9*PANWFOs8fwLO>;)~m&gUH z@AL@Y-o?pYoPMS6JULdR`;8qoI;1or%pU@|n32VsQQ8I2y@(3p4*{nA8cpjMmuH+C z84UaDco#<0rT`Qoo&C6Oi8uVl|Isp|fY3rib)PC=PSK51ixTu|P(5zP`34{=(||tN zQ=LPz{j;w!OAL{Y(H@JbV-{phL5kP^{6JrZ__JyK12se^LDmdl~R%huo#|xclXCL2Umi=n0lY* zLBh~;P(J*7KJ!FO!d@W8otX?n7xtwcB7vWz@wj8%5}N~sGhb0N0jX&r_aeeM0J z!<#f}HMz4EYPAvzF^-ivZv z6MxoFIUaI1h%;?Vk&XsRy~EMs_aZdaegDH1_h zZV=r```Y~$wzxuT-AI8MmHilKL!Su%(|yU?koq#wV8B7%WSoH?E$`R1LguIw1t>Q) zDs!4-#5-28J*L%Q7PS3Ez-bBcynDse03-aurxOJkv&madZvReKju9mGzk`+)jN?cYib$$oX0JN3~$^z3Sfxv-*86kHBiY;_+9X6aK2)}ES z4q=DH@ZFBnQaN!1z#J3t{L|-{NflyYw&mG4(u#TT2W%a)DF;V#Oo5-^zb}rMY*sq+ zxTb7QWAv5Yc8eUTe{ibVuW$i51y|eaebEc^7;{;CRi;Fx$RPRtELx$MI+FfGO^i@o zbW@zRFw;7de#o(?cw%)@LmZiAnJ6K*3K+I~dJ7j`EF-qP-}ceL*!z(*n$bd;coo`f)Vo8~hUe8ZXFwg&34)LT^B9St1cX z0`|X;^jK+s{9&fJ_F_AI7Q9l>YlnKouJ9$n#GSP7R`*EypTYGw!42ItQ$G1Tt_k1y zS>rM11F%<)xxKDu;j`F+zKlRQs|E9Z4rXQu_cTB6Z28%87*pu$okuiKjeBtXR#mo!;QG$Jckl=6-Gcogbkuyw zFLZrcir~^K!}n|z1dPv-5b7|*>1;5Td#JtU zw0?W(4o7rCMwqzk_H=+hAipbd>_Y)JEud8uAF^{JI_Qzdd(dxq3h#?Ky1FJ^!?WJ6 zYnHpsF(vzEP8&nLFpHa>2@VMr8xxb6L0s|5qvkgmO!sR$l97y+GqFEWJiXJUe_dxW z=YPG|2TX(Tft#XgQWxE=Z4ZG03r+qiHizZ>(-$(m?{zDagY zykPfF`@A{%tz>f7NpEfM@lC5z4rzCm)W(YEIT(5qqW4!<1kC r@}4^rU#l;Z5FuG6A&A-idt=s`EpJxfh9mZ`032mSHE6NCx&QwGMB`^o literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png.mcmeta b/src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png.mcmeta old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/assets/forestry/textures/blocks/liquid/short.mead.png.mcmeta rename to src/main/resources/assets/forestry/textures/blocks/liquid/short.mead_still.png.mcmeta From 305be1b979460f3d59226840623d00b52f1d4e20 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 23 Dec 2014 12:43:57 -0800 Subject: [PATCH 085/175] Convert old honey using the still #390 --- .../java/forestry/core/EventHandlerCore.java | 2 -- .../java/forestry/core/fluids/Fluids.java | 9 +++--- .../forestry/core/fluids/ForestryFluids.java | 30 +++++++++++-------- .../java/forestry/plugins/PluginFactory.java | 3 ++ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index 465fb4752..a3e514938 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -89,8 +89,6 @@ public class EventHandlerCore { if(event.map.getTextureType() == 1) { ErrorStateRegistry.initIcons(event.map); TextureManager.getInstance().initDefaultIcons(event.map); - } else if(event.map.getTextureType() == 0) { - ForestryFluids.resetFluidIcons(event.map); } } diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index dcf17563a..b0c8d82e9 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -24,8 +24,11 @@ import net.minecraftforge.fluids.FluidStack; */ public enum Fluids { - WATER, LAVA, FUEL, BIOMASS, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, - COAL, PYROTHEUM, HONEY("for.honey"), MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD("short.mead"); + WATER, LAVA, + FUEL, OIL, BIOFUEL, + CREOSOTE, STEAM, + COAL, PYROTHEUM, + BIOMASS, BIOETHANOL, LEGACY_HONEY("honey"), HONEY("for.honey"), MILK, JUICE, ICE, GLASS, SEEDOIL, SHORT_MEAD("short.mead"); private final String tag; @@ -69,6 +72,4 @@ public enum Fluids { return true; return fluid == null && fluidStack == null; } - - } diff --git a/src/main/java/forestry/core/fluids/ForestryFluids.java b/src/main/java/forestry/core/fluids/ForestryFluids.java index aa0c0d31e..8fc257100 100644 --- a/src/main/java/forestry/core/fluids/ForestryFluids.java +++ b/src/main/java/forestry/core/fluids/ForestryFluids.java @@ -99,6 +99,7 @@ public enum ForestryFluids { ); } }, + LEGACY_HONEY(Fluids.LEGACY_HONEY, new Color(224, 194, 57), 1420, 73600), ICE(Fluids.ICE, new Color(175, 242, 255), 920, 1000, 265) { @Override public Block makeBlock() { @@ -177,6 +178,10 @@ public enum ForestryFluids { protected Fluid fluid; protected Block fluidBlock; + private ForestryFluids(Fluids standardFluid, Color color) { + this(standardFluid, color, 1000, 1000, 295); + } + private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity) { this(standardFluid, color, density, viscosity, 295); } @@ -192,9 +197,12 @@ public enum ForestryFluids { private void initFluid() { if (fluid == null && Config.isFluidEnabled(this)) { - fluid = new Fluid(standardFluid.getTag()).setDensity(density).setViscosity(viscosity).setTemperature(temperature); - FluidRegistry.registerFluid(fluid); - initBlock(); + String fluidName = standardFluid.getTag(); + if (!FluidRegistry.isFluidRegistered(fluidName)) { + fluid = new Fluid(fluidName).setDensity(density).setViscosity(viscosity).setTemperature(temperature); + FluidRegistry.registerFluid(fluid); + initBlock(); + } } } @@ -202,7 +210,9 @@ public enum ForestryFluids { return Collections.emptyList(); } - abstract Block makeBlock(); + Block makeBlock() { + return null; + } private void initBlock() { if (fluidBlock != null) @@ -217,8 +227,10 @@ public enum ForestryFluids { if (Config.isBlockEnabled(tag)) if (fluidBlock == null) { fluidBlock = makeBlock(); - fluidBlock.setBlockName("forestry." + tag); - Proxies.common.registerBlock(fluidBlock, ItemBlock.class); + if (fluidBlock != null) { + fluidBlock.setBlockName("forestry." + tag); + Proxies.common.registerBlock(fluidBlock, ItemBlock.class); + } } else { GameRegistry.UniqueIdentifier blockID = GameRegistry.findUniqueIdentifierFor(fluidBlock); Proxies.log.severe("Pre-existing {0} fluid block detected, deferring to {1}:{2}, " @@ -227,12 +239,6 @@ public enum ForestryFluids { } } - public static void resetFluidIcons(IIconRegister register) { - for (ForestryFluids fluid : VALUES) { - fluid.getBlock().registerBlockIcons(register); - } - } - public Block getBlock() { return fluidBlock; } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index b757cd5ee..0afaa7a02 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -299,6 +299,9 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.get(Defaults.STILL_DESTILLATION_INPUT), Fluids.BIOETHANOL.get(Defaults.STILL_DESTILLATION_OUTPUT)); + // convert old honey to new honey + RecipeManagers.stillManager.addRecipe(1, Fluids.LEGACY_HONEY.get(1000), Fluids.HONEY.get(1000)); + // MOISTENER RecipeManagers.moistenerManager.addRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Blocks.mycelium), 5000); RecipeManagers.moistenerManager.addRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.mossy_cobblestone), 20000); From a4f7e4c5835255c7e48418eb8ee07151dc2477ff Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 00:43:22 -0800 Subject: [PATCH 086/175] rename Fluids.get() to Fluids.getFluid() in preparation for refactor --- .../gadgets/TileAlvearyHygroregulator.java | 6 +- src/main/java/forestry/core/ForestryCore.java | 12 +-- .../core/fluids/BlockForestryFluid.java | 2 +- .../java/forestry/core/fluids/Fluids.java | 10 +-- .../forestry/core/fluids/ForestryFluids.java | 6 +- .../forestry/core/gadgets/TileAnalyzer.java | 6 +- .../forestry/core/gui/ContainerAnalyzer.java | 2 +- .../forestry/core/utils/LiquidHelper.java | 2 +- .../java/forestry/core/utils/RecipeUtil.java | 10 +-- .../factory/gadgets/MachineCarpenter.java | 4 +- .../factory/gadgets/MachineFabricator.java | 2 +- .../factory/gadgets/MachineFermenter.java | 2 +- .../factory/gadgets/MachineRaintank.java | 6 +- .../farming/gadgets/TileFarmPlain.java | 4 +- .../farming/logic/FarmLogicWatered.java | 2 +- .../forestry/plugins/PluginApiculture.java | 18 ++-- .../forestry/plugins/PluginArboriculture.java | 22 ++--- .../plugins/PluginBuildCraftFuels.java | 8 +- .../plugins/PluginBuildCraftRecipes.java | 2 +- .../java/forestry/plugins/PluginFactory.java | 82 +++++++++---------- src/main/java/forestry/plugins/PluginIC2.java | 6 +- .../plugins/PluginLepidopterology.java | 2 +- .../java/forestry/plugins/PluginMail.java | 4 +- .../java/forestry/plugins/PluginNatura.java | 4 +- .../java/forestry/plugins/PluginStorage.java | 12 +-- 25 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 948d9cbdb..23e76f592 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -68,9 +68,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv")); - Fluid water = Fluids.WATER.get(); - Fluid lava = Fluids.LAVA.get(); - Fluid liquidIce = Fluids.ICE.get(); + Fluid water = Fluids.WATER.getFluid(); + Fluid lava = Fluids.LAVA.getFluid(); + Fluid liquidIce = Fluids.ICE.getFluid(); liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce); tankManager = new TankManager(liquidTank); diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index bec6868b0..b1c90d33e 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -92,17 +92,17 @@ public class ForestryCore { FuelManager.copperEngineFuel.put(ForestryItem.bituminousPeat.getItemStack(), new EngineCopperFuel(ForestryItem.bituminousPeat.getItemStack(), Defaults.ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT, Defaults.ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT)); - FuelManager.bronzeEngineFuel.put(Fluids.BIOMASS.get(), new EngineBronzeFuel(Fluids.BIOMASS.get(), + FuelManager.bronzeEngineFuel.put(Fluids.BIOMASS.getFluid(), new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), Defaults.ENGINE_FUEL_VALUE_BIOMASS, (int) (Defaults.ENGINE_CYCLE_DURATION_BIOMASS * GameMode.getGameMode().getFloatSetting("fuel.biomass.biogas")), 1)); - FuelManager.bronzeEngineFuel.put(Fluids.WATER.get(), new EngineBronzeFuel(Fluids.WATER.get(), + FuelManager.bronzeEngineFuel.put(Fluids.WATER.getFluid(), new EngineBronzeFuel(Fluids.WATER.getFluid(), Defaults.ENGINE_FUEL_VALUE_WATER, Defaults.ENGINE_CYCLE_DURATION_WATER, 3)); - FuelManager.bronzeEngineFuel.put(Fluids.MILK.get(), new EngineBronzeFuel(Fluids.MILK.get(), + FuelManager.bronzeEngineFuel.put(Fluids.MILK.getFluid(), new EngineBronzeFuel(Fluids.MILK.getFluid(), Defaults.ENGINE_FUEL_VALUE_MILK, Defaults.ENGINE_CYCLE_DURATION_MILK, 3)); - FuelManager.bronzeEngineFuel.put(Fluids.SEEDOIL.get(), new EngineBronzeFuel(Fluids.SEEDOIL.get(), + FuelManager.bronzeEngineFuel.put(Fluids.SEEDOIL.getFluid(), new EngineBronzeFuel(Fluids.SEEDOIL.getFluid(), Defaults.ENGINE_FUEL_VALUE_SEED_OIL, Defaults.ENGINE_CYCLE_DURATION_SEED_OIL, 1)); - FuelManager.bronzeEngineFuel.put(Fluids.HONEY.get(), new EngineBronzeFuel(Fluids.HONEY.get(), + FuelManager.bronzeEngineFuel.put(Fluids.HONEY.getFluid(), new EngineBronzeFuel(Fluids.HONEY.getFluid(), Defaults.ENGINE_FUEL_VALUE_HONEY, Defaults.ENGINE_CYCLE_DURATION_HONEY, 1)); - FuelManager.bronzeEngineFuel.put(Fluids.JUICE.get(), new EngineBronzeFuel(Fluids.JUICE.get(), + FuelManager.bronzeEngineFuel.put(Fluids.JUICE.getFluid(), new EngineBronzeFuel(Fluids.JUICE.getFluid(), Defaults.ENGINE_FUEL_VALUE_JUICE, Defaults.ENGINE_CYCLE_DURATION_JUICE, 1)); // Set rain substrates diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java index 794459ff3..9f091b267 100644 --- a/src/main/java/forestry/core/fluids/BlockForestryFluid.java +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -57,7 +57,7 @@ public class BlockForestryFluid extends BlockFluidClassic { } public BlockForestryFluid(ForestryFluids forestryFluid, int flammability, boolean flammable) { - this(forestryFluid.standardFluid.get(), flammability, flammable, forestryFluid.getColor()); + this(forestryFluid.standardFluid.getFluid(), flammability, flammable, forestryFluid.getColor()); } private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) { diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index b0c8d82e9..8e9de0c00 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -44,27 +44,27 @@ public enum Fluids { return tag; } - public Fluid get() { + public Fluid getFluid() { return FluidRegistry.getFluid(tag); } /** * Gets a FluidStack filled with mb milliBuckets worth of Fluid. */ - public FluidStack get(int mb) { + public FluidStack getFluid(int mb) { return FluidRegistry.getFluidStack(tag, mb); } public boolean is(Fluid fluid) { - return get() == fluid; + return getFluid() == fluid; } public boolean is(FluidStack fluidStack) { - return fluidStack != null && get() == fluidStack.getFluid(); + return fluidStack != null && getFluid() == fluidStack.getFluid(); } public boolean isContained(ItemStack containerStack) { - return containerStack != null && FluidHelper.containsFluid(containerStack, get()); + return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid()); } public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { diff --git a/src/main/java/forestry/core/fluids/ForestryFluids.java b/src/main/java/forestry/core/fluids/ForestryFluids.java index 8fc257100..4d3e25930 100644 --- a/src/main/java/forestry/core/fluids/ForestryFluids.java +++ b/src/main/java/forestry/core/fluids/ForestryFluids.java @@ -218,7 +218,7 @@ public enum ForestryFluids { if (fluidBlock != null) return; - Fluid fluid = standardFluid.get(); + Fluid fluid = standardFluid.getFluid(); if (fluid == null) return; @@ -263,7 +263,7 @@ public enum ForestryFluids { public static void init() { for (ForestryFluids fluidType : VALUES) { - if (fluidType.standardFluid.get() == null) + if (fluidType.standardFluid.getFluid() == null) continue; for (ItemStack filledContainer : fluidType.getFilledContainers()) { @@ -275,7 +275,7 @@ public enum ForestryFluids { public static void postInit() { for (ForestryFluids fluidType : VALUES) { fluidType.initBlock(); - if (fluidType.standardFluid.get() == null) + if (fluidType.standardFluid.getFluid() == null) throw new MissingFluidException(fluidType.standardFluid.getTag()); } } diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index fab454295..985cc7eda 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -67,7 +67,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public TileAnalyzer() { super(800, 40, Defaults.MACHINE_MAX_ENERGY); setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); - resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.get()); + resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.getFluid()); tankManager = new TankManager(resourceTank); invInput = new InventoryMapper(getInternalInventory(), SLOT_INPUT_1, 6); } @@ -127,9 +127,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui // Check if we have suitable items waiting in the can slot FluidHelper.drainContainers(tankManager, this, SLOT_CAN); ItemStack can = getStackInSlot(SLOT_CAN); - if (ForestryItem.honeyDrop.isItemEqual(can) && resourceTank.fill(Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), false) == Defaults.FLUID_PER_HONEY_DROP) { + if (ForestryItem.honeyDrop.isItemEqual(can) && resourceTank.fill(Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP), false) == Defaults.FLUID_PER_HONEY_DROP) { setInventorySlotContents(SLOT_CAN, InvTools.depleteItem(can)); - resourceTank.fill(Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), true); + resourceTank.fill(Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP), true); } for (int i = 0; i < invInput.getSizeInventory(); i++) { diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index ff01abcb3..3b9434171 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -36,7 +36,7 @@ public class ContainerAnalyzer extends ContainerLiquidTanks { addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); // Can slot - addSlotToContainer(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.get()) { + addSlotToContainer(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.getFluid()) { @Override public boolean isItemValid(ItemStack stack) { diff --git a/src/main/java/forestry/core/utils/LiquidHelper.java b/src/main/java/forestry/core/utils/LiquidHelper.java index 56d42c337..98be60181 100755 --- a/src/main/java/forestry/core/utils/LiquidHelper.java +++ b/src/main/java/forestry/core/utils/LiquidHelper.java @@ -67,7 +67,7 @@ public class LiquidHelper { } public static void injectLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty, ItemStack remnant, int chance) { - FluidStack contained = fluid.get(volume); + FluidStack contained = fluid.getFluid(volume); if (contained == null) throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", fluid)); diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 6804a3c3e..258bbbebc 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -34,13 +34,13 @@ public class RecipeUtil { if (RecipeManagers.fermenterManager == null) return; - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, output.get(1), Fluids.WATER.get(1)); + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0f, output.getFluid(1), Fluids.WATER.getFluid(1)); - if (FluidRegistry.isFluidRegistered(Fluids.JUICE.get())) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.get(1), Fluids.JUICE.get(1)); + if (FluidRegistry.isFluidRegistered(Fluids.JUICE.getFluid())) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.getFluid(1), Fluids.JUICE.getFluid(1)); - if (FluidRegistry.isFluidRegistered(Fluids.HONEY.get())) - RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.get(1), Fluids.HONEY.get(1)); + if (FluidRegistry.isFluidRegistered(Fluids.HONEY.getFluid())) + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5f, output.getFluid(1), Fluids.HONEY.getFluid(1)); } /** diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 8ab5f23a5..048dac69c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -142,14 +142,14 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL @Override public void addCrating(ItemStack itemStack) { ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.get(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.getFluid(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), itemStack, new Object[] { "###", "###", "###", '#', uncrated }); addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack }); } @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { - addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.get(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), + addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.getFluid(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), ForestryItem.crate.getItemStack(), crated, new Object[] { "###", "###", "###", '#', toCrate }); addRecipe(null, new ItemStack(unpack.getItem(), 9, unpack.getItemDamage()), new Object[] { "#", '#', crated }); } diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index e097856ee..0dc646413 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -230,7 +230,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT super(1100, 50, 3300); setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); invCrafting = new InventoryMapper(getInternalInventory(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.get()); + moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.getFluid()); moltenTank.tankMode = StandardTank.TankMode.INTERNAL; tankManager = new TankManager(moltenTank); } diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index a5c70bd59..fa1ae1989 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -133,7 +133,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output) { - addRecipe(resource, fermentationValue, modifier, output, Fluids.WATER.get(1000)); + addRecipe(resource, fermentationValue, modifier, output, Fluids.WATER.getFluid(1000)); } public static Recipe findMatchingRecipe(ItemStack res, FluidStack liqu) { diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 81680d09c..14fd000f9 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -43,7 +43,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui /* CONSTANTS */ public static final short SLOT_RESOURCE = 0; public static final short SLOT_PRODUCT = 1; - private static final FluidStack STACK_WATER = Fluids.WATER.get(Defaults.RAINTANK_AMOUNT_PER_UPDATE); + private static final FluidStack STACK_WATER = Fluids.WATER.getFluid(Defaults.RAINTANK_AMOUNT_PER_UPDATE); /* MEMBER */ private final FilteredTank resourceTank; @@ -131,7 +131,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui tryToStartFillling(); else { fillingTime--; - if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get())) + if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid())) fillingTime = 0; } } @@ -142,7 +142,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private void tryToStartFillling() { // Nothing to do if no empty cans are available - if (!FluidHelper.fillContainers(tankManager, getInternalInventory(), SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.get(), false)) + if (!FluidHelper.fillContainers(tankManager, getInternalInventory(), SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid(), false)) return; fillingTime = Defaults.RAINTANK_FILLING_TIME; diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index e275ae474..5aebd7df8 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -432,7 +432,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable else hasFertilizer = true; - FluidStack liquid = Fluids.WATER.get(logic.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = Fluids.WATER.getFluid(logic.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) continue; else @@ -555,7 +555,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } // Check water - FluidStack liquid = Fluids.WATER.get(provider.getWaterConsumption(getHydrationModifier())); + FluidStack liquid = Fluids.WATER.getFluid(provider.getWaterConsumption(getHydrationModifier())); if (liquid.amount > 0 && !hasLiquid(liquid)) { setErrorState(EnumErrorCode.NOLIQUID); return false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 526dab75f..176d3133d 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -30,7 +30,7 @@ public abstract class FarmLogicWatered extends FarmLogic { protected final ItemStack ground; private final ItemStack[] resource; - private static final FluidStack STACK_WATER = Fluids.WATER.get(1000); + private static final FluidStack STACK_WATER = Fluids.WATER.getFluid(1000); ArrayList produce = new ArrayList(); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 1c6c44c03..8101a36e8 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -530,13 +530,13 @@ public class PluginApiculture extends ForestryPlugin { '#', ForestryItem.propolis.getItemStack(1, 2)); // / CANDLES - RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.get(600), null, ForestryBlock.candle.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.getFluid(600), null, ForestryBlock.candle.getItemStack(24), " X ", "###", "###", '#', ForestryItem.beeswax, 'X', Items.string); - RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(200), null, ForestryBlock.candle.getItemStack(6), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(200), null, ForestryBlock.candle.getItemStack(6), "#X#", '#', ForestryItem.beeswax, 'X', ForestryItem.craftingMaterial.getItemStack(1, 2)); @@ -606,20 +606,20 @@ public class PluginApiculture extends ForestryPlugin { 'W', ForestryItem.craftingMaterial.getItemStack(1, 3)); // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP), ForestryItem.propolis.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, Fluids.LAVA.get(2000)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, Fluids.LAVA.get(1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, Fluids.LAVA.getFluid(2000)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, Fluids.LAVA.getFluid(1600)); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.beealyzer.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.beealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotTin", 'R', Items.redstone, 'D', Items.diamond); - RecipeManagers.carpenterManager.addRecipe(50, Fluids.HONEY.get(500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), + RecipeManagers.carpenterManager.addRecipe(50, Fluids.HONEY.getFluid(500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), " J ", "###", "WPW", '#', "plankWood", 'J', ForestryItem.royalJelly, @@ -674,7 +674,7 @@ public class PluginApiculture extends ForestryPlugin { ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10}); // / FERMENTER - RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.get(1), Fluids.HONEY.get(1)); + RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.getFluid(1), Fluids.HONEY.getFluid(1)); // ANALYZER definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 6436d5254..43a15c5d5 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -408,7 +408,7 @@ public class PluginArboriculture extends ForestryPlugin { ItemStack logStack = forestryBlock.getItemStack(1, i); ItemStack fireproofLogStack = fireproofLog.getItemStack(1, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofLogStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofLogStack, new Object[]{ " # ", "#X#", " # ", @@ -423,7 +423,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -435,7 +435,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), fireproofPlankStack, new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlankStack, new Object[]{ "X#X", "#X#", "X#X", @@ -473,7 +473,7 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i)); // Treealyzer - RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotCopper", 'R', Items.redstone, @@ -483,13 +483,13 @@ public class PluginArboriculture extends ForestryPlugin { int seedOilMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); int juiceMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); int mulchMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); - RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{EnumFruit.CHERRY.getStack()}, Fluids.SEEDOIL.get(5 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{EnumFruit.WALNUT.getStack()}, Fluids.SEEDOIL.get(18 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{EnumFruit.CHESTNUT.getStack()}, Fluids.SEEDOIL.get(22 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 2); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.LEMON.getStack()}, Fluids.JUICE.get(juiceMultiplier * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PLUM.getStack()}, Fluids.JUICE.get((int) Math.floor(juiceMultiplier * 0.5f)), ForestryItem.mulch.getItemStack(), mulchMultiplier * 3); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PAPAYA.getStack()}, Fluids.JUICE.get(juiceMultiplier * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.DATES.getStack()}, Fluids.JUICE.get((int) Math.floor(juiceMultiplier * 0.25)), ForestryItem.mulch.getItemStack(), mulchMultiplier); + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{EnumFruit.CHERRY.getStack()}, Fluids.SEEDOIL.getFluid(5 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{EnumFruit.WALNUT.getStack()}, Fluids.SEEDOIL.getFluid(18 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{EnumFruit.CHESTNUT.getStack()}, Fluids.SEEDOIL.getFluid(22 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 2); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.LEMON.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PLUM.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.5f)), ForestryItem.mulch.getItemStack(), mulchMultiplier * 3); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PAPAYA.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.DATES.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.25)), ForestryItem.mulch.getItemStack(), mulchMultiplier); RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index 87798e991..c527645b3 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -44,16 +44,16 @@ public class PluginBuildCraftFuels extends ForestryPlugin { @Optional.Method(modid = "BuildCraftAPI|fuels") @Override public void doInit() { - BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.get(), 10.0f); + BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.getFluid(), 10.0f); - Fluid ethanol = Fluids.BIOETHANOL.get(); + Fluid ethanol = Fluids.BIOETHANOL.getFluid(); if (ethanol != null) { int ethanolPower = 40; int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); } - Fluid oil = Fluids.OIL.get(); + Fluid oil = Fluids.OIL.getFluid(); if (oil != null) { Block oilBlock = oil.getBlock(); if (oilBlock != null) { @@ -68,7 +68,7 @@ public class PluginBuildCraftFuels extends ForestryPlugin { } } - Fluid fuel = Fluids.FUEL.get(); + Fluid fuel = Fluids.FUEL.getFluid(); if (fuel != null) { Block fuelBlock = fuel.getBlock(); if (fuelBlock != null) { diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 2fa56db8b..674bb9f05 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -33,6 +33,6 @@ public class PluginBuildCraftRecipes extends ForestryPlugin { @Override protected void registerRecipes() { // Add recipe for ethanol - BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.get(4), Fluids.BIOETHANOL.get(1), 100, 1); + BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.BIOETHANOL.getFluid(1), 100, 1); } } diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index 0afaa7a02..1b4192fd9 100755 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -247,34 +247,34 @@ public class PluginFactory extends ForestryPlugin { // / FABRICATOR - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 0), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotCopper"}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 1), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotTin"}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 2), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', "ingotBronze"}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 3), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.iron_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 4), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.gold_ingot}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 5), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.diamond}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 6), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Blocks.obsidian}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 7), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.blaze_powder}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 9), new Object[]{ " X ", "#X#", "XXX", '#', Items.redstone, 'X', Items.emerald}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 10), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 10), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', "gemApatite"}); - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 11), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 11), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', new ItemStack(Items.dye, 1, 4)}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; if (PluginManager.Module.APICULTURE.isEnabled()) { - FluidStack liquidGlass = Fluids.GLASS.get(Defaults.BUCKET_VOLUME); + FluidStack liquidGlass = Fluids.GLASS.getFluid(Defaults.BUCKET_VOLUME); for (int i = 0; i < 16; i++) RecipeManagers.fabricatorManager.addRecipe(ForestryItem.waxCast.getItemStack(1, Defaults.WILDCARD), liquidGlass, ForestryBlock.glass.getItemStack(1, 15 - i), new Object[]{"#", "X", '#', dyes[i], 'X', ForestryItem.propolis.getItemStack(1, Defaults.WILDCARD)}); @@ -283,24 +283,24 @@ public class PluginFactory extends ForestryPlugin { // / SQUEEZER int appleMulchAmount = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); int appleJuiceAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, Fluids.JUICE.get(appleJuiceAmount), + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, Fluids.JUICE.getFluid(appleJuiceAmount), ForestryItem.mulch.getItemStack(), appleMulchAmount); int seedOilAmount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); - FluidStack seedOil = Fluids.SEEDOIL.get(seedOilAmount); + FluidStack seedOil = Fluids.SEEDOIL.getFluid(seedOilAmount); RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.wheat_seeds)}, seedOil); RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.pumpkin_seeds)}, seedOil); RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.melon_seeds)}, seedOil); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)}, Fluids.LAVA.get(1600)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, Fluids.WATER.get(500)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)}, Fluids.ICE.get(4000)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.cobblestone)}, Fluids.LAVA.getFluid(1600)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.cactus)}, Fluids.WATER.getFluid(500)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.snowball), ForestryItem.craftingMaterial.getItemStack(4, 5)}, Fluids.ICE.getFluid(4000)); // STILL - RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.get(Defaults.STILL_DESTILLATION_INPUT), - Fluids.BIOETHANOL.get(Defaults.STILL_DESTILLATION_OUTPUT)); + RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.getFluid(Defaults.STILL_DESTILLATION_INPUT), + Fluids.BIOETHANOL.getFluid(Defaults.STILL_DESTILLATION_OUTPUT)); // convert old honey to new honey - RecipeManagers.stillManager.addRecipe(1, Fluids.LEGACY_HONEY.get(1000), Fluids.HONEY.get(1000)); + RecipeManagers.stillManager.addRecipe(1, Fluids.LEGACY_HONEY.getFluid(1000), Fluids.HONEY.getFluid(1000)); // MOISTENER RecipeManagers.moistenerManager.addRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(Blocks.mycelium), 5000); @@ -319,17 +319,17 @@ public class PluginFactory extends ForestryPlugin { // FABRICATOR - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), Fluids.GLASS.get(1000), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), Fluids.GLASS.get(375), 1000); - RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), Fluids.GLASS.get(1000), 3000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass), Fluids.GLASS.getFluid(1000), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.glass_pane), Fluids.GLASS.getFluid(375), 1000); + RecipeManagers.fabricatorManager.addSmelting(new ItemStack(Blocks.sand), Fluids.GLASS.getFluid(1000), 3000); // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.get(250), null, ForestryItem.impregnatedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.getFluid(250), null, ForestryItem.impregnatedCasing.getItemStack(), "###", "# #", "###", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.get(500), null, + RecipeManagers.carpenterManager.addRecipe(50, Fluids.SEEDOIL.getFluid(500), null, ForestryBlock.core.getItemStack(1, Defaults.DEFINITION_ESCRITOIRE_META), "# ", "###", @@ -337,35 +337,35 @@ public class PluginFactory extends ForestryPlugin { '#', "plankWood"); // RESOURCES - RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.get(100), null, + RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.getFluid(100), null, ForestryItem.stickImpregnated.getItemStack(2), "#", "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(250), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(250), null, ForestryItem.woodPulp.getItemStack(4), "#", '#', "logWood"); - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(250), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(250), null, new ItemStack(Items.paper, 1), "#", "#", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, ForestryBlock.soil.getItemStack(9), "###", "#X#", "###", '#', Blocks.dirt, 'X', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, ForestryBlock.soil.getItemStack(8, 1), "#X#", "XYX", "#X#", '#', Blocks.dirt, 'X', Blocks.sand, 'Y', ForestryItem.mulch); - RecipeManagers.carpenterManager.addRecipe(75, Fluids.WATER.get(5000), null, ForestryItem.hardenedCasing.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(75, Fluids.WATER.getFluid(5000), null, ForestryItem.hardenedCasing.getItemStack(), "# #", " Y ", "# #", @@ -373,21 +373,21 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.sturdyCasing); // / CHIPSETS - RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 0), + RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, ForestryItem.circuitboards.getItemStack(1, 0), "R R", "R#R", "R R", '#', "ingotTin", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 1), + RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.getFluid(1000), null, ForestryItem.circuitboards.getItemStack(1, 1), "R#R", "R#R", "R#R", '#', "ingotBronze", 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 2), + RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.getFluid(1000), null, ForestryItem.circuitboards.getItemStack(1, 2), "R#R", "R#R", "R#R", '#', Items.iron_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.get(1000), null, ForestryItem.circuitboards.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(80, Fluids.WATER.getFluid(1000), null, ForestryItem.circuitboards.getItemStack(1, 3), "R#R", "R#R", "R#R", '#', Items.gold_ingot, 'R', Items.redstone); - RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.get(1000), null, ForestryItem.solderingIron.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(40, Fluids.WATER.getFluid(1000), null, ForestryItem.solderingIron.getItemStack(), " # ", "# #", " B", '#', Items.iron_ingot, 'B', "ingotBronze"); // ForestryCore.oreHandler.registerCarpenterRecipe(solderingIron); // RAIN SUBSTRATES if (PluginManager.Module.APICULTURE.isEnabled()) { - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.iodineCharge.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, ForestryItem.iodineCharge.getItemStack(), "Z#Z", "#Y#", "X#X", @@ -396,7 +396,7 @@ public class PluginFactory extends ForestryPlugin { 'Y', ForestryItem.canEmpty, 'Z', ForestryItem.honeyDrop); // ForestryCore.oreHandler.registerCarpenterRecipe(iodineCapsule); - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, ForestryItem.craftingMaterial.getItemStack(1, 4), "Z#Z", "#Y#", "X#X", @@ -411,13 +411,13 @@ public class PluginFactory extends ForestryPlugin { RecipeManagers.carpenterManager.addRecipe(100, null, new ItemStack(Items.ender_pearl, 1), " # ", "###", " # ", '#', ForestryItem.craftingMaterial.getItemStack(1, 1)); // Woven Silk - RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(500), null, ForestryItem.craftingMaterial.getItemStack(1, 3), "###", "###", "###", '#', ForestryItem.craftingMaterial.getItemStack(1, 2)); // Boxes - RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.get(1000), null, ForestryItem.carton.getItemStack(2), + RecipeManagers.carpenterManager.addRecipe(5, Fluids.WATER.getFluid(1000), null, ForestryItem.carton.getItemStack(2), " # ", "# #", " # ", '#', "pulpWood"); - RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.get(1000), null, ForestryItem.crate.getItemStack(24), + RecipeManagers.carpenterManager.addRecipe(20, Fluids.WATER.getFluid(1000), null, ForestryItem.crate.getItemStack(24), " # ", "# #", " # ", '#', "logWood"); // Assembly Kits diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index e8d6ca8df..a8e6096b2 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -195,11 +195,11 @@ public class PluginIC2 extends ForestryPlugin { definitionEngineTin.register(); definitionGenerator.register(); - FluidStack ethanol = Fluids.BIOETHANOL.get(1); + FluidStack ethanol = Fluids.BIOETHANOL.getFluid(1); GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4); FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel); - FluidStack biomass = Fluids.BIOMASS.get(1); + FluidStack biomass = Fluids.BIOMASS.getFluid(1); GeneratorFuel biomassFuel = new GeneratorFuel(biomass, (int) (8 * GameMode.getGameMode().getFloatSetting("fuel.biomass.generator")), 1); FuelManager.generatorFuel.put(biomass.getFluid(), biomassFuel); @@ -265,7 +265,7 @@ public class PluginIC2 extends ForestryPlugin { if (rubber != null) { for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.get(500), ForestryItem.tubes.getItemStack(4, 8), + RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), ForestryItem.tubes.getItemStack(4, 8), new Object[]{" X ", "#X#", "XXX", '#', Items.redstone, 'X', rubberOreDict}); } } diff --git a/src/main/java/forestry/plugins/PluginLepidopterology.java b/src/main/java/forestry/plugins/PluginLepidopterology.java index b61184225..f8a2d5988 100755 --- a/src/main/java/forestry/plugins/PluginLepidopterology.java +++ b/src/main/java/forestry/plugins/PluginLepidopterology.java @@ -145,7 +145,7 @@ public class PluginLepidopterology extends ForestryPlugin { protected void registerRecipes() { CraftingManager.getInstance().getRecipeList().add(new MatingRecipe()); - RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.get(2000), null, ForestryItem.flutterlyzer.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.flutterlyzer.getItemStack(), "X#X", "X#X", "RDR", '#', Blocks.glass_pane, 'X', "ingotBronze", 'R', Items.redstone, 'D', Items.diamond); } diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index 91f256930..ce8fc0548 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -182,7 +182,7 @@ public class PluginMail extends ForestryPlugin { 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper, 'Z', stampGlue); - RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.get(300), null, ForestryItem.stamps.getItemStack(9, i), + RecipeManagers.carpenterManager.addRecipe(10, Fluids.SEEDOIL.getFluid(300), null, ForestryItem.stamps.getItemStack(9, i), "XXX", "###", 'X', stampDefinitions[i].getCraftingIngredient(), '#', Items.paper); @@ -192,7 +192,7 @@ public class PluginMail extends ForestryPlugin { Proxies.common.addRecipe(new ItemStack(Items.paper), "###", '#', ForestryItem.letters.getItemStack(1, Defaults.WILDCARD)); // Carpenter - RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.get(250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(250), null, ForestryItem.letters.getItemStack(), "###", "###", '#', ForestryItem.woodPulp); Proxies.common.addShapelessRecipe(ForestryItem.catalogue.getItemStack(), ForestryItem.stamps.getItemStack(1, Defaults.WILDCARD), new ItemStack(Items.book)); } diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 0cc9b89ca..859572794 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -82,7 +82,7 @@ public class PluginNatura extends ForestryPlugin { int amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); for (ItemStack aSeedList : seedList) - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.get(amount)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.getFluid(amount)); ItemStack berryBlight = GameRegistry.findItemStack(NATURA, "berryBlight", 1); ItemStack berryDusk = GameRegistry.findItemStack(NATURA, "berryDusk", 1); @@ -114,7 +114,7 @@ public class PluginNatura extends ForestryPlugin { amount = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple") / 25; amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. for (ItemStack berry : berries) - RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.get(amount)); + RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.getFluid(amount)); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 6ffdc76aa..8686d08db 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -500,22 +500,22 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl // / CARPENTER // / BACKPACKS T2 - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.minerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.minerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.diggerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.diggerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.foresterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.foresterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.hunterBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.hunterBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.get(1000), null, ForestryItem.builderBackpackT2.getItemStack(), + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.builderBackpackT2.getItemStack(), "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack); From 98e62aa1e346845e423a0b0d0d5b4067a1609fc2 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 00:38:42 -0800 Subject: [PATCH 087/175] Refactor fluids code, create PluginFluids --- lang | 2 +- .../java/forestry/core/EventHandlerCore.java | 1 - src/main/java/forestry/core/ForestryCore.java | 14 - .../java/forestry/core/config/Config.java | 21 +- .../forestry/core/config/ForestryItem.java | 18 - .../core/fluids/BlockForestryFluid.java | 8 +- .../forestry/core/fluids/FluidHelper.java | 5 + .../java/forestry/core/fluids/Fluids.java | 490 +++++++++++++++--- .../forestry/core/fluids/ForestryFluids.java | 323 ------------ .../core/items/ItemLiquidContainer.java | 2 - .../plugins/PluginBuildCraftFuels.java | 39 +- .../plugins/PluginBuildCraftRecipes.java | 2 +- .../java/forestry/plugins/PluginCore.java | 63 --- .../java/forestry/plugins/PluginFactory.java | 2 +- .../java/forestry/plugins/PluginFluids.java | 194 +++++++ src/main/java/forestry/plugins/PluginIC2.java | 2 +- .../java/forestry/plugins/PluginManager.java | 15 +- 17 files changed, 645 insertions(+), 556 deletions(-) delete mode 100644 src/main/java/forestry/core/fluids/ForestryFluids.java mode change 100755 => 100644 src/main/java/forestry/plugins/PluginFactory.java create mode 100644 src/main/java/forestry/plugins/PluginFluids.java diff --git a/lang b/lang index 05bee96e8..98cf44234 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 05bee96e8aa617756ab7445cf32163a901c82028 +Subproject commit 98cf44234957090e6d1400431c83cb01803af43d diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index a3e514938..6057cf491 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -23,7 +23,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.core.ErrorStateRegistry; -import forestry.core.fluids.ForestryFluids; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.ISaveEventHandler; diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index b1c90d33e..d6bcac59c 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -43,7 +43,6 @@ import forestry.core.gadgets.TileEngine; import forestry.core.gadgets.TileMachine; import forestry.core.gadgets.TileMill; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import forestry.plugins.PluginManager; public class ForestryCore { @@ -66,8 +65,6 @@ public class ForestryCore { public void init(Object basemod) { - registerLiquidContainers(); - // Register world generator GameRegistry.registerWorldGenerator(new WorldGenerator(), 0); @@ -146,15 +143,4 @@ public class ForestryCore { public String getPriorities() { return "after:mod_IC2;after:mod_BuildCraftCore;after:mod_BuildCraftEnergy;after:mod_BuildCraftFactory;after:mod_BuildCraftSilicon;after:mod_BuildCraftTransport;after:mod_RedPowerWorld"; } - - /** Set containers for vanilla liquids */ - private void registerLiquidContainers() { - LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.canLava.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.LAVA, ForestryItem.refractoryLava.getItemStack()); - - LiquidHelper.injectLiquidContainer(Fluids.WATER, Defaults.BUCKET_VOLUME, new ItemStack(Items.potionitem), new ItemStack(Items.glass_bottle)); - LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.canWater.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.waxCapsuleWater.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.WATER, ForestryItem.refractoryWater.getItemStack()); - } } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index e66da0a98..1ea5d2a79 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -19,11 +19,10 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; -import java.util.Map; import java.util.Properties; import java.util.Set; -import forestry.core.fluids.ForestryFluids; +import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; public class Config { @@ -88,8 +87,8 @@ public class Config { return !Config.disabledStructures.contains(uid); } - public static boolean isFluidEnabled(ForestryFluids fluids) { - return !Config.disabledFluids.contains(fluids.tag); + public static boolean isFluidEnabled(Fluids fluids) { + return !Config.disabledFluids.contains(fluids.getTag()); } public static boolean isBlockEnabled(String tag) { @@ -244,16 +243,16 @@ public class Config { private static void loadFluids() { Property property; - for (ForestryFluids fluid : ForestryFluids.values()) { - property = config.get("disable.fluid." + fluid.tag, CATEGORY_FLUIDS, false); - property.comment = "set to true to disable the fluid for " + fluid.tag; + for (Fluids fluid : Fluids.values()) { + property = config.get("disable.fluid." + fluid.getTag(), CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the fluid for " + fluid.getTag(); if (Boolean.parseBoolean(property.value)) - Config.disabledFluids.add(fluid.tag); + Config.disabledFluids.add(fluid.getTag()); - property = config.get("disable.fluidBlock." + fluid.tag, CATEGORY_FLUIDS, false); - property.comment = "set to true to disable the in-world FluidBlock for " + fluid.tag; + property = config.get("disable.fluidBlock." + fluid.getTag(), CATEGORY_FLUIDS, false); + property.comment = "set to true to disable the in-world FluidBlock for " + fluid.getTag(); if (Boolean.parseBoolean(property.value)) - Config.disabledBlocks.add(fluid.tag); + Config.disabledBlocks.add(fluid.getTag()); } } diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index 4e839aae8..ae8c7a20c 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -10,16 +10,12 @@ ******************************************************************************/ package forestry.core.config; -import forestry.core.fluids.ForestryFluids; -import forestry.core.items.ItemLiquidContainer; import forestry.core.proxy.Proxies; import forestry.plugins.PluginManager; import forestry.plugins.PluginManager.Stage; -import java.awt.Color; import java.util.EnumSet; -import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -295,18 +291,4 @@ public enum ForestryItem { return null; return new ItemStack(item, qty, meta); } - - public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid, int healAmount, float saturationModifier) { - ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()); - liquidContainer.setDrink(healAmount, saturationModifier); - registerItem(liquidContainer, toString()); - } - - public void registerContainer(ItemLiquidContainer.EnumContainerType type, ForestryFluids fluid) { - registerItem(new ItemLiquidContainer(type, fluid.getBlock(), fluid.getColor()), toString()); - } - - public void registerContainer(ItemLiquidContainer.EnumContainerType type, Block block, Color color) { - registerItem(new ItemLiquidContainer(type, block, color), toString()); - } } diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java index 9f091b267..dde8cf45b 100644 --- a/src/main/java/forestry/core/fluids/BlockForestryFluid.java +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -11,9 +11,7 @@ package forestry.core.fluids; import java.awt.Color; -import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Random; @@ -52,12 +50,12 @@ public class BlockForestryFluid extends BlockFluidClassic { @SideOnly(Side.CLIENT) private List icons; - public BlockForestryFluid(ForestryFluids forestryFluid) { + public BlockForestryFluid(Fluids forestryFluid) { this(forestryFluid, 0, false); } - public BlockForestryFluid(ForestryFluids forestryFluid, int flammability, boolean flammable) { - this(forestryFluid.standardFluid.getFluid(), flammability, flammable, forestryFluid.getColor()); + public BlockForestryFluid(Fluids forestryFluid, int flammability, boolean flammable) { + this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getColor()); } private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) { diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 6320b5979..952966deb 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -365,4 +365,9 @@ public final class FluidHelper { return null; } + public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { + if (fluidStack != null && fluid == fluidStack.getFluid()) + return true; + return fluid == null && fluidStack == null; + } } diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 8e9de0c00..b9bd526eb 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -1,75 +1,415 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.fluids; - -import java.util.Locale; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -/** - * - * @author CovertJaguar - */ -public enum Fluids { - - WATER, LAVA, - FUEL, OIL, BIOFUEL, - CREOSOTE, STEAM, - COAL, PYROTHEUM, - BIOMASS, BIOETHANOL, LEGACY_HONEY("honey"), HONEY("for.honey"), MILK, JUICE, ICE, GLASS, SEEDOIL, SHORT_MEAD("short.mead"); - - private final String tag; - - private Fluids() { - tag = name().toLowerCase(Locale.ENGLISH); - } - - private Fluids(String tag) { - this.tag = tag; - } - - public String getTag() { - return tag; - } - - public Fluid getFluid() { - return FluidRegistry.getFluid(tag); - } - - /** - * Gets a FluidStack filled with mb milliBuckets worth of Fluid. - */ - public FluidStack getFluid(int mb) { - return FluidRegistry.getFluidStack(tag, mb); - } - - public boolean is(Fluid fluid) { - return getFluid() == fluid; - } - - public boolean is(FluidStack fluidStack) { - return fluidStack != null && getFluid() == fluidStack.getFluid(); - } - - public boolean isContained(ItemStack containerStack) { - return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid()); - } - - public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { - if (fluidStack != null && fluid == fluidStack.getFluid()) - return true; - return fluid == null && fluidStack == null; - } -} +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.fluids; + +import java.awt.Color; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.items.ItemLiquidContainer; + +import static forestry.core.items.ItemLiquidContainer.EnumContainerType; + +public enum Fluids { + + ETHANOL(new Color(255, 111, 0), 790, 1000) { + @Override + public String getTag() { + return "bioethanol"; + } + + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 300, true); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketEthanol; + case CAN: + return ForestryItem.canEthanol; + case CAPSULE: + return ForestryItem.waxCapsuleEthanol; + case REFRACTORY: + return ForestryItem.refractoryEthanol; + default: + return null; + } + } + }, + BIOMASS(new Color(100, 132, 41), 400, 6560) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 100, true); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketBiomass; + case CAN: + return ForestryItem.canBiomass; + case CAPSULE: + return ForestryItem.waxCapsuleBiomass; + case REFRACTORY: + return ForestryItem.refractoryBiomass; + default: + return null; + } + } + }, + GLASS(new Color(164, 164, 164), 2400, 10000) { + @Override + public int getTemperature() { + return 1200; + } + + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 0, true); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketGlass; + default: + return null; + } + } + }, + HONEY(new Color(255, 196, 35), 1420, 73600) { + @Override + public String getTag() { + return "for.honey"; + } + + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketHoney; + case CAN: + return ForestryItem.canHoney; + case CAPSULE: + return ForestryItem.waxCapsuleHoney; + case REFRACTORY: + return ForestryItem.refractoryHoney; + default: + return null; + } + } + + @Override + public void setDrink(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) + liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + } + }, + LEGACY_HONEY { + @Override + public String getTag() { + return "honey"; + } + }, + ICE(new Color(175, 242, 255), 920, 1000) { + @Override + public int getTemperature() { + return 265; + } + + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketIce; + case CAN: + return ForestryItem.canIce; + case CAPSULE: + return ForestryItem.waxCapsuleIce; + case REFRACTORY: + return ForestryItem.refractoryIce; + default: + return null; + } + } + }, + JUICE(new Color(168, 201, 114)) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketJuice; + case CAN: + return ForestryItem.canJuice; + case CAPSULE: + return ForestryItem.waxCapsuleJuice; + case REFRACTORY: + return ForestryItem.refractoryJuice; + default: + return null; + } + } + + @Override + public void setDrink(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) + liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + } + }, + MILK(new Color(255, 255, 255), 1030, 3000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + + @Override + public List getOtherContainers() { + return Arrays.asList( + new ItemStack(Items.milk_bucket) + ); + } + }, + SEEDOIL(new Color(255, 255, 168), 885, 5000) { + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 2, true); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketSeedoil; + case CAN: + return ForestryItem.canSeedOil; + case CAPSULE: + return ForestryItem.waxCapsuleSeedOil; + case REFRACTORY: + return ForestryItem.refractorySeedOil; + default: + return null; + } + } + }, + SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) { + @Override + public String getTag() { + return "short.mead"; + } + + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } + + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketShortMead; + default: + return null; + } + } + }, + // Vanilla + WATER(new Color(0x2432ec)) { + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canWater; + case CAPSULE: + return ForestryItem.waxCapsuleWater; + case REFRACTORY: + return ForestryItem.refractoryWater; + default: + return null; + } + } + }, + LAVA(new Color(0xfd461f)) { + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canLava; + case REFRACTORY: + return ForestryItem.refractoryLava; + default: + return null; + } + } + }, + // BuildCraft + FUEL(new Color(0xffff00)) { + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canFuel; + case CAPSULE: + return ForestryItem.waxCapsuleFuel; + case REFRACTORY: + return ForestryItem.refractoryFuel; + default: + return null; + } + } + }, + OIL(new Color(0x404040)) { + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canOil; + case CAPSULE: + return ForestryItem.waxCapsuleOil; + case REFRACTORY: + return ForestryItem.refractoryOil; + default: + return null; + } + } + }, + // Railcraft + CREOSOTE, STEAM, + // Thermal Expansion + COAL, PYROTHEUM; + + private final String tag; + private final int density, viscosity; + private final Color color; + + private Fluids() { + this(null); + } + + private Fluids(Color color) { + this(color, 1000, 1000); + } + + private Fluids(Color color, int density, int viscosity) { + this.tag = name().toLowerCase(Locale.ENGLISH); + this.color = color; + this.density = density; + this.viscosity = viscosity; + } + + public int getTemperature() { + return 295; + } + + public String getTag() { + return tag; + } + + public final int getDensity() { + return density; + } + + public final int getViscosity() { + return viscosity; + } + + public final Fluid getFluid() { + return FluidRegistry.getFluid(getTag()); + } + + public final FluidStack getFluid(int mb) { + return FluidRegistry.getFluidStack(getTag(), mb); + } + + public final Block getBlock() { + Fluid fluid = getFluid(); + if (fluid == null) + return null; + return fluid.getBlock(); + } + + public final Color getColor() { + return color; + } + + public final boolean is(Fluid fluid) { + return getFluid() == fluid; + } + + public final boolean is(FluidStack fluidStack) { + return fluidStack != null && getFluid() == fluidStack.getFluid(); + } + + public final boolean isContained(ItemStack containerStack) { + return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid()); + } + + /** FluidBlock and Container registration */ + + /** + * Add the filled containers for the fluid, to have them get created and registered. + */ + public ForestryItem getContainerForType(EnumContainerType type) { + return null; + } + + /** + * Add non-forestry containers for the fluid. + */ + public List getOtherContainers() { + return Collections.emptyList(); + } + + /** + * Override for Forestry fluids to create FluidBlocks. + */ + public Block makeBlock() { + return null; + } + + /** + * Set the drink properties for a ItemLiquidContainer before it gets registered. + */ + public void setDrink(ItemLiquidContainer liquidContainer) { + + } +} diff --git a/src/main/java/forestry/core/fluids/ForestryFluids.java b/src/main/java/forestry/core/fluids/ForestryFluids.java deleted file mode 100644 index 4d3e25930..000000000 --- a/src/main/java/forestry/core/fluids/ForestryFluids.java +++ /dev/null @@ -1,323 +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.fluids; - -import java.awt.Color; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MovingObjectPosition; - -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.event.entity.player.FillBucketEvent; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -import cpw.mods.fml.common.eventhandler.Event; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import forestry.core.config.Config; -import forestry.core.config.ForestryItem; -import forestry.core.items.ItemLiquidContainer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; - -public enum ForestryFluids { - - ETHANOL(Fluids.BIOETHANOL, new Color(255, 111, 0), 790, 1000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 300, true); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketEthanol.getItemStack(), - ForestryItem.canEthanol.getItemStack(), - ForestryItem.waxCapsuleEthanol.getItemStack(), - ForestryItem.refractoryEthanol.getItemStack() - ); - } - }, - BIOMASS(Fluids.BIOMASS, new Color(100, 132, 41), 400, 6560) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 100, true); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketBiomass.getItemStack(), - ForestryItem.canBiomass.getItemStack(), - ForestryItem.waxCapsuleBiomass.getItemStack(), - ForestryItem.refractoryBiomass.getItemStack() - ); - } - }, - LIQUID_GLASS(Fluids.GLASS, new Color(164, 164, 164), 2400, 10000, 1200) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 0, true); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketGlass.getItemStack() - ); - } - }, - HONEY(Fluids.HONEY, new Color(255, 173, 31), 1420, 73600) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketHoney.getItemStack(), - ForestryItem.canHoney.getItemStack(), - ForestryItem.waxCapsuleHoney.getItemStack(), - ForestryItem.refractoryHoney.getItemStack() - ); - } - }, - LEGACY_HONEY(Fluids.LEGACY_HONEY, new Color(224, 194, 57), 1420, 73600), - ICE(Fluids.ICE, new Color(175, 242, 255), 920, 1000, 265) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketIce.getItemStack(), - ForestryItem.canIce.getItemStack(), - ForestryItem.waxCapsuleIce.getItemStack(), - ForestryItem.refractoryIce.getItemStack() - ); - } - }, - JUICE(Fluids.JUICE, new Color(168, 201, 114), 1000, 1000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketJuice.getItemStack(), - ForestryItem.canJuice.getItemStack(), - ForestryItem.waxCapsuleJuice.getItemStack(), - ForestryItem.refractoryJuice.getItemStack() - ); - } - }, - MILK(Fluids.MILK, new Color(255, 255, 255), 1030, 3000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } - @Override - List getFilledContainers() { - return Arrays.asList( - new ItemStack(Items.milk_bucket) - ); - } - }, - SEEDOIL(Fluids.SEEDOIL, new Color(255, 255, 168), 885, 5000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 2, true); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketSeedoil.getItemStack(), - ForestryItem.canSeedOil.getItemStack(), - ForestryItem.waxCapsuleSeedOil.getItemStack(), - ForestryItem.refractorySeedOil.getItemStack() - ); - } - }, - SHORT_MEAD(Fluids.SHORT_MEAD, new Color(239, 153, 0), 1000, 1200) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } - @Override - List getFilledContainers() { - return Arrays.asList( - ForestryItem.bucketShortMead.getItemStack() - ); - } - }; - - public static final ForestryFluids[] VALUES = values(); - public final String tag; - public final Fluids standardFluid; - public final int density, viscosity, temperature; - private final Color color; - protected Fluid fluid; - protected Block fluidBlock; - - private ForestryFluids(Fluids standardFluid, Color color) { - this(standardFluid, color, 1000, 1000, 295); - } - - private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity) { - this(standardFluid, color, density, viscosity, 295); - } - - private ForestryFluids(Fluids standardFluid, Color color, int density, int viscosity, int temperature) { - this.tag = "fluid." + standardFluid.getTag(); - this.standardFluid = standardFluid; - this.color = color; - this.density = density; - this.viscosity = viscosity; - this.temperature = temperature; - } - - private void initFluid() { - if (fluid == null && Config.isFluidEnabled(this)) { - String fluidName = standardFluid.getTag(); - if (!FluidRegistry.isFluidRegistered(fluidName)) { - fluid = new Fluid(fluidName).setDensity(density).setViscosity(viscosity).setTemperature(temperature); - FluidRegistry.registerFluid(fluid); - initBlock(); - } - } - } - - List getFilledContainers() { - return Collections.emptyList(); - } - - Block makeBlock() { - return null; - } - - private void initBlock() { - if (fluidBlock != null) - return; - - Fluid fluid = standardFluid.getFluid(); - if (fluid == null) - return; - - fluidBlock = fluid.getBlock(); - - if (Config.isBlockEnabled(tag)) - if (fluidBlock == null) { - fluidBlock = makeBlock(); - if (fluidBlock != null) { - fluidBlock.setBlockName("forestry." + tag); - Proxies.common.registerBlock(fluidBlock, ItemBlock.class); - } - } else { - GameRegistry.UniqueIdentifier blockID = GameRegistry.findUniqueIdentifierFor(fluidBlock); - Proxies.log.severe("Pre-existing {0} fluid block detected, deferring to {1}:{2}, " - + "this may cause issues if the server/client have different mod load orders, " - + "recommended that you disable all but one instance of {0} fluid blocks via your configs.", fluid.getName(), blockID.modId, blockID.name); - } - } - - public Block getBlock() { - return fluidBlock; - } - - public Color getColor() { - return color; - } - - public static class MissingFluidException extends RuntimeException { - - public MissingFluidException(String tag) { - super("Fluid '" + tag + "' was not found. Please check your configs."); - } - - } - - public static void preInit() { - for (ForestryFluids fluidType : VALUES) { - fluidType.initFluid(); - } - } - - public static void init() { - for (ForestryFluids fluidType : VALUES) { - if (fluidType.standardFluid.getFluid() == null) - continue; - - for (ItemStack filledContainer : fluidType.getFilledContainers()) { - LiquidHelper.injectLiquidContainer(fluidType.standardFluid, filledContainer); - } - } - } - - public static void postInit() { - for (ForestryFluids fluidType : VALUES) { - fluidType.initBlock(); - if (fluidType.standardFluid.getFluid() == null) - throw new MissingFluidException(fluidType.standardFluid.getTag()); - } - } - - public static class TextureHook { - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void textureHook(TextureStitchEvent.Post event) { - if (event.map.getTextureType() == 0) { - for (ForestryFluids fluidType : VALUES) { - if (fluidType.fluid != null) - fluidType.fluid.setIcons(fluidType.fluidBlock.getBlockTextureFromSide(1), fluidType.fluidBlock.getBlockTextureFromSide(2)); - } - } - } - - } - - public static Object getTextureHook() { - return new TextureHook(); - } - - public static class FillBucketHook { - @SubscribeEvent - public void fillBucket(FillBucketEvent event) { - MovingObjectPosition movingObjectPosition = event.target; - int x = movingObjectPosition.blockX; - int y = movingObjectPosition.blockY; - int z = movingObjectPosition.blockZ; - Block targetedBlock = event.world.getBlock(x, y, z); - if (targetedBlock instanceof BlockForestryFluid) { - Item filledBucket = ItemLiquidContainer.getExistingBucket(targetedBlock); - if (filledBucket != null) { - event.result = new ItemStack(filledBucket); - event.setResult(Event.Result.ALLOW); - } - } - } - } - - public static Object getFillBucketHook() { - return new FillBucketHook(); - } -} \ No newline at end of file diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 9007cb4e0..0b4bbf171 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -63,12 +63,10 @@ public class ItemLiquidContainer extends Item { private final Color color; public ItemLiquidContainer(EnumContainerType type, Block contents, Color color) { - super(); this.type = type; this.contents = contents; this.color = color; setCreativeTab(CreativeTabForestry.tabForestry); - setMaxStackSize(16); if (type == EnumContainerType.BUCKET) { setContainerItem(Items.bucket); this.maxStackSize = 1; diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index c527645b3..5b3e2150f 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -10,23 +10,16 @@ ******************************************************************************/ package forestry.plugins; -import java.awt.Color; - -import net.minecraft.block.Block; - import net.minecraftforge.fluids.Fluid; import cpw.mods.fml.common.Optional; import forestry.core.GameMode; import forestry.core.config.Defaults; -import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; -import forestry.core.utils.LiquidHelper; import buildcraft.api.fuels.BuildcraftFuelRegistry; -import forestry.core.items.ItemLiquidContainer.EnumContainerType; @Plugin(pluginID = "BC6|Fuels", name = "BuildCraft 6 Fuels", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends ForestryPlugin { @@ -46,42 +39,12 @@ public class PluginBuildCraftFuels extends ForestryPlugin { public void doInit() { BuildcraftFuelRegistry.coolant.addCoolant(Fluids.ICE.getFluid(), 10.0f); - Fluid ethanol = Fluids.BIOETHANOL.getFluid(); + Fluid ethanol = Fluids.ETHANOL.getFluid(); if (ethanol != null) { int ethanolPower = 40; int ethanolBurnTime = Math.round(Defaults.ENGINE_CYCLE_DURATION_ETHANOL * GameMode.getGameMode().getFloatSetting("fuel.ethanol.combustion")); BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); } - - Fluid oil = Fluids.OIL.getFluid(); - if (oil != null) { - Block oilBlock = oil.getBlock(); - if (oilBlock != null) { - Color oilColor = new Color(0x404040); - ForestryItem.waxCapsuleOil.registerContainer(EnumContainerType.CAPSULE, oilBlock, oilColor); - ForestryItem.canOil.registerContainer(EnumContainerType.CAN, oilBlock, oilColor); - ForestryItem.refractoryOil.registerContainer(EnumContainerType.REFRACTORY, oilBlock, oilColor); - - LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.waxCapsuleOil.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.refractoryOil.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.OIL, ForestryItem.canOil.getItemStack()); - } - } - - Fluid fuel = Fluids.FUEL.getFluid(); - if (fuel != null) { - Block fuelBlock = fuel.getBlock(); - if (fuelBlock != null) { - Color fuelColor = new Color(0xffff00); - ForestryItem.waxCapsuleFuel.registerContainer(EnumContainerType.CAPSULE, fuelBlock, fuelColor); - ForestryItem.canFuel.registerContainer(EnumContainerType.CAN, fuelBlock, fuelColor); - ForestryItem.refractoryFuel.registerContainer(EnumContainerType.REFRACTORY, fuelBlock, fuelColor); - - LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.waxCapsuleFuel.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.refractoryFuel.getItemStack()); - LiquidHelper.injectLiquidContainer(Fluids.FUEL, ForestryItem.canFuel.getItemStack()); - } - } } } diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 674bb9f05..78ae9dde2 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -33,6 +33,6 @@ public class PluginBuildCraftRecipes extends ForestryPlugin { @Override protected void registerRecipes() { // Add recipe for ethanol - BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.BIOETHANOL.getFluid(1), 100, 1); + BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.ETHANOL.getFluid(1), 100, 1); } } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index 30a62f5af..debdfb838 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.plugins; -import java.awt.Color; import java.util.ArrayList; import net.minecraft.block.material.Material; @@ -43,7 +42,6 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; -import forestry.core.fluids.ForestryFluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.BlockResource; import forestry.core.gadgets.BlockResourceStorageBlock; @@ -65,7 +63,6 @@ import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemForestryPickaxe; import forestry.core.items.ItemForestryShovel; import forestry.core.items.ItemFruit; -import forestry.core.items.ItemLiquidContainer; import forestry.core.items.ItemMisc; import forestry.core.items.ItemOverlay; import forestry.core.items.ItemOverlay.OverlayInfo; @@ -76,11 +73,6 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.ForestryModEnvWarningCallable; import forestry.core.utils.ShapedRecipeCustom; -import static forestry.core.items.ItemLiquidContainer.EnumContainerType.BUCKET; -import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAN; -import static forestry.core.items.ItemLiquidContainer.EnumContainerType.CAPSULE; -import static forestry.core.items.ItemLiquidContainer.EnumContainerType.REFRACTORY; - @Plugin(pluginID = "Core", name = "Core", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.core.description") public class PluginCore extends ForestryPlugin { @@ -96,10 +88,6 @@ public class PluginCore extends ForestryPlugin { rootCommand.addChildCommand(new CommandVersion()); rootCommand.addChildCommand(new CommandPlugins()); - ForestryFluids.preInit(); - MinecraftForge.EVENT_BUS.register(ForestryFluids.getTextureHook()); - MinecraftForge.EVENT_BUS.register(ForestryFluids.getFillBucketHook()); - ChipsetManager.solderManager = new ItemSolderingIron.SolderManager(); CircuitRegistry circuitRegistry = new CircuitRegistry(); @@ -149,8 +137,6 @@ public class PluginCore extends ForestryPlugin { public void doInit() { super.doInit(); - ForestryFluids.init(); - definitionEscritoire.register(); crashCallable = new ForestryModEnvWarningCallable(); @@ -174,7 +160,6 @@ public class PluginCore extends ForestryPlugin { @Override protected void registerItems() { - // / FERTILIZERS ForestryItem.fertilizerBio.registerItem((new ItemForestry()), "fertilizerBio"); ForestryItem.fertilizerCompound.registerItem((new ItemForestry()).setBonemeal(true), "fertilizerCompound"); @@ -278,58 +263,10 @@ public class PluginCore extends ForestryPlugin { // FRUITS ForestryItem.fruits.registerItem(new ItemFruit(), "fruits"); - - // / EMPTY LIQUID CONTAINERS - ForestryItem.waxCapsule.registerItem(new ItemLiquidContainer(CAPSULE, Blocks.air, null).setMaxStackSize(64), "waxCapsule"); - ForestryItem.canEmpty.registerItem(new ItemLiquidContainer(CAN, Blocks.air, null).setMaxStackSize(64), "canEmpty"); - ForestryItem.refractoryEmpty.registerItem(new ItemLiquidContainer(REFRACTORY, Blocks.air, null).setMaxStackSize(64), "refractoryEmpty"); - - // / BUCKETS - ForestryItem.bucketBiomass.registerContainer(BUCKET, ForestryFluids.BIOMASS); - ForestryItem.bucketEthanol.registerContainer(BUCKET, ForestryFluids.ETHANOL); - ForestryItem.bucketGlass.registerContainer(BUCKET, ForestryFluids.LIQUID_GLASS); - ForestryItem.bucketHoney.registerContainer(BUCKET, ForestryFluids.HONEY); - ForestryItem.bucketIce.registerContainer(BUCKET, ForestryFluids.ICE); - ForestryItem.bucketJuice.registerContainer(BUCKET, ForestryFluids.JUICE); - ForestryItem.bucketSeedoil.registerContainer(BUCKET, ForestryFluids.SEEDOIL); - ForestryItem.bucketShortMead.registerContainer(BUCKET, ForestryFluids.SHORT_MEAD); - - Color colorWater = new Color(0x2432ec); - Color colorLava = new Color(0xfd461f); - - // / WAX CAPSULES - ForestryItem.waxCapsuleBiomass.registerContainer(CAPSULE, ForestryFluids.BIOMASS); - ForestryItem.waxCapsuleEthanol.registerContainer(CAPSULE, ForestryFluids.ETHANOL); - ForestryItem.waxCapsuleHoney.registerContainer(CAPSULE, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); - ForestryItem.waxCapsuleIce.registerContainer(CAPSULE, ForestryFluids.ICE); - ForestryItem.waxCapsuleJuice.registerContainer(CAPSULE, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); - ForestryItem.waxCapsuleSeedOil.registerContainer(CAPSULE, ForestryFluids.SEEDOIL); - ForestryItem.waxCapsuleWater.registerContainer(CAPSULE, Blocks.flowing_water, colorWater); - - // / CANS - ForestryItem.canBiomass.registerContainer(CAN, ForestryFluids.BIOMASS); - ForestryItem.canEthanol.registerContainer(CAN, ForestryFluids.ETHANOL); - ForestryItem.canLava.registerContainer(CAN, Blocks.flowing_lava, colorLava); - ForestryItem.canHoney.registerContainer(CAN, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); - ForestryItem.canIce.registerContainer(CAN, ForestryFluids.ICE); - ForestryItem.canJuice.registerContainer(CAN, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); - ForestryItem.canSeedOil.registerContainer(CAN, ForestryFluids.SEEDOIL); - ForestryItem.canWater.registerContainer(CAN, Blocks.flowing_water, colorWater); - - // / REFRACTORY CAPSULES - ForestryItem.refractoryBiomass.registerContainer(REFRACTORY, ForestryFluids.BIOMASS); - ForestryItem.refractoryEthanol.registerContainer(REFRACTORY, ForestryFluids.ETHANOL); - ForestryItem.refractoryLava.registerContainer(REFRACTORY, Blocks.flowing_lava, colorLava); - ForestryItem.refractoryHoney.registerContainer(REFRACTORY, ForestryFluids.HONEY, Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); - ForestryItem.refractoryIce.registerContainer(REFRACTORY, ForestryFluids.ICE); - ForestryItem.refractoryJuice.registerContainer(REFRACTORY, ForestryFluids.JUICE, Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); - ForestryItem.refractorySeedOil.registerContainer(REFRACTORY, ForestryFluids.SEEDOIL); - ForestryItem.refractoryWater.registerContainer(REFRACTORY, Blocks.flowing_water, colorWater); } @Override public void postInit() { - ForestryFluids.postInit(); } @Override diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java old mode 100755 new mode 100644 index 1b4192fd9..c1ac25896 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -297,7 +297,7 @@ public class PluginFactory extends ForestryPlugin { // STILL RecipeManagers.stillManager.addRecipe(Defaults.STILL_DESTILLATION_DURATION, Fluids.BIOMASS.getFluid(Defaults.STILL_DESTILLATION_INPUT), - Fluids.BIOETHANOL.getFluid(Defaults.STILL_DESTILLATION_OUTPUT)); + Fluids.ETHANOL.getFluid(Defaults.STILL_DESTILLATION_OUTPUT)); // convert old honey to new honey RecipeManagers.stillManager.addRecipe(1, Fluids.LEGACY_HONEY.getFluid(1000), Fluids.HONEY.getFluid(1000)); diff --git a/src/main/java/forestry/plugins/PluginFluids.java b/src/main/java/forestry/plugins/PluginFluids.java new file mode 100644 index 000000000..0011d14a1 --- /dev/null +++ b/src/main/java/forestry/plugins/PluginFluids.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * 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.plugins; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryItem; +import forestry.core.fluids.BlockForestryFluid; +import forestry.core.fluids.Fluids; +import forestry.core.items.ItemLiquidContainer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.LiquidHelper; + +import static forestry.core.items.ItemLiquidContainer.EnumContainerType; + +@Plugin(pluginID = "Fluids", name = "Fluids", author = "mezz", url = Defaults.URL, unlocalizedDescription = "for.plugin.fluids.description") +public class PluginFluids extends ForestryPlugin { + + private static final List forestryFluidsWithBlocks = new ArrayList(); + + private static void createFluid(Fluids forestryFluid) { + if (forestryFluid.getFluid() == null && Config.isFluidEnabled(forestryFluid)) { + String fluidName = forestryFluid.getTag(); + if (!FluidRegistry.isFluidRegistered(fluidName)) { + Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity()).setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature()); + FluidRegistry.registerFluid(fluid); + createBlock(forestryFluid); + } + } + } + + private static void createBlock(Fluids forestryFluid) { + Fluid fluid = forestryFluid.getFluid(); + Block fluidBlock = fluid.getBlock(); + + if (Config.isBlockEnabled(forestryFluid.getTag())) { + if (fluidBlock == null) { + fluidBlock = forestryFluid.makeBlock(); + if (fluidBlock != null) { + fluidBlock.setBlockName("forestry.fluid." + forestryFluid.getTag()); + Proxies.common.registerBlock(fluidBlock, ItemBlock.class); + forestryFluidsWithBlocks.add(forestryFluid); + } + } else { + GameRegistry.UniqueIdentifier blockID = GameRegistry.findUniqueIdentifierFor(fluidBlock); + Proxies.log.severe("Pre-existing {0} fluid block detected, deferring to {1}:{2}, " + + "this may cause issues if the server/client have different mod load orders, " + + "recommended that you disable all but one instance of {0} fluid blocks via your configs.", fluid.getName(), blockID.modId, blockID.name); + } + } + } + + @Override + public void preInit() { + for (Fluids fluidType : Fluids.values()) { + createFluid(fluidType); + } + MinecraftForge.EVENT_BUS.register(getTextureHook()); + MinecraftForge.EVENT_BUS.register(getFillBucketHook()); + } + + @Override + public void registerItems() { + for (EnumContainerType type : EnumContainerType.values()) { + Item emptyContainer = new ItemLiquidContainer(type, Blocks.air, null); + switch (type) { + case CAN: + ForestryItem.canEmpty.registerItem(emptyContainer, "canEmpty"); + break; + case CAPSULE: + ForestryItem.waxCapsule.registerItem(emptyContainer, "waxCapsule"); + break; + case REFRACTORY: + ForestryItem.refractoryEmpty.registerItem(emptyContainer, "refractoryEmpty"); + break; + } + + for (Fluids fluidType : Fluids.values()) { + ForestryItem container = fluidType.getContainerForType(type); + if (container == null) + continue; + + ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor()); + fluidType.setDrink(liquidContainer); + container.registerItem(liquidContainer, container.toString()); + } + } + } + + @Override + public void doInit() { + for (Fluids fluidType : Fluids.values()) { + if (fluidType.getFluid() == null) + continue; + + for (EnumContainerType type : EnumContainerType.values()) { + ForestryItem container = fluidType.getContainerForType(type); + if (container == null) + continue; + + LiquidHelper.injectLiquidContainer(fluidType, container.getItemStack()); + } + + for (ItemStack filledContainer : fluidType.getOtherContainers()) { + LiquidHelper.injectLiquidContainer(fluidType, filledContainer); + } + } + } + + public static class MissingFluidException extends RuntimeException { + public MissingFluidException(String tag) { + super("Fluid '" + tag + "' was not found. Please check your configs."); + } + } + + @Override + public void postInit() { + for (Fluids fluidType : Fluids.values()) { + if (fluidType.getFluid() == null) + throw new MissingFluidException(fluidType.getTag()); + } + } + + public static class TextureHook { + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void textureHook(TextureStitchEvent.Post event) { + if (event.map.getTextureType() == 0) { + for (Fluids fluidType : forestryFluidsWithBlocks) { + Fluid fluid = fluidType.getFluid(); + Block fluidBlock = fluidType.getBlock(); + if (fluid != null && fluidBlock != null) + fluid.setIcons(fluidBlock.getBlockTextureFromSide(1), fluidBlock.getBlockTextureFromSide(2)); + } + } + } + } + + private static Object getTextureHook() { + return new TextureHook(); + } + + public static class FillBucketHook { + @SubscribeEvent + public void fillBucket(FillBucketEvent event) { + MovingObjectPosition movingObjectPosition = event.target; + int x = movingObjectPosition.blockX; + int y = movingObjectPosition.blockY; + int z = movingObjectPosition.blockZ; + Block targetedBlock = event.world.getBlock(x, y, z); + if (targetedBlock instanceof BlockForestryFluid) { + Item filledBucket = ItemLiquidContainer.getExistingBucket(targetedBlock); + if (filledBucket != null) { + event.result = new ItemStack(filledBucket); + event.setResult(Event.Result.ALLOW); + } + } + } + } + + private static Object getFillBucketHook() { + return new FillBucketHook(); + } +} diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index a8e6096b2..bdb0a5839 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -195,7 +195,7 @@ public class PluginIC2 extends ForestryPlugin { definitionEngineTin.register(); definitionGenerator.register(); - FluidStack ethanol = Fluids.BIOETHANOL.getFluid(1); + FluidStack ethanol = Fluids.ETHANOL.getFluid(1); GeneratorFuel ethanolFuel = new GeneratorFuel(ethanol, (int) (32 * GameMode.getGameMode().getFloatSetting("fuel.ethanol.generator")), 4); FuelManager.generatorFuel.put(ethanol.getFluid(), ethanolFuel); diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 3de650512..3be35f5ff 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -61,7 +61,8 @@ public class PluginManager { public enum Module { - CORE(new PluginCore()), + CORE(new PluginCore(), false), + FLUIDS(new PluginFluids(), false), APICULTURE(new PluginApiculture()), ARBORICULTURE(new PluginArboriculture()), ENERGY(new PluginEnergy()), @@ -82,9 +83,15 @@ public class PluginManager { NATURA(new PluginNatura()),; private final ForestryPlugin instance; + private final boolean canBeDisabled; private Module(ForestryPlugin plugin) { + this(plugin, true); + } + + private Module(ForestryPlugin plugin, boolean canBeDisabled) { this.instance = plugin; + this.canBeDisabled = canBeDisabled; } public ForestryPlugin instance() { @@ -95,6 +102,10 @@ public class PluginManager { return isModuleLoaded(this); } + public boolean canBeDisabled() { + return canBeDisabled; + } + } public static Stage getStage() { @@ -128,7 +139,7 @@ public class PluginManager { Iterator it = toLoad.iterator(); while (it.hasNext()) { Module m = it.next(); - if (m == Module.CORE) + if (!m.canBeDisabled()) continue; if (!isEnabled(config, m)) { it.remove(); From 20b2dcf9c3711b1c66998b8b60cc11320bd20848 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 01:09:33 -0800 Subject: [PATCH 088/175] Clean up Fluids comments. method name setDrink -> setProperties --- src/main/java/forestry/core/fluids/Fluids.java | 15 ++++++++------- src/main/java/forestry/plugins/PluginFluids.java | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index b9bd526eb..0c6d9c2c3 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -130,7 +130,7 @@ public enum Fluids { } @Override - public void setDrink(ItemLiquidContainer liquidContainer) { + public void setProperties(ItemLiquidContainer liquidContainer) { if (liquidContainer.getType() != EnumContainerType.BUCKET) liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); } @@ -191,7 +191,7 @@ public enum Fluids { } @Override - public void setDrink(ItemLiquidContainer liquidContainer) { + public void setProperties(ItemLiquidContainer liquidContainer) { if (liquidContainer.getType() != EnumContainerType.BUCKET) liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); } @@ -386,30 +386,31 @@ public enum Fluids { /** FluidBlock and Container registration */ /** - * Add the filled containers for the fluid, to have them get created and registered. + * Add the filled containers for this fluid. + * They will be automatically created and registered. */ public ForestryItem getContainerForType(EnumContainerType type) { return null; } /** - * Add non-forestry containers for the fluid. + * Add non-forestry containers for this fluid. */ public List getOtherContainers() { return Collections.emptyList(); } /** - * Override for Forestry fluids to create FluidBlocks. + * Create a FluidBlock for this fluid. */ public Block makeBlock() { return null; } /** - * Set the drink properties for a ItemLiquidContainer before it gets registered. + * Set the properties for an ItemLiquidContainer before it gets registered. */ - public void setDrink(ItemLiquidContainer liquidContainer) { + public void setProperties(ItemLiquidContainer liquidContainer) { } } diff --git a/src/main/java/forestry/plugins/PluginFluids.java b/src/main/java/forestry/plugins/PluginFluids.java index 0011d14a1..a27950d84 100644 --- a/src/main/java/forestry/plugins/PluginFluids.java +++ b/src/main/java/forestry/plugins/PluginFluids.java @@ -111,7 +111,7 @@ public class PluginFluids extends ForestryPlugin { continue; ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor()); - fluidType.setDrink(liquidContainer); + fluidType.setProperties(liquidContainer); container.registerItem(liquidContainer, container.toString()); } } From 62261a5b8f7ff7233a9e3696c1dd7c31ff541d2f Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:10:06 -0800 Subject: [PATCH 089/175] TankManager.tankCanDrainFluid() should take the fluid type into account (oops) --- .../forestry/core/fluids/FluidHelper.java | 33 +- .../java/forestry/core/fluids/Fluids.java | 511 +++++++++--------- .../forestry/core/fluids/TankManager.java | 72 +-- 3 files changed, 309 insertions(+), 307 deletions(-) diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 952966deb..663a3e7bd 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -166,16 +166,14 @@ public final class FluidHelper { ItemStack emptyItem = getEmptyContainer(input); - if (output != null && emptyItem != null) { + if (output != null && emptyItem != null) if (outputSlot == inputSlot) { if (input.stackSize > 1) return false; - } else if (!StackUtils.isIdenticalItem(output, emptyItem)) { + } else if (!StackUtils.isIdenticalItem(output, emptyItem)) return false; - } else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) { + else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) return false; - } - } fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); @@ -185,11 +183,10 @@ public final class FluidHelper { return true; } - if (output == null) { + if (output == null) inv.setInventorySlotContents(outputSlot, emptyItem); - } else { + else output.stackSize++; - } } inv.decrStackSize(inputSlot, 1); return true; @@ -207,7 +204,7 @@ public final class FluidHelper { Item item = stack.getItem(); if (item instanceof IFluidContainerItem) { - IFluidContainerItem containerItem = (IFluidContainerItem)item; + IFluidContainerItem containerItem = (IFluidContainerItem) item; FluidStack fluidStack = containerItem.getFluid(stack); return fluidStack != null && fluidStack.amount > 0; } @@ -218,7 +215,7 @@ public final class FluidHelper { public static boolean isFillableContainer(ItemStack empty, FluidStack liquid) { Item item = empty.getItem(); if (item instanceof IFluidContainerItem) { - IFluidContainerItem containerItem = (IFluidContainerItem)item; + IFluidContainerItem containerItem = (IFluidContainerItem) item; return containerItem.fill(empty, liquid, false) > 0; } @@ -237,7 +234,7 @@ public final class FluidHelper { Item item = empty.getItem(); if (item instanceof IFluidContainerItem) { - IFluidContainerItem containerItem = (IFluidContainerItem)item; + IFluidContainerItem containerItem = (IFluidContainerItem) item; FluidStack fluid = containerItem.getFluid(empty); return fluid == null || fluid.amount == 0; } @@ -252,7 +249,7 @@ public final class FluidHelper { return item.getContainerItem(container); } - + public static ItemStack getFullyDrainedContainer(ItemStack container) { return container.getItem().getContainerItem(container); } @@ -312,12 +309,6 @@ public final class FluidHelper { return containsFluidStack(stack, new FluidStack(fluid, 1)); } - public static boolean isFluidEqual(FluidStack L1, FluidStack L2) { - if (L1 == null || L2 == null) - return false; - return L1.isFluidEqual(L2); - } - public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) { return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain); } @@ -364,10 +355,4 @@ public final class FluidHelper { return FluidRegistry.LAVA; return null; } - - public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { - if (fluidStack != null && fluid == fluidStack.getFluid()) - return true; - return fluid == null && fluidStack == null; - } } diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index 0c6d9c2c3..d4c178690 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -33,285 +33,285 @@ import static forestry.core.items.ItemLiquidContainer.EnumContainerType; public enum Fluids { ETHANOL(new Color(255, 111, 0), 790, 1000) { - @Override - public String getTag() { - return "bioethanol"; - } + @Override + public String getTag() { + return "bioethanol"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 300, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 300, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketEthanol; - case CAN: - return ForestryItem.canEthanol; - case CAPSULE: - return ForestryItem.waxCapsuleEthanol; - case REFRACTORY: - return ForestryItem.refractoryEthanol; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketEthanol; + case CAN: + return ForestryItem.canEthanol; + case CAPSULE: + return ForestryItem.waxCapsuleEthanol; + case REFRACTORY: + return ForestryItem.refractoryEthanol; + default: + return null; + } + } + }, BIOMASS(new Color(100, 132, 41), 400, 6560) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 100, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 100, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketBiomass; - case CAN: - return ForestryItem.canBiomass; - case CAPSULE: - return ForestryItem.waxCapsuleBiomass; - case REFRACTORY: - return ForestryItem.refractoryBiomass; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketBiomass; + case CAN: + return ForestryItem.canBiomass; + case CAPSULE: + return ForestryItem.waxCapsuleBiomass; + case REFRACTORY: + return ForestryItem.refractoryBiomass; + default: + return null; + } + } + }, GLASS(new Color(164, 164, 164), 2400, 10000) { - @Override - public int getTemperature() { - return 1200; - } + @Override + public int getTemperature() { + return 1200; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 0, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 0, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketGlass; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketGlass; + default: + return null; + } + } + }, HONEY(new Color(255, 196, 35), 1420, 73600) { - @Override - public String getTag() { - return "for.honey"; - } + @Override + public String getTag() { + return "for.honey"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketHoney; - case CAN: - return ForestryItem.canHoney; - case CAPSULE: - return ForestryItem.waxCapsuleHoney; - case REFRACTORY: - return ForestryItem.refractoryHoney; - default: - return null; - } - } + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketHoney; + case CAN: + return ForestryItem.canHoney; + case CAPSULE: + return ForestryItem.waxCapsuleHoney; + case REFRACTORY: + return ForestryItem.refractoryHoney; + default: + return null; + } + } - @Override - public void setProperties(ItemLiquidContainer liquidContainer) { - if (liquidContainer.getType() != EnumContainerType.BUCKET) - liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); - } - }, + @Override + public void setProperties(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) + liquidContainer.setDrink(Defaults.FOOD_HONEY_HEAL, Defaults.FOOD_HONEY_SATURATION); + } + }, LEGACY_HONEY { - @Override - public String getTag() { - return "honey"; - } - }, + @Override + public String getTag() { + return "honey"; + } + }, ICE(new Color(175, 242, 255), 920, 1000) { - @Override - public int getTemperature() { - return 265; - } + @Override + public int getTemperature() { + return 265; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketIce; - case CAN: - return ForestryItem.canIce; - case CAPSULE: - return ForestryItem.waxCapsuleIce; - case REFRACTORY: - return ForestryItem.refractoryIce; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketIce; + case CAN: + return ForestryItem.canIce; + case CAPSULE: + return ForestryItem.waxCapsuleIce; + case REFRACTORY: + return ForestryItem.refractoryIce; + default: + return null; + } + } + }, JUICE(new Color(168, 201, 114)) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketJuice; - case CAN: - return ForestryItem.canJuice; - case CAPSULE: - return ForestryItem.waxCapsuleJuice; - case REFRACTORY: - return ForestryItem.refractoryJuice; - default: - return null; - } - } + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketJuice; + case CAN: + return ForestryItem.canJuice; + case CAPSULE: + return ForestryItem.waxCapsuleJuice; + case REFRACTORY: + return ForestryItem.refractoryJuice; + default: + return null; + } + } - @Override - public void setProperties(ItemLiquidContainer liquidContainer) { - if (liquidContainer.getType() != EnumContainerType.BUCKET) - liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); - } - }, + @Override + public void setProperties(ItemLiquidContainer liquidContainer) { + if (liquidContainer.getType() != EnumContainerType.BUCKET) + liquidContainer.setDrink(Defaults.FOOD_JUICE_HEAL, Defaults.FOOD_JUICE_SATURATION); + } + }, MILK(new Color(255, 255, 255), 1030, 3000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public List getOtherContainers() { - return Arrays.asList( - new ItemStack(Items.milk_bucket) - ); - } - }, + @Override + public List getOtherContainers() { + return Arrays.asList( + new ItemStack(Items.milk_bucket) + ); + } + }, SEEDOIL(new Color(255, 255, 168), 885, 5000) { - @Override - public Block makeBlock() { - return new BlockForestryFluid(this, 2, true); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this, 2, true); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketSeedoil; - case CAN: - return ForestryItem.canSeedOil; - case CAPSULE: - return ForestryItem.waxCapsuleSeedOil; - case REFRACTORY: - return ForestryItem.refractorySeedOil; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketSeedoil; + case CAN: + return ForestryItem.canSeedOil; + case CAPSULE: + return ForestryItem.waxCapsuleSeedOil; + case REFRACTORY: + return ForestryItem.refractorySeedOil; + default: + return null; + } + } + }, SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) { - @Override - public String getTag() { - return "short.mead"; - } + @Override + public String getTag() { + return "short.mead"; + } - @Override - public Block makeBlock() { - return new BlockForestryFluid(this); - } + @Override + public Block makeBlock() { + return new BlockForestryFluid(this); + } - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case BUCKET: - return ForestryItem.bucketShortMead; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case BUCKET: + return ForestryItem.bucketShortMead; + default: + return null; + } + } + }, // Vanilla WATER(new Color(0x2432ec)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canWater; - case CAPSULE: - return ForestryItem.waxCapsuleWater; - case REFRACTORY: - return ForestryItem.refractoryWater; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canWater; + case CAPSULE: + return ForestryItem.waxCapsuleWater; + case REFRACTORY: + return ForestryItem.refractoryWater; + default: + return null; + } + } + }, LAVA(new Color(0xfd461f)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canLava; - case REFRACTORY: - return ForestryItem.refractoryLava; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canLava; + case REFRACTORY: + return ForestryItem.refractoryLava; + default: + return null; + } + } + }, // BuildCraft FUEL(new Color(0xffff00)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canFuel; - case CAPSULE: - return ForestryItem.waxCapsuleFuel; - case REFRACTORY: - return ForestryItem.refractoryFuel; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canFuel; + case CAPSULE: + return ForestryItem.waxCapsuleFuel; + case REFRACTORY: + return ForestryItem.refractoryFuel; + default: + return null; + } + } + }, OIL(new Color(0x404040)) { - @Override - public ForestryItem getContainerForType(EnumContainerType type) { - switch (type) { - case CAN: - return ForestryItem.canOil; - case CAPSULE: - return ForestryItem.waxCapsuleOil; - case REFRACTORY: - return ForestryItem.refractoryOil; - default: - return null; - } - } - }, + @Override + public ForestryItem getContainerForType(EnumContainerType type) { + switch (type) { + case CAN: + return ForestryItem.canOil; + case CAPSULE: + return ForestryItem.waxCapsuleOil; + case REFRACTORY: + return ForestryItem.refractoryOil; + default: + return null; + } + } + }, // Railcraft CREOSOTE, STEAM, // Thermal Expansion @@ -383,8 +383,21 @@ public enum Fluids { return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid()); } - /** FluidBlock and Container registration */ + public static boolean areEqual(Fluid fluid, FluidStack fluidStack) { + if (fluidStack != null && fluid == fluidStack.getFluid()) + return true; + return fluid == null && fluidStack == null; + } + public static boolean areEqual(FluidStack a, FluidStack b) { + if (a == b) + return true; + if (a == null || b == null) + return false; + return a.isFluidEqual(b); + } + + /** FluidBlock and Container registration */ /** * Add the filled containers for this fluid. * They will be automatically created and registered. diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index 85b348684..9510e8508 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -68,12 +68,8 @@ public class TankManager extends ForwardingList implements IFluidH } @Override - public boolean addAll(Collection collection) { - boolean changed = false; - for (StandardTank tank : collection) - changed |= add(tank); - - return changed; + public final boolean addAll(Collection collection) { + return standardAddAll(collection); } @Override @@ -114,8 +110,9 @@ public class TankManager extends ForwardingList implements IFluidH } public void writePacketData(DataOutputStream data) throws IOException { - for (int i = 0; i < tanks.size(); i++) + for (int i = 0; i < tanks.size(); i++) { writePacketData(data, i); + } } public void writePacketData(DataOutputStream data, int tankIndex) throws IOException { @@ -132,8 +129,9 @@ public class TankManager extends ForwardingList implements IFluidH } public void readPacketData(DataInputStream data) throws IOException { - for (int i = 0; i < tanks.size(); i++) + for (int i = 0; i < tanks.size(); i++) { readPacketData(data, i); + } } public void readPacketData(DataInputStream data, int tankIndex) throws IOException { @@ -149,8 +147,9 @@ public class TankManager extends ForwardingList implements IFluidH } public void initGuiData(Container container, ICrafting player) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { initGuiData(container, player, tank.getTankIndex()); + } } public void initGuiData(Container container, ICrafting player, int tankIndex) { @@ -166,12 +165,13 @@ public class TankManager extends ForwardingList implements IFluidH player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA, fluidId); PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount); - Proxies.net.sendToPlayer(packet, (EntityPlayerMP)player); + Proxies.net.sendToPlayer(packet, (EntityPlayerMP) player); } public void updateGuiData(Container container, List crafters) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { updateGuiData(container, crafters, tank.getTankIndex()); + } } public void updateGuiData(Container container, List crafters, int tankIndex) { @@ -226,16 +226,16 @@ public class TankManager extends ForwardingList implements IFluidH int color = tank.colorCache; boolean newLiquid = false; switch (messageId % NETWORK_DATA) { - case 0: - fluidId = data; - newLiquid = true; - break; - case 1: - amount = data; - break; - case 2: - color = data; - break; + case 0: + fluidId = data; + newLiquid = true; + break; + case 1: + amount = data; + break; + case 2: + color = data; + break; } if (newLiquid) { fluidStack = new FluidStack(fluidId, 0); @@ -247,9 +247,10 @@ public class TankManager extends ForwardingList implements IFluidH @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { if (tankAcceptsFluid(tank, resource)) return fill(tank.getTankIndex(), resource, doFill); + } return FakeTank.INSTANCE.fill(resource, doFill); } @@ -267,9 +268,10 @@ public class TankManager extends ForwardingList implements IFluidH @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { if (tankCanDrain(tank)) return drain(tank.getTankIndex(), maxDrain, doDrain); + } return FakeTank.INSTANCE.drain(maxDrain, doDrain); } @@ -285,9 +287,10 @@ public class TankManager extends ForwardingList implements IFluidH } public FluidStack drain(FluidStack resource, boolean doDrain) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { if (tankCanDrainFluid(tank, resource)) return tank.drain(resource.amount, doDrain); + } return null; } @@ -309,8 +312,9 @@ public class TankManager extends ForwardingList implements IFluidH @Override public FluidTankInfo[] getTankInfo(ForgeDirection direction) { FluidTankInfo[] info = new FluidTankInfo[size()]; - for (int i = 0; i < size(); i++) + for (int i = 0; i < size(); i++) { info[i] = get(i).getInfo(); + } return info; } @@ -347,9 +351,10 @@ public class TankManager extends ForwardingList implements IFluidH } public boolean accepts(Fluid fluid) { - for (StandardTank tank : tanks) + for (StandardTank tank : tanks) { if (tank.accepts(fluid)) return true; + } return false; } @@ -359,22 +364,21 @@ public class TankManager extends ForwardingList implements IFluidH return false; if (!tank.canBeFilledExternally()) return false; - if (tank.fill(fluidStack, false) > 0) - return true; - return false; + return tank.fill(fluidStack, false) > 0; } private boolean tankCanDrain(StandardTank tank) { if (!tank.canBeDrainedExternally()) return false; FluidStack drained = tank.drain(1, false); - if (drained != null && drained.amount > 0) - return true; - return false; + return drained != null && drained.amount > 0; } private boolean tankCanDrainFluid(StandardTank tank, FluidStack fluidStack) { - return fluidStack != null && tankCanDrain(tank); + if (fluidStack == null) + return false; + if (!Fluids.areEqual(tank.getFluidType(), fluidStack)) + return false; + return tankCanDrain(tank); } - } From ca64f8811341395486364c87f47239aa258a9a06 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:21:11 -0800 Subject: [PATCH 090/175] Remove Forestry API in prep for adding RF API as a submodule (changing the directory tree) --- .gitmodules | 3 --- api | 1 - 2 files changed, 4 deletions(-) delete mode 160000 api diff --git a/.gitmodules b/.gitmodules index 8739ca90f..5b6c99def 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "lang"] path = lang url = https://github.com/ForestryMC/Forestry-Localization.git -[submodule "api"] - path = api - url = https://github.com/ForestryMC/ForestryAPI.git diff --git a/api b/api deleted file mode 160000 index 32e4fa061..000000000 --- a/api +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 32e4fa061c31ac225274070937e1c37e91fac046 From a449e1b3b2b7fb94066fc5c9028e64e6f2e02a37 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:26:14 -0800 Subject: [PATCH 091/175] Remove API from the ignored folders --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 172724f05..05b1bfc97 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !/forestry_techne !/gradle/wrapper !/src +!/api # files !/.gitignore From 70d8d76934b6d8ccc41323f34a98d986eea9dc8d Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:28:20 -0800 Subject: [PATCH 092/175] Readd APIs as submodules --- .gitmodules | 6 ++++++ api/forestry | 1 + api/redstoneflux | 1 + 3 files changed, 8 insertions(+) create mode 160000 api/forestry create mode 160000 api/redstoneflux diff --git a/.gitmodules b/.gitmodules index 5b6c99def..3f574740e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "lang"] path = lang url = https://github.com/ForestryMC/Forestry-Localization.git +[submodule "api/redstoneflux"] + path = api/redstoneflux + url = git@github.com:CoFH/RedstoneFlux-API.git +[submodule "api/forestry"] + path = api/forestry + url = git@github.com:ForestryMC/ForestryAPI.git diff --git a/api/forestry b/api/forestry new file mode 160000 index 000000000..10e10af21 --- /dev/null +++ b/api/forestry @@ -0,0 +1 @@ +Subproject commit 10e10af21489e351624813120ed6474c44b09ff6 diff --git a/api/redstoneflux b/api/redstoneflux new file mode 160000 index 000000000..10e10af21 --- /dev/null +++ b/api/redstoneflux @@ -0,0 +1 @@ +Subproject commit 10e10af21489e351624813120ed6474c44b09ff6 From 6d7f30ea6b91e524d7306105936b684983c72500 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:30:42 -0800 Subject: [PATCH 093/175] Remove Forestry API again because I derped it up --- .gitmodules | 3 --- api/forestry | 1 - 2 files changed, 4 deletions(-) delete mode 160000 api/forestry diff --git a/.gitmodules b/.gitmodules index 3f574740e..9bc6db640 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "api/redstoneflux"] path = api/redstoneflux url = git@github.com:CoFH/RedstoneFlux-API.git -[submodule "api/forestry"] - path = api/forestry - url = git@github.com:ForestryMC/ForestryAPI.git diff --git a/api/forestry b/api/forestry deleted file mode 160000 index 10e10af21..000000000 --- a/api/forestry +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 10e10af21489e351624813120ed6474c44b09ff6 From b23167d468bf567cd2bf0355115167372a303bf2 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:31:59 -0800 Subject: [PATCH 094/175] Readd Forestry API correctly this time. --- .gitmodules | 3 +++ api/forestry | 1 + 2 files changed, 4 insertions(+) create mode 160000 api/forestry diff --git a/.gitmodules b/.gitmodules index 9bc6db640..3f574740e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "api/redstoneflux"] path = api/redstoneflux url = git@github.com:CoFH/RedstoneFlux-API.git +[submodule "api/forestry"] + path = api/forestry + url = git@github.com:ForestryMC/ForestryAPI.git diff --git a/api/forestry b/api/forestry new file mode 160000 index 000000000..32e4fa061 --- /dev/null +++ b/api/forestry @@ -0,0 +1 @@ +Subproject commit 32e4fa061c31ac225274070937e1c37e91fac046 From 885fc1291ea83713c3755863816ae26188b66017 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 07:34:16 -0800 Subject: [PATCH 095/175] Remove RF API sources from repo --- src/main/java/cofh/api/CoFHAPIProps.java | 11 -- .../java/cofh/api/energy/EnergyStorage.java | 158 ------------------ .../cofh/api/energy/IEnergyConnection.java | 21 --- .../cofh/api/energy/IEnergyContainerItem.java | 52 ------ .../java/cofh/api/energy/IEnergyHandler.java | 51 ------ .../java/cofh/api/energy/IEnergyStorage.java | 45 ----- .../cofh/api/energy/ItemEnergyContainer.java | 110 ------------ .../cofh/api/energy/TileEnergyHandler.java | 62 ------- .../java/cofh/api/energy/package-info.java | 10 -- src/main/java/cofh/api/package-info.java | 9 - 10 files changed, 529 deletions(-) delete mode 100644 src/main/java/cofh/api/CoFHAPIProps.java delete mode 100644 src/main/java/cofh/api/energy/EnergyStorage.java delete mode 100644 src/main/java/cofh/api/energy/IEnergyConnection.java delete mode 100644 src/main/java/cofh/api/energy/IEnergyContainerItem.java delete mode 100644 src/main/java/cofh/api/energy/IEnergyHandler.java delete mode 100644 src/main/java/cofh/api/energy/IEnergyStorage.java delete mode 100644 src/main/java/cofh/api/energy/ItemEnergyContainer.java delete mode 100644 src/main/java/cofh/api/energy/TileEnergyHandler.java delete mode 100644 src/main/java/cofh/api/energy/package-info.java delete mode 100644 src/main/java/cofh/api/package-info.java diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java deleted file mode 100644 index 22096377f..000000000 --- a/src/main/java/cofh/api/CoFHAPIProps.java +++ /dev/null @@ -1,11 +0,0 @@ -package cofh.api; - -public class CoFHAPIProps { - - private CoFHAPIProps() { - - } - - public static final String VERSION = "1.7.10R1.0.1"; - -} diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java deleted file mode 100644 index 2dfd2b1b6..000000000 --- a/src/main/java/cofh/api/energy/EnergyStorage.java +++ /dev/null @@ -1,158 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class EnergyStorage implements IEnergyStorage { - - protected int energy; - protected int capacity; - protected int maxReceive; - protected int maxExtract; - - public EnergyStorage(int capacity) { - - this(capacity, capacity, capacity); - } - - public EnergyStorage(int capacity, int maxTransfer) { - - this(capacity, maxTransfer, maxTransfer); - } - - public EnergyStorage(int capacity, int maxReceive, int maxExtract) { - - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } - - public EnergyStorage readFromNBT(NBTTagCompound nbt) { - - this.energy = nbt.getInteger("Energy"); - - if (energy > capacity) { - energy = capacity; - } - return this; - } - - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - - if (energy < 0) { - energy = 0; - } - nbt.setInteger("Energy", energy); - return nbt; - } - - public void setCapacity(int capacity) { - - this.capacity = capacity; - - if (energy > capacity) { - energy = capacity; - } - } - - public void setMaxTransfer(int maxTransfer) { - - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } - - public void setMaxReceive(int maxReceive) { - - this.maxReceive = maxReceive; - } - - public void setMaxExtract(int maxExtract) { - - this.maxExtract = maxExtract; - } - - public int getMaxReceive() { - - return maxReceive; - } - - public int getMaxExtract() { - - return maxExtract; - } - - /** - * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are - * guaranteed to have it. - * - * @param energy - */ - public void setEnergyStored(int energy) { - - this.energy = energy; - - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } - - /** - * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this - * externally, as not all IEnergyHandlers are guaranteed to have it. - * - * @param energy - */ - public void modifyEnergyStored(int energy) { - - this.energy += energy; - - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } - - /* IEnergyStorage */ - @Override - public int receiveEnergy(int maxReceive, boolean simulate) { - - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - - if (!simulate) { - energy += energyReceived; - } - return energyReceived; - } - - @Override - public int extractEnergy(int maxExtract, boolean simulate) { - - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - - if (!simulate) { - energy -= energyExtracted; - } - return energyExtracted; - } - - @Override - public int getEnergyStored() { - - return energy; - } - - @Override - public int getMaxEnergyStored() { - - return capacity; - } - -} diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java deleted file mode 100644 index 63faffb9f..000000000 --- a/src/main/java/cofh/api/energy/IEnergyConnection.java +++ /dev/null @@ -1,21 +0,0 @@ -package cofh.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not - * accept it; otherwise just use IEnergyHandler. - * - * Note that {@link IEnergyHandler} is an extension of this. - * - * @author King Lemming - * - */ -public interface IEnergyConnection { - - /** - * Returns TRUE if the TileEntity can connect on a given side. - */ - boolean canConnectEnergy(ForgeDirection from); - -} diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java deleted file mode 100644 index 0bcfda600..000000000 --- a/src/main/java/cofh/api/energy/IEnergyContainerItem.java +++ /dev/null @@ -1,52 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.item.ItemStack; - -/** - * Implement this interface on Item classes that support external manipulation of their internal energy storages. - * - * A reference implementation is provided {@link ItemEnergyContainer}. - * - * @author King Lemming - * - */ -public interface IEnergyContainerItem { - - /** - * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. - * - * @param container - * ItemStack to be charged. - * @param maxReceive - * Maximum amount of energy to be sent into the item. - * @param simulate - * If TRUE, the charge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) received by the item. - */ - int receiveEnergy(ItemStack container, int maxReceive, boolean simulate); - - /** - * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally - * discharged. - * - * @param container - * ItemStack to be discharged. - * @param maxExtract - * Maximum amount of energy to be extracted from the item. - * @param simulate - * If TRUE, the discharge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted from the item. - */ - int extractEnergy(ItemStack container, int maxExtract, boolean simulate); - - /** - * Get the amount of energy currently stored in the container item. - */ - int getEnergyStored(ItemStack container); - - /** - * Get the max amount of energy that can be stored in the container item. - */ - int getMaxEnergyStored(ItemStack container); - -} diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java deleted file mode 100644 index 3df312346..000000000 --- a/src/main/java/cofh/api/energy/IEnergyHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -package cofh.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. - * - * A reference implementation is provided {@link TileEnergyHandler}. - * - * @author King Lemming - * - */ -public interface IEnergyHandler extends IEnergyConnection { - - /** - * Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. - * - * @param from - * Orientation the energy is received from. - * @param maxReceive - * Maximum amount of energy to receive. - * @param simulate - * If TRUE, the charge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) received. - */ - int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); - - /** - * Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. - * - * @param from - * Orientation the energy is extracted from. - * @param maxExtract - * Maximum amount of energy to extract. - * @param simulate - * If TRUE, the extraction will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted. - */ - int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - - /** - * Returns the amount of energy currently stored. - */ - int getEnergyStored(ForgeDirection from); - - /** - * Returns the maximum amount of energy that can be stored. - */ - int getMaxEnergyStored(ForgeDirection from); - -} diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java deleted file mode 100644 index 1e84bc221..000000000 --- a/src/main/java/cofh/api/energy/IEnergyStorage.java +++ /dev/null @@ -1,45 +0,0 @@ -package cofh.api.energy; - -/** - * An energy storage is the unit of interaction with Energy inventories. - * - * A reference implementation can be found at {@link EnergyStorage}. - * - * @author King Lemming - * - */ -public interface IEnergyStorage { - - /** - * Adds energy to the storage. Returns quantity of energy that was accepted. - * - * @param maxReceive - * Maximum amount of energy to be inserted. - * @param simulate - * If TRUE, the insertion will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) accepted by the storage. - */ - int receiveEnergy(int maxReceive, boolean simulate); - - /** - * Removes energy from the storage. Returns quantity of energy that was removed. - * - * @param maxExtract - * Maximum amount of energy to be extracted. - * @param simulate - * If TRUE, the extraction will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted from the storage. - */ - int extractEnergy(int maxExtract, boolean simulate); - - /** - * Returns the amount of energy currently stored. - */ - int getEnergyStored(); - - /** - * Returns the maximum amount of energy that can be stored. - */ - int getMaxEnergyStored(); - -} diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java deleted file mode 100644 index 055ae45bc..000000000 --- a/src/main/java/cofh/api/energy/ItemEnergyContainer.java +++ /dev/null @@ -1,110 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -/** - * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class ItemEnergyContainer extends Item implements IEnergyContainerItem { - - protected int capacity; - protected int maxReceive; - protected int maxExtract; - - public ItemEnergyContainer() { - - } - - public ItemEnergyContainer(int capacity) { - - this(capacity, capacity, capacity); - } - - public ItemEnergyContainer(int capacity, int maxTransfer) { - - this(capacity, maxTransfer, maxTransfer); - } - - public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { - - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } - - public ItemEnergyContainer setCapacity(int capacity) { - - this.capacity = capacity; - return this; - } - - public void setMaxTransfer(int maxTransfer) { - - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } - - public void setMaxReceive(int maxReceive) { - - this.maxReceive = maxReceive; - } - - public void setMaxExtract(int maxExtract) { - - this.maxExtract = maxExtract; - } - - /* IEnergyContainerItem */ - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } - - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } - - @Override - public int getEnergyStored(ItemStack container) { - - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } - - @Override - public int getMaxEnergyStored(ItemStack container) { - - return capacity; - } - -} diff --git a/src/main/java/cofh/api/energy/TileEnergyHandler.java b/src/main/java/cofh/api/energy/TileEnergyHandler.java deleted file mode 100644 index 86436b014..000000000 --- a/src/main/java/cofh/api/energy/TileEnergyHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class TileEnergyHandler extends TileEntity implements IEnergyHandler { - - protected final EnergyStorage storage = new EnergyStorage(32000); - - @Override - public void readFromNBT(NBTTagCompound nbt) { - - super.readFromNBT(nbt); - storage.readFromNBT(nbt); - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - - super.writeToNBT(nbt); - storage.writeToNBT(nbt); - } - - /* IEnergyHandler */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - - return true; - } - - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - - return storage.receiveEnergy(maxReceive, simulate); - } - - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - - return storage.extractEnergy(maxExtract, simulate); - } - - @Override - public int getEnergyStored(ForgeDirection from) { - - return storage.getEnergyStored(); - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) { - - return storage.getMaxEnergyStored(); - } - -} diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/main/java/cofh/api/energy/package-info.java deleted file mode 100644 index 7379702b8..000000000 --- a/src/main/java/cofh/api/energy/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub - * http://www.teamcofh.com - */ -@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy") -package cofh.api.energy; - -import cofh.api.CoFHAPIProps; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java deleted file mode 100644 index 08ff5fcb6..000000000 --- a/src/main/java/cofh/api/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub - * http://www.teamcofh.com - */ -@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI") -package cofh.api; - -import cpw.mods.fml.common.API; - From 52994b2a39d69d84bd6663852162f2d676f39572 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 08:05:17 -0800 Subject: [PATCH 096/175] Fix Lang submodule default url to use the github protocol. --- .gitmodules | 2 +- lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3f574740e..483723604 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "lang"] path = lang - url = https://github.com/ForestryMC/Forestry-Localization.git + url = git@github.com:ForestryMC/Forestry-Localization.git [submodule "api/redstoneflux"] path = api/redstoneflux url = git@github.com:CoFH/RedstoneFlux-API.git diff --git a/lang b/lang index 98cf44234..cc1783de4 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 98cf44234957090e6d1400431c83cb01803af43d +Subproject commit cc1783de445988c1855a04ceca120995259d82a1 From 0fcd1517768d027d31aef65d98c1178c27039cb5 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 24 Dec 2014 08:07:51 -0800 Subject: [PATCH 097/175] Update build.gradle with the submodule changes....clean up api inclusion code (hacks on top of hacks! one hack adds APIs to the jar while another is removing it lol) --- build.gradle | 65 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/build.gradle b/build.gradle index b409aeda8..9f1cfa117 100755 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,9 @@ archivesBaseName = "forestry_" + mcversion ext.dirDest = './build/dist' ext.dirLang = "./lang" -ext.dirApi = "./api" + +ext.apiForestry = "./api/forestry" +ext.apiRedstoneFlux = "./api/redstoneflux" ext.CraftGuideRepo = "https://github.com/Uristqwerty/CraftGuide.git" ext.CraftGuideTmp = "build/tmp/CraftGuide" @@ -54,7 +56,8 @@ sourceSets { main { java { - srcDir project.dirApi + srcDir project.apiForestry + srcDir project.apiRedstoneFlux + "/src/main/java" } resources { srcDir project.dirLang @@ -70,13 +73,13 @@ repositories { } configurations { - apis - compile.extendsFrom apis + api + compile.extendsFrom api } dependencies { - compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api' - apis 'com.mod-buildcraft:buildcraft:6.2.1:dev' + api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api' + api 'com.mod-buildcraft:buildcraft:6.2.1:dev' } processResources { @@ -178,12 +181,11 @@ jar { destinationDir = file("build/tmp") archiveName = "main.jar" - from { - configurations.apis.collect { - it.isDirectory() ? it : zipTree(it).matching { - include '**/api/**' - } - } + into ('forestry/api') { + from project.apiForestry + "/LICENSE.txt" + } + into ('cofh/api') { + from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt" } } @@ -191,8 +193,6 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) { from (zipTree(jar.getArchivePath())) { exclude '**/api/**' exclude '**/codechicken/**' - exclude '**/old/lang/**' - exclude '**/buildcraft/api/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -219,8 +219,6 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) { from (zipTree(jar.getArchivePath())) { include '**' exclude '**/codechicken/**' - exclude '**/old/lang/**' - exclude '**/buildcraft/api/**' } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -233,8 +231,6 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) { from(sourceSets.main.output) { exclude '**/api/**' exclude '**/codechicken/**' - exclude '**/old/lang/**' - exclude '**/buildcraft/api/**' } destinationDir = file("build/tmp") @@ -260,23 +256,11 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) { from(sourceSets.main.allSource) { include '**' exclude '**/codechicken/**' - exclude '**/old/lang/**' - exclude '**/buildcraft/api/**' } from(sourceSets.main.output) { include '**' exclude '**/codechicken/**' - exclude '**/old/lang/**' - exclude '**/buildcraft/api/**' - } - - from { - configurations.apis.collect { - it.isDirectory() ? it : zipTree(it).matching { - include '**/api/**' - } - } } duplicatesStrategy = DuplicatesStrategy.EXCLUDE @@ -287,9 +271,7 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) { } task apiJar(type: Jar, dependsOn: 'classes') { - from (dirApi) { - include '**' - } + from project.apiForestry from (sourceSets.main.output) { include 'forestry/api/**' @@ -300,14 +282,19 @@ task apiJar(type: Jar, dependsOn: 'classes') { classifier = 'api' } -task release(dependsOn: [apiJar, devJar, mainJar]) { - doLast { - println '*************************************************************' - println 'This build will be version: ' + project.version - println '*************************************************************' - } +task releaseInit << { + println '*************************************************************' + println 'This build will be version: ' + rootProject.version + println '*************************************************************' } +task release (dependsOn: [releaseInit, apiJar, devJar, mainJar]) { +} + +mainJar.shouldRunAfter releaseInit +devJar.shouldRunAfter releaseInit +apiJar.shouldRunAfter releaseInit + afterEvaluate { compileApiJava.dependsOn initCraftGuide } From 8fe121f8b9ddf6702695993571a36dd7c1977a48 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 13:42:10 -0800 Subject: [PATCH 098/175] Use HTTPS for git subomdules --- .gitmodules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 483723604..f66d05872 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "lang"] path = lang - url = git@github.com:ForestryMC/Forestry-Localization.git + url = https://github.com/ForestryMC/Forestry-Localization.git [submodule "api/redstoneflux"] path = api/redstoneflux - url = git@github.com:CoFH/RedstoneFlux-API.git + url = https://github.com/CoFH/RedstoneFlux-API.git [submodule "api/forestry"] path = api/forestry - url = git@github.com:ForestryMC/ForestryAPI.git + url = https://github.com/ForestryMC/ForestryAPI.git From 1c6d55931d4ec58be2beaf122d26785c0e97348a Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 16:03:44 -0800 Subject: [PATCH 099/175] Fix #399 Middle clicking Forestry slabs gets the wrong slab --- .../arboriculture/gadgets/BlockSlab.java | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index f72dfa92f..fea77be91 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -10,13 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.gadgets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.core.Tabs; -import forestry.arboriculture.IWoodTyped; -import forestry.arboriculture.WoodType; import java.util.List; import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -26,8 +22,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.Tabs; +import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.WoodType; + public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped { public static enum SlabCat { @@ -69,21 +73,6 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp return Item.getItemFromBlock(this); } - /** - * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) - */ - /*public int idPicked(World world, int x, int y, int z) { - return blockID; - }*/ - - /** - * Get the block's damage value (for use with pick block). - */ - @Override - public int getDamageValue(World world, int x, int y, int z) { - return super.getDamageValue(world, x, y, z) & 7; - } - @Override protected ItemStack createStackedBlock(int meta) { return new ItemStack(Blocks.wooden_slab, 2, meta & 7); @@ -134,4 +123,11 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp public boolean getUseNeighborBrightness() { return true; } + + // Minecraft's BlockSlab overrides this for their slabs, so we change it back to normal here + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World world, int x, int y, int z) { + return Item.getItemFromBlock(this); + } } From 68f61ab9ab84adf68584f306e26c05922d37af96 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 16:11:08 -0800 Subject: [PATCH 100/175] Fix #405 Alveary should only be made with wooden slabs --- .../java/forestry/apiculture/gadgets/StructureLogicAlveary.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java index 7294c3790..b435e0308 100755 --- a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java @@ -33,7 +33,6 @@ public class StructureLogicAlveary extends StructureLogic { public static final HashSet slabBlocks = new HashSet(); static { - slabBlocks.add(Blocks.stone_slab); slabBlocks.add(Blocks.wooden_slab); slabBlocks.add(ForestryBlock.slabs1.block()); slabBlocks.add(ForestryBlock.slabs2.block()); From 77295ab74e337677dd24ac6f5fa81c8b701deb04 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 20:02:11 -0800 Subject: [PATCH 101/175] Add better logs for invalid genome errors #400 --- .../java/forestry/core/genetics/Allele.java | 5 ++ .../forestry/core/genetics/Chromosome.java | 58 +++++++++++++++++-- .../java/forestry/core/genetics/Genome.java | 38 +++++++++--- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index b652ae3ac..f87886311 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -707,4 +707,9 @@ public class Allele implements IAllele { name = string; return this; } + + @Override + public String toString() { + return uid; + } } diff --git a/src/main/java/forestry/core/genetics/Chromosome.java b/src/main/java/forestry/core/genetics/Chromosome.java index 4b4a4e0f4..1ce9719c4 100755 --- a/src/main/java/forestry/core/genetics/Chromosome.java +++ b/src/main/java/forestry/core/genetics/Chromosome.java @@ -10,10 +10,14 @@ ******************************************************************************/ package forestry.core.genetics; +import com.google.common.base.Objects; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IChromosome; import forestry.api.genetics.ILegacyHandler; +import forestry.core.proxy.Proxies; + import java.util.Random; import net.minecraft.nbt.NBTTagCompound; @@ -101,20 +105,59 @@ public class Chromosome implements IChromosome { return secondary; } - public void overrideInvalidAlleles(IAllele template, Class chromosomeClass) { - if (primary == null || !chromosomeClass.isInstance(primary)) + public boolean overrideInvalidAlleles(IAllele template, Class chromosomeClass) { + boolean foundInvalidAlleles = false; + + // use the other chromosome instead of the template if it's valid + if (primary != null && chromosomeClass.isInstance(primary)) { + template = primary; + } else if (secondary != null && chromosomeClass.isInstance(secondary)) { + template = secondary; + } + + if (primary == null) { + Proxies.log.warning("Missing primary allele: {0}. Setting to: {1}", this, template); primary = template; + foundInvalidAlleles = true; + } else if (!chromosomeClass.isInstance(primary)) { + Proxies.log.warning("Wrong primary allele: {0}. Setting to: {1}", this, template); + primary = template; + foundInvalidAlleles = true; + } - if (secondary == null || !chromosomeClass.isInstance(secondary)) + if (secondary == null) { + Proxies.log.warning("Missing secondary allele: {0}. Setting to: {1}", this, template); secondary = template; + foundInvalidAlleles = true; + } else if (!chromosomeClass.isInstance(secondary)) { + Proxies.log.warning("Wrong secondary allele: {0}. Setting to: {1}", this, template); + secondary = template; + foundInvalidAlleles = true; + } + + return foundInvalidAlleles; } public boolean hasInvalidAlleles(Class chromosomeClass) { - if (primary == null || !chromosomeClass.isInstance(primary)) + if (primary == null) { + Proxies.log.severe("Missing primary allele: {0}", this); return true; + } + + if (!chromosomeClass.isInstance(primary)) { + Proxies.log.severe("Wrong primary allele for: {0}. Should be: {1}", this, chromosomeClass.getSimpleName()); + return true; + } - if (secondary == null || !chromosomeClass.isInstance(secondary)) + if (secondary == null) { + Proxies.log.severe("Missing secondary allele: {0}", this); return true; + } + + if (!chromosomeClass.isInstance(secondary)) { + Proxies.log.severe("Wrong secondary allele for: {0}. Should be: {1}", this, chromosomeClass.getSimpleName()); + return true; + } return false; } @@ -146,4 +189,9 @@ public class Chromosome implements IChromosome { return new Chromosome(choice2, choice1); } + @Override + public String toString() { + return Objects.toStringHelper(this).add("Primary", primary).add("Secondary", secondary).toString(); + } + } diff --git a/src/main/java/forestry/core/genetics/Genome.java b/src/main/java/forestry/core/genetics/Genome.java index 6cf5952fc..51b49cdda 100755 --- a/src/main/java/forestry/core/genetics/Genome.java +++ b/src/main/java/forestry/core/genetics/Genome.java @@ -10,6 +10,12 @@ ******************************************************************************/ package forestry.core.genetics; +import com.google.common.base.Objects; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleSpecies; @@ -17,9 +23,7 @@ import forestry.api.genetics.IChromosome; import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IGenome; import forestry.core.config.Config; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; +import forestry.core.proxy.Proxies; public abstract class Genome implements IGenome { @@ -81,6 +85,9 @@ public abstract class Genome implements IGenome { NBTTagList nbttaglist = nbttagcompound.getTagList("Chromosomes", 10); chromosomes = new Chromosome[chromosomes.length]; + + Boolean invalidGenome = false; + for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); byte byte0 = nbttagcompound1.getByte(SLOT_TAG); @@ -88,15 +95,22 @@ public abstract class Genome implements IGenome { if (byte0 >= 0 && byte0 < chromosomes.length) { Chromosome chromosome = Chromosome.loadChromosomeFromNBT(nbttagcompound1); chromosomes[byte0] = chromosome; - - if (Config.clearInvalidChromosomes) - chromosome.overrideInvalidAlleles(getDefaultTemplate()[byte0], getSpeciesRoot().getKaryotype()[byte0].getAlleleClass()); + + if (Config.clearInvalidChromosomes) { + if (chromosome.overrideInvalidAlleles(getDefaultTemplate()[byte0], getSpeciesRoot().getKaryotype()[byte0].getAlleleClass())) { + invalidGenome = true; + } + } if (chromosome.hasInvalidAlleles(getSpeciesRoot().getKaryotype()[byte0].getAlleleClass())) - throw new RuntimeException("Found Chromosome with invalid Alleles. See config option \"genetics.clear.invalid.chromosomes\"."); + throw new RuntimeException("Found Chromosome with invalid Alleles.\nNBTTagCompound: " + nbttaglist + "\nSee config option \"genetics.clear.invalid.chromosomes\"."); } } + if (invalidGenome) { + Proxies.log.warning("Overrode alleles for genome:\n{0}\nOriginal NBTTagCompound: {1}", this, nbttaglist); + } + // handle old saves that have missing chromosomes IChromosome speciesChromosome = chromosomes[EnumTreeChromosome.SPECIES.ordinal()]; if (speciesChromosome != null) { @@ -172,4 +186,14 @@ public abstract class Genome implements IGenome { return true; } + + @Override + public String toString() { + Objects.ToStringHelper toStringHelper = Objects.toStringHelper(this); + int i = 0; + for (IChromosome chromosome : chromosomes) { + toStringHelper.add(String.valueOf(i++), chromosome); + } + return toStringHelper.toString(); + } } From 1430becdff87763c23988201b0356d7ea5405e76 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 20:21:15 -0800 Subject: [PATCH 102/175] Fix #406 locked worktable recipes sometimes become unlocked --- src/main/java/forestry/factory/recipes/RecipeMemory.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/forestry/factory/recipes/RecipeMemory.java b/src/main/java/forestry/factory/recipes/RecipeMemory.java index 3a5cdf560..444c56019 100644 --- a/src/main/java/forestry/factory/recipes/RecipeMemory.java +++ b/src/main/java/forestry/factory/recipes/RecipeMemory.java @@ -161,6 +161,8 @@ public class RecipeMemory implements INBTTagable { Recipe memory = getMemorized(crafting, world); if (memory != null) { + if (memory.isLocked() != recipe.isLocked()) + recipe.toggleLock(); int index = recipes.indexOf(memory); recipes.set(index, recipe); return; From 107047a04cf5bc5938e8e5bd4c276a19ceafc581 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 24 Dec 2014 20:48:52 -0800 Subject: [PATCH 103/175] Fix #394. Add shift-for-more-info on long tooltips --- .../forestry/core/circuits/CircuitBoard.java | 27 +++++++++++++------ .../core/fluids/tanks/FilteredTank.java | 25 +++++++++-------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/java/forestry/core/circuits/CircuitBoard.java b/src/main/java/forestry/core/circuits/CircuitBoard.java index 009ddb54a..e2ab7f05a 100755 --- a/src/main/java/forestry/core/circuits/CircuitBoard.java +++ b/src/main/java/forestry/core/circuits/CircuitBoard.java @@ -10,21 +10,25 @@ ******************************************************************************/ package forestry.core.circuits; -import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.ICircuit; -import forestry.api.circuits.ICircuitBoard; -import forestry.api.circuits.ICircuitLayout; import java.util.ArrayList; import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import forestry.api.circuits.ChipsetManager; +import forestry.api.circuits.ICircuit; +import forestry.api.circuits.ICircuitBoard; +import forestry.api.circuits.ICircuitLayout; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; + public class CircuitBoard implements ICircuitBoard { - EnumCircuitBoardType type; - ICircuitLayout layout; - ICircuit[] circuits; + private EnumCircuitBoardType type; + private ICircuitLayout layout; + private ICircuit[] circuits; public CircuitBoard(EnumCircuitBoardType type, ICircuitLayout layout, ICircuit[] circuits) { this.type = type; @@ -51,9 +55,16 @@ public class CircuitBoard implements ICircuitBoard { if (layout != null) list.add("\u00A76" + layout.getUsage() + ":"); + List extendedTooltip = new ArrayList(); for (ICircuit circuit : circuits) if (circuit != null) - circuit.addTooltip(list); + circuit.addTooltip(extendedTooltip); + + if(Proxies.common.isShiftDown() || extendedTooltip.size() <= 4) { + list.addAll(extendedTooltip); + } else { + list.add("\u00A7o<" + StringUtil.localize("gui.tooltip.tmi") + ">"); + } } @Override diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index 4fbb44b62..657e3d27b 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -22,6 +22,8 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import forestry.core.gui.tooltips.ToolTipLine; +import forestry.core.proxy.Proxies; +import forestry.core.utils.StringUtil; /** * @@ -75,19 +77,20 @@ public class FilteredTank extends StandardTank { } 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, 2); - toolTip.add(name); - if (getFluid() != null) - amount = getFluid().amount; + if(Proxies.common.isShiftDown() || filters.size() < 5) { + 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, 2); + toolTip.add(name); + } + } else { + toolTip.add("\u00A7o<" + StringUtil.localize("gui.tooltip.tmi") + ">"); } - toolTip.add(new ToolTipLine(String.format("%,d", amount) + " / " + String.format("%,d", getCapacity()))); + toolTip.add(String.format("%,d", getFluidAmount()) + " / " + String.format("%,d", getCapacity())); } } From e4b8342e1ca20937eebea97665e784444a1af3da Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 25 Dec 2014 01:00:13 -0800 Subject: [PATCH 104/175] Close #392 Generate Crate Icons Automatically --- .../java/forestry/core/items/ItemCrated.java | 33 +- .../core/render/CrateRenderingHandler.java | 322 ++++++++++++++++++ src/main/java/forestry/plugins/PluginIC2.java | 18 +- .../java/forestry/plugins/PluginStorage.java | 68 ++-- .../storage/proxy/ClientProxyStorage.java | 24 ++ .../forestry/storage/proxy/ProxyStorage.java | 20 ++ .../forestry/textures/items/crate-filled.png | Bin 0 -> 212 bytes .../textures/items/crates/apatite.png | Bin 256 -> 0 bytes .../forestry/textures/items/crates/apples.png | Bin 248 -> 0 bytes .../forestry/textures/items/crates/ash.png | Bin 245 -> 0 bytes .../textures/items/crates/beeswax.png | Bin 244 -> 0 bytes .../textures/items/crates/bogearth.png | Bin 246 -> 0 bytes .../forestry/textures/items/crates/brass.png | Bin 250 -> 0 bytes .../forestry/textures/items/crates/brick.png | Bin 302 -> 0 bytes .../forestry/textures/items/crates/bronze.png | Bin 254 -> 0 bytes .../forestry/textures/items/crates/cacti.png | Bin 264 -> 0 bytes .../textures/items/crates/charcoal.png | Bin 274 -> 0 bytes .../forestry/textures/items/crates/clay.png | Bin 244 -> 0 bytes .../forestry/textures/items/crates/coal.png | Bin 274 -> 0 bytes .../textures/items/crates/cobblestone.png | Bin 385 -> 0 bytes .../textures/items/crates/cocoacomb.png | Bin 239 -> 0 bytes .../textures/items/crates/cookies.png | Bin 249 -> 0 bytes .../forestry/textures/items/crates/copper.png | Bin 254 -> 0 bytes .../forestry/textures/items/crates/dirt.png | Bin 260 -> 0 bytes .../textures/items/crates/drippingcombs.png | Bin 236 -> 0 bytes .../textures/items/crates/fertilizer.png | Bin 244 -> 0 bytes .../textures/items/crates/frozencombs.png | Bin 239 -> 0 bytes .../textures/items/crates/glowstone.png | Bin 246 -> 0 bytes .../forestry/textures/items/crates/gravel.png | Bin 241 -> 0 bytes .../textures/items/crates/honeycombs.png | Bin 242 -> 0 bytes .../textures/items/crates/honeydew.png | Bin 241 -> 0 bytes .../textures/items/crates/honeydrop.png | Bin 241 -> 0 bytes .../forestry/textures/items/crates/humus.png | Bin 246 -> 0 bytes .../forestry/textures/items/crates/iron.png | Bin 249 -> 0 bytes .../forestry/textures/items/crates/lapis.png | Bin 248 -> 0 bytes .../forestry/textures/items/crates/mulch.png | Bin 250 -> 0 bytes .../textures/items/crates/mycelium.png | Bin 332 -> 0 bytes .../textures/items/crates/netherbrick.png | Bin 267 -> 0 bytes .../textures/items/crates/netherrack.png | Bin 397 -> 0 bytes .../textures/items/crates/netherwart.png | Bin 239 -> 0 bytes .../textures/items/crates/nikolite.png | Bin 246 -> 0 bytes .../textures/items/crates/obsidian.png | Bin 352 -> 0 bytes .../forestry/textures/items/crates/peat.png | Bin 248 -> 0 bytes .../textures/items/crates/phosphor.png | Bin 245 -> 0 bytes .../forestry/textures/items/crates/pollen.png | Bin 239 -> 0 bytes .../textures/items/crates/propolis.png | Bin 268 -> 0 bytes .../textures/items/crates/redstone.png | Bin 246 -> 0 bytes .../forestry/textures/items/crates/reeds.png | Bin 248 -> 0 bytes .../textures/items/crates/refractorywax.png | Bin 244 -> 0 bytes .../forestry/textures/items/crates/resin.png | Bin 416 -> 0 bytes .../textures/items/crates/royaljelly.png | Bin 252 -> 0 bytes .../forestry/textures/items/crates/rubber.png | Bin 245 -> 0 bytes .../forestry/textures/items/crates/sand.png | Bin 402 -> 0 bytes .../textures/items/crates/sandstone.png | Bin 434 -> 0 bytes .../textures/items/crates/saplings.png | Bin 239 -> 0 bytes .../forestry/textures/items/crates/scrap.png | Bin 248 -> 0 bytes .../forestry/textures/items/crates/seeds.png | Bin 240 -> 0 bytes .../forestry/textures/items/crates/silver.png | Bin 249 -> 0 bytes .../textures/items/crates/simmeringcombs.png | Bin 239 -> 0 bytes .../textures/items/crates/soulsand.png | Bin 373 -> 0 bytes .../forestry/textures/items/crates/stone.png | Bin 414 -> 0 bytes .../textures/items/crates/stringycombs.png | Bin 239 -> 0 bytes .../textures/items/crates/tile]-16.png | Bin 239 -> 0 bytes .../forestry/textures/items/crates/tin.png | Bin 254 -> 0 bytes .../forestry/textures/items/crates/uum.png | Bin 261 -> 0 bytes .../forestry/textures/items/crates/wheat.png | Bin 263 -> 0 bytes .../forestry/textures/items/crates/wood.png | Bin 282 -> 0 bytes 67 files changed, 427 insertions(+), 58 deletions(-) create mode 100644 src/main/java/forestry/core/render/CrateRenderingHandler.java create mode 100644 src/main/java/forestry/storage/proxy/ClientProxyStorage.java create mode 100644 src/main/java/forestry/storage/proxy/ProxyStorage.java create mode 100644 src/main/resources/assets/forestry/textures/items/crate-filled.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/apatite.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/apples.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/ash.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/beeswax.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/bogearth.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/brass.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/brick.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/bronze.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/cacti.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/charcoal.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/clay.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/coal.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/cobblestone.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/cocoacomb.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/cookies.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/copper.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/dirt.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/drippingcombs.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/fertilizer.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/frozencombs.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/glowstone.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/gravel.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/honeycombs.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/honeydew.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/honeydrop.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/humus.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/iron.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/lapis.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/mulch.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/mycelium.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/netherbrick.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/netherrack.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/netherwart.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/nikolite.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/obsidian.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/peat.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/phosphor.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/pollen.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/propolis.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/redstone.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/reeds.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/refractorywax.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/resin.png delete mode 100644 src/main/resources/assets/forestry/textures/items/crates/royaljelly.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/rubber.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/sand.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/sandstone.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/saplings.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/scrap.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/seeds.png delete mode 100644 src/main/resources/assets/forestry/textures/items/crates/silver.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/simmeringcombs.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/soulsand.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/stone.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/stringycombs.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/tile]-16.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/tin.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/uum.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/wheat.png delete mode 100755 src/main/resources/assets/forestry/textures/items/crates/wood.png diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 3a0650f5b..72a6ed063 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -10,32 +10,31 @@ ******************************************************************************/ package forestry.core.items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.recipes.IGenericCrate; -import forestry.core.proxy.Proxies; -import forestry.core.render.TextureManager; -import forestry.core.utils.StringUtil; -import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.recipes.IGenericCrate; +import forestry.core.proxy.Proxies; +import forestry.core.render.TextureManager; +import forestry.core.utils.StringUtil; +import forestry.plugins.PluginStorage; + public class ItemCrated extends Item implements IGenericCrate { private ItemStack contained; - public ItemCrated() { - this(null); - } - public ItemCrated(ItemStack contained) { - super(); this.contained = contained; + PluginStorage.proxy.registerCrate(this); } @Override @@ -80,16 +79,18 @@ public class ItemCrated extends Item implements IGenericCrate { @Override public String getItemStackDisplayName(ItemStack itemstack) { - if (contained != null) + if (contained == null) { + return StatCollector.translateToLocal("item.for.crate.name"); + } else { return StringUtil.localize("item.crated.adj") + " " + Proxies.common.getDisplayName(contained); - else - return StringUtil.localize("item.crated.unknown"); + } } @SideOnly(Side.CLIENT) @Override public void registerIcons(IIconRegister register) { - itemIcon = TextureManager.getInstance().registerTex(register, "crates/" + getUnlocalizedName().replace("item.for.crated", "").toLowerCase(Locale.ENGLISH)); + String textureName = (contained == null) ? "crate" : "crate-filled"; + itemIcon = TextureManager.getInstance().registerTex(register, textureName); } } diff --git a/src/main/java/forestry/core/render/CrateRenderingHandler.java b/src/main/java/forestry/core/render/CrateRenderingHandler.java new file mode 100644 index 000000000..b1937bc5d --- /dev/null +++ b/src/main/java/forestry/core/render/CrateRenderingHandler.java @@ -0,0 +1,322 @@ +/******************************************************************************* + * 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.render; + +import java.util.Random; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +import forestry.api.recipes.IGenericCrate; + +/** + * Adapted from RenderTankCartItem by CovertJaguar + */ +public class CrateRenderingHandler implements IItemRenderer { + + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; + private static final ResourceLocation ITEM_TEXTURE = TextureMap.locationItemsTexture; + private static final ResourceLocation GLINT_TEXTURE = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + public static final float PIXEL = 1.0f / 16.0f; + + private final RenderItem renderItem = new RenderItem(); + + @Override + public boolean handleRenderType(ItemStack stack, ItemRenderType type) { + switch(type){ + case INVENTORY: + case ENTITY: + case EQUIPPED: + case EQUIPPED_FIRST_PERSON: + return true; + default: + return false; + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack stack, ItemRendererHelper helper) { + return helper == ItemRendererHelper.ENTITY_BOBBING; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { + if (type == ItemRenderType.INVENTORY) + render(ItemRenderType.INVENTORY, stack); + else if (type == ItemRenderType.ENTITY) + if (RenderManager.instance.options.fancyGraphics) + renderAsEntity(stack, (EntityItem) data[1]); + else + renderAsEntityFlat(stack); + else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glPushMatrix(); + renderEquipped(stack); + + ItemStack contained = getContainedFromCrate(stack); + + if (contained != null) { + float scale = 0.5f; + GL11.glScalef(scale, scale, 1.1f); + GL11.glTranslatef(10f * PIXEL, 8f * PIXEL, 0.001f); + if (contained.getItem() instanceof ItemBlock) { + renderIn3D(contained); + } else { + renderEquipped(contained); + } + } + GL11.glPopMatrix(); + } + } + + private void renderEquipped(ItemStack stack) { + GL11.glPushMatrix(); + Tessellator tessellator = Tessellator.instance; + + int meta = stack.getItemDamage(); + for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { + IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); + if(icon == null) + continue; + + if (renderItem.renderWithColor) { + int color = stack.getItem().getColorFromItemStack(stack, pass); + float c1 = (float) (color >> 16 & 255) / 255.0F; + float c2 = (float) (color >> 8 & 255) / 255.0F; + float c3 = (float) (color & 255) / 255.0F; + + GL11.glColor4f(c1, c2, c3, 1.0F); + } + + float uv1 = icon.getMinU(); + float uv2 = icon.getMaxU(); + float uv3 = icon.getMinV(); + float uv4 = icon.getMaxV(); + + ItemRenderer.renderItemIn2D(tessellator, uv2, uv3, uv1, uv4, icon.getIconWidth(), icon.getIconHeight(), PIXEL); + } + + GL11.glPopMatrix(); + } + + private void renderAsEntity(ItemStack stack, EntityItem entity) { + GL11.glPushMatrix(); + byte iterations = 1; + if (stack.stackSize > 1) iterations = 2; + if (stack.stackSize > 15) iterations = 3; + if (stack.stackSize > 31) iterations = 4; + + Random rand = new Random(187L); + + float offsetZ = PIXEL + 0.021875F; + + GL11.glRotatef((((float) entity.age + 1.0F) / 20.0F + entity.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.25F, -(offsetZ * (float) iterations / 2.0F)); + + for (int count = 0; count < iterations; ++count) { + if (count > 0) { + float offsetX = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float offsetY = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(offsetX, offsetY, offsetZ); + } else + GL11.glTranslatef(0f, 0f, offsetZ); + + renderIn3D(stack); + + ItemStack contained = getContainedFromCrate(stack); + + if (contained != null) { + GL11.glPushMatrix(); + float scale = 0.5f; + GL11.glScalef(scale, scale, 1.1F); + GL11.glTranslatef(10.0f * PIXEL, 8.0f * PIXEL, 0.003F); + renderIn3D(contained); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + } + + private void renderIn3D(ItemStack stack) { + GL11.glPushMatrix(); + Tessellator tessellator = Tessellator.instance; + if (RenderManager.instance.renderEngine == null) + return; + + int meta = stack.getItemDamage(); + for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { + IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); + if(icon == null) + continue; + + if (renderItem.renderWithColor) { + int color = stack.getItem().getColorFromItemStack(stack, pass); + float c1 = (float) (color >> 16 & 255) / 255.0F; + float c2 = (float) (color >> 8 & 255) / 255.0F; + float c3 = (float) (color & 255) / 255.0F; + + GL11.glColor4f(c1, c2, c3, 1.0F); + } + + float minU = icon.getMinU(); + float maxU = icon.getMaxU(); + float minV = icon.getMinV(); + float maxV = icon.getMaxV(); + + if (stack.getItemSpriteNumber() == 0) + RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE); + else + RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE); + + ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), PIXEL); + + if (stack.hasEffect(pass)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f13 = 0.76F; + GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f14 = 0.125F; + GL11.glScalef(f14, f14, f14); + float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f15, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f14, f14, f14); + f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f15, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + + private void renderAsEntityFlat(ItemStack stack) { + GL11.glPushMatrix(); + byte iterations = 1; + if (stack.stackSize > 1) iterations = 2; + if (stack.stackSize > 15) iterations = 3; + if (stack.stackSize > 31) iterations = 4; + + Random rand = new Random(187L); + + for (int ii = 0; ii < iterations; ++ii) { + GL11.glPushMatrix(); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180 - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); + + if (ii > 0) { + float var12 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var13 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var14 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(var12, var13, var14); + } + + GL11.glTranslatef(0.5f, 0.8f, 0); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glScalef(1f / 16f, 1f / 16f, 1); + + render(ItemRenderType.ENTITY, stack); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + } + + private void render(ItemRenderType type, ItemStack stack) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + IIcon crateTexture = stack.getIconIndex(); + renderItem.renderIcon(0, 0, crateTexture, 16, 16); + + ItemStack contained = getContainedFromCrate(stack); + + if (contained != null) { + + int meta = contained.getItemDamage(); + + float scale = 0.5f; + GL11.glScalef(scale, scale, 1); + GL11.glTranslatef(6f, 8f, 0); + if (type == ItemRenderType.ENTITY) + GL11.glTranslatef(0, 0, -0.1f); + + if (contained.getItem() instanceof ItemBlock) { + GL11.glScalef(16f, 16f, 1f); + GL11.glTranslatef(1f, 1f, 0.1f); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + renderIn3D(contained); + } else { + for (int pass = 0; pass < contained.getItem().getRenderPasses(meta); ++pass) { + IIcon containedTexture = contained.getItem().getIconFromDamageForRenderPass(meta, pass); + if (containedTexture == null) + continue; + + if (renderItem.renderWithColor) { + int color = contained.getItem().getColorFromItemStack(contained, pass); + float c1 = (float) (color >> 16 & 255) / 255.0F; + float c2 = (float) (color >> 8 & 255) / 255.0F; + float c3 = (float) (color & 255) / 255.0F; + + GL11.glColor4f(c1, c2, c3, 1.0F); + } + + renderItem.renderIcon(0, 0, containedTexture, 16, 16); + } + } + } + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private static ItemStack getContainedFromCrate(ItemStack crate) { + if (crate == null) + return null; + + Item crateItem = crate.getItem(); + if (crateItem instanceof IGenericCrate) { + return ((IGenericCrate) crateItem).getContained(crate); + } + return null; + } + +} \ No newline at end of file diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index bdb0a5839..52a9aa371 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -230,33 +230,27 @@ public class PluginIC2 extends ForestryPlugin { @Optional.Method(modid = "IC2") protected void registerCrates() { if (resin != null) { - ForestryItem.cratedResin.registerItem(new ItemCrated(), "cratedResin"); - ((ItemCrated) ForestryItem.cratedResin.item()).setContained(ForestryItem.cratedResin.getItemStack(), resin); + ForestryItem.cratedResin.registerItem(new ItemCrated(resin), "cratedResin"); } if (rubber != null) { - ForestryItem.cratedRubber.registerItem(new ItemCrated(), "cratedRubber"); - ((ItemCrated) ForestryItem.cratedRubber.item()).setContained(ForestryItem.cratedRubber.getItemStack(), rubber); + ForestryItem.cratedRubber.registerItem(new ItemCrated(rubber), "cratedRubber"); } if (scrap != null) { - ForestryItem.cratedScrap.registerItem(new ItemCrated(), "cratedScrap"); - ((ItemCrated) ForestryItem.cratedScrap.item()).setContained(ForestryItem.cratedScrap.getItemStack(), scrap); + ForestryItem.cratedScrap.registerItem(new ItemCrated(scrap), "cratedScrap"); } if (uuMatter != null) { - ForestryItem.cratedUUM.registerItem(new ItemCrated(), "cratedUUM"); - ((ItemCrated) ForestryItem.cratedUUM.item()).setContained(ForestryItem.cratedUUM.getItemStack(), uuMatter); + ForestryItem.cratedUUM.registerItem(new ItemCrated(uuMatter), "cratedUUM"); } if (silver != null) { - ForestryItem.cratedSilver.registerItem(new ItemCrated(), "cratedSilver"); - ((ItemCrated) ForestryItem.cratedSilver.item()).setContained(ForestryItem.cratedSilver.getItemStack(), silver); + ForestryItem.cratedSilver.registerItem(new ItemCrated(silver), "cratedSilver"); } if (brass != null) { - ForestryItem.cratedBrass.registerItem(new ItemCrated(), "cratedBrass"); - ((ItemCrated) ForestryItem.cratedBrass.item()).setContained(ForestryItem.cratedBrass.getItemStack(), brass); + ForestryItem.cratedBrass.registerItem(new ItemCrated(brass), "cratedBrass"); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 8686d08db..1bae63f45 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -10,40 +10,12 @@ ******************************************************************************/ package forestry.plugins; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; -import cpw.mods.fml.common.network.IGuiHandler; -import cpw.mods.fml.common.registry.GameData; -import forestry.api.core.Tabs; -import forestry.api.recipes.RecipeManagers; -import forestry.api.storage.BackpackManager; -import forestry.api.storage.EnumBackpackType; -import forestry.api.storage.IBackpackDefinition; -import forestry.core.config.Configuration; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.config.Property; -import forestry.core.fluids.Fluids; -import forestry.core.interfaces.IOreDictionaryHandler; -import forestry.core.interfaces.IPickupHandler; -import forestry.core.interfaces.IResupplyHandler; -import forestry.core.interfaces.ISaveEventHandler; -import forestry.core.items.ItemForestry; -import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.storage.BackpackDefinition; -import forestry.storage.BackpackHelper; -import forestry.storage.GuiHandlerStorage; -import forestry.storage.PickupHandlerStorage; -import forestry.storage.ResupplyHandler; -import forestry.storage.items.ItemNaturalistBackpack; -import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionApiarist; -import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionLepidopterist; import java.text.NumberFormat; import java.text.ParseException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; + import net.minecraft.block.Block; import net.minecraft.block.BlockBasePressurePlate; import net.minecraft.block.BlockButton; @@ -68,13 +40,49 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; + import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IShearable; import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.registry.GameData; + +import forestry.api.core.Tabs; +import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.BackpackManager; +import forestry.api.storage.EnumBackpackType; +import forestry.api.storage.IBackpackDefinition; +import forestry.core.config.Configuration; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryItem; +import forestry.core.config.Property; +import forestry.core.fluids.Fluids; +import forestry.core.interfaces.IOreDictionaryHandler; +import forestry.core.interfaces.IPickupHandler; +import forestry.core.interfaces.IResupplyHandler; +import forestry.core.interfaces.ISaveEventHandler; +import forestry.core.items.ItemCrated; +import forestry.core.network.GuiId; +import forestry.core.proxy.Proxies; +import forestry.storage.BackpackDefinition; +import forestry.storage.BackpackHelper; +import forestry.storage.GuiHandlerStorage; +import forestry.storage.PickupHandlerStorage; +import forestry.storage.ResupplyHandler; +import forestry.storage.items.ItemNaturalistBackpack; +import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionApiarist; +import forestry.storage.items.ItemNaturalistBackpack.BackpackDefinitionLepidopterist; +import forestry.storage.proxy.ProxyStorage; + @Plugin(pluginID = "Storage", name = "Storage", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.storage.description") public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandler { + @SidedProxy(clientSide = "forestry.storage.proxy.ClientProxyStorage", serverSide = "forestry.storage.proxy.ProxyStorage") + public static ProxyStorage proxy; private final ArrayList minerItems = new ArrayList(); private final ArrayList diggerItems = new ArrayList(); private final ArrayList foresterItems = new ArrayList(); @@ -237,7 +245,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl @Override protected void registerItems() { // CRATE - ForestryItem.crate.registerItem((new ItemForestry()), "crate"); + ForestryItem.crate.registerItem((new ItemCrated(null)), "crate"); // BACKPACKS BackpackDefinition definition; diff --git a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java new file mode 100644 index 000000000..64a4e43f9 --- /dev/null +++ b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * 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.storage.proxy; + +import net.minecraftforge.client.MinecraftForgeClient; + +import forestry.core.items.ItemCrated; +import forestry.core.render.CrateRenderingHandler; + +public class ClientProxyStorage extends ProxyStorage{ + + @Override + public void registerCrate(ItemCrated crate) { + MinecraftForgeClient.registerItemRenderer(crate, new CrateRenderingHandler()); + } +} diff --git a/src/main/java/forestry/storage/proxy/ProxyStorage.java b/src/main/java/forestry/storage/proxy/ProxyStorage.java new file mode 100644 index 000000000..a2043a210 --- /dev/null +++ b/src/main/java/forestry/storage/proxy/ProxyStorage.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.storage.proxy; + +import forestry.core.items.ItemCrated; + +public class ProxyStorage { + + public void registerCrate(ItemCrated crate) { + } + +} diff --git a/src/main/resources/assets/forestry/textures/items/crate-filled.png b/src/main/resources/assets/forestry/textures/items/crate-filled.png new file mode 100644 index 0000000000000000000000000000000000000000..08cb41c649a48e694f3a53ea5bba8da1c2e90da6 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa4)6(a{r~@eah&D+7T-NHlD15U z$_z2~b5M`=)ZyUZ*e!6c2B?g&B*-tA!Qt7BG$1G4)5S5QBF^`eA|F#AkL$(nhA%uL z7%F`^rfq9tEn%KeGmW9_PDX&vY`f#3?lC>CvW*Y7Y^i?y>)$;4eo^HUT#5I7WxgmB zuh7s}G@5hB=(muP-ZZ96S4Hg;|0~TynU|-3XWDRom#DqEi;UiRN9zedD;Ydp{an^L HB{Ts58T(2b literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/items/crates/apatite.png b/src/main/resources/assets/forestry/textures/items/crates/apatite.png deleted file mode 100755 index f24613f07dce3a73ebdae327aec0f20e84138456..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0CVw;#(YNxo1YwmI+ar zA;#Q%CP2a7$A3wFh6XR;M?3Fy1rv# zQj5Lqdd)PYLx03qd8IvB!!)f(?^rgg$IfeEE@6q5cgyo5SR-Zi_!h@*x%OK^?YEod yF^gYuiGsx+IMY7vXD#{M)lmHK^OIXYJ}~b&#O79gWVbZX0Sun5elF{r5}E*H!(MFw diff --git a/src/main/resources/assets/forestry/textures/items/crates/apples.png b/src/main/resources/assets/forestry/textures/items/crates/apples.png deleted file mode 100755 index 2f882f32627aaaa8dfda8e31c2fe24674d0e1cbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sZ(ykTh1%;Uq(Abg)@Yc@Bg&9TZH9A?(l2@s$eV$@(X5gcy=QV$SL!5 zaSW-5OHL4BVPs`vb5mAL6@IFqa9GFCS66dSW8=jL&yz(x^ocn+5C{@#35V*S0p_gRhvT>Ae%ob!l5;m#V)GX`dcW=w`NoE#ZW oBn0TQH*vACvGwsOWF#;!Sm&#*a@4Eb4|D;8r>mdKI;Vst057^tkpKVy diff --git a/src/main/resources/assets/forestry/textures/items/crates/ash.png b/src/main/resources/assets/forestry/textures/items/crates/ash.png deleted file mode 100755 index ff4bbcb3611edcce0e123c585899606dd6e6c4bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sbg#FbMxlS`SUlQIB{avu7m5>@7?2nz8fgbSQ6wH%;50sMjDV)=IP=X zQW2M&Ai~1P%EsoVtePtPR6*gej-juv=AOpJixHkDk4hZj;AL6GXxKBwq_@X`XX#b- z-WUg-$JXg;nvD`o>E-w5aU@CX-&vf`)v?gz{grH0fx|~q)m(Zvc5W2xI4Hu!*C!r;iv%&;&{o%4p0sS?ly44$rjF6*2UngAUMP;USL diff --git a/src/main/resources/assets/forestry/textures/items/crates/beeswax.png b/src/main/resources/assets/forestry/textures/items/crates/beeswax.png deleted file mode 100755 index 12039ea9dab088ce687b3ebb84ba2979d96c8fe7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#snZo9{o-oY>}0w9t4v

RiTqaVb!au_VYZn8D%MjWi&q!qdeuq#`ak zL4<{om5t3!Sv6Jose-~`9YbGT%{`5c7b84R9+f!4!OOCW(XeMqnv`Utgx93i>N^`G zj%^N`8^UC$628{fSn$Y(nBA|=hzK}mUO%$S1_l`~B|A-9S0Uk|4ie28U-i(tw;QPZ!6Kin!zi z5f(;PHa0h9)l}i93JQmH41IMq_cS(MjPN{pRN_cS%-&yL+yo96JwInV*@0)R>FzRl z#_l(FEvtn)6t`A?f7PtecJ-X)=5-Acw^paUXVczhwYU1alEC2`M{am@u?&qK$?WxmS!x8Smx_bfl{C1Ax%eZGSE&K_TW-JNv3ubV5 zb|VeQDe`o245^57?Th3)tia*1MY~A9oJTv z9=ZH@PEuco!G5REmx&#B8PAC}xExW~WOZZBFMdnMu+_W2@3YbgnxP$@F#p~C*ZZ!^ tCfNpU@K*gNbm6QBtGiHTk(%;d~G$**5x3o)(=x*7GA=JAACB2RpWTS}k0)+I?}f z`=(^ScvH>(0Q+7)+vRcYlLG9f1UWRgTW}X>O#&LnSQ6wH%;50sMjDV)@9E+gQW59c z7cO+zfP?j`+=?C3zSR9sK4#%|^J0IQSew8nc}};m$Uxmifptnt=S*6oZ}wJg+Y*th zu`UedHVtoBttY&Bscghx(eLn)N%*JDMzP8xHIj|lcMW}ZlpcAcTx9X+>#-UE{S6Zm s{;zb}x*~Qvcc-Xun$&To#ieilvvPH^i5c!&2nrDfPgg&ebxsLQ02Nzm6#xJL diff --git a/src/main/resources/assets/forestry/textures/items/crates/bronze.png b/src/main/resources/assets/forestry/textures/items/crates/bronze.png deleted file mode 100755 index f1946a4ecf162b8db22b3d86e7c3c11adaa34c99..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0CVw;#(YNxo1YwmI+ar zA;!T@B0#}cHS3j3^P6da5UH*w0hXzJ01`yL_vK zBGvh+zmhX=D#E+}=>&rW{btFtM)dzXV)78&qol`;+ E01+iu2><{9 diff --git a/src/main/resources/assets/forestry/textures/items/crates/charcoal.png b/src/main/resources/assets/forestry/textures/items/crates/charcoal.png deleted file mode 100755 index b3bfcf15ede4b310b32839aa55be4313fe1f8aa1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 274 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfbE0CVw;#(YNxo1YwmI+ar zA;!$i%+k`*Kygt~QE_qcXiptK2X#F?J#B4m1qB6TV`B{s4OLZDGcz+~Wo0fdE^cma zUS3{)e*VMN9Tq@sj3q&S!3+-1ZlnP@rJgR1Ar*11J?=uxh8!&A9hcaifB8RM>ZI7K zCgxaU9d6$ZCLMwX+z}szmj-BdT&#V)$lYbef2YusJxvoCuI-kt2x0j2xWsJYpTy~} zbJt36Dpl{eo@F9@uk{K4mFKVjp5*H8kThW3d}LXJnlH^Yvg;$`iV{Dr+Xj?lED7=pW^j0RBMr!@@N{tusfbHX z5Mg0tWn*(wR!tRts-SRK$Iw?-b5CRA#R$)nM^LaG#pJ-&TxBT` jVqjoUP{QEI%*=4)oVwr^PW|UVH!yg*`njxgN@xNArUFgg diff --git a/src/main/resources/assets/forestry/textures/items/crates/coal.png b/src/main/resources/assets/forestry/textures/items/crates/coal.png deleted file mode 100755 index b3bfcf15ede4b310b32839aa55be4313fe1f8aa1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 274 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfbE0CVw;#(YNxo1YwmI+ar zA;!$i%+k`*Kygt~QE_qcXiptK2X#F?J#B4m1qB6TV`B{s4OLZDGcz+~Wo0fdE^cma zUS3{)e*VMN9Tq@sj3q&S!3+-1ZlnP@rJgR1Ar*11J?=uxh8!&A9hcaifB8RM>ZI7K zCgxaU9d6$ZCLMwX+z}szmj-BdT&#V)$lYbef2YusJxvoCuI-kt2x0j2xWsJYpTy~} zbJt36Dpl{eo@F9@uk{K4mFKVjp5*H8kThW3d}LXJnlHkv$HcXF)=bSa`EEDt5>gXX=zDIODicUiI0!Z$;o-oEq5JgH)~0dAIPN)42QDW zHUg=so-U3d6>+Y8SJyEc^0++C&1Ijy@C=XmzyHsrmiksbS-w~@yTu@0z@g&ci^ORs zxb8b;FE;%ZTq^C-;c@bhV3t=|=#;BxjUhvn2IoIFGD|I}Vg%ED7=pW^j0RBMqe0)5S5QA}%>W zgoTlnjm=G2HC6bjg2G`PLtkCZJ&lbQBRo$Yl{mt|%d(2mu*YPox@4n-*XFYMB|u*K z`8$=IM<&?qOuObLaJcCCyPLrYSyLQ%gx}AsKFE_SoUAO+tSQ3Mz{B>nNMS`nLc)U= d3{7lo3^$*vw}+H$e*v_f!PC{xWt~$(69AVqP7?qC diff --git a/src/main/resources/assets/forestry/textures/items/crates/cookies.png b/src/main/resources/assets/forestry/textures/items/crates/cookies.png deleted file mode 100755 index 48174ee7f38c89ac26b232fcf211c000246ee680..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sdKa0&RawL`2?qKZ|!h>sh!29u3ExhufDhoRKZvhR^go+pn=9O2+)S;c7BW0J0C#AG-n z?ft!%Oi4G+>?y4l>QLO7{_RbtLfhRp!Mo=-NOlg?gc0Zj22WQ%mvv4FO#q8MQ-%Nl diff --git a/src/main/resources/assets/forestry/textures/items/crates/copper.png b/src/main/resources/assets/forestry/textures/items/crates/copper.png deleted file mode 100755 index 8a95f48303caaa5ab14a8417d097c995e73002dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0CVw;#(YNxo1YwmI+ar zA;!_>VnD$Uw~jvE-gmmjXm-3>U$}C#r;eY4`r1q_H*LX7y}lc=wY6`2_XVnBED7=p zW^j0RBMrzY_H=O!sfcs!^W&K5Dfy_O7_H5m{_1Uv$ zm7!MCa=do7#_XAqG{40+(pGcJgs9>;OQ4#}5aVc19X|*4_V)I(QWF$_LaZf0ejt+= z7!GB#Z3I#ko-U3d6>+ZpkwS+Rc#b+<`o3p_>i7LQwp%Qk^n1@dc$}dh=Eb>CY(?1R zMEi@?ukSwUtJd2%DJt}T5{IM3g)+qs=IORcOPU+5Z?8~bdb3E7@!?N4#YczI`z1UW z6{fW+GX$>)i`^gnC|No3k&(p;*q#`akL4<{o zm5t3!Sv6Jose-~`9YbGT%{`5c7b84R9+f!4!OOCW(XhuP{Hz(1;goAa~d0str2sn7)z=4a5 cEWA7nKaQ&(Grz%l253Elr>mdKI;Vst0PS^8tpET3 diff --git a/src/main/resources/assets/forestry/textures/items/crates/fertilizer.png b/src/main/resources/assets/forestry/textures/items/crates/fertilizer.png deleted file mode 100755 index f1e2bc592356e98995c38d4a705db5930458bc8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sUsy9THAarB<5sB{&{PcJ^PkU5d+FGmIV0)GdMiEkp|>cc)B=-RKz7G zh_EoSvaz`-tELJ+RZuvrW9X}^xu>!5Vua_(qY_6rc;{$pa3o1&uA7&_lB99ga`R=@ zBL;C>Uu_fWP^^4){osQV#$C diff --git a/src/main/resources/assets/forestry/textures/items/crates/frozencombs.png b/src/main/resources/assets/forestry/textures/items/crates/frozencombs.png deleted file mode 100755 index 3fcf0962a6f0562fa1c3c9fadcc8985992335fdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sq_E;|C9g!dmp$^eQ}5GqD?m@PdosWV=M{s3ubV5b|Vd>)zif>q#`ak zL4<{om5t3!Sv6Jose-~`9YbGT%{`5c7b84R9+f!4!OOCW(Xhv4s=8#OgxBV>`6WPJ z`uRJRoJS_u?M%DoCUCgu`MaCJ30YGdc!b~2tUkz-ES#(?(5xxK(!j&^wMbz_LPElW e7Yt2oYz#M_tG9=gY<~f?p25@A&t;ucLK6Tac~hDI diff --git a/src/main/resources/assets/forestry/textures/items/crates/glowstone.png b/src/main/resources/assets/forestry/textures/items/crates/glowstone.png deleted file mode 100755 index b9b68e858073eb22d9729a8ff4c926cfd9e04f24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sS_N`aOo1m?AZ)$Z4CeaGbAT7@Kw8A14=WN1o;IsI6S+N2IQ1`x;TbZ z#EG6#Mm=TCUBo6$qcgku}SCL!*FQ&f30e=A6SJ5nDmTR2fH zi&G_e_U+n)Vw?4T?TjZ+o@=cW?@y39%VPH4UH!-E8cmbbRpp7+Q-6s>*xPgMl=eKh ndA7mpP=?puC9DSfU77zS?ovH1RDHz+=mZ8&S3j3^P6?I)=WwntK`>FGhHtJSuUdBW7#*H79|?MQ2~lob14JHgI$nk3*t^lPOOM?7@862M7NCWBiba4!+ zh)YfoVPRxtV{=nhO%;Bspm12n&{tP;Ph;c72+xy8C5~|LvaDh>>@k_DF4-vIwfWnf z5+E=A{GFd1M<(ptS$54$;Be9NcQ=C*vZgrj2*02C`v6a}aI&&Mv!)130}tERB83$R h2?-BgFf_5TF}!J1Ka=@yy9&^H22WQ%mvv4FO#loqRm1=Q diff --git a/src/main/resources/assets/forestry/textures/items/crates/honeydew.png b/src/main/resources/assets/forestry/textures/items/crates/honeydew.png deleted file mode 100755 index d9636a50a7001f16ae08bd3ab9e2c723aae27e34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sZ-%0yFE{5X0*zhbj>-jsC(r>5p00i_>zopr0HSqBEdT%j diff --git a/src/main/resources/assets/forestry/textures/items/crates/honeydrop.png b/src/main/resources/assets/forestry/textures/items/crates/honeydrop.png deleted file mode 100755 index fd1ba3628e98ad24d960234499362ee40e0da49b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sk6CC%-0Tv?`MWyueSq&0ivvx1nXp~UXGoCudfhSowSy`Z2Q-q~~hwW>T!it21 ggamdKI;Vst09!Xo)c^nh diff --git a/src/main/resources/assets/forestry/textures/items/crates/humus.png b/src/main/resources/assets/forestry/textures/items/crates/humus.png deleted file mode 100755 index 5a9fdd5c0bc315f13e6520a9727a7a0d9dff69a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sbeg`q9M#I&&MRn#iTFBBDv-7S)d$aNswPKgTu2MX+Tbur;B4qMO<=% z2n!=C8=IT5YO3&41%<;phQ7L*dm0-rMtGh)DsiMEX78^rZUTpko}aUw?7*|uba$CN zWA~f8mes-?id(C{ziL)!yL!%Y^STC!TdULFvuSU$+FSiyN#O8}BR4!aPb6@$GAcAX n?v>%tl8}(FuxeP)$jI+)?^wrhe)7W@1!t>-&i6b1mEUOre9I|?P9C%a( zr+extv~7I4#@0)r?a8XU)%r~m({|^-uVYHen0NR4KjDrFR*S=_>!wNji6aO$x+Oqe5=IaZO-W+HzOX-jP%)U)pTusT#@ZS*$JGRd^ z3w1YYtx~E_Oygs@Q{L=SKmUN7;>WJOhHHFZB-29<*M95lNM}!b#-GwJ;J~NxnveCG puBwYkJ!jNLms!b^D+@&>_q8;$YQ0WNlLA`L;OXk;vd$@?2>`2YRQ3P> diff --git a/src/main/resources/assets/forestry/textures/items/crates/mulch.png b/src/main/resources/assets/forestry/textures/items/crates/mulch.png deleted file mode 100755 index dcae6f9c063a913894289753f8885f5be44905a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sUs`EVz0twAkD5N!S1QWqaeg;D8td5Jn;@t1!GB&UoeBivm0qZPKBq7 zV@O4u=qW?4Lk=RY7tO=AO?&x-b<6*Hfj65OTNBo{Mqe;mx;9C8x`EJlMV=k1|94;2 z)Vt)Q+nAD5yqiC#@A=i21`3upcV2k^NU&$|%mdHKL7v# diff --git a/src/main/resources/assets/forestry/textures/items/crates/mycelium.png b/src/main/resources/assets/forestry/textures/items/crates/mycelium.png deleted file mode 100755 index 6860834a706388ca32f605fe581770a5a91e5054..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbK}QGic~E0CVw;=5-?Qbs~{Lw0_0 zY#dOer?|X0&T`9ysM3O#%n;+^^_?1*P#((OC)E8Sz=o`Ng@3DVYh`6`48Jxiy)IIbk884S7W^g=P5}We*>y+XL-j zED7=pW^j0RBMr#u@N{tusfcs!3l}fQfElVuja`EdALb7kn${|>4Z zEs{qVW;{?|^Yz*xo0V(DH@Y}E#JFbNd7<(7Uba#nZ|NLsTgL11JC;9I%UHBf_bpqp z$wT#GtK$5kpM^V*y%Sr$dme-RvV#IgFCDf$oBibba*iVnm-0j>a48+x()Gq^?TLS^ YS|J=;R=a=I0lJC7)78&qol`;+0DmEZegFUf diff --git a/src/main/resources/assets/forestry/textures/items/crates/netherbrick.png b/src/main/resources/assets/forestry/textures/items/crates/netherbrick.png deleted file mode 100755 index 087302b202521532fb01d1e209974bde69787a73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 267 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Q-Dv1E09(Z5jT*Kncw0o$;-cI zMv|O>aB-aFmI+arA;v&id46F(2Xzw(*=SE4NnQaNJ^?*3X=7=5XtE>RWw_g=)hSf`$wUV8s`-I}Ki*o1T{RLaSO0myCuPMh z=Kto8EZtqJWY1rhHWHTRoD@7`s-4pG309nfX|hM;-ZbB^7kHwb*S0FvV#dpt)q~bWsEfbaC~$Hun4C~|5 z?I)=WwntK`>FGhHtJSuU7qc>(ppuiD>OHnl^IF1BNvP<2{a>QWX z*4stG9f}gAQj3n=`1K%7Sispc^Qxe#z~LjQ{X#PmbCPmck_=j#7$zKC5XZ+N%EQAW fBkOSC00YC4r>b-QF3+$7x`4sc)z4*}Q$iB}hH6W{ diff --git a/src/main/resources/assets/forestry/textures/items/crates/nikolite.png b/src/main/resources/assets/forestry/textures/items/crates/nikolite.png deleted file mode 100755 index c8d522ef6e72d4269fead71ccd74d378d720cbce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sl%YB%TQFv5E9Jb<;nQ}4}+QM*WA>6pfqDikY6x^!?PP{Ku)=*i(^Pd zoaiY8MMU_YMw}RxiBlY33g%icH zI8~Bo->yw4wps7j&Uo_Vxz;-I{sft`EN1WB)qkw6(KJb2Ri0=)^_NJ5y*<}XY0rb3 nXB)f@Wq9pf!fLSJmHA)dF4faQ)mKb_PGInK^>bP0l+XkKCGk@6 diff --git a/src/main/resources/assets/forestry/textures/items/crates/obsidian.png b/src/main/resources/assets/forestry/textures/items/crates/obsidian.png deleted file mode 100755 index a6cf7b677bceb0b6c22cd51f2013c311ce780295..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbK}OMp*^E0CVw;=5-?l7N83mI+ar zA;v(F;y6owesLRvFgXcr0Rc&Velb4>bv{0^Xipt0y%0V=Q6V8|4h|kpPCh<9Aprpq zUS1J?etrP~X+A!2K|vXQei051UJed^K|w_oIYR*fS!q!X0RaI)K`DNIDM3D2PEJmK zeo;X|Ngf_yAoF*bI>>>HB|(0{3=Yq3qyafyo-U3d6>+Y8p+YQ%9IVVPsVP_QKK=Lo zwu*Ji?jH+ZJK8Fqkr$9`p5QR0fve6bd$H+~K;LkePLECt4%aK|PRcE76TY&0qO`xw z`~zpsi=Up#ze&yPT<+bx^PIwSZQCweUX!1my(iH7h`Phxz4kQ~*W?=G-uHjs#^utv p^R9wJ=%y3P5--KQn6amxQI3V9*Y|wRAE2ukJYD@<);T3K0RZsYVe|k1 diff --git a/src/main/resources/assets/forestry/textures/items/crates/peat.png b/src/main/resources/assets/forestry/textures/items/crates/peat.png deleted file mode 100755 index 18e307926332c433d7d13c3a08b5cf80b4f326c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sl(63Vxq{aDa9qu&n73#t|HFK&CWDwNmdn51!GB&UoeBivm0qZPMN2R zV@O3@a)Jm8BP$!5o3d)E@KXha!#ak(x|(|$8!tw9o;)gXgoBr56{C?uR!@%ukLtvk z-7yY4rz2N~X*Nn+T7B)#Z;qsh_qE^Oad#}-`TnoCs=(oteH(>lB<3XLup}9@HZe>% oxFC*?MU;n!M@H7+!T|<`9w)VHKiFETfi7V1boFyt=akR{05EAvp8x;= diff --git a/src/main/resources/assets/forestry/textures/items/crates/phosphor.png b/src/main/resources/assets/forestry/textures/items/crates/phosphor.png deleted file mode 100755 index fee61a3c11cf6ebf263770e30e8e5037cb918117..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sUr~;z3tWOxJ#F3KYr4F_g?wUTRZL3?gOP6OM?7@862M7NCR@pJY5_^ zD&mq8L|7PE+1T8aRa1qZDkvP*G4$2d+|$^2F~alYQHdiQyez924SS}T^!7OLEWN7U z8{@$9*g9QJvr(ccz5M<>jwFfwJB#zVIu@F|zmlygaQH~7noIA-&W(Z{2SvD;9N3zx lECoUg3=9fN7#x|I85YK=bKX!gRRX$z!PC{xWt~$(696l0P=){i diff --git a/src/main/resources/assets/forestry/textures/items/crates/pollen.png b/src/main/resources/assets/forestry/textures/items/crates/pollen.png deleted file mode 100755 index f807d28428fe85109d04a851a4f974d6048d02f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv5AX?b1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sk5j{wK7A-*Gb6LTHs*3%r&3{V@Z%-FoVOh8)-mJnWu|mNJU(7f(Q#E zD;t}evTCaEQw4>?I)=WwntK`>FGhHtJSuU7qc>(ppuiD>OHnl^IF1BNvP<2{a>QWX z*4stG9f}gAQj3n=`1K%7Sispc^Qxe#z~LjQ{X#PmbCPmck_=j#7$zKC5XZ+N%EQAW fBkOSC00YC4r>b-QF3+$7x`4sc)z4*}Q$iB}1XxUp diff --git a/src/main/resources/assets/forestry/textures/items/crates/propolis.png b/src/main/resources/assets/forestry/textures/items/crates/propolis.png deleted file mode 100755 index f680be088b7f625684079658c1320492df303f50..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Q-Dv1E0CVw;=5-?(v}HPnIXm- z=2{lVS*ArRp4t(6a(fg|_UID(MBej85@cduy6KS0dr)PeDRPgRMGXn=(V&m_=a-bU+ NJYD@<);T3K0RS!jX0`wT diff --git a/src/main/resources/assets/forestry/textures/items/crates/redstone.png b/src/main/resources/assets/forestry/textures/items/crates/redstone.png deleted file mode 100755 index d15529c8965cd172433392c7c2dd74c77436857d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 246 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#siVulP{hCx!oc9k!0?}e!Hj{SfkXQ>P@1tM$S;_|;n|HeAgA2Z#WAEJ zPV|%_-ysJP*Nf&FI-C0Ts6F^Uf5L;^j2==Z9NQQ+32`5sqRONBTS4;Mk@|4i!ii#8 zoGQt)Z`URi+pPC%XFPfGTx*?pe}c?e7PI&6>OWT3Xqu$1Do?bY`b#9j-kxixwCBOi nvkhK{GQ9RKVKvzA%KR^Jm+EPu>MJHdCop)r`njxgN@xNAG22h; diff --git a/src/main/resources/assets/forestry/textures/items/crates/reeds.png b/src/main/resources/assets/forestry/textures/items/crates/reeds.png deleted file mode 100755 index eb34cd95e5a4c6f4ec1c32a758a4803e07dfcbf8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sk7>KNz;nRX$R9X+ueh+Ewn9UkNKNk|4ie28U-i(tw-_PZ!6Kin!zi z5f(;PHa0h9)l}i93JQmH41IMq_cS(MjPN{pRN@E+FUu-M!=5Q=Qj(1lUXxaSH7 khn9qdgoRbZf<{J$SS{5p-(AnG1iFF2)78&qol`;+03xJI8vpb%ybb5*&sWx0r~C^y|+rqCE7vA;$s*+qI{k=vXa zpJ+F&xdkTqftpM5)aK{uRK{6v>I$7%?%A1XyR}OD;WVS>Sk10j#i^+(Er~`Y5k`GE zc3a9-w-pGL1dg>I#>cJs1Ssv@-NgT-eh zNwkKEmqwbMtdng^F>g+@FY%KKaZs^W7TF7QF=I)PUoeBivm0qZPM@cXV@O4uYxh+l zW`vaqpz%g)?cUbLN2^85b(=l^d@W@P?-cgq&za>t&##=fUcJN9IsJd}6c zp=V2HQC_-3&+ay<|!^0yhD@#R1g_)T-J3HIV%#4wdk)NMGVb(qtpf<*mAirP+ zhi5m^fSfE(7srr_IM<$NA!b94!%5N}WxwD3<-e_{>so(}<5&lqGACn0%7n+-ClnkH zUEg@r@63|<1>Y@CcC28s@N_C|s*GE=-8wVW$8KKD*UK|%j63xv*)eWV4`_|#+A_iC lQv8A0x@=(+tu4Fm$V=R2(QCeP*aT=RgQu&X%Q~loCICk#OpyQp diff --git a/src/main/resources/assets/forestry/textures/items/crates/sand.png b/src/main/resources/assets/forestry/textures/items/crates/sand.png deleted file mode 100755 index 39481d26d04f5534a520b9b038de285cb3990552..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 402 zcmV;D0d4+?P)?&7x7%$4HWq{qLB;MJ+n z$&uI3nBLQ;w61o$w0_UYk~4E>QEPdFi_v$fi3* wt~{Q}>m7fbK$J+|6#|rl1euVbo`@Lgzs`UPU!3OVO#lD@07*qoM6N<$f`@s}(f|Me diff --git a/src/main/resources/assets/forestry/textures/items/crates/sandstone.png b/src/main/resources/assets/forestry/textures/items/crates/sandstone.png deleted file mode 100755 index aa3fb342d5f7402dcf17d4b9c25b71f0ae52e2fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 434 zcmV;j0ZsmiP)*BV9#vD(tB;@hglzJ1uyn8m())y|sP(wybqv)k68-Po_j zzI5r~vf*KS+yLaf{vdP4V<>0%`$C2dQuG`b2-q^6_-m~A>s^8b5mvrF)00001 zbW%=J06^y0W&i*Hlu1NERCr!Rj#U!GPzVGAPonGY?(XjQzte_n$ae8V*9?VWh(BNu z0>KAS0xI|kt%cU$kFu>m1Q96_L!rjmvKfmfOu>m{DxGn1`2ts7T(QLWx zPPf{#kpKpgvGFD?HWH_M#Cv$nf`%HhCVTCrZ(_QNJ>@~Xx0>AY2ab|TBNWdAtB+x e3x*~(HilCz${ZI&4@CoAz~JfX=d#Wzp$Pyn@kRpx diff --git a/src/main/resources/assets/forestry/textures/items/crates/scrap.png b/src/main/resources/assets/forestry/textures/items/crates/scrap.png deleted file mode 100755 index 019d876f8c8a56dd621048724196fdef3d24ab5b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0CVw;tM4A%t+cYAu2P( zxH!%-DOe*RA;Hf@#HZ0xW(P3lhV!Gfp(-O~v>yDY|&i~q}J!{Uid)LKRA1r_0e|-8nHji7S6LUFt pw5E8f3LMpxdY1HN?ple*?Dml?+qqV&ya8Iw;OXk;vd$@?2>?bzRJs5F diff --git a/src/main/resources/assets/forestry/textures/items/crates/seeds.png b/src/main/resources/assets/forestry/textures/items/crates/seeds.png deleted file mode 100755 index 74920f38e4bd431564b94fd4154a287c77089ccd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF3h)VW1=7WFmh)SD_smGzG9fB6 z#26^z=b#?#sl)I{AajF-OOcA6GtZh076MOryMS_xB|(0{3=Yq3qyaf4o-U3d6>-T4 zA}oxoY;11Is;RgTe~DWM4f%Qi>L diff --git a/src/main/resources/assets/forestry/textures/items/crates/silver.png b/src/main/resources/assets/forestry/textures/items/crates/silver.png deleted file mode 100644 index 7de7391af82ebe4e2b38052b118779d1a67eb304..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU{r~^}i4!O0wD=Xp+hl~9 z?VOPm?QP)iti5qUG*HR=_wRdqdy9&SzJ2?)YuB#K%uGgUgKVG#V@Z%-FoVOh8)-mJ zxu=U`NJU(7f*BhlD;wK01=Xt@q3R0CMW1}mdcNc2IkV8qOLn0`Teool?*zsmVG))j zjmQ$2R}6+u$>;P!m<)5?-HX~Qd88w9clK3o0cZEByTAPv+>X5b@8zZ7mf?~i&~fky r6O#j5bCspQ6hi}p4NDmvnV1W zgoTlnjm=G2HC6bjg2G`PLtkCZJ&lbQBRo$Yl{mt|%d(2mu*YPox@4n-*XFYMB|u*K z`8$=IM<&?qOuObLaJcCCyPLrYSyLQ%gx}AsKFE_SoUAO+tSQ3Mz{B>nNMS`nLc)U= d3{7lo3^$*vw}+H$e*v_f!PC{xWt~$(699W?P2vCm diff --git a/src/main/resources/assets/forestry/textures/items/crates/soulsand.png b/src/main/resources/assets/forestry/textures/items/crates/soulsand.png deleted file mode 100755 index ab2882eac593213f3edd0824922673cda726df3b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbMfv;dzFS0FvV#dpt)q~bWsEfbS&_bFasE+mme!hb!H#C7 zaen#Xo~Fu@2|o7z*809ShFwL;&W7p^ddhy*`bXI~Hv-+kSQ6wH%;50sMjDXQ>*?Yc zQW59c7b=@WNqA16Q3>_CnK=#fNr? z*SdHeaa{3fhrvYOpo5*2X=jS2&i}#UmTcU)Y_n6*p_!}V@;B+KAIYoV;Q2V}zw*k< zoA;XZ`74xOH`~5__xr$*{^zS}>i0NI@p#L|c*?oS=fnlSBRp^8J>5CJId$v=1t){2 LtDnm{r-UW|?*D#c diff --git a/src/main/resources/assets/forestry/textures/items/crates/stone.png b/src/main/resources/assets/forestry/textures/items/crates/stone.png deleted file mode 100755 index 54afd48d3967f18f05bf06c3c4f3139d255b3514..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 414 zcmV;P0b%}$P)ZES3_u&-oWSCfp4cyn}*kdkI#S(l55otm1Pm6d&aeSdy`l8lRneSCa=frf;J zacpc^Q&Ck>PobEVla!aIp`Mb7h;U(MbZBI1W?_?%ma(s|tD&8bh=!$~pr4kQnv#!$ zcypJGh;3(Ue|dJVt*wiIeuH>+kcEYPZ)yeFve*Cs00DGTPE!Ct=GbNc005FnL_t(| zUPX>o62mYIL?g)%C^M$a%zXcAHFhKSjehiIS0m5Uf50)xGVrai z5g`y$A#1eFWOMm~=0uT7WvWz(D?nkr(QLIlf)m}Cdi}w0#0fo~OlNaiEZvROI^4V| z+HnQ;hvSK&^Tqvfz0v*ge0`ii6llIn1xSYx#so~VTYSdsUmgz%mqm#39{>OV07*qo IM6N<$f@WB-T4 zA}oxoY;11Is;RDxyf&B3F9Gt> z&)=!!JTk#61|GJrMG7kt5)vM~ dU}$1vW4QTTy*;F4`wO7;44$rjF6*2UngIGcP%Hod diff --git a/src/main/resources/assets/forestry/textures/items/crates/tile]-16.png b/src/main/resources/assets/forestry/textures/items/crates/tile]-16.png deleted file mode 100755 index 93f68cbe78c5cf376c06293655be4368b4ec08bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=7WFmh)SD_smGzG9fB6 z#Q6XJ|9%eY(VjYYrJN6nTkR6F`1Jq(rMq_@zI}W2_(Bn&2F8*gzhDN3XE)M-oB~f5 z$B>G+$#6@pNayQlC5bY=fFK%-FQkxL6q#njQDbaA-+L gNLW}kENEn8&}CL$Cc&`o3eau_Pgg&ebxsLQ0El`_mjD0& diff --git a/src/main/resources/assets/forestry/textures/items/crates/tin.png b/src/main/resources/assets/forestry/textures/items/crates/tin.png deleted file mode 100755 index 0e05104247b56de2c191ae4ac14939db03dc7d61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Wq?nJE0CVw;#(YNxo1YwmI+ar zA;wkPF9HSs{Qdjz-IvW*pUggSXUdVA(VjYf4(dzJ-Y?jA_Q2hjOV2%6yDqsJsE)BD z$S;_|;n|HeAg9>V#WAEJ&b7~zk6Dq2B{M%~v+Do)93Ek3PQKVp(SDs~9?VG=XPCnF zD5am0{P)Fb`3z;HGxZBseK9)nj^Q|$gHn<}q-;*uD|SQ2Ft4>=EyCI>v(|o%XsmsI x?f2(3)<^RE&*_Q&_jWK3R*7kRep0gM53}<`R$m`Z0VbgJ44$rjF6*2Ung9dFV7LGP diff --git a/src/main/resources/assets/forestry/textures/items/crates/uum.png b/src/main/resources/assets/forestry/textures/items/crates/uum.png deleted file mode 100755 index 24e3bca3d87e9674c2b7d7ca8ab31e21b523f3f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Q-Dv1E0CVw;=5-?(v}HP#c`II zA;y^unLxoE{yTQMbon``A9I-+?Wwa-r(&^A_C=SAdo0`6TUJlinR?iN`o)VEm&s+m zJ{pn%)WBF0qrnIXoi zrkp^L!bH{8Yc=W`HH+gcuikR?b5KuB7hki%BHB|YFixFvp1%0%7x_!&p_83(Vb7u$jN6Y+d8|dcg^7Vu#rJ9|K*$;OXk;vd$@? F2>?Z)Sc(7u diff --git a/src/main/resources/assets/forestry/textures/items/crates/wood.png b/src/main/resources/assets/forestry/textures/items/crates/wood.png deleted file mode 100755 index 938c9f0697ec83221932f8bf2dba63a33b4890d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 282 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!Uw}`DE0A7QZMFR*FJY4WzFmiFzuQ zdv(n^5PtXLLeBT|c0LPuC(EAZV$&Zgc>WsWa Date: Thu, 25 Dec 2014 01:09:13 -0800 Subject: [PATCH 105/175] Only need one crate renderer instance --- src/main/java/forestry/storage/proxy/ClientProxyStorage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java index 64a4e43f9..ecfd3d9f7 100644 --- a/src/main/java/forestry/storage/proxy/ClientProxyStorage.java +++ b/src/main/java/forestry/storage/proxy/ClientProxyStorage.java @@ -17,8 +17,10 @@ import forestry.core.render.CrateRenderingHandler; public class ClientProxyStorage extends ProxyStorage{ + private static final CrateRenderingHandler crateRenderer = new CrateRenderingHandler(); + @Override public void registerCrate(ItemCrated crate) { - MinecraftForgeClient.registerItemRenderer(crate, new CrateRenderingHandler()); + MinecraftForgeClient.registerItemRenderer(crate, crateRenderer); } } From eefd71ef567c4975a0a65e9c1eb80f5a2a231379 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Thu, 25 Dec 2014 09:26:04 -0800 Subject: [PATCH 106/175] Grab and insert the Buildcraft License file into the jar --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 9f1cfa117..27564b68b 100755 --- a/build.gradle +++ b/build.gradle @@ -181,12 +181,16 @@ jar { destinationDir = file("build/tmp") archiveName = "main.jar" + // Copy various READMEs and Licensing files into the jar into ('forestry/api') { from project.apiForestry + "/LICENSE.txt" } into ('cofh/api') { from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt" } + into ('buildcraft/api') { + from "./src/main/java/buildcraft/LICENSE-API" + } } task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) { From bcaaf251c66b924f9aec31f109a44c39b41e5a33 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 25 Dec 2014 03:10:07 -0800 Subject: [PATCH 107/175] Fix #397, Fix #404, GUI showing incorrect genetic info --- .../apiculture/genetics/BeeGenome.java | 2 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 42 ++++--- .../arboriculture/genetics/TreeGenome.java | 2 +- .../arboriculture/gui/GuiTreealyzer.java | 113 ++++++------------ .../java/forestry/core/genetics/Genome.java | 4 +- .../java/forestry/core/gui/GuiAlyzer.java | 9 ++ .../genetics/ButterflyGenome.java | 2 +- 7 files changed, 72 insertions(+), 102 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java index 4912cc2ef..9601a7fc6 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java +++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java @@ -72,7 +72,7 @@ public class BeeGenome extends Genome implements IBeeGenome { // NBT RETRIEVAL public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) { - IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumBeeChromosome.SPECIES); + IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES); if (speciesAllele instanceof IAlleleBeeSpecies) return (IAlleleBeeSpecies)speciesAllele; else diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 4e9d06193..8f2babe5c 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -14,15 +14,20 @@ import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IBee; import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; import forestry.api.genetics.IAlleleFlowers; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosome; import forestry.apiculture.genetics.BeeGenome; import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; import forestry.core.config.ForestryItem; import forestry.core.genetics.AlleleArea; import forestry.core.genetics.AlleleBoolean; +import forestry.core.genetics.Chromosome; +import forestry.core.genetics.Genome; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.core.vect.Vect; @@ -102,37 +107,30 @@ public class GuiBeealyzer extends GuiAlyzer { drawSpeciesRow(StringUtil.localize("gui.species"), bee, EnumBeeChromosome.SPECIES, checkCustomName(customPrimaryBeeKey), checkCustomName(customSecondaryBeeKey)); } - drawRow(StringUtil.localize("gui.lifespan"), bee.getGenome().getActiveAllele(EnumBeeChromosome.LIFESPAN).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.LIFESPAN).getName(), bee, - EnumBeeChromosome.LIFESPAN); + drawChromosomeRow(StringUtil.localize("gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN); - drawRow(StringUtil.localize("gui.speed"), bee.getGenome().getActiveAllele(EnumBeeChromosome.SPEED).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.SPEED).getName(), bee, EnumBeeChromosome.SPEED); + drawChromosomeRow(StringUtil.localize("gui.speed"), bee, EnumBeeChromosome.SPEED); - drawRow(StringUtil.localize("gui.pollination"), bee.getGenome().getActiveAllele(EnumBeeChromosome.FLOWERING).getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWERING).getName(), bee, - EnumBeeChromosome.FLOWERING); + drawChromosomeRow(StringUtil.localize("gui.pollination"), bee, EnumBeeChromosome.FLOWERING); - drawRow(StringUtil.localize("gui.flowers"), bee.getGenome().getFlowerProvider().getDescription(), - ((IAlleleFlowers) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider() - .getDescription(), bee, EnumBeeChromosome.FLOWER_PROVIDER); + drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER); drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); - drawFertilityInfo(bee.getGenome().getFertility(), COLUMN_1, getColorCoding(bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY) - .isDominant()), 0); - drawFertilityInfo(((IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY)).getValue(), COLUMN_2, getColorCoding(bee - .getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY).isDominant()), 0); + IAlleleInteger primaryFertility = (IAlleleInteger)bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY); + IAlleleInteger secondaryFertility = (IAlleleInteger)bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY); + drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0); + drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0); newLine(); - int[] areaAr = bee.getGenome().getTerritory(); - Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]); - drawRow(StringUtil.localize("gui.area"), area.toString(), ((AlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY)) - .getArea().toString(), bee, EnumBeeChromosome.TERRITORY); + IAlleleArea activeTerritory = (IAlleleArea)bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY); + IAlleleArea inactiveTerritory = (IAlleleArea)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY); + drawRow(StringUtil.localize("gui.area"), + new Vect(activeTerritory.getValue()).toString(), + new Vect(inactiveTerritory.getValue()).toString(), + bee, EnumBeeChromosome.TERRITORY); - drawRow(StringUtil.localize("gui.effect"), bee.getGenome().getEffect().getName(), - bee.getGenome().getInactiveAllele(EnumBeeChromosome.EFFECT).getName(), bee, - EnumBeeChromosome.EFFECT); + drawChromosomeRow(StringUtil.localize("gui.effect"), bee, EnumBeeChromosome.EFFECT); newLine(); diff --git a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java index fd8468608..73f571436 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeGenome.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeGenome.java @@ -45,7 +45,7 @@ public class TreeGenome extends Genome implements ITreeGenome { // NBT RETRIEVAL public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) { - IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumTreeChromosome.SPECIES); + IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumTreeChromosome.SPECIES); if (speciesAllele instanceof IAlleleTreeSpecies) return (IAlleleTreeSpecies)speciesAllele; else diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index e15442e58..ea0a4d24b 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -4,7 +4,7 @@ * 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 ******************************************************************************/ @@ -71,23 +71,23 @@ public class GuiTreealyzer extends GuiAlyzer { } switch (page) { - case 1: - drawAnalyticsPage1(tree, treeType); - break; - case 2: - drawAnalyticsPage2(tree); - break; - case 3: - drawAnalyticsPage3(tree); - break; - case 4: - drawAnalyticsPage4(tree); - break; - case 6: - drawAnalyticsPageClassification(tree); - break; - default: - drawAnalyticsOverview(); + case 1: + drawAnalyticsPage1(tree, treeType); + break; + case 2: + drawAnalyticsPage2(tree); + break; + case 3: + drawAnalyticsPage3(tree); + break; + case 4: + drawAnalyticsPage4(tree); + break; + case 6: + drawAnalyticsPageClassification(tree); + break; + default: + drawAnalyticsOverview(); } } @@ -121,52 +121,20 @@ public class GuiTreealyzer extends GuiAlyzer { } newLine(); - drawLine(StringUtil.localize("gui.saplings"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY).getName(), COLUMN_1, tree, EnumTreeChromosome.FERTILITY, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FERTILITY).getName(), COLUMN_2, tree, - EnumTreeChromosome.FERTILITY, true); - - newLine(); - - drawRow(StringUtil.localize("gui.maturity"), tree.getGenome().getActiveAllele(EnumTreeChromosome.MATURATION).getName(), - tree.getGenome().getInactiveAllele(EnumTreeChromosome.MATURATION).getName(), tree, - EnumTreeChromosome.MATURATION); - - drawLine(StringUtil.localize("gui.height"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT).getName(), COLUMN_1, tree, EnumTreeChromosome.HEIGHT, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.HEIGHT).getName(), COLUMN_2, tree, - EnumTreeChromosome.HEIGHT, true); - - newLine(); + drawChromosomeRow(StringUtil.localize("gui.saplings"), tree, EnumTreeChromosome.FERTILITY); + drawChromosomeRow(StringUtil.localize("gui.maturity"), tree, EnumTreeChromosome.MATURATION); + drawChromosomeRow(StringUtil.localize("gui.height"), tree, EnumTreeChromosome.HEIGHT); + IAlleleInteger activeGirth = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH); + IAlleleInteger inactiveGirth = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH); drawLine(StringUtil.localize("gui.girth"), COLUMN_0); - drawLine(String.format("%sx%s", tree.getGenome().getGirth(), tree.getGenome().getGirth()), COLUMN_1, tree, EnumTreeChromosome.FERTILITY, false); - int secondGirth = ((IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH)).getValue(); - drawLine(String.format("%sx%s", secondGirth, secondGirth), COLUMN_2, tree, EnumTreeChromosome.FERTILITY, true); + drawLine(String.format("%sx%s", activeGirth.getValue(), activeGirth.getValue()), COLUMN_1, tree, EnumTreeChromosome.GIRTH, false); + drawLine(String.format("%sx%s", inactiveGirth.getValue(), inactiveGirth.getValue()), COLUMN_2, tree, EnumTreeChromosome.GIRTH, true); newLine(); - drawLine(StringUtil.localize("gui.yield"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.YIELD).getName(), COLUMN_1, tree, EnumTreeChromosome.YIELD, false); - drawLine(tree.getGenome().getInactiveAllele(EnumTreeChromosome.YIELD).getName(), COLUMN_2, tree, - EnumTreeChromosome.YIELD, true); - - newLine(); - - drawLine(StringUtil.localize("gui.sappiness"), COLUMN_0); - drawLine(tree.getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(), COLUMN_1, tree, EnumTreeChromosome.SAPPINESS, false); - - // FIXME: Legacy handling - IAllele sappiness = tree.getGenome().getInactiveAllele(EnumTreeChromosome.SAPPINESS); - String sap; - if (sappiness instanceof IAlleleFloat) - sap = sappiness.getName(); - else - sap = Allele.saplingsLowest.getName(); - - drawLine(sap, COLUMN_2, tree, EnumTreeChromosome.SAPPINESS, true); - - newLine(); + drawChromosomeRow(StringUtil.localize("gui.yield"), tree, EnumTreeChromosome.YIELD); + drawChromosomeRow(StringUtil.localize("gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS); String yes = StringUtil.localize("yes"); String no = StringUtil.localize("no"); @@ -180,12 +148,7 @@ public class GuiTreealyzer extends GuiAlyzer { newLine(); - drawRow(StringUtil.localize("gui.effect"), tree.getGenome().getEffect().getName(), - tree.getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT).getName(), tree, - EnumTreeChromosome.EFFECT); - - newLine(); - newLine(); + drawChromosomeRow(StringUtil.localize("gui.effect"), tree, EnumTreeChromosome.EFFECT); endPage(); } @@ -220,22 +183,22 @@ public class GuiTreealyzer extends GuiAlyzer { drawLine(StringUtil.localize("gui.tolerated"), COLUMN_0); - List tolerated0 = new ArrayList(tree.getGenome().getPlantTypes()); - List tolerated1 = Collections.emptyList(); + List activeTolerated = new ArrayList(tree.getGenome().getPlantTypes()); + List inactiveTolerated = Collections.emptyList(); - IAllele allele1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT); - if (allele1 instanceof AllelePlantType) { - tolerated1 = new ArrayList(((AllelePlantType) allele1).getPlantTypes()); + IAllele inactiveAllelePlant = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT); + if (inactiveAllelePlant instanceof AllelePlantType) { + inactiveTolerated = new ArrayList(((AllelePlantType) inactiveAllelePlant).getPlantTypes()); } - int max = Math.max(tolerated0.size(), tolerated1.size()); + int max = Math.max(activeTolerated.size(), inactiveTolerated.size()); for (int i = 0; i < max; i++) { if (i > 0) newLine(); - if(tolerated0.size() > i) - drawLine(StringUtil.localize("gui." + tolerated0.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, tree, EnumTreeChromosome.PLANT, false); - if(tolerated1.size() > i) - drawLine(StringUtil.localize("gui." + tolerated1.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, tree, EnumTreeChromosome.PLANT, true); + if(activeTolerated.size() > i) + drawLine(StringUtil.localize("gui." + activeTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, tree, EnumTreeChromosome.PLANT, false); + if(inactiveTolerated.size() > i) + drawLine(StringUtil.localize("gui." + inactiveTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, tree, EnumTreeChromosome.PLANT, true); } newLine(); diff --git a/src/main/java/forestry/core/genetics/Genome.java b/src/main/java/forestry/core/genetics/Genome.java index 51b49cdda..275eb6ee6 100755 --- a/src/main/java/forestry/core/genetics/Genome.java +++ b/src/main/java/forestry/core/genetics/Genome.java @@ -72,11 +72,11 @@ public abstract class Genome implements IGenome { return null; } - public static IAllele getPrimaryAllele(ItemStack itemStack, IChromosomeType chromosomeType) { + public static IAllele getActiveAllele(ItemStack itemStack, IChromosomeType chromosomeType) { Chromosome chromosome = getChromosome(itemStack, chromosomeType); if (chromosome == null) return null; - return chromosome.getPrimaryAllele(); + return chromosome.getActiveAllele(); } // / SAVING & LOADING diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index 6c11ff0c8..5cc02a966 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -26,6 +26,7 @@ import forestry.api.genetics.ISpeciesRoot; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; import forestry.core.genetics.EnumMutateChance; +import forestry.core.genetics.Genome; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; import java.util.HashMap; @@ -92,6 +93,14 @@ public abstract class GuiAlyzer extends GuiForestry { getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } + protected final void drawChromosomeRow(String chromosomeName, IIndividual individual, IChromosomeType chromosome) { + IAllele active = individual.getGenome().getActiveAllele(chromosome); + IAllele inactive = individual.getGenome().getInactiveAllele(chromosome); + drawRow(chromosomeName, active.getName(), inactive.getName(), + fontColor.get("gui.screen"), getColorCoding(active.isDominant()), + getColorCoding(inactive.isDominant())); + } + protected final void drawSpeciesRow(String text0, IIndividual individual, IChromosomeType chromosome, String customPrimaryName, String customSecondaryName) { IAlleleSpecies primary = individual.getGenome().getPrimary(); IAlleleSpecies secondary = individual.getGenome().getSecondary(); diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java index b30d9fac6..b14ef54e1 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyGenome.java @@ -42,7 +42,7 @@ public class ButterflyGenome extends Genome implements IButterflyGenome { // NBT RETRIEVAL public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) { - IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumButterflyChromosome.SPECIES); + IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumButterflyChromosome.SPECIES); if (speciesAllele instanceof IAlleleButterflySpecies) return (IAlleleButterflySpecies)speciesAllele; else From 7b93aca1e60bc6caa8f25fc7c45a6a0cec6a5b84 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 25 Dec 2014 23:43:30 -0800 Subject: [PATCH 108/175] Clean up crates code --- api/forestry | 2 +- .../forestry/core/config/ForestryCrate.java | 46 +++++++++++ .../forestry/core/config/ForestryItem.java | 68 ++-------------- .../java/forestry/core/items/ItemCrated.java | 11 ++- .../factory/gadgets/MachineCarpenter.java | 13 ++++ .../forestry/plugins/PluginApiculture.java | 25 +++--- .../java/forestry/plugins/PluginCore.java | 78 +++++++++---------- .../java/forestry/plugins/PluginFactory.java | 58 +------------- src/main/java/forestry/plugins/PluginIC2.java | 13 ++-- .../java/forestry/plugins/PluginStorage.java | 23 +++++- 10 files changed, 157 insertions(+), 180 deletions(-) create mode 100644 src/main/java/forestry/core/config/ForestryCrate.java diff --git a/api/forestry b/api/forestry index 32e4fa061..f94ccd6d4 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 32e4fa061c31ac225274070937e1c37e91fac046 +Subproject commit f94ccd6d4aaca8851a5a67d468ada074fe65d148 diff --git a/src/main/java/forestry/core/config/ForestryCrate.java b/src/main/java/forestry/core/config/ForestryCrate.java new file mode 100644 index 000000000..004aa76b6 --- /dev/null +++ b/src/main/java/forestry/core/config/ForestryCrate.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.config; + +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import forestry.core.items.ItemCrated; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginManager; +import forestry.plugins.PluginStorage; + +public class ForestryCrate { + + public static ItemCrated registerCrate(Item item, String name) { + return registerCrate(new ItemCrated(new ItemStack(item)), name); + } + + public static ItemCrated registerCrate(Block block, String name) { + return registerCrate(new ItemCrated(new ItemStack(block)), name); + } + + public static ItemCrated registerCrate(ItemStack stack, String name) { + return registerCrate(new ItemCrated(stack), name); + } + + public static ItemCrated registerCrate(ItemCrated crate, String name) { + if (!EnumSet.of(PluginManager.Stage.PRE_INIT, PluginManager.Stage.INIT).contains(PluginManager.getStage())) + throw new RuntimeException("Tried to register Item outside of Pre-Init or Init"); + crate.setUnlocalizedName("for." + name); + Proxies.common.registerItem(crate); + PluginStorage.registerCrate(crate); + return crate; + } +} diff --git a/src/main/java/forestry/core/config/ForestryItem.java b/src/main/java/forestry/core/config/ForestryItem.java index ae8c7a20c..259792017 100755 --- a/src/main/java/forestry/core/config/ForestryItem.java +++ b/src/main/java/forestry/core/config/ForestryItem.java @@ -10,16 +10,17 @@ ******************************************************************************/ package forestry.core.config; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginManager; -import forestry.plugins.PluginManager.Stage; - import java.util.EnumSet; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import net.minecraftforge.oredict.OreDictionary; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginManager; +import forestry.plugins.PluginManager.Stage; + /** * Allows direct access to Forestry's items. Will be populated during * preInit and Init. @@ -194,64 +195,7 @@ public enum ForestryItem { canSeedOil, canHoney, canJuice, - canIce, - // Crating - cratedWood, - cratedCobblestone, - cratedDirt, - cratedStone, - cratedBrick, - cratedCacti, - cratedSand, - cratedObsidian, - cratedNetherrack, - cratedSoulsand, - cratedSandstone, - cratedBogearth, - cratedHumus, - cratedNetherbrick, - cratedPeat, - cratedApatite, - cratedFertilizer, - cratedTin, - cratedCopper, - cratedBronze, - cratedWheat, - cratedMycelium, - cratedMulch, - cratedSilver, - cratedBrass, - cratedCookies, - cratedHoneycombs, - cratedBeeswax, - cratedPollen, - cratedPropolis, - cratedHoneydew, - cratedRoyalJelly, - cratedCocoaComb, - cratedRedstone, - cratedLapis, - cratedReeds, - cratedClay, - cratedGlowstone, - cratedApples, - cratedNetherwart, - cratedResin, - cratedRubber, - cratedScrap, - cratedUUM, - cratedSimmeringCombs, - cratedStringyCombs, - cratedFrozenCombs, - cratedDrippingCombs, - cratedRefractoryWax, - cratedPhosphor, - cratedAsh, - cratedCharcoal, - cratedGravel, - cratedCoal, - cratedSeeds, - cratedSaplings; + canIce; private Item item; public void registerItem(Item item, String name) { diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 72a6ed063..41d7b0a80 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -26,15 +26,22 @@ import forestry.api.recipes.IGenericCrate; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; -import forestry.plugins.PluginStorage; public class ItemCrated extends Item implements IGenericCrate { private ItemStack contained; + private boolean usesOreDict = false; public ItemCrated(ItemStack contained) { this.contained = contained; - PluginStorage.proxy.registerCrate(this); + } + + public void setUsesOreDict(boolean usesOreDict) { + this.usesOreDict = usesOreDict; + } + + public boolean usesOreDict() { + return usesOreDict; } @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 048dac69c..990e78c9c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -12,6 +12,7 @@ package forestry.factory.gadgets; import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICarpenterManager; +import forestry.api.recipes.IGenericCrate; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; @@ -25,6 +26,7 @@ import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.items.ItemCrated; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; @@ -51,6 +53,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.oredict.OreDictionary; public class MachineCarpenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -147,6 +150,16 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL addRecipe(null, new ItemStack(uncrated.getItem(), 9, uncrated.getItemDamage()), new Object[] { "#", '#', itemStack }); } + @Override + public void addCratingWithOreDict(ItemStack itemStack) { + ItemStack uncrated = ((forestry.core.items.ItemCrated) itemStack.getItem()).getContained(itemStack); + int[] oreIds = OreDictionary.getOreIDs(uncrated); + for (int oreId : oreIds) { + String oreName = OreDictionary.getOreName(oreId); + addCrating(oreName, uncrated, itemStack); + } + } + @Override public void addCrating(String toCrate, ItemStack unpack, ItemStack crated) { addRecipe(Defaults.CARPENTER_CRATING_CYCLES, Fluids.WATER.getFluid(Defaults.CARPENTER_CRATING_LIQUID_QUANTITY), diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 8101a36e8..5e82b464e 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -119,6 +119,7 @@ import forestry.core.config.Config; import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.config.Property; import forestry.core.fluids.Fluids; @@ -431,20 +432,20 @@ public class PluginApiculture extends ForestryPlugin { @Override protected void registerCrates() { - ForestryItem.cratedBeeswax.registerItem(new ItemCrated(ForestryItem.beeswax.getItemStack()), "cratedBeeswax"); - ForestryItem.cratedPollen.registerItem(new ItemCrated(ForestryItem.pollenCluster.getItemStack()), "cratedPollen"); - ForestryItem.cratedPropolis.registerItem(new ItemCrated(ForestryItem.propolis.getItemStack()), "cratedPropolis"); - ForestryItem.cratedHoneydew.registerItem(new ItemCrated(ForestryItem.honeydew.getItemStack()), "cratedHoneydew"); - ForestryItem.cratedRoyalJelly.registerItem(new ItemCrated(ForestryItem.royalJelly.getItemStack()), "cratedRoyalJelly"); + ForestryCrate.registerCrate(ForestryItem.beeswax.getItemStack(), "cratedBeeswax"); + ForestryCrate.registerCrate(ForestryItem.pollenCluster.getItemStack(), "cratedPollen"); + ForestryCrate.registerCrate(ForestryItem.propolis.getItemStack(), "cratedPropolis"); + ForestryCrate.registerCrate(ForestryItem.honeydew.getItemStack(), "cratedHoneydew"); + ForestryCrate.registerCrate(ForestryItem.royalJelly.getItemStack(), "cratedRoyalJelly"); - ForestryItem.cratedHoneycombs.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 0)), "cratedHoneycombs"); - ForestryItem.cratedCocoaComb.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 1)), "cratedCocoaComb"); - ForestryItem.cratedSimmeringCombs.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 2)), "cratedSimmeringCombs"); - ForestryItem.cratedStringyCombs.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 3)), "cratedStringyCombs"); - ForestryItem.cratedFrozenCombs.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 4)), "cratedFrozenCombs"); - ForestryItem.cratedDrippingCombs.registerItem(new ItemCrated(ForestryItem.beeComb.getItemStack(1, 5)), "cratedDrippingCombs"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 0), "cratedHoneycombs"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 1), "cratedCocoaComb"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 2), "cratedSimmeringCombs"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 3), "cratedStringyCombs"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 4), "cratedFrozenCombs"); + ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 5), "cratedDrippingCombs"); - ForestryItem.cratedRefractoryWax.registerItem(new ItemCrated(ForestryItem.refractoryWax.getItemStack()), "cratedRefractoryWax"); + ForestryCrate.registerCrate(ForestryItem.refractoryWax.getItemStack(), "cratedRefractoryWax"); } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index debdfb838..d585c4c04 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -41,6 +41,7 @@ import forestry.core.commands.RootCommand; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.BlockResource; @@ -275,45 +276,44 @@ public class PluginCore extends ForestryPlugin { @Override protected void registerCrates() { - // / CRATES - ForestryItem.cratedWood.registerItem(new ItemCrated(new ItemStack(Blocks.log)), "cratedWood"); - ForestryItem.cratedCobblestone.registerItem(new ItemCrated(new ItemStack(Blocks.cobblestone)), "cratedCobblestone"); - ForestryItem.cratedDirt.registerItem(new ItemCrated(new ItemStack(Blocks.dirt)), "cratedDirt"); - ForestryItem.cratedStone.registerItem(new ItemCrated(new ItemStack(Blocks.stone)), "cratedStone"); - ForestryItem.cratedBrick.registerItem(new ItemCrated(new ItemStack(Blocks.brick_block)), "cratedBrick"); - ForestryItem.cratedCacti.registerItem(new ItemCrated(new ItemStack(Blocks.cactus)), "cratedCacti"); - ForestryItem.cratedSand.registerItem(new ItemCrated(new ItemStack(Blocks.sand)), "cratedSand"); - ForestryItem.cratedObsidian.registerItem(new ItemCrated(new ItemStack(Blocks.obsidian)), "cratedObsidian"); - ForestryItem.cratedNetherrack.registerItem(new ItemCrated(new ItemStack(Blocks.netherrack)), "cratedNetherrack"); - ForestryItem.cratedSoulsand.registerItem(new ItemCrated(new ItemStack(Blocks.soul_sand)), "cratedSoulsand"); - ForestryItem.cratedSandstone.registerItem(new ItemCrated(new ItemStack(Blocks.sandstone)), "cratedSandstone"); - ForestryItem.cratedBogearth.registerItem(new ItemCrated(ForestryBlock.soil.getItemStack(1, 1)), "cratedBogearth"); - ForestryItem.cratedHumus.registerItem(new ItemCrated(ForestryBlock.soil.getItemStack(1, 0)), "cratedHumus"); - ForestryItem.cratedNetherbrick.registerItem(new ItemCrated(new ItemStack(Blocks.nether_brick)), "cratedNetherbrick"); - ForestryItem.cratedPeat.registerItem(new ItemCrated(ForestryItem.peat.getItemStack()), "cratedPeat"); - ForestryItem.cratedApatite.registerItem(new ItemCrated(ForestryItem.apatite.getItemStack()), "cratedApatite"); - ForestryItem.cratedFertilizer.registerItem(new ItemCrated(ForestryItem.fertilizerCompound.getItemStack()), "cratedFertilizer"); - ForestryItem.cratedTin.registerItem(new ItemCrated(ForestryItem.ingotTin.getItemStack()), "cratedTin"); - ForestryItem.cratedCopper.registerItem(new ItemCrated(ForestryItem.ingotCopper.getItemStack()), "cratedCopper"); - ForestryItem.cratedBronze.registerItem(new ItemCrated(ForestryItem.ingotBronze.getItemStack()), "cratedBronze"); - ForestryItem.cratedWheat.registerItem(new ItemCrated(new ItemStack(Items.wheat)), "cratedWheat"); - ForestryItem.cratedMycelium.registerItem(new ItemCrated(new ItemStack(Blocks.mycelium)), "cratedMycelium"); - ForestryItem.cratedMulch.registerItem(new ItemCrated(ForestryItem.mulch.getItemStack()), "cratedMulch"); - ForestryItem.cratedCookies.registerItem(new ItemCrated(new ItemStack(Items.cookie)), "cratedCookies"); - ForestryItem.cratedRedstone.registerItem(new ItemCrated(new ItemStack(Items.redstone)), "cratedRedstone"); - ForestryItem.cratedLapis.registerItem(new ItemCrated(new ItemStack(Items.dye, 1, 4)), "cratedLapis"); - ForestryItem.cratedReeds.registerItem(new ItemCrated(new ItemStack(Items.reeds)), "cratedReeds"); - ForestryItem.cratedClay.registerItem(new ItemCrated(new ItemStack(Items.clay_ball)), "cratedClay"); - ForestryItem.cratedGlowstone.registerItem(new ItemCrated(new ItemStack(Items.glowstone_dust)), "cratedGlowstone"); - ForestryItem.cratedApples.registerItem(new ItemCrated(new ItemStack(Items.apple)), "cratedApples"); - ForestryItem.cratedNetherwart.registerItem(new ItemCrated(new ItemStack(Items.nether_wart)), "cratedNetherwart"); - ForestryItem.cratedPhosphor.registerItem(new ItemCrated(ForestryItem.phosphor.getItemStack()), "cratedPhosphor"); - ForestryItem.cratedAsh.registerItem(new ItemCrated(ForestryItem.ash.getItemStack()), "cratedAsh"); - ForestryItem.cratedCharcoal.registerItem(new ItemCrated(new ItemStack(Items.coal, 1, 1)), "cratedCharcoal"); - ForestryItem.cratedGravel.registerItem(new ItemCrated(new ItemStack(Blocks.gravel)), "cratedGravel"); - ForestryItem.cratedCoal.registerItem(new ItemCrated(new ItemStack(Items.coal, 1, 0)), "cratedCoal"); - ForestryItem.cratedSeeds.registerItem(new ItemCrated(new ItemStack(Items.wheat_seeds)), "cratedSeeds"); - ForestryItem.cratedSaplings.registerItem(new ItemCrated(new ItemStack(Blocks.sapling)), "cratedSaplings"); + ForestryCrate.registerCrate(Blocks.log, "cratedWood"); + ForestryCrate.registerCrate(Blocks.cobblestone, "cratedCobblestone"); + ForestryCrate.registerCrate(Blocks.dirt, "cratedDirt"); + ForestryCrate.registerCrate(Blocks.stone, "cratedStone"); + ForestryCrate.registerCrate(Blocks.brick_block, "cratedBrick"); + ForestryCrate.registerCrate(Blocks.cactus, "cratedCacti"); + ForestryCrate.registerCrate(Blocks.sand, "cratedSand"); + ForestryCrate.registerCrate(Blocks.obsidian, "cratedObsidian"); + ForestryCrate.registerCrate(Blocks.netherrack, "cratedNetherrack"); + ForestryCrate.registerCrate(Blocks.soul_sand, "cratedSoulsand"); + ForestryCrate.registerCrate(Blocks.sandstone, "cratedSandstone"); + ForestryCrate.registerCrate(ForestryBlock.soil.getItemStack(1, 0), "cratedHumus"); + ForestryCrate.registerCrate(ForestryBlock.soil.getItemStack(1, 1), "cratedBogearth"); + ForestryCrate.registerCrate(Blocks.nether_brick, "cratedNetherbrick"); + ForestryCrate.registerCrate(ForestryItem.peat.item(), "cratedPeat"); + ForestryCrate.registerCrate(ForestryItem.apatite.item(), "cratedApatite"); + ForestryCrate.registerCrate(ForestryItem.fertilizerCompound.item(), "cratedFertilizer"); + ForestryCrate.registerCrate(ForestryItem.ingotTin.item(), "cratedTin").setUsesOreDict(true); + ForestryCrate.registerCrate(ForestryItem.ingotCopper.item(), "cratedCopper").setUsesOreDict(true); + ForestryCrate.registerCrate(ForestryItem.ingotBronze.item(), "cratedBronze").setUsesOreDict(true); + ForestryCrate.registerCrate(Items.wheat, "cratedWheat"); + ForestryCrate.registerCrate(Blocks.mycelium, "cratedMycelium"); + ForestryCrate.registerCrate(ForestryItem.mulch.item(), "cratedMulch"); + ForestryCrate.registerCrate(Items.cookie, "cratedCookies"); + ForestryCrate.registerCrate(Items.redstone, "cratedRedstone"); + ForestryCrate.registerCrate(new ItemStack(Items.dye, 1, 4), "cratedLapis"); + ForestryCrate.registerCrate(Items.reeds, "cratedReeds"); + ForestryCrate.registerCrate(Items.clay_ball, "cratedClay"); + ForestryCrate.registerCrate(Items.glowstone_dust, "cratedGlowstone"); + ForestryCrate.registerCrate(Items.apple, "cratedApples"); + ForestryCrate.registerCrate(new ItemStack(Items.nether_wart), "cratedNetherwart"); + ForestryCrate.registerCrate(ForestryItem.phosphor.item(), "cratedPhosphor"); + ForestryCrate.registerCrate(ForestryItem.ash.item(), "cratedAsh"); + ForestryCrate.registerCrate(new ItemStack(Items.coal, 1, 1), "cratedCharcoal"); + ForestryCrate.registerCrate(new ItemStack(Items.coal, 1, 0), "cratedCoal"); + ForestryCrate.registerCrate(Blocks.gravel, "cratedGravel"); + ForestryCrate.registerCrate(Items.wheat_seeds, "cratedSeeds"); + ForestryCrate.registerCrate(Blocks.sapling, "cratedSaplings"); } @Override diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index c1ac25896..0ea4b22a0 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -436,63 +436,9 @@ public class PluginFactory extends ForestryPlugin { "#", '#', ForestryItem.brokenBronzePickaxe); RecipeManagers.carpenterManager.addRecipe(null, ForestryItem.ingotBronze.getItemStack(), "#", '#', ForestryItem.brokenBronzeShovel); - // Crating and uncrating condensed + // Crating and uncrating if (PluginManager.Module.STORAGE.isEnabled()) { - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedWood.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCobblestone.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedDirt.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedStone.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedBrick.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCacti.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSand.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedObsidian.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedNetherrack.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSoulsand.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSandstone.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedBogearth.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedHumus.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedNetherbrick.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedPeat.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedApatite.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedFertilizer.getItemStack()); - RecipeManagers.carpenterManager.addCrating("ingotTin", ForestryItem.ingotTin.getItemStack(), ForestryItem.cratedTin.getItemStack()); - RecipeManagers.carpenterManager.addCrating("ingotCopper", ForestryItem.ingotCopper.getItemStack(), ForestryItem.cratedCopper.getItemStack()); - RecipeManagers.carpenterManager.addCrating("ingotBronze", ForestryItem.ingotBronze.getItemStack(), ForestryItem.cratedBronze.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedWheat.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedMycelium.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedMulch.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCookies.getItemStack()); - - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedRedstone.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedLapis.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedReeds.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedClay.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedGlowstone.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedApples.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedNetherwart.getItemStack()); - - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedPhosphor.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedAsh.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCharcoal.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedGravel.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCoal.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSeeds.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSaplings.getItemStack()); - - if (PluginManager.Module.APICULTURE.isEnabled()) { - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedHoneycombs.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedBeeswax.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedPollen.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedPropolis.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedHoneydew.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedRoyalJelly.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedCocoaComb.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedSimmeringCombs.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedStringyCombs.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedFrozenCombs.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedDrippingCombs.getItemStack()); - RecipeManagers.carpenterManager.addCrating(ForestryItem.cratedRefractoryWax.getItemStack()); - } + PluginStorage.createCrateRecipes(); } } diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 52a9aa371..0dd38e3e7 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -27,6 +27,7 @@ import forestry.core.config.Config; import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; +import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; @@ -230,27 +231,27 @@ public class PluginIC2 extends ForestryPlugin { @Optional.Method(modid = "IC2") protected void registerCrates() { if (resin != null) { - ForestryItem.cratedResin.registerItem(new ItemCrated(resin), "cratedResin"); + ForestryCrate.registerCrate(resin, "cratedResin"); } if (rubber != null) { - ForestryItem.cratedRubber.registerItem(new ItemCrated(rubber), "cratedRubber"); + ForestryCrate.registerCrate(rubber, "cratedRubber"); } if (scrap != null) { - ForestryItem.cratedScrap.registerItem(new ItemCrated(scrap), "cratedScrap"); + ForestryCrate.registerCrate(scrap, "cratedScrap"); } if (uuMatter != null) { - ForestryItem.cratedUUM.registerItem(new ItemCrated(uuMatter), "cratedUUM"); + ForestryCrate.registerCrate(uuMatter, "cratedUUM"); } if (silver != null) { - ForestryItem.cratedSilver.registerItem(new ItemCrated(silver), "cratedSilver"); + ForestryCrate.registerCrate(silver, "cratedSilver").setUsesOreDict(true); } if (brass != null) { - ForestryItem.cratedBrass.registerItem(new ItemCrated(brass), "cratedBrass"); + ForestryCrate.registerCrate(brass, "cratedBrass").setUsesOreDict(true); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 1bae63f45..ca9033457 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -13,6 +13,7 @@ package forestry.plugins; import java.text.NumberFormat; import java.text.ParseException; import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,6 +82,9 @@ import forestry.storage.proxy.ProxyStorage; @Plugin(pluginID = "Storage", name = "Storage", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.storage.description") public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandler { + private static final List crates = new ArrayList(); + private static final String CONFIG_CATEGORY = "backpacks"; + @SidedProxy(clientSide = "forestry.storage.proxy.ClientProxyStorage", serverSide = "forestry.storage.proxy.ProxyStorage") public static ProxyStorage proxy; private final ArrayList minerItems = new ArrayList(); @@ -89,8 +93,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl private final ArrayList hunterItems = new ArrayList(); private final ArrayList adventurerItems = new ArrayList(); private final ArrayList builderItems = new ArrayList(); - private final static String CONFIG_CATEGORY = "backpacks"; - Configuration config; + private Configuration config; @Override @SuppressWarnings({"unchecked","rawtypes"}) @@ -142,6 +145,22 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl BackpackManager.definitions.get("builder").addValidItems(builderItems); } + public static void registerCrate(ItemCrated crate) { + proxy.registerCrate(crate); + crates.add(crate); + } + + public static void createCrateRecipes() { + for (ItemCrated crate : crates) { + ItemStack itemStack = new ItemStack(crate); + if (crate.usesOreDict()) { + RecipeManagers.carpenterManager.addCratingWithOreDict(itemStack); + } else { + RecipeManagers.carpenterManager.addCrating(itemStack); + } + } + } + public static void addBackpackItem(String pack, ItemStack stack) { if (stack == null) return; From 7183d734f0a2918e8cba7c2d36c0dec66a2bb0c5 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 25 Dec 2014 23:44:18 -0800 Subject: [PATCH 109/175] Close #354 Add Crated Potatoes and Crated Carrots --- src/main/java/forestry/plugins/PluginCore.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index d585c4c04..c48655cb1 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -314,6 +314,8 @@ public class PluginCore extends ForestryPlugin { ForestryCrate.registerCrate(Blocks.gravel, "cratedGravel"); ForestryCrate.registerCrate(Items.wheat_seeds, "cratedSeeds"); ForestryCrate.registerCrate(Blocks.sapling, "cratedSaplings"); + ForestryCrate.registerCrate(Items.potato, "cratedPotatoes"); + ForestryCrate.registerCrate(Items.carrot, "cratedCarrots"); } @Override From d652cd7a9baef2d42575519a3cc526fd1b93533b Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 25 Dec 2014 23:54:49 -0800 Subject: [PATCH 110/175] Minor cleanup in MachineCarpenter --- .../factory/gadgets/MachineCarpenter.java | 82 ++++++------------- 1 file changed, 23 insertions(+), 59 deletions(-) diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 990e78c9c..4e344902b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -10,9 +10,30 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.oredict.OreDictionary; + import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICarpenterManager; -import forestry.api.recipes.IGenericCrate; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.Defaults; @@ -26,7 +47,6 @@ import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.items.ItemCrated; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; @@ -34,26 +54,6 @@ import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.gui.ContainerCarpenter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.oredict.OreDictionary; public class MachineCarpenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -101,25 +101,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return internal.matches(inventorycrafting, world); } - public boolean hasLiquid(FluidStack resource) { - if (liquid != null && resource != null) - return liquid.isFluidEqual(resource); - else - return false; - } - - public boolean hasBox(ItemStack resource) { - if (box == null && resource == null) - return true; - else if (box == null) - return true; - - if (box.getItemDamage() > 0) - return box.isItemEqual(resource); - else - return box.getItem() == resource.getItem(); - } - public boolean isIngredient(ItemStack resource) { return internal.isIngredient(resource); } @@ -192,10 +173,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return null; } - public static boolean isResourceLiquid(FluidStack liquid) { - return recipeFluids.contains(liquid.getFluid()); - } - public static boolean isBox(ItemStack resource) { for (Recipe recipe : recipes) { if (StackUtils.isIdenticalItem(recipe.getBox(), resource)) @@ -290,20 +267,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL tankManager.readTanksFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("CraftItems")) - craftingInventory.readFromNBT(nbttagcompound); - else { - // FIXME: Legacy conversion for carpenters <= 2.2.2.2 - NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10); - - for (int j = 0; j < nbttaglist.tagCount(); ++j) { - NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(j); - int index = nbttagcompound2.getByte("Slot"); - if (index < 9) - craftingInventory.setInventorySlotContents(index, ItemStack.loadItemStackFromNBT(nbttagcompound2)); - } - - } + craftingInventory.readFromNBT(nbttagcompound); // Load pending product if (nbttagcompound.hasKey("PendingProduct")) { From 676361928940f257720a61e796362e1941bad09e Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 02:13:39 -0800 Subject: [PATCH 111/175] Expose crate registration to the API --- api/forestry | 2 +- .../forestry/core/config/ForestryCrate.java | 46 ---------- .../java/forestry/core/items/ItemCrated.java | 10 +-- .../forestry/plugins/PluginApiculture.java | 72 ++++++++-------- .../java/forestry/plugins/PluginCore.java | 86 ++++++++++--------- src/main/java/forestry/plugins/PluginIC2.java | 32 ++++--- .../java/forestry/plugins/PluginStorage.java | 6 +- .../java/forestry/storage/CrateRegistry.java | 62 +++++++++++++ 8 files changed, 172 insertions(+), 144 deletions(-) delete mode 100644 src/main/java/forestry/core/config/ForestryCrate.java create mode 100644 src/main/java/forestry/storage/CrateRegistry.java diff --git a/api/forestry b/api/forestry index f94ccd6d4..de0260bad 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit f94ccd6d4aaca8851a5a67d468ada074fe65d148 +Subproject commit de0260bad67c805e14a159d97646e244542bd446 diff --git a/src/main/java/forestry/core/config/ForestryCrate.java b/src/main/java/forestry/core/config/ForestryCrate.java deleted file mode 100644 index 004aa76b6..000000000 --- a/src/main/java/forestry/core/config/ForestryCrate.java +++ /dev/null @@ -1,46 +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.config; - -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import forestry.core.items.ItemCrated; -import forestry.core.proxy.Proxies; -import forestry.plugins.PluginManager; -import forestry.plugins.PluginStorage; - -public class ForestryCrate { - - public static ItemCrated registerCrate(Item item, String name) { - return registerCrate(new ItemCrated(new ItemStack(item)), name); - } - - public static ItemCrated registerCrate(Block block, String name) { - return registerCrate(new ItemCrated(new ItemStack(block)), name); - } - - public static ItemCrated registerCrate(ItemStack stack, String name) { - return registerCrate(new ItemCrated(stack), name); - } - - public static ItemCrated registerCrate(ItemCrated crate, String name) { - if (!EnumSet.of(PluginManager.Stage.PRE_INIT, PluginManager.Stage.INIT).contains(PluginManager.getStage())) - throw new RuntimeException("Tried to register Item outside of Pre-Init or Init"); - crate.setUnlocalizedName("for." + name); - Proxies.common.registerItem(crate); - PluginStorage.registerCrate(crate); - return crate; - } -} diff --git a/src/main/java/forestry/core/items/ItemCrated.java b/src/main/java/forestry/core/items/ItemCrated.java index 41d7b0a80..013301a27 100755 --- a/src/main/java/forestry/core/items/ItemCrated.java +++ b/src/main/java/forestry/core/items/ItemCrated.java @@ -29,14 +29,11 @@ import forestry.core.utils.StringUtil; public class ItemCrated extends Item implements IGenericCrate { - private ItemStack contained; - private boolean usesOreDict = false; + private final ItemStack contained; + private final boolean usesOreDict; - public ItemCrated(ItemStack contained) { + public ItemCrated(ItemStack contained, boolean usesOreDict) { this.contained = contained; - } - - public void setUsesOreDict(boolean usesOreDict) { this.usesOreDict = usesOreDict; } @@ -46,7 +43,6 @@ public class ItemCrated extends Item implements IGenericCrate { @Override public void setContained(ItemStack crated, ItemStack contained) { - this.contained = contained; } @Override diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 5e82b464e..7f3109ea6 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -10,6 +10,28 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.util.IIcon; +import net.minecraft.util.WeightedRandomChestContent; + +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -20,6 +42,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -37,6 +60,8 @@ import forestry.api.genetics.IAllele; import forestry.api.genetics.IClassification; import forestry.api.genetics.IClassification.EnumClassLevel; import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; import forestry.apiculture.FlowerProviderCacti; import forestry.apiculture.FlowerProviderEnd; import forestry.apiculture.FlowerProviderGourd; @@ -119,7 +144,6 @@ import forestry.core.config.Config; import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.config.Property; import forestry.core.fluids.Fluids; @@ -130,7 +154,6 @@ import forestry.core.genetics.Allele; import forestry.core.interfaces.IOreDictionaryHandler; import forestry.core.interfaces.IPacketHandler; import forestry.core.interfaces.ISaveEventHandler; -import forestry.core.items.ItemCrated; import forestry.core.items.ItemForestry; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemOverlay; @@ -139,25 +162,6 @@ import forestry.core.items.ItemScoop; import forestry.core.proxy.Proxies; import forestry.core.render.EntitySnowFX; import forestry.core.utils.ShapedRecipeCustom; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.util.IIcon; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; @Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description") public class PluginApiculture extends ForestryPlugin { @@ -432,21 +436,21 @@ public class PluginApiculture extends ForestryPlugin { @Override protected void registerCrates() { - ForestryCrate.registerCrate(ForestryItem.beeswax.getItemStack(), "cratedBeeswax"); - ForestryCrate.registerCrate(ForestryItem.pollenCluster.getItemStack(), "cratedPollen"); - ForestryCrate.registerCrate(ForestryItem.propolis.getItemStack(), "cratedPropolis"); - ForestryCrate.registerCrate(ForestryItem.honeydew.getItemStack(), "cratedHoneydew"); - ForestryCrate.registerCrate(ForestryItem.royalJelly.getItemStack(), "cratedRoyalJelly"); + ICrateRegistry crateRegistry = StorageManager.crateRegistry; + crateRegistry.registerCrate(ForestryItem.beeswax.getItemStack(), "cratedBeeswax"); + crateRegistry.registerCrate(ForestryItem.pollenCluster.getItemStack(), "cratedPollen"); + crateRegistry.registerCrate(ForestryItem.propolis.getItemStack(), "cratedPropolis"); + crateRegistry.registerCrate(ForestryItem.honeydew.getItemStack(), "cratedHoneydew"); + crateRegistry.registerCrate(ForestryItem.royalJelly.getItemStack(), "cratedRoyalJelly"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 0), "cratedHoneycombs"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 1), "cratedCocoaComb"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 2), "cratedSimmeringCombs"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 3), "cratedStringyCombs"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 4), "cratedFrozenCombs"); - ForestryCrate.registerCrate(ForestryItem.beeComb.getItemStack(1, 5), "cratedDrippingCombs"); - - ForestryCrate.registerCrate(ForestryItem.refractoryWax.getItemStack(), "cratedRefractoryWax"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 0), "cratedHoneycombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 1), "cratedCocoaComb"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 2), "cratedSimmeringCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 3), "cratedStringyCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 4), "cratedFrozenCombs"); + crateRegistry.registerCrate(ForestryItem.beeComb.getItemStack(1, 5), "cratedDrippingCombs"); + crateRegistry.registerCrate(ForestryItem.refractoryWax.getItemStack(), "cratedRefractoryWax"); } @Override diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index c48655cb1..1d88ebb75 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -28,6 +28,8 @@ import cpw.mods.fml.common.network.IGuiHandler; import forestry.api.circuits.ChipsetManager; import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; import forestry.core.CreativeTabForestry; import forestry.core.GameMode; import forestry.core.PickupHandlerCore; @@ -41,7 +43,6 @@ import forestry.core.commands.RootCommand; import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.BlockResource; @@ -58,7 +59,6 @@ import forestry.core.interfaces.IPickupHandler; import forestry.core.interfaces.ISaveEventHandler; import forestry.core.items.ItemArmorNaturalist; import forestry.core.items.ItemAssemblyKit; -import forestry.core.items.ItemCrated; import forestry.core.items.ItemForestry; import forestry.core.items.ItemForestryBlock; import forestry.core.items.ItemForestryPickaxe; @@ -276,46 +276,48 @@ public class PluginCore extends ForestryPlugin { @Override protected void registerCrates() { - ForestryCrate.registerCrate(Blocks.log, "cratedWood"); - ForestryCrate.registerCrate(Blocks.cobblestone, "cratedCobblestone"); - ForestryCrate.registerCrate(Blocks.dirt, "cratedDirt"); - ForestryCrate.registerCrate(Blocks.stone, "cratedStone"); - ForestryCrate.registerCrate(Blocks.brick_block, "cratedBrick"); - ForestryCrate.registerCrate(Blocks.cactus, "cratedCacti"); - ForestryCrate.registerCrate(Blocks.sand, "cratedSand"); - ForestryCrate.registerCrate(Blocks.obsidian, "cratedObsidian"); - ForestryCrate.registerCrate(Blocks.netherrack, "cratedNetherrack"); - ForestryCrate.registerCrate(Blocks.soul_sand, "cratedSoulsand"); - ForestryCrate.registerCrate(Blocks.sandstone, "cratedSandstone"); - ForestryCrate.registerCrate(ForestryBlock.soil.getItemStack(1, 0), "cratedHumus"); - ForestryCrate.registerCrate(ForestryBlock.soil.getItemStack(1, 1), "cratedBogearth"); - ForestryCrate.registerCrate(Blocks.nether_brick, "cratedNetherbrick"); - ForestryCrate.registerCrate(ForestryItem.peat.item(), "cratedPeat"); - ForestryCrate.registerCrate(ForestryItem.apatite.item(), "cratedApatite"); - ForestryCrate.registerCrate(ForestryItem.fertilizerCompound.item(), "cratedFertilizer"); - ForestryCrate.registerCrate(ForestryItem.ingotTin.item(), "cratedTin").setUsesOreDict(true); - ForestryCrate.registerCrate(ForestryItem.ingotCopper.item(), "cratedCopper").setUsesOreDict(true); - ForestryCrate.registerCrate(ForestryItem.ingotBronze.item(), "cratedBronze").setUsesOreDict(true); - ForestryCrate.registerCrate(Items.wheat, "cratedWheat"); - ForestryCrate.registerCrate(Blocks.mycelium, "cratedMycelium"); - ForestryCrate.registerCrate(ForestryItem.mulch.item(), "cratedMulch"); - ForestryCrate.registerCrate(Items.cookie, "cratedCookies"); - ForestryCrate.registerCrate(Items.redstone, "cratedRedstone"); - ForestryCrate.registerCrate(new ItemStack(Items.dye, 1, 4), "cratedLapis"); - ForestryCrate.registerCrate(Items.reeds, "cratedReeds"); - ForestryCrate.registerCrate(Items.clay_ball, "cratedClay"); - ForestryCrate.registerCrate(Items.glowstone_dust, "cratedGlowstone"); - ForestryCrate.registerCrate(Items.apple, "cratedApples"); - ForestryCrate.registerCrate(new ItemStack(Items.nether_wart), "cratedNetherwart"); - ForestryCrate.registerCrate(ForestryItem.phosphor.item(), "cratedPhosphor"); - ForestryCrate.registerCrate(ForestryItem.ash.item(), "cratedAsh"); - ForestryCrate.registerCrate(new ItemStack(Items.coal, 1, 1), "cratedCharcoal"); - ForestryCrate.registerCrate(new ItemStack(Items.coal, 1, 0), "cratedCoal"); - ForestryCrate.registerCrate(Blocks.gravel, "cratedGravel"); - ForestryCrate.registerCrate(Items.wheat_seeds, "cratedSeeds"); - ForestryCrate.registerCrate(Blocks.sapling, "cratedSaplings"); - ForestryCrate.registerCrate(Items.potato, "cratedPotatoes"); - ForestryCrate.registerCrate(Items.carrot, "cratedCarrots"); + ICrateRegistry crateRegistry = StorageManager.crateRegistry; + crateRegistry.registerCrate(Blocks.log, "cratedWood"); + crateRegistry.registerCrate(Blocks.cobblestone, "cratedCobblestone"); + crateRegistry.registerCrate(Blocks.dirt, "cratedDirt"); + crateRegistry.registerCrate(Blocks.stone, "cratedStone"); + crateRegistry.registerCrate(Blocks.brick_block, "cratedBrick"); + crateRegistry.registerCrate(Blocks.cactus, "cratedCacti"); + crateRegistry.registerCrate(Blocks.sand, "cratedSand"); + crateRegistry.registerCrate(Blocks.obsidian, "cratedObsidian"); + crateRegistry.registerCrate(Blocks.netherrack, "cratedNetherrack"); + crateRegistry.registerCrate(Blocks.soul_sand, "cratedSoulsand"); + crateRegistry.registerCrate(Blocks.sandstone, "cratedSandstone"); + crateRegistry.registerCrate(ForestryBlock.soil.getItemStack(1, 0), "cratedHumus"); + crateRegistry.registerCrate(ForestryBlock.soil.getItemStack(1, 1), "cratedBogearth"); + crateRegistry.registerCrate(Blocks.nether_brick, "cratedNetherbrick"); + crateRegistry.registerCrate(ForestryItem.peat.item(), "cratedPeat"); + crateRegistry.registerCrate(ForestryItem.apatite.item(), "cratedApatite"); + crateRegistry.registerCrate(ForestryItem.fertilizerCompound.item(), "cratedFertilizer"); + crateRegistry.registerCrate(Items.wheat, "cratedWheat"); + crateRegistry.registerCrate(Blocks.mycelium, "cratedMycelium"); + crateRegistry.registerCrate(ForestryItem.mulch.item(), "cratedMulch"); + crateRegistry.registerCrate(Items.cookie, "cratedCookies"); + crateRegistry.registerCrate(Items.redstone, "cratedRedstone"); + crateRegistry.registerCrate(new ItemStack(Items.dye, 1, 4), "cratedLapis"); + crateRegistry.registerCrate(Items.reeds, "cratedReeds"); + crateRegistry.registerCrate(Items.clay_ball, "cratedClay"); + crateRegistry.registerCrate(Items.glowstone_dust, "cratedGlowstone"); + crateRegistry.registerCrate(Items.apple, "cratedApples"); + crateRegistry.registerCrate(new ItemStack(Items.nether_wart), "cratedNetherwart"); + crateRegistry.registerCrate(ForestryItem.phosphor.item(), "cratedPhosphor"); + crateRegistry.registerCrate(ForestryItem.ash.item(), "cratedAsh"); + crateRegistry.registerCrate(new ItemStack(Items.coal, 1, 1), "cratedCharcoal"); + crateRegistry.registerCrate(new ItemStack(Items.coal, 1, 0), "cratedCoal"); + crateRegistry.registerCrate(Blocks.gravel, "cratedGravel"); + crateRegistry.registerCrate(Items.wheat_seeds, "cratedSeeds"); + crateRegistry.registerCrate(Blocks.sapling, "cratedSaplings"); + crateRegistry.registerCrate(Items.potato, "cratedPotatoes"); + crateRegistry.registerCrate(Items.carrot, "cratedCarrots"); + + crateRegistry.registerCrateUsingOreDict(ForestryItem.ingotTin.item(), "cratedTin"); + crateRegistry.registerCrateUsingOreDict(ForestryItem.ingotCopper.item(), "cratedCopper"); + crateRegistry.registerCrateUsingOreDict(ForestryItem.ingotBronze.item(), "cratedBronze"); } @Override diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 0dd38e3e7..95a228f25 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -10,15 +10,26 @@ ******************************************************************************/ package forestry.plugins; +import java.util.EnumSet; + +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.Optional; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameData; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitLayout; import forestry.api.fuels.FuelManager; import forestry.api.fuels.GeneratorFuel; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; +import forestry.api.storage.ICrateRegistry; +import forestry.api.storage.StorageManager; import forestry.core.GameMode; import forestry.core.circuits.Circuit; import forestry.core.circuits.CircuitId; @@ -27,12 +38,10 @@ import forestry.core.config.Config; import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryCrate; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; -import forestry.core.items.ItemCrated; import forestry.core.proxy.Proxies; import forestry.core.utils.LiquidHelper; import forestry.core.utils.RecipeUtil; @@ -47,14 +56,10 @@ import forestry.energy.gadgets.EngineTin; import forestry.energy.gadgets.MachineGenerator; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicRubber; + import ic2.api.item.IC2Items; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.Recipes; -import java.util.EnumSet; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; @Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends ForestryPlugin { @@ -230,28 +235,29 @@ public class PluginIC2 extends ForestryPlugin { @Override @Optional.Method(modid = "IC2") protected void registerCrates() { + ICrateRegistry crateRegistry = StorageManager.crateRegistry; if (resin != null) { - ForestryCrate.registerCrate(resin, "cratedResin"); + crateRegistry.registerCrate(resin, "cratedResin"); } if (rubber != null) { - ForestryCrate.registerCrate(rubber, "cratedRubber"); + crateRegistry.registerCrate(rubber, "cratedRubber"); } if (scrap != null) { - ForestryCrate.registerCrate(scrap, "cratedScrap"); + crateRegistry.registerCrate(scrap, "cratedScrap"); } if (uuMatter != null) { - ForestryCrate.registerCrate(uuMatter, "cratedUUM"); + crateRegistry.registerCrate(uuMatter, "cratedUUM"); } if (silver != null) { - ForestryCrate.registerCrate(silver, "cratedSilver").setUsesOreDict(true); + crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver"); } if (brass != null) { - ForestryCrate.registerCrate(brass, "cratedBrass").setUsesOreDict(true); + crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass"); } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index ca9033457..1d35eaa82 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -56,6 +56,7 @@ import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; import forestry.api.storage.EnumBackpackType; import forestry.api.storage.IBackpackDefinition; +import forestry.api.storage.StorageManager; import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; @@ -71,6 +72,7 @@ import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.storage.BackpackDefinition; import forestry.storage.BackpackHelper; +import forestry.storage.CrateRegistry; import forestry.storage.GuiHandlerStorage; import forestry.storage.PickupHandlerStorage; import forestry.storage.ResupplyHandler; @@ -108,6 +110,8 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl BackpackManager.backpackItems[3] = hunterItems; BackpackManager.backpackItems[4] = adventurerItems; BackpackManager.backpackItems[5] = builderItems; + + StorageManager.crateRegistry = new CrateRegistry(); } @Override @@ -264,7 +268,7 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl @Override protected void registerItems() { // CRATE - ForestryItem.crate.registerItem((new ItemCrated(null)), "crate"); + ForestryItem.crate.registerItem((new ItemCrated(null, false)), "crate"); // BACKPACKS BackpackDefinition definition; diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java new file mode 100644 index 000000000..8ad509857 --- /dev/null +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -0,0 +1,62 @@ +package forestry.storage; + +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import forestry.api.storage.ICrateRegistry; +import forestry.core.items.ItemCrated; +import forestry.core.proxy.Proxies; +import forestry.plugins.PluginManager; +import forestry.plugins.PluginStorage; + +public class CrateRegistry implements ICrateRegistry { + + public void registerCrate(ItemStack stack, String uid, boolean useOreDict) { + if (!EnumSet.of(PluginManager.Stage.INIT).contains(PluginManager.getStage())) + throw new RuntimeException("Tried to make a crate outside of Init"); + + if (stack == null || stack.getItem() == null) + throw new RuntimeException("Tried to make a crate without an item"); + + if (uid == null) + throw new RuntimeException("Tried to make a crate without a uid"); + + ItemCrated crate = new ItemCrated(stack, useOreDict); + crate.setUnlocalizedName(uid); + Proxies.common.registerItem(crate); + PluginStorage.registerCrate(crate); + } + + @Override + public void registerCrate(Item item, String uid) { + registerCrate(new ItemStack(item), uid, false); + } + + @Override + public void registerCrateUsingOreDict(Item item, String uid) { + registerCrate(new ItemStack(item), uid, true); + } + + @Override + public void registerCrate(Block block, String uid) { + registerCrate(new ItemStack(block), uid, false); + } + + @Override + public void registerCrateUsingOreDict(Block block, String uid) { + registerCrate(new ItemStack(block), uid, true); + } + + @Override + public void registerCrate(ItemStack stack, String uid) { + registerCrate(stack, uid, false); + } + + @Override + public void registerCrateUsingOreDict(ItemStack stack, String uid) { + registerCrate(stack, uid, true); + } +} From e23a38e1f1905f3d6e9ef90cf3c739317f0651f5 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 18:06:18 -0800 Subject: [PATCH 112/175] Fix #393 Farm block icons are sometimes black --- src/main/java/forestry/farming/render/FarmItemRenderer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/farming/render/FarmItemRenderer.java b/src/main/java/forestry/farming/render/FarmItemRenderer.java index f5b8898e0..1f65bf0c5 100755 --- a/src/main/java/forestry/farming/render/FarmItemRenderer.java +++ b/src/main/java/forestry/farming/render/FarmItemRenderer.java @@ -25,6 +25,10 @@ import forestry.farming.gadgets.EnumFarmBlock; public class FarmItemRenderer implements IItemRenderer { private void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; BlockFarm block = (BlockFarm) StackUtils.getBlock(item); @@ -76,6 +80,7 @@ public class FarmItemRenderer implements IItemRenderer { block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopAttrib(); } @Override From f5a73db68d0c87676b142222ec319033e3ab1632 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 21:42:11 -0800 Subject: [PATCH 113/175] Minor Cleanup --- .../java/forestry/apiculture/gadgets/BlockBeehives.java | 1 + src/main/java/forestry/plugins/PluginApiculture.java | 9 --------- src/main/java/forestry/storage/CrateRegistry.java | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index 72f9798ee..4eaccd7c5 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -41,6 +41,7 @@ public class BlockBeehives extends BlockContainer { setLightLevel(0.8f); setHardness(1.0f); setCreativeTab(Tabs.tabApiculture); + setHarvestLevel("scoop", 0); } @Override diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 7f3109ea6..4c4b366bc 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -237,15 +237,6 @@ public class PluginApiculture extends ForestryPlugin { PluginApiculture.proxy.getRendererAnalyzer(Defaults.TEXTURE_PATH_BLOCKS + "/analyzer_"))); ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemForestryBlock.class, "beehives"); - ForestryBlock.beehives.block().setHarvestLevel("pickaxe", 1, 0); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 1); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 2); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 3); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 4); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 5); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 6); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 7); - ForestryBlock.beehives.block().setHarvestLevel("scoop", 0, 8); createHives(); diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java index 8ad509857..2734668c6 100644 --- a/src/main/java/forestry/storage/CrateRegistry.java +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -14,7 +14,7 @@ import forestry.plugins.PluginStorage; public class CrateRegistry implements ICrateRegistry { - public void registerCrate(ItemStack stack, String uid, boolean useOreDict) { + private void registerCrate(ItemStack stack, String uid, boolean useOreDict) { if (!EnumSet.of(PluginManager.Stage.INIT).contains(PluginManager.getStage())) throw new RuntimeException("Tried to make a crate outside of Init"); From d32530caba35f55848b983d6ffd84f450b02761d Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 22:13:47 -0800 Subject: [PATCH 114/175] Fix #409 Custom book duplication on Worktable crashes client --- .../java/forestry/core/utils/RecipeUtil.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/core/utils/RecipeUtil.java b/src/main/java/forestry/core/utils/RecipeUtil.java index 258bbbebc..af8054b0d 100755 --- a/src/main/java/forestry/core/utils/RecipeUtil.java +++ b/src/main/java/forestry/core/utils/RecipeUtil.java @@ -10,22 +10,25 @@ ******************************************************************************/ package forestry.core.utils; -import forestry.api.recipes.RecipeManagers; -import forestry.core.fluids.Fluids; -import forestry.core.gui.ContainerDummy; -import forestry.core.interfaces.IDescriptiveRecipe; -import forestry.core.proxy.Proxies; import java.util.ArrayList; import java.util.Collections; import java.util.List; + import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.world.World; + import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; +import forestry.api.recipes.RecipeManagers; +import forestry.core.fluids.Fluids; +import forestry.core.gui.ContainerDummy; +import forestry.core.interfaces.IDescriptiveRecipe; +import forestry.core.proxy.Proxies; + public class RecipeUtil { private static final Container DUMMY_CONTAINER = new ContainerDummy(); @@ -122,7 +125,7 @@ public class RecipeUtil { // Use crafting equivalent (not oredict) items first for (ItemStack stockStack : stockCopy) { if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, false, false)) { - ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); + ItemStack stack = StackUtils.createSplitStack(stockStack, 1); stockStack.stackSize--; crafting.setInventorySlotContents(slot, stack); break; @@ -133,7 +136,7 @@ public class RecipeUtil { if (crafting.getStackInSlot(slot) == null) { for (ItemStack stockStack : stockCopy) { if (stockStack.stackSize > 0 && StackUtils.isCraftingEquivalent(recipeStack, stockStack, true, true)) { - ItemStack stack = new ItemStack(stockStack.getItem(), 1, stockStack.getItemDamage()); + ItemStack stack = StackUtils.createSplitStack(stockStack, 1); stockStack.stackSize--; crafting.setInventorySlotContents(slot, stack); break; From 6346039f144fc3e9b3290a25c6edd0c5e04b5c16 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 22:14:22 -0800 Subject: [PATCH 115/175] Fix worktable lock icon rendering poorly over enchanted items --- src/main/java/forestry/factory/gui/GuiWorktable.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index 36248e8b5..c5d4fd342 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -54,10 +54,11 @@ public class GuiWorktable extends GuiForestryTitled { ItemStack output = getOutputStack(); if (output != null) manager.gui.drawItemStack(output, startX + xPos, startY + yPos); - //RenderHelper.disableStandardItemLighting(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (worktable.getMemory().isLocked(slotNumber)) { manager.gui.setZLevel(110f); From defbdc8e71e6549dbe219194a22e0053ac55a3e3 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 22:24:31 -0800 Subject: [PATCH 116/175] Fix #407 Crash after naming a new Trade Station --- src/main/java/forestry/mail/gui/ContainerTradeName.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index 6ccc21e62..95a63d41e 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -46,13 +46,13 @@ public class ContainerTradeName extends ContainerForestry { PacketUpdate packet = new PacketUpdate(PacketIds.TRADING_ADDRESS_SET, payload); Proxies.net.sendToServer(packet); - IMailAddress address = PostManager.postRegistry.getValidMailAddress(machine.getWorld(), addressName); + IMailAddress address = PostManager.postRegistry.getMailAddress(addressName); machine.setAddress(address); } public void handleSetAddress(PacketUpdate packet) { String addressName = packet.payload.stringPayload[0]; - IMailAddress address = PostManager.postRegistry.getValidMailAddress(machine.getWorld(), addressName); + IMailAddress address = PostManager.postRegistry.getMailAddress(addressName); machine.setAddress(address); } From 550462221cf5e8d9fa9d8c5449f812aa9d2533c2 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 23:29:12 -0800 Subject: [PATCH 117/175] Cleanup --- src/main/java/forestry/core/WorldGenerator.java | 11 +++++++---- src/main/java/forestry/plugins/PluginCore.java | 9 ++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/core/WorldGenerator.java b/src/main/java/forestry/core/WorldGenerator.java index 5b199687d..0b8d11d6b 100755 --- a/src/main/java/forestry/core/WorldGenerator.java +++ b/src/main/java/forestry/core/WorldGenerator.java @@ -10,15 +10,18 @@ ******************************************************************************/ package forestry.core; +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + import cpw.mods.fml.common.IWorldGenerator; + import forestry.core.config.Config; import forestry.core.config.ForestryBlock; import forestry.core.proxy.Proxies; import forestry.core.worldgen.WorldGenMinableMeta; import forestry.plugins.PluginManager; -import java.util.Random; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; public class WorldGenerator implements IWorldGenerator { @@ -30,7 +33,7 @@ public class WorldGenerator implements IWorldGenerator { public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (apatiteGenerator == null) { - apatiteGenerator = new WorldGenMinableMeta(ForestryBlock.resources.block(), 0, 36); + apatiteGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 0, 36); copperGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 1, 6); tinGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 2, 6); } diff --git a/src/main/java/forestry/plugins/PluginCore.java b/src/main/java/forestry/plugins/PluginCore.java index 1d88ebb75..d338d5e4d 100755 --- a/src/main/java/forestry/plugins/PluginCore.java +++ b/src/main/java/forestry/plugins/PluginCore.java @@ -112,19 +112,14 @@ public class PluginCore extends ForestryPlugin { ForestryBlock.soil.block().setHarvestLevel("shovel", 0, 1); ForestryBlock.resources.registerBlock(new BlockResource(), ItemForestryBlock.class, "resources"); - ForestryBlock.resources.block().setHarvestLevel("pickaxe", 1, 0); - ForestryBlock.resources.block().setHarvestLevel("pickaxe", 1, 1); - ForestryBlock.resources.block().setHarvestLevel("pickaxe", 1, 2); + ForestryBlock.resources.block().setHarvestLevel("pickaxe", 1); OreDictionary.registerOre("oreApatite", ForestryBlock.resources.getItemStack(1, 0)); OreDictionary.registerOre("oreCopper", ForestryBlock.resources.getItemStack(1, 1)); OreDictionary.registerOre("oreTin", ForestryBlock.resources.getItemStack(1, 2)); ForestryBlock.resourceStorage.registerBlock(new BlockResourceStorageBlock(), ItemForestryBlock.class, "resourceStorage"); - ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0, 0); - ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0, 1); - ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0, 2); - ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0, 3); + ForestryBlock.resourceStorage.block().setHarvestLevel("pickaxe", 0); OreDictionary.registerOre("blockApatite", ForestryBlock.resourceStorage.getItemStack(1, 0)); OreDictionary.registerOre("blockCopper", ForestryBlock.resourceStorage.getItemStack(1, 1)); From 36508a191adeea7ab60caffb1f322e940a044561 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 23:40:52 -0800 Subject: [PATCH 118/175] Fix #408 Bronze and Copper storage blocks break into Apatite blocks --- .../forestry/core/gadgets/BlockResourceStorageBlock.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java index 622f5e933..cd38198de 100644 --- a/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java +++ b/src/main/java/forestry/core/gadgets/BlockResourceStorageBlock.java @@ -39,6 +39,11 @@ public class BlockResourceStorageBlock extends Block { itemList.add(new ItemStack(this, 1, 2)); itemList.add(new ItemStack(this, 1, 3)); } + + @Override + public int damageDropped(int damage) { + return damage; + } @Override @SideOnly(Side.CLIENT) From 3c5c62425129eb802df80e0985fadcfa389db357 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 26 Dec 2014 23:42:13 -0800 Subject: [PATCH 119/175] Update development Forge (not the required version) --- application.properties | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application.properties b/application.properties index 8c91f8142..75c3a02a7 100644 --- a/application.properties +++ b/application.properties @@ -1,6 +1,5 @@ mcversion=1.7.10 -forgeversion=10.13.0.1207 +forgeversion=10.13.2.1277 version_major=3 version_minor=3 version_patch=0 - From e78021510070c6a41304d1bec01fc84a24e181bf Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 27 Dec 2014 12:02:13 -0800 Subject: [PATCH 120/175] Cleanup --- .../core/render/RenderEscritoire.java | 19 ++++++++++--------- .../java/forestry/storage/CrateRegistry.java | 14 +++++++++++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/core/render/RenderEscritoire.java b/src/main/java/forestry/core/render/RenderEscritoire.java index 4a03a16ec..5d9123a9e 100755 --- a/src/main/java/forestry/core/render/RenderEscritoire.java +++ b/src/main/java/forestry/core/render/RenderEscritoire.java @@ -10,31 +10,32 @@ ******************************************************************************/ package forestry.core.render; -import forestry.core.config.Defaults; -import forestry.core.gadgets.TileEscritoire; -import forestry.core.interfaces.IBlockRenderer; -import forestry.core.proxy.Proxies; -import forestry.core.utils.ForestryResource; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; +import forestry.core.config.Defaults; +import forestry.core.gadgets.TileEscritoire; +import forestry.core.interfaces.IBlockRenderer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ForestryResource; + public class RenderEscritoire extends TileEntitySpecialRenderer implements IBlockRenderer { + private static final ResourceLocation texture = new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/escritoire.png"); private final ModelEscritoire modelEscritoire; - private final ResourceLocation texture = new ForestryResource(Defaults.TEXTURE_PATH_BLOCKS + "/escritoire.png"); - //private final EntityItem dummyEntityItem = new EntityItem(null); - private final RenderItem customRenderItem; public RenderEscritoire() { modelEscritoire = new ModelEscritoire(); - customRenderItem = new RenderItem() { + RenderItem customRenderItem = new RenderItem() { @Override public boolean shouldBob() { return false; diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java index 2734668c6..504025ffc 100644 --- a/src/main/java/forestry/storage/CrateRegistry.java +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -1,7 +1,15 @@ +/******************************************************************************* + * 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.storage; -import java.util.EnumSet; - import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -15,7 +23,7 @@ import forestry.plugins.PluginStorage; public class CrateRegistry implements ICrateRegistry { private void registerCrate(ItemStack stack, String uid, boolean useOreDict) { - if (!EnumSet.of(PluginManager.Stage.INIT).contains(PluginManager.getStage())) + if (PluginManager.getStage() != PluginManager.Stage.INIT) throw new RuntimeException("Tried to make a crate outside of Init"); if (stack == null || stack.getItem() == null) From 00c444a46dde332764af1da49b9df57f82a02aea Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 27 Dec 2014 20:29:34 -0800 Subject: [PATCH 121/175] Improve GUI ItemStack rendering. Fix tooltip hover area --- .../java/forestry/core/gui/GuiForestry.java | 23 ++++++++++++------- .../forestry/core/gui/tooltips/ToolTip.java | 9 ++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 169960341..33ec29a83 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -30,11 +30,14 @@ import forestry.core.utils.FontColour; import java.awt.Color; import java.util.Collection; import java.util.List; + +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -408,6 +411,12 @@ public abstract class GuiForestry extends GuiContainer i } public void drawItemStack(ItemStack stack, int xPos, int yPos) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glTranslatef(0.0F, 0.0F, 32.0F); this.zLevel = 100.0F; itemRender.zLevel = 100.0F; @@ -420,6 +429,9 @@ public abstract class GuiForestry extends GuiContainer i itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos); this.zLevel = 0.0F; itemRender.zLevel = 0.0F; + + RenderHelper.disableStandardItemLighting(); + GL11.glPopAttrib(); } protected class ItemStackWidget extends Widget { @@ -427,24 +439,19 @@ public abstract class GuiForestry extends GuiContainer i public ItemStackWidget(int xPos, int yPos, ItemStack itemStack) { super(widgetManager, xPos, yPos); - - IIcon icon = itemStack.getItem().getIcon(itemStack, 0); - - this.width = icon.getIconWidth(); - this.height = icon.getIconHeight(); this.itemStack = itemStack; } @Override public void draw(int startX, int startY) { - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, itemStack, xPos + startX, yPos + startY); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemStack, xPos + startX, yPos + startY); + drawItemStack(itemStack, xPos + startX, yPos + startY); } @Override public ToolTip getToolTip() { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; ToolTip tip = new ToolTip(); - tip.add(itemStack.getDisplayName()); + tip.add(itemStack.getTooltip(player, false)); return tip; } } diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTip.java b/src/main/java/forestry/core/gui/tooltips/ToolTip.java index 7676e25ea..de09d3434 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTip.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTip.java @@ -41,6 +41,15 @@ public class ToolTip extends ForwardingList { return add(new ToolTipLine(line)); } + public boolean add(List lines) { + boolean changed = false; + for (Object line : lines) { + if (line instanceof String) + changed |= add((String) line); + } + return changed; + } + public void onTick(boolean mouseOver) { if (delay == 0) return; From d55b1190192caecba94a79d20c1770c1b0e7d6af Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 27 Dec 2014 21:58:41 -0800 Subject: [PATCH 122/175] Fix #410 Catalogue has glitched text --- .../java/forestry/core/gui/GuiForestry.java | 15 ++++--- .../forestry/core/gui/tooltips/ToolTip.java | 2 +- .../core/gui/tooltips/ToolTipLine.java | 10 ++--- .../java/forestry/mail/gui/GuiCatalogue.java | 41 +++++++++++++------ .../java/forestry/mail/gui/GuiLetter.java | 11 ++--- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 33ec29a83..5ecee202e 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -41,6 +41,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -248,7 +249,7 @@ public abstract class GuiForestry extends GuiContainer i int y; for (ToolTipLine tip : toolTips) { - y = this.fontRendererObj.getStringWidth(tip.getText()); + y = this.fontRendererObj.getStringWidth(tip.toString()); height += 10 + tip.getSpacing(); if (y > length) @@ -277,17 +278,19 @@ public abstract class GuiForestry extends GuiContainer i 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); + boolean firstLine = true; for (ToolTipLine tip : toolTips) { - String line = tip.getText(); + String line = tip.toString(); - if (tip.getColor() == null) - line = "\u00a77" + line; - else - line = "\u00a7" + tip.getColor().getFormattingCode() + line; + if (!firstLine) { + line = EnumChatFormatting.GRAY + line; + } this.fontRendererObj.drawStringWithShadow(line, x, y, -1); y += 10 + tip.getSpacing(); + + firstLine = false; } this.zLevel = 0.0F; diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTip.java b/src/main/java/forestry/core/gui/tooltips/ToolTip.java index de09d3434..701684388 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTip.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTip.java @@ -74,7 +74,7 @@ public class ToolTip extends ForwardingList { public List convertToStrings() { List tips = new ArrayList(size()); for (ToolTipLine line : this) { - tips.add(line.getText()); + tips.add(line.toString()); } return tips; } diff --git a/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java b/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java index a8fe70cc2..3fcfd02e9 100755 --- a/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java +++ b/src/main/java/forestry/core/gui/tooltips/ToolTipLine.java @@ -40,12 +40,10 @@ public class ToolTipLine { return spacing; } - public String getText() { - return text; - } - - public EnumChatFormatting getColor() { - return color; + public String toString() { + if (color == null) + return text; + return color + text; } } diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 983369f27..0e694c8dc 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -10,26 +10,35 @@ ******************************************************************************/ package forestry.mail.gui; +import java.util.ArrayList; +import java.util.List; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.TradeStationInfo; import forestry.core.config.SessionVars; import forestry.core.gadgets.TileForestry; import forestry.core.gui.GuiForestry; +import forestry.core.gui.widgets.Widget; import forestry.core.utils.StringUtil; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; public class GuiCatalogue extends GuiForestry { + private static final String boldUnderline = EnumChatFormatting.BOLD.toString() + EnumChatFormatting.UNDERLINE; + // GuiButton buttonTrade; // GuiButton buttonClose; private GuiButton buttonFilter; private GuiButton buttonCopy; + private final List tradeInfoWidgets = new ArrayList(); private final ContainerCatalogue container; public GuiCatalogue(EntityPlayer player) { @@ -85,30 +94,36 @@ public class GuiCatalogue extends GuiForestry { private void drawTradePreview(int x, int y) { - fontRendererObj.drawString("\u00A7l\u00A7n" + container.getTradeInfo().address.getName(), x, y, fontColor.get("gui.book")); + fontRendererObj.drawString(boldUnderline + container.getTradeInfo().address.getName(), x, y, fontColor.get("gui.book")); TradeStationInfo info = container.getTradeInfo(); fontRendererObj.drawString(String.format(StringUtil.localize("gui.mail.willtrade"), info.owner.getName()), x, y + 18, fontColor.get("gui.book")); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, info.tradegood, x, y + 28); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, info.tradegood, x, y + 28); + clearTradeInfoWidgets(); + + addTradeInfoWidget(new ItemStackWidget(x - guiLeft, y - guiTop + 28, info.tradegood)); - GL11.glDisable(GL11.GL_LIGHTING); fontRendererObj.drawString(StringUtil.localize("gui.mail.tradefor"), x, y + 46, fontColor.get("gui.book")); - GL11.glEnable(GL11.GL_LIGHTING); for (int i = 0; i < container.getTradeInfo().required.length; i++) { - GL11.glDisable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, info.required[i], x + i * 18, y + 56); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, info.required[i], x + i * 18, y + 56); - GL11.glEnable(GL11.GL_LIGHTING); + addTradeInfoWidget(new ItemStackWidget(x - guiLeft + i * 18, y - guiTop + 56, info.required[i])); } - GL11.glDisable(GL11.GL_LIGHTING); if(info.state.isOk()) - fontRendererObj.drawSplitString("\u00A72" + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); + fontRendererObj.drawSplitString(EnumChatFormatting.DARK_GREEN + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); else - fontRendererObj.drawSplitString("\u00A74" + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); - GL11.glEnable(GL11.GL_LIGHTING); + fontRendererObj.drawSplitString(EnumChatFormatting.DARK_RED + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book")); + } + + private void addTradeInfoWidget(ItemStackWidget widget) { + tradeInfoWidgets.add(widget); + widgetManager.add(widget); + } + + private void clearTradeInfoWidgets() { + for (Widget widget : tradeInfoWidgets) { + widgetManager.remove(widget); + } + tradeInfoWidgets.clear(); } @Override diff --git a/src/main/java/forestry/mail/gui/GuiLetter.java b/src/main/java/forestry/mail/gui/GuiLetter.java index 3135b6c1f..67b519b15 100755 --- a/src/main/java/forestry/mail/gui/GuiLetter.java +++ b/src/main/java/forestry/mail/gui/GuiLetter.java @@ -70,11 +70,10 @@ public class GuiLetter extends GuiForestry { private GuiTextField address; private GuiTextBox text; - boolean addressFocus; - boolean textFocus; - - protected final ArrayList tradeInfoWidgets; + private boolean addressFocus; + private boolean textFocus; + private final ArrayList tradeInfoWidgets; private final ContainerLetter container; public GuiLetter(EntityPlayer player, LetterInventory inventory) { @@ -217,8 +216,10 @@ public class GuiLetter extends GuiForestry { } private void clearTradeInfoWidgets() { - for (Widget widget : tradeInfoWidgets) + for (Widget widget : tradeInfoWidgets) { widgetManager.remove(widget); + } + tradeInfoWidgets.clear(); } @Override From 8f1b1e03f493f44eb3d4d1c21531f072c0b45bb8 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 27 Dec 2014 22:00:51 -0800 Subject: [PATCH 123/175] Use EnumChatFormatting values instead of unicode text --- .../forestry/apiculture/genetics/Bee.java | 9 ++++---- .../forestry/apiculture/items/ItemBeeGE.java | 5 +++-- .../forestry/arboriculture/genetics/Tree.java | 21 ++++++++++++------- .../arboriculture/gui/GuiTreealyzer.java | 6 ++++-- .../forestry/core/TickHandlerCoreClient.java | 7 ++++--- .../forestry/core/circuits/CircuitBoard.java | 5 +++-- .../core/commands/CommandPlugins.java | 18 +++++++--------- .../core/commands/CommandVersion.java | 2 +- .../core/fluids/tanks/FilteredTank.java | 3 ++- .../java/forestry/core/genetics/ItemGE.java | 3 ++- .../core/genetics/ItemResearchNote.java | 5 +++-- .../java/forestry/core/gui/GuiEscritoire.java | 5 ++++- .../lepidopterology/genetics/Butterfly.java | 15 ++++++------- .../forestry/mail/commands/CommandMail.java | 6 ++---- 14 files changed, 63 insertions(+), 47 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 505140fda..a856f7d0b 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -19,6 +19,7 @@ import java.util.Set; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -322,7 +323,7 @@ public class Bee extends IndividualLiving implements IBee { IAlleleBeeSpecies primary = genome.getPrimary(); IAlleleBeeSpecies secondary = genome.getSecondary(); if (!isPureBred(EnumBeeChromosome.SPECIES)) - list.add("\u00A79" + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); + list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED); String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", ""); @@ -334,14 +335,14 @@ public class Bee extends IndividualLiving implements IBee { list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); - list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); + list.add(EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); - list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); + list.add(EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); list.add(genome.getFlowerProvider().getDescription()); if (genome.getNocturnal()) - list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), false)); + list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false)); } @Override diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java index eb5decdff..0a7135150 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java +++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java @@ -34,6 +34,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; public class ItemBeeGE extends ItemGE { @@ -94,9 +95,9 @@ public class ItemBeeGE extends ItemGE { if(type != EnumBeeType.DRONE) { IBee individual = new Bee(itemstack.getTagCompound()); if (individual.isNatural()) - list.add("\u00A7e\u00A7o" + StringUtil.localize("bees.stock.pristine")); + list.add(EnumChatFormatting.YELLOW + EnumChatFormatting.ITALIC.toString() + StringUtil.localize("bees.stock.pristine")); else - list.add("\u00A7e" + StringUtil.localize("bees.stock.ignoble")); + list.add(EnumChatFormatting.YELLOW + StringUtil.localize("bees.stock.ignoble")); } super.addInformation(itemstack, player, list, flag); diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index a8335c0a6..9921df7b9 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -38,6 +38,7 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -274,22 +275,28 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable IAlleleTreeSpecies primary = genome.getPrimary(); IAlleleTreeSpecies secondary = genome.getSecondary(); if (!isPureBred(EnumTreeChromosome.SPECIES)) - list.add("\u00A79" + StringUtil.localize("trees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); - list.add(String.format("\u00A76S: %s, \u00A7cM: %s", genome.getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(), genome.getActiveAllele(EnumTreeChromosome.MATURATION).getName())); - list.add(String.format("\u00A7dH: %s, \u00A7bG: %sx%s", genome.getActiveAllele(EnumTreeChromosome.HEIGHT).getName(), genome.getGirth(), genome.getGirth())); + list.add(EnumChatFormatting.BLUE + StringUtil.localize("trees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); - list.add(String.format("\u00A7eS: %s, \u00A7fY: %s", genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName(), genome.getActiveAllele(EnumTreeChromosome.YIELD).getName())); + String sappiness = EnumChatFormatting.GOLD + "S: " + genome.getActiveAllele(EnumTreeChromosome.SAPPINESS).getName(); + String maturation = EnumChatFormatting.RED + "M: " + genome.getActiveAllele(EnumTreeChromosome.MATURATION).getName(); + String height = EnumChatFormatting.LIGHT_PURPLE + "H: " + genome.getActiveAllele(EnumTreeChromosome.HEIGHT).getName(); + String girth = EnumChatFormatting.AQUA + "G: " + String.format("%sx%s", genome.getGirth(), genome.getGirth()); + String fertility = EnumChatFormatting.YELLOW + "S: " + genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName(); + String yield = EnumChatFormatting.WHITE + "Y: " + genome.getActiveAllele(EnumTreeChromosome.YIELD).getName(); + list.add(String.format("%s, %s", sappiness, maturation)); + list.add(String.format("%s, %s", height, girth)); + list.add(String.format("%s, %s", fertility, yield)); IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); if (primaryFireproof.getValue()) - list.add(String.format("\u00A7c%s", StatCollector.translateToLocal("for.gui.fireresist"))); + list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("for.gui.fireresist")); IAllele fruit = getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if(fruit != Allele.fruitNone) { String strike = ""; if (!canBearFruit()) - strike = "\u00A7m"; - list.add(strike + "\u00A7aF: " + StringUtil.localize(genome.getFruitProvider().getDescription())); + strike = EnumChatFormatting.STRIKETHROUGH.toString(); + list.add(strike + EnumChatFormatting.GREEN + "F: " + StringUtil.localize(genome.getFruitProvider().getDescription())); } } diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index ea0a4d24b..30463833a 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -35,6 +35,8 @@ import java.util.List; import java.util.Locale; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + import net.minecraftforge.common.EnumPlantType; public class GuiTreealyzer extends GuiAlyzer { @@ -229,13 +231,13 @@ public class GuiTreealyzer extends GuiAlyzer { String strike = ""; IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if (!tree.canBearFruit() && fruit0 != Allele.fruitNone) - strike = "\u00A7m"; + strike = EnumChatFormatting.STRIKETHROUGH.toString(); drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0); strike = ""; IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS); if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != Allele.fruitNone) - strike = "\u00A7m"; + strike = EnumChatFormatting.STRIKETHROUGH.toString(); drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1); newLine(); diff --git a/src/main/java/forestry/core/TickHandlerCoreClient.java b/src/main/java/forestry/core/TickHandlerCoreClient.java index ca2708997..ab33a8706 100755 --- a/src/main/java/forestry/core/TickHandlerCoreClient.java +++ b/src/main/java/forestry/core/TickHandlerCoreClient.java @@ -14,6 +14,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -60,14 +61,14 @@ public class TickHandlerCoreClient { } if (!naggedVersion && !Config.disableVersionCheck && Version.needsUpdateNoticeAndMarkAsSeen()) { - queueChatMessage(String.format("\u00A7cNew version of Forestry available: %s for Minecraft %s", Version.getRecommendedVersion(), + queueChatMessage(EnumChatFormatting.RED + String.format("New version of Forestry available: %s for Minecraft %s", Version.getRecommendedVersion(), Proxies.common.getMinecraftVersion())); - queueChatMessage("\u00A7cThis message only displays once. Type '/forestry version' to see the changelog."); + queueChatMessage(EnumChatFormatting.RED + "This message only displays once. Type '/forestry version' to see the changelog."); naggedVersion = true; } if (!naggedVerify && Config.invalidFingerprint) { - queueChatMessage("\u00A76Forestry's jar file was tampered with. Some machines have shut down and beekeeping has grown dangerous. Get a new jar from the official download page to fix that!"); + queueChatMessage(EnumChatFormatting.GOLD + "Forestry's jar file was tampered with. Some machines have shut down and beekeeping has grown dangerous. Get a new jar from the official download page to fix that!"); naggedVerify = true; } } diff --git a/src/main/java/forestry/core/circuits/CircuitBoard.java b/src/main/java/forestry/core/circuits/CircuitBoard.java index e2ab7f05a..1fe85ff27 100755 --- a/src/main/java/forestry/core/circuits/CircuitBoard.java +++ b/src/main/java/forestry/core/circuits/CircuitBoard.java @@ -16,6 +16,7 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; @@ -53,7 +54,7 @@ public class CircuitBoard implements ICircuitBoard { @Override public void addTooltip(List list) { if (layout != null) - list.add("\u00A76" + layout.getUsage() + ":"); + list.add(EnumChatFormatting.GOLD + layout.getUsage() + ":"); List extendedTooltip = new ArrayList(); for (ICircuit circuit : circuits) @@ -63,7 +64,7 @@ public class CircuitBoard implements ICircuitBoard { if(Proxies.common.isShiftDown() || extendedTooltip.size() <= 4) { list.addAll(extendedTooltip); } else { - list.add("\u00A7o<" + StringUtil.localize("gui.tooltip.tmi") + ">"); + list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); } } diff --git a/src/main/java/forestry/core/commands/CommandPlugins.java b/src/main/java/forestry/core/commands/CommandPlugins.java index 16aa894ca..90ec50349 100644 --- a/src/main/java/forestry/core/commands/CommandPlugins.java +++ b/src/main/java/forestry/core/commands/CommandPlugins.java @@ -16,6 +16,7 @@ import forestry.plugins.Plugin; import forestry.plugins.PluginManager; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; /** @@ -49,9 +50,7 @@ public class CommandPlugins extends SubCommand { } private String makeListEntry(ForestryPlugin plugin) { - String entry = "\u00A7c"; - if (plugin.isAvailable()) - entry = "\u00A7a"; + String entry = plugin.isAvailable() ? EnumChatFormatting.GREEN.toString() : EnumChatFormatting.RED.toString(); Plugin info = plugin.getClass().getAnnotation(Plugin.class); if (info != null) { @@ -95,18 +94,17 @@ public class CommandPlugins extends SubCommand { if (found == null) throw new CommandException(StringUtil.localizeAndFormat("chat.plugins.error", plugin)); - String entry = "\u00A7c"; - if (found.isAvailable()) - entry = "\u00A7a"; + EnumChatFormatting formatting = found.isAvailable() ? EnumChatFormatting.GREEN : EnumChatFormatting.RED; + Plugin info = found.getClass().getAnnotation(Plugin.class); if (info != null) { - CommandHelpers.sendChatMessage(sender, entry + "Plugin: " + info.name()); + CommandHelpers.sendChatMessage(sender, formatting + "Plugin: " + info.name()); if (!info.version().isEmpty()) - CommandHelpers.sendChatMessage(sender, "\u00A79Version: " + info.version()); + CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "Version: " + info.version()); if (!info.author().isEmpty()) - CommandHelpers.sendChatMessage(sender, "\u00A79Author(s): " + info.author()); + CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "Author(s): " + info.author()); if (!info.url().isEmpty()) - CommandHelpers.sendChatMessage(sender, "\u00A79URL: " + info.url()); + CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + "URL: " + info.url()); if (!info.unlocalizedDescription().isEmpty()) CommandHelpers.sendChatMessage(sender, StatCollector.translateToLocal(info.unlocalizedDescription())); } diff --git a/src/main/java/forestry/core/commands/CommandVersion.java b/src/main/java/forestry/core/commands/CommandVersion.java index feee964df..55a18f927 100644 --- a/src/main/java/forestry/core/commands/CommandVersion.java +++ b/src/main/java/forestry/core/commands/CommandVersion.java @@ -37,7 +37,7 @@ public class CommandVersion extends SubCommand { CommandHelpers.sendLocalizedChatMessage(sender, style, "for.chat.version", Version.getVersion(), Proxies.common.getMinecraftVersion(), Version.getRecommendedVersion()); if (Version.isOutdated()) for (String updateLine : Version.getChangelog()) { - CommandHelpers.sendChatMessage(sender, "\u00A79" + updateLine); + CommandHelpers.sendChatMessage(sender, EnumChatFormatting.BLUE + updateLine); } } diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index 657e3d27b..ae2cd8b3d 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -16,6 +16,7 @@ import java.util.HashSet; import net.minecraft.item.EnumRarity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -87,7 +88,7 @@ public class FilteredTank extends StandardTank { toolTip.add(name); } } else { - toolTip.add("\u00A7o<" + StringUtil.localize("gui.tooltip.tmi") + ">"); + toolTip.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); } toolTip.add(String.format("%,d", getFluidAmount()) + " / " + String.format("%,d", getCapacity())); diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index 669763d7e..049c76bd8 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -21,6 +21,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; public abstract class ItemGE extends Item { @@ -71,7 +72,7 @@ public abstract class ItemGE extends Item { if(Proxies.common.isShiftDown()) individual.addTooltip(list); else - list.add("\u00A7o<" + StringUtil.localize("gui.tooltip.tmi") + ">"); + list.add(EnumChatFormatting.ITALIC + "<" + StringUtil.localize("gui.tooltip.tmi") + ">"); } else list.add("<" + StringUtil.localize("gui.unknown") + ">"); } diff --git a/src/main/java/forestry/core/genetics/ItemResearchNote.java b/src/main/java/forestry/core/genetics/ItemResearchNote.java index 38eeb9256..0eadd47b9 100755 --- a/src/main/java/forestry/core/genetics/ItemResearchNote.java +++ b/src/main/java/forestry/core/genetics/ItemResearchNote.java @@ -33,6 +33,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -88,7 +89,7 @@ public class ItemResearchNote extends ItemForestry { if(encoded.getSpecialConditions() != null && encoded.getSpecialConditions().size() > 0) { for(String line : encoded.getSpecialConditions()) - tooltips.add("\u00A76" + line); + tooltips.add(EnumChatFormatting.GOLD + line); } } else if(this == SPECIES) { IAlleleSpecies allele0 = (IAlleleSpecies)AlleleManager.alleleRegistry.getAllele(compound.getString("AL0")); @@ -213,7 +214,7 @@ public class ItemResearchNote extends ItemForestry { public void addTooltip(List list) { ArrayList tooltips = type.getTooltip(inner); if(tooltips.size() <= 0) { - list.add("\u00A7o\u00A7c" + StringUtil.localize("researchNote.error.0")); + list.add(EnumChatFormatting.ITALIC + EnumChatFormatting.RED.toString() + StringUtil.localize("researchNote.error.0")); list.add(StringUtil.localize("researchNote.error.1")); return; } diff --git a/src/main/java/forestry/core/gui/GuiEscritoire.java b/src/main/java/forestry/core/gui/GuiEscritoire.java index ec3b69252..99bc525a5 100755 --- a/src/main/java/forestry/core/gui/GuiEscritoire.java +++ b/src/main/java/forestry/core/gui/GuiEscritoire.java @@ -23,6 +23,8 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + import org.lwjgl.opengl.GL11; public class GuiEscritoire extends GuiForestry { @@ -214,7 +216,8 @@ public class GuiEscritoire extends GuiForestry { newLine(); newLine(); - drawLine("\u00A7n\u00A7oAttempt No. " + (NaturalistGame.BOUNTY_MAX - tile.getGame().getBountyLevel()), 171, fontColor.get("gui.mail.lettertext")); + String format = EnumChatFormatting.UNDERLINE + EnumChatFormatting.ITALIC.toString(); + drawLine(format + "Attempt No. " + (NaturalistGame.BOUNTY_MAX - tile.getGame().getBountyLevel()), 171, fontColor.get("gui.mail.lettertext")); newLine(); drawSplitLine(getResearchNote(), 171, 46, fontColor.get("gui.mail.lettertext")); diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index e440e9484..4bdcfb9c3 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -38,6 +38,7 @@ import java.util.Map; import net.minecraft.entity.EntityCreature; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeDictionary; @@ -66,21 +67,21 @@ public class Butterfly extends IndividualLiving implements IButterfly { IAlleleButterflySpecies primary = genome.getPrimary(); IAlleleButterflySpecies secondary = genome.getSecondary(); if (!isPureBred(EnumButterflyChromosome.SPECIES)) - list.add("\u00A79" + StringUtil.localize("butterflies.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); + list.add(EnumChatFormatting.BLUE + StringUtil.localize("butterflies.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); if(getMate() != null) - list.add("\u00A7c" + StringUtil.localize("gui.fecundated").toUpperCase(Locale.ENGLISH)); - list.add("\u00A7e" + genome.getActiveAllele(EnumButterflyChromosome.SIZE).getName()); - list.add("\u00A7f" + genome.getActiveAllele(EnumButterflyChromosome.SPEED).getName() + " " + StringUtil.localize("gui.flyer")); + list.add(EnumChatFormatting.RED + StringUtil.localize("gui.fecundated").toUpperCase(Locale.ENGLISH)); + list.add(EnumChatFormatting.YELLOW + genome.getActiveAllele(EnumButterflyChromosome.SIZE).getName()); + list.add(EnumChatFormatting.WHITE + genome.getActiveAllele(EnumButterflyChromosome.SPEED).getName() + " " + StringUtil.localize("gui.flyer")); list.add(genome.getActiveAllele(EnumButterflyChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); - list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); + list.add(EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE); - list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); + list.add(EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); - list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), genome.getPrimary().isNocturnal())); + list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), genome.getPrimary().isNocturnal())); } /* SAVING & LOADING */ diff --git a/src/main/java/forestry/mail/commands/CommandMail.java b/src/main/java/forestry/mail/commands/CommandMail.java index 7967c996a..da9585882 100644 --- a/src/main/java/forestry/mail/commands/CommandMail.java +++ b/src/main/java/forestry/mail/commands/CommandMail.java @@ -57,9 +57,7 @@ public class CommandMail extends SubCommand { } private String makeTradeListEntry(TradeStationInfo info) { - String entry = "\u00A7c"; - if (info.state == EnumStationState.OK) - entry = "\u00A7a"; + EnumChatFormatting formatting = info.state.isOk() ? EnumChatFormatting.GREEN : EnumChatFormatting.RED; String tradegood = "[ ? ]"; if (info.tradegood != null) @@ -72,7 +70,7 @@ public class CommandMail extends SubCommand { } } - return String.format("%s%-12s | %-20s | %s", entry, info.address.getName(), tradegood, demand); + return String.format("%s%-12s | %-20s | %s", formatting, info.address.getName(), tradegood, demand); } } From 17182cc2b224da78f31fb379df8f15e17adde8eb Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 00:46:50 -0800 Subject: [PATCH 124/175] Fix java.io.EOFException console spam --- .../forestry/core/network/PacketTileUpdate.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/core/network/PacketTileUpdate.java b/src/main/java/forestry/core/network/PacketTileUpdate.java index e5a1f523d..81eb0a7fb 100755 --- a/src/main/java/forestry/core/network/PacketTileUpdate.java +++ b/src/main/java/forestry/core/network/PacketTileUpdate.java @@ -51,10 +51,7 @@ public class PacketTileUpdate extends PacketUpdate { @Override public void writeData(DataOutputStream data) throws IOException { - - data.writeInt(posX); - data.writeInt(posY); - data.writeInt(posZ); + super.writeData(data); data.writeByte(this.orientation.ordinal()); data.writeShort(this.errorState.getID()); @@ -74,16 +71,11 @@ public class PacketTileUpdate extends PacketUpdate { } } else data.writeInt(-1); - - super.writeData(data); } @Override public void readData(DataInputStream data) throws IOException { - - posX = data.readInt(); - posY = data.readInt(); - posZ = data.readInt(); + super.readData(data); orientation = ForgeDirection.getOrientation(data.readByte()); errorState = ErrorStateRegistry.getErrorState(data.readShort()); @@ -99,8 +91,6 @@ public class PacketTileUpdate extends PacketUpdate { owner = null; } } - - super.readData(data); } public ForgeDirection getOrientation() { From daa3ab13bebbb68293f7494b329159e28dda3c73 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 00:47:50 -0800 Subject: [PATCH 125/175] Fix catalog display bug introduced in the previous fix --- src/main/java/forestry/mail/gui/GuiCatalogue.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/forestry/mail/gui/GuiCatalogue.java b/src/main/java/forestry/mail/gui/GuiCatalogue.java index 0e694c8dc..3e76ef725 100755 --- a/src/main/java/forestry/mail/gui/GuiCatalogue.java +++ b/src/main/java/forestry/mail/gui/GuiCatalogue.java @@ -79,6 +79,7 @@ public class GuiCatalogue extends GuiForestry { fontRendererObj.drawString(String.format("%s / %s", container.getCurrentPos(), container.getMaxCount()), guiLeft + xSize - 72, guiTop + 12, fontColor.get("gui.book")); + clearTradeInfoWidgets(); if(container.getTradeInfo() != null) drawTradePreview(guiLeft + 38, guiTop + 30); else @@ -99,8 +100,6 @@ public class GuiCatalogue extends GuiForestry { TradeStationInfo info = container.getTradeInfo(); fontRendererObj.drawString(String.format(StringUtil.localize("gui.mail.willtrade"), info.owner.getName()), x, y + 18, fontColor.get("gui.book")); - clearTradeInfoWidgets(); - addTradeInfoWidget(new ItemStackWidget(x - guiLeft, y - guiTop + 28, info.tradegood)); fontRendererObj.drawString(StringUtil.localize("gui.mail.tradefor"), x, y + 46, fontColor.get("gui.book")); From 0d1d8295b45dc8048ca750fadd64c3fbfc91be46 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 12:56:31 -0800 Subject: [PATCH 126/175] Fix #411 Trade Station does not show its name in the GUI --- api/forestry | 2 +- src/main/java/forestry/mail/MailAddress.java | 2 +- src/main/java/forestry/mail/PostRegistry.java | 15 -------- .../forestry/mail/gadgets/MachineTrader.java | 34 +++++++++++++++---- .../forestry/mail/gui/ContainerLetter.java | 4 +-- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/api/forestry b/api/forestry index de0260bad..76ba9ef8a 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit de0260bad67c805e14a159d97646e244542bd446 +Subproject commit 76ba9ef8a474db454fdd3d5c1a187822a689d4a0 diff --git a/src/main/java/forestry/mail/MailAddress.java b/src/main/java/forestry/mail/MailAddress.java index c4a22fa4a..ee54ed71f 100644 --- a/src/main/java/forestry/mail/MailAddress.java +++ b/src/main/java/forestry/mail/MailAddress.java @@ -75,7 +75,7 @@ public class MailAddress implements INBTTagable, IMailAddress { @Override public boolean isValid() { - return !PlayerUtil.isSameGameProfile(gameProfile, invalidGameProfile); + return gameProfile.getName() != null && !PlayerUtil.isSameGameProfile(gameProfile, invalidGameProfile); } @Override diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 6571fc46a..467680f20 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -160,26 +160,11 @@ public class PostRegistry implements IPostRegistry { return new MailAddress(gameProfile); } - public IMailAddress getValidMailAddress(World world, GameProfile gameProfile) { - IMailAddress address = new MailAddress(gameProfile); - if (getPOBox(world, address) != null) - return address; - return null; - } - @Override public IMailAddress getMailAddress(String traderName) { return new MailAddress(traderName); } - @Override - public IMailAddress getValidMailAddress(World world, String traderName) { - IMailAddress address = new MailAddress(traderName); - if (getTradeStation(world, address) != null) - return address; - return null; - } - /* CARRIER */ private final HashMap carriers = new HashMap(); diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 3b356198b..ee4db10d8 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -34,6 +34,7 @@ import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; import forestry.core.inventory.InventoryAdapter; import forestry.core.network.GuiId; +import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumAccess; import forestry.core.utils.StackUtils; @@ -46,7 +47,7 @@ import buildcraft.api.statements.ITriggerExternal; public class MachineTrader extends TileBase implements ISidedInventory { - private MailAddress address; + private IMailAddress address; public MachineTrader() { address = new MailAddress(); @@ -91,6 +92,27 @@ public class MachineTrader extends TileBase implements ISidedInventory { address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address")); } + @Override + public PacketPayload getPacketPayload() { + if (address == null) + return null; + + PacketPayload payload = new PacketPayload(0, 0, 1); + payload.stringPayload[0] = address.getName(); + return payload; + } + + @Override + public void fromPacketPayload(PacketPayload payload) { + if (payload.isEmpty()) { + address = null; + return; + } + + String addressName = payload.stringPayload[0]; + address = PostManager.postRegistry.getMailAddress(addressName); + } + /* UPDATING */ /** * The trade station should show errors for missing stamps and paper first. @@ -149,7 +171,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { /* STATE INFORMATION */ public boolean isLinked() { - return address.isValid(); + return address.isValid() && getErrorState() != EnumErrorCode.NOTALPHANUMERIC && getErrorState() != EnumErrorCode.NOTUNIQUE; } /** @@ -255,11 +277,10 @@ public class MachineTrader extends TileBase implements ISidedInventory { return; } - this.address = new MailAddress(address); + this.address = address; PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); setErrorState(EnumErrorCode.OK); - } else - this.address = new MailAddress(address); + } } /* TRADING */ @@ -275,7 +296,6 @@ public class MachineTrader extends TileBase implements ISidedInventory { return PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); } - /* ISIDEDINVENTORY */ @Override public int getSizeInventory() { @@ -334,7 +354,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { public boolean isUseableByPlayer(EntityPlayer player) { if (!Utils.isUseableByPlayer(player, this)) return false; - return getOrCreateTradeInventory().isUseableByPlayer(player); + return allowsInteraction(player); } /* ISIDEDINVENTORY */ diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index f97dffc88..6dfe3946c 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -158,9 +158,9 @@ public class ContainerLetter extends ContainerItemInventory { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); if (gameProfile == null) gameProfile = new GameProfile(new UUID(0, 0), recipientName); - recipient = PostManager.postRegistry.getValidMailAddress(player.worldObj, gameProfile); + recipient = PostManager.postRegistry.getMailAddress(gameProfile); } else if (type == EnumAddressee.TRADER) { - recipient = PostManager.postRegistry.getValidMailAddress(player.worldObj, recipientName); + recipient = PostManager.postRegistry.getMailAddress(recipientName); } else { return; } From a2938d8e55e12363da700d7e8b1e0aaecf45412f Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 16:31:54 -0800 Subject: [PATCH 127/175] Fix OpenGL stack overflow in worktable --- src/main/java/forestry/factory/gui/GuiWorktable.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/forestry/factory/gui/GuiWorktable.java b/src/main/java/forestry/factory/gui/GuiWorktable.java index c5d4fd342..27cb8d04f 100755 --- a/src/main/java/forestry/factory/gui/GuiWorktable.java +++ b/src/main/java/forestry/factory/gui/GuiWorktable.java @@ -44,13 +44,6 @@ public class GuiWorktable extends GuiForestryTitled { @Override public void draw(int startX, int startY) { - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - RenderHelper.enableGUIStandardItemLighting(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - ItemStack output = getOutputStack(); if (output != null) manager.gui.drawItemStack(output, startX + xPos, startY + yPos); From 291fa986392c81cacd5c6a133bd80ac180f16873 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 16:59:28 -0800 Subject: [PATCH 128/175] Fix #413, Fix access permissions --- .../apiculture/gadgets/TileAlvearyPlain.java | 8 -- .../gui/ContainerAlvearyHygroregulator.java | 8 +- .../apiculture/gui/ContainerAlvearySieve.java | 2 +- .../apiculture/gui/ContainerApiary.java | 2 +- .../apiculture/items/ItemImprinter.java | 14 +-- .../gadgets/TileTreeContainer.java | 15 ---- .../java/forestry/core/gadgets/BlockBase.java | 17 ++-- .../forestry/core/gadgets/BlockStructure.java | 20 ++--- .../forestry/core/gadgets/TileForestry.java | 89 +++++++++---------- .../forestry/core/gui/ContainerForestry.java | 45 ++++++---- .../core/gui/ContainerLiquidTanks.java | 5 +- .../gui/ContainerNaturalistInventory.java | 19 ++-- .../forestry/core/gui/ContainerSocketed.java | 11 +-- .../java/forestry/core/gui/GuiForestry.java | 54 +++++------ .../java/forestry/core/gui/OwnerLedger.java | 41 ++++----- .../forestry/core/interfaces/IOwnable.java | 9 +- .../core/interfaces/IRestrictedAccess.java | 27 ++++++ .../core/inventory/TileInventoryAdapter.java | 6 +- .../java/forestry/core/utils/PlayerUtil.java | 10 +++ .../factory/gui/ContainerMoistener.java | 2 +- .../factory/gui/ContainerWorktable.java | 2 +- .../forestry/farming/gui/ContainerFarm.java | 2 +- .../java/forestry/food/items/ItemInfuser.java | 4 +- .../forestry/mail/gadgets/MachineTrader.java | 2 +- .../forestry/mail/gui/ContainerCatalogue.java | 24 +++-- .../forestry/mail/gui/ContainerMailbox.java | 14 +-- .../forestry/mail/gui/ContainerTradeName.java | 17 ++-- .../pipes/gui/ContainerPropolisPipe.java | 16 ++-- 28 files changed, 259 insertions(+), 226 deletions(-) create mode 100644 src/main/java/forestry/core/interfaces/IRestrictedAccess.java diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index b0e44b75e..74d256b1b 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -236,14 +236,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB return (getHealthDisplay() * i) / getMaxHealthDisplay(); } - @Override - public boolean allowsInteraction(EntityPlayer player) { - if (!super.allowsInteraction(player)) - return false; - - return this.isIntegratedIntoStructure(); - } - /* STRUCTURE MANAGMENT */ @Override protected void createInventory() { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java index 2a46f2e8a..0cf557808 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java @@ -18,17 +18,17 @@ import net.minecraft.inventory.Slot; public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks { - public ContainerAlvearyHygroregulator(IInventory inventory, TileAlvearyHygroregulator tile) { - super(inventory, tile); + public ContainerAlvearyHygroregulator(IInventory playerInventory, TileAlvearyHygroregulator tile) { + super(playerInventory, tile); this.addSlotToContainer(new SlotLiquidContainer(tile, 0, 56, 38)); for (int i = 0; i < 3; ++i) for (int var4 = 0; var4 < 9; ++var4) - this.addSlotToContainer(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); + this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18)); for (int i = 0; i < 9; ++i) - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142)); } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index 8b36b55dc..9f2432e73 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -22,7 +22,7 @@ import forestry.core.gui.slots.SlotCustom; public class ContainerAlvearySieve extends ContainerForestry { public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) { - super(tile.getInternalInventory()); + super(tile); IInventory inventory = tile.getInternalInventory(); diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index 6d1eed40a..a35dd2d5f 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -26,7 +26,7 @@ public class ContainerApiary extends ContainerForestry { private final TileBeehouse tile; public ContainerApiary(InventoryPlayer player, TileBeehouse tile, boolean hasFrames) { - super(tile.getInternalInventory()); + super(tile); this.tile = tile; tile.sendNetworkUpdate(); diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 70512ecf4..8cb647ba5 100755 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -10,24 +10,25 @@ ******************************************************************************/ package forestry.apiculture.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.apiculture.genetics.Bee; +import forestry.core.inventory.ItemInventory; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ItemImprinter extends ItemForestry { - public static class ImprinterInventory implements IInventory { + public static class ImprinterInventory extends ItemInventory { private final ItemStack[] inventoryStacks = new ItemStack[2]; private final short specimenSlot = 0; @@ -39,6 +40,7 @@ public class ItemImprinter extends ItemForestry { private final EntityPlayer player; public ImprinterInventory(EntityPlayer player) { + super(ItemImprinter.class); this.player = player; } diff --git a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java index ecc93c0bb..30207dc41 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileTreeContainer.java @@ -119,16 +119,6 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked return true; } - @Override - public boolean allowsInteraction(EntityPlayer player) { - return true; - } - - @Override - public EnumAccess getAccess() { - return EnumAccess.SHARED; - } - @Override public boolean isOwnable() { return false; @@ -158,9 +148,4 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked return PlayerUtil.isSameGameProfile(owner, player.getGameProfile()); } - @Override - public boolean switchAccessRule(EntityPlayer player) { - return false; - } - } diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index d131f8f15..53e9dd88c 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -38,7 +38,7 @@ import forestry.core.fluids.FluidHelper; import forestry.core.interfaces.IOwnable; import forestry.core.items.ItemNBTTile; import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; +import forestry.core.utils.PlayerUtil; import forestry.core.utils.Utils; public class BlockBase extends BlockForestry { @@ -168,7 +168,7 @@ public class BlockBase extends BlockForestry { return false; ItemStack current = player.getCurrentEquippedItem(); - if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsInteraction(player)) { + if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsAlteration(player)) { if (Proxies.common.isSimulating(world)) { if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { return true; @@ -183,17 +183,10 @@ public class BlockBase extends BlockForestry { if (!Proxies.common.isSimulating(world)) return true; - if (tile.allowsInteraction(player)) { + if (tile.allowsViewing(player)) { tile.openGui(player, tile); - } - else { - String ownerName = StringUtil.localize("gui.derelict"); - - if (tile.getOwnerProfile() != null) - ownerName = tile.getOwnerProfile().getName(); - - - player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked",ownerName)); + } else { + player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", PlayerUtil.getOwnerName(tile))); } return true; } diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index 1b26d285a..e4ccaa9cd 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.core.gadgets; -import forestry.api.core.ITileStructure; -import forestry.core.proxy.Proxies; -import forestry.core.utils.StringUtil; -import forestry.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; @@ -21,6 +17,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; +import forestry.api.core.ITileStructure; +import forestry.core.proxy.Proxies; +import forestry.core.utils.PlayerUtil; +import forestry.core.utils.Utils; + public abstract class BlockStructure extends BlockForestry { public enum EnumStructureState { @@ -71,15 +72,10 @@ public abstract class BlockStructure extends BlockForestry { if (!((ITileStructure) tile).isIntegratedIntoStructure()) return false; - if (tile.allowsInteraction(player)) + if (tile.allowsViewing(player)) { tile.openGui(player); - else { - String ownerName = StringUtil.localize("gui.derelict"); - - if (tile.getOwnerProfile() != null) - ownerName = tile.getOwnerProfile().getName(); - - player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", ownerName)); + } else { + player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", PlayerUtil.getOwnerName(tile))); } return true; } diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 00c9f53a1..98a2710d0 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -10,28 +10,8 @@ ******************************************************************************/ package forestry.core.gadgets; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.common.Optional; -import forestry.api.core.IErrorState; -import forestry.core.EnumErrorCode; -import forestry.core.config.Config; -import forestry.core.interfaces.IErrorSource; -import forestry.core.interfaces.IOwnable; -import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.network.ForestryPacket; -import forestry.core.network.INetworkedEntity; -import forestry.core.network.PacketPayload; -import forestry.core.network.PacketTileUpdate; -import forestry.core.proxy.Proxies; -import forestry.core.utils.AdjacentTileCache; -import forestry.core.utils.EnumAccess; -import forestry.core.utils.PlayerUtil; -import forestry.core.vect.Vect; import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -42,10 +22,36 @@ import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.Optional; + +import forestry.api.core.IErrorState; +import forestry.core.EnumErrorCode; +import forestry.core.config.Config; +import forestry.core.interfaces.IErrorSource; +import forestry.core.interfaces.IRestrictedAccess; +import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.network.ForestryPacket; +import forestry.core.network.INetworkedEntity; +import forestry.core.network.PacketPayload; +import forestry.core.network.PacketTileUpdate; +import forestry.core.proxy.Proxies; +import forestry.core.utils.AdjacentTileCache; +import forestry.core.utils.EnumAccess; +import forestry.core.utils.PlayerUtil; +import forestry.core.vect.Vect; + +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; + @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public abstract class TileForestry extends TileEntity implements INetworkedEntity, IOwnable, IErrorSource, ITriggerProvider { +public abstract class TileForestry extends TileEntity implements INetworkedEntity, IRestrictedAccess, IErrorSource, ITriggerProvider { protected final AdjacentTileCache tileCache = new AdjacentTileCache(this); protected boolean isInited = false; @@ -234,33 +240,18 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit private EnumAccess access = EnumAccess.SHARED; @Override - public boolean allowsRemoval(EntityPlayer player) { - if (!isOwnable()) - return true; - if (!isOwned()) - return true; - if (isOwner(player)) - return true; - if (Proxies.common.isOp(player)) - return true; - - return getAccess() == EnumAccess.SHARED; + public final boolean allowsRemoval(EntityPlayer player) { + return Config.disablePermissions || !isOwnable() || !isOwned() || isOwner(player) || Proxies.common.isOp(player); } @Override - public boolean allowsInteraction(EntityPlayer player) { - if (Config.disablePermissions) - return true; - if (!isOwnable()) - return true; - if (!isOwned()) - return true; - if (isOwner(player)) - return true; - if (Proxies.common.isOp(player)) - return true; + public final boolean allowsAlteration(EntityPlayer player) { + return allowsRemoval(player) || getAccess() == EnumAccess.SHARED; + } - return getAccess() == EnumAccess.SHARED || getAccess() == EnumAccess.VIEWABLE; + @Override + public final boolean allowsViewing(EntityPlayer player) { + return allowsAlteration(player) || getAccess() == EnumAccess.VIEWABLE; } @Override @@ -300,10 +291,10 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit if (!isOwner(player)) return false; - if (access.ordinal() < EnumAccess.values().length - 1) - access = EnumAccess.values()[access.ordinal() + 1]; - else - access = EnumAccess.values()[0]; + int ordinal = (access.ordinal() + 1) % EnumAccess.values().length; + access = EnumAccess.values()[ordinal]; + if (!this.worldObj.isRemote) + sendNetworkUpdate(); return true; } diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 67f487444..0fe0c6a61 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.core.gadgets.TileForestry; -import forestry.core.gui.slots.SlotForestry; -import forestry.core.utils.EnumAccess; -import forestry.core.utils.StackUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -21,17 +17,29 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import forestry.core.gadgets.TileForestry; +import forestry.core.gui.slots.SlotForestry; +import forestry.core.interfaces.IRestrictedAccess; +import forestry.core.inventory.ItemInventory; +import forestry.core.utils.StackUtils; + public class ContainerForestry extends Container { - protected final IInventory inventory; - protected final TileForestry inventoryForestry; + protected final IInventory inventoryAccess; + protected final IRestrictedAccess restrictedAccess; - public ContainerForestry(IInventory inventory) { - this.inventory = inventory; - if (inventory instanceof TileForestry) - this.inventoryForestry = (TileForestry) inventory; + public ContainerForestry(TileForestry tileForestry) { + if (tileForestry instanceof IInventory) + this.inventoryAccess = (IInventory) tileForestry; else - this.inventoryForestry = null; + this.inventoryAccess = tileForestry.getInternalInventory(); + + this.restrictedAccess = tileForestry; + } + + public ContainerForestry(ItemInventory itemInventory) { + this.inventoryAccess = itemInventory; + this.restrictedAccess = null; } @Override @@ -39,9 +47,8 @@ public class ContainerForestry extends Container { if (player == null) return null; - if ((inventoryForestry != null) && (inventoryForestry.getAccess() != EnumAccess.SHARED)) - if (!inventoryForestry.isOwner(player)) - return null; + if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) + return null; Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex); if (slot instanceof SlotForestry) @@ -181,6 +188,12 @@ public class ContainerForestry extends Container { @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { + if (player == null) + return null; + + if (restrictedAccess != null && !restrictedAccess.allowsAlteration(player)) + return null; + ItemStack originalStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); int numSlots = inventorySlots.size(); @@ -211,6 +224,8 @@ public class ContainerForestry extends Container { @Override public final boolean canInteractWith(EntityPlayer entityplayer) { - return inventory.isUseableByPlayer(entityplayer); + if (inventoryAccess == null) + return true; + return inventoryAccess.isUseableByPlayer(entityplayer); } } diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 0c8cc1b09..5ce1d2784 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -12,6 +12,7 @@ package forestry.core.gui; import forestry.api.core.IToolPipette; import forestry.core.fluids.tanks.StandardTank; +import forestry.core.gadgets.TileForestry; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; @@ -28,8 +29,8 @@ public class ContainerLiquidTanks extends ContainerForestry { private final ILiquidTankContainer tile; - public ContainerLiquidTanks(IInventory inventory, ILiquidTankContainer tile) { - super(inventory); + public ContainerLiquidTanks(IInventory playerInventory, T tile) { + super(tile); this.tile = tile; } diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index a103c04c2..318bac49d 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -10,21 +10,23 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.network.PacketUpdate; -import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import forestry.api.genetics.ISpeciesRoot; +import forestry.core.gadgets.TileNaturalistChest; +import forestry.core.gui.slots.SlotCustom; +import forestry.core.network.PacketUpdate; +import forestry.core.proxy.Proxies; + public class ContainerNaturalistInventory extends ContainerForestry implements IGuiSelectable { private final IPagedInventory inv; private final ISpeciesRoot speciesRoot; - public ContainerNaturalistInventory(ISpeciesRoot speciesRoot, InventoryPlayer player, IPagedInventory inventory, int page, int pageSize) { + public ContainerNaturalistInventory(ISpeciesRoot speciesRoot, InventoryPlayer player, TileNaturalistChest inventory, int page, int pageSize) { super(inventory); this.inv = inventory; this.speciesRoot = speciesRoot; @@ -49,8 +51,9 @@ public class ContainerNaturalistInventory extends ContainerForestry implements I } public void purgeBag(EntityPlayer player) { - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); + + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); if (stack == null) continue; @@ -58,7 +61,7 @@ public class ContainerNaturalistInventory extends ContainerForestry implements I continue; Proxies.common.dropItemPlayer(player, stack); - inventory.setInventorySlotContents(i, null); + inv.setInventorySlotContents(i, null); } } diff --git a/src/main/java/forestry/core/gui/ContainerSocketed.java b/src/main/java/forestry/core/gui/ContainerSocketed.java index 672905d56..15735eb16 100755 --- a/src/main/java/forestry/core/gui/ContainerSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerSocketed.java @@ -10,6 +10,11 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import forestry.core.gadgets.TileForestry; import forestry.core.interfaces.ISocketable; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; @@ -17,16 +22,12 @@ import forestry.core.network.PacketSocketUpdate; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; public class ContainerSocketed extends ContainerForestry { private final ISocketable tile; - public ContainerSocketed(IInventory inventory, ISocketable tile) { + public ContainerSocketed(TileForestry inventory, ISocketable tile) { super(inventory); this.tile = tile; } diff --git a/src/main/java/forestry/core/gui/GuiForestry.java b/src/main/java/forestry/core/gui/GuiForestry.java index 5ecee202e..b46e84d4b 100755 --- a/src/main/java/forestry/core/gui/GuiForestry.java +++ b/src/main/java/forestry/core/gui/GuiForestry.java @@ -10,10 +10,29 @@ ******************************************************************************/ package forestry.core.gui; -import codechicken.nei.VisiblityData; -import codechicken.nei.api.INEIGuiHandler; -import codechicken.nei.api.TaggedInventoryArea; +import java.awt.Color; +import java.util.Collection; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + import cpw.mods.fml.common.Optional; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + import forestry.core.config.Config; import forestry.core.gadgets.TileForestry; import forestry.core.gui.tooltips.IToolTipProvider; @@ -27,25 +46,10 @@ import forestry.core.interfaces.IOwnable; import forestry.core.interfaces.IPowerHandler; import forestry.core.proxy.Proxies; import forestry.core.utils.FontColour; -import java.awt.Color; -import java.util.Collection; -import java.util.List; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; +import codechicken.nei.VisiblityData; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.TaggedInventoryArea; @Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") public abstract class GuiForestry extends GuiContainer implements INEIGuiHandler { @@ -58,20 +62,20 @@ public abstract class GuiForestry extends GuiContainer i protected final FontColour fontColor; public final ResourceLocation textureFile; - public GuiForestry(String texture, ContainerForestry container) { + public GuiForestry(String texture, Container container) { this(new ResourceLocation("forestry", texture), container, null); } - public GuiForestry(String texture, ContainerForestry container, Object inventory) { + public GuiForestry(String texture, Container container, Object inventory) { this(new ResourceLocation("forestry", texture), container, inventory); } - public GuiForestry(ResourceLocation texture, ContainerForestry container) { + public GuiForestry(ResourceLocation texture, Container container) { this(texture, container, null); } @SuppressWarnings("unchecked") - public GuiForestry(ResourceLocation texture, ContainerForestry container, Object inventory) { + public GuiForestry(ResourceLocation texture, Container container, Object inventory) { super(container); this.widgetManager = new WidgetManager(this); this.ledgerManager = new LedgerManager(this); diff --git a/src/main/java/forestry/core/gui/OwnerLedger.java b/src/main/java/forestry/core/gui/OwnerLedger.java index 8c6303cc0..4fe3e979d 100755 --- a/src/main/java/forestry/core/gui/OwnerLedger.java +++ b/src/main/java/forestry/core/gui/OwnerLedger.java @@ -11,11 +11,13 @@ package forestry.core.gui; import forestry.core.interfaces.IOwnable; +import forestry.core.interfaces.IRestrictedAccess; import forestry.core.network.PacketCoordinates; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.EnumAccess; +import forestry.core.utils.PlayerUtil; import forestry.core.utils.StringUtil; import java.util.Locale; import net.minecraft.tileentity.TileEntity; @@ -50,7 +52,6 @@ public class OwnerLedger extends Ledger { // Update state boolean playerIsOwner = tile.isOwner(manager.minecraft.thePlayer); - EnumAccess access = tile.getAccess(); if (playerIsOwner) maxHeight = 60; @@ -61,6 +62,12 @@ public class OwnerLedger extends Ledger { drawBackground(x, y); // Draw icon + EnumAccess access; + if (tile instanceof IRestrictedAccess) { + access = ((IRestrictedAccess)tile).getAccess(); + } else { + access = EnumAccess.SHARED; + } IIcon accessIcon = TextureManager.getInstance().getDefault("misc/access." + access.toString().toLowerCase(Locale.ENGLISH)); drawIcon(accessIcon, x + 3, y + 4); @@ -70,42 +77,32 @@ public class OwnerLedger extends Ledger { manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.owner"), x + 22, y + 8, manager.gui.fontColor.get("ledger.owner.header")); - String ownerName = StringUtil.localize("gui.derelict"); - - if (tile.getOwnerProfile() != null) - ownerName = tile.getOwnerProfile().getName(); - - manager.minecraft.fontRenderer.drawString(ownerName, x + 22, y + 20, manager.gui.fontColor.get("ledger.owner.text")); - - if (!playerIsOwner) - return; - - manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.access") + ":", x + 22, y + 32, - manager.gui.fontColor.get("ledger.owner.subheader")); - // Access rules - drawIcon(accessIcon, x + 20, y + 40); - manager.minecraft.fontRenderer.drawString(StringUtil.localize(access.getName()), x + 38, y + 44, manager.gui.fontColor.get("ledger.owner.text")); + manager.minecraft.fontRenderer.drawString(PlayerUtil.getOwnerName(tile), x + 22, y + 20, manager.gui.fontColor.get("ledger.owner.text")); + if (playerIsOwner && tile instanceof IRestrictedAccess) { + manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.access") + ":", x + 22, y + 32, + manager.gui.fontColor.get("ledger.owner.subheader")); + // Access rules + drawIcon(accessIcon, x + 20, y + 40); + manager.minecraft.fontRenderer.drawString(StringUtil.localize(access.getName()), x + 38, y + 44, manager.gui.fontColor.get("ledger.owner.text")); + } } @Override public String getTooltip() { - if (tile.getOwnerProfile() != null) - return StringUtil.localize("gui.owner") + ": " + tile.getOwnerProfile().getName(); - else - return StringUtil.localize("gui.derelict"); + return StringUtil.localize("gui.owner") + ": " + PlayerUtil.getOwnerName(tile); } @Override public boolean handleMouseClicked(int x, int y, int mouseButton) { - if (isAccessButton(x, y)) { + if (isAccessButton(x, y) && tile instanceof IRestrictedAccess) { if (!Proxies.common.isSimulating(((TileEntity) tile).getWorldObj())) { TileEntity te = (TileEntity) tile; Proxies.net.sendToServer(new PacketCoordinates(PacketIds.ACCESS_SWITCH, te.xCoord, te.yCoord, te.zCoord)); } - tile.switchAccessRule(manager.minecraft.thePlayer); + ((IRestrictedAccess) tile).switchAccessRule(manager.minecraft.thePlayer); return true; } diff --git a/src/main/java/forestry/core/interfaces/IOwnable.java b/src/main/java/forestry/core/interfaces/IOwnable.java index f79c7770a..290e977f8 100755 --- a/src/main/java/forestry/core/interfaces/IOwnable.java +++ b/src/main/java/forestry/core/interfaces/IOwnable.java @@ -10,10 +10,10 @@ ******************************************************************************/ package forestry.core.interfaces; -import com.mojang.authlib.GameProfile; -import forestry.core.utils.EnumAccess; import net.minecraft.entity.player.EntityPlayer; +import com.mojang.authlib.GameProfile; + public interface IOwnable { boolean isOwnable(); @@ -26,11 +26,6 @@ public interface IOwnable { boolean isOwner(EntityPlayer player); - boolean switchAccessRule(EntityPlayer player); - - EnumAccess getAccess(); - boolean allowsRemoval(EntityPlayer player); - boolean allowsInteraction(EntityPlayer player); } diff --git a/src/main/java/forestry/core/interfaces/IRestrictedAccess.java b/src/main/java/forestry/core/interfaces/IRestrictedAccess.java new file mode 100644 index 000000000..3a941b7ee --- /dev/null +++ b/src/main/java/forestry/core/interfaces/IRestrictedAccess.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.interfaces; + +import net.minecraft.entity.player.EntityPlayer; + +import forestry.core.utils.EnumAccess; + +public interface IRestrictedAccess extends IOwnable { + + boolean switchAccessRule(EntityPlayer player); + + EnumAccess getAccess(); + + boolean allowsAlteration(EntityPlayer player); + + boolean allowsViewing(EntityPlayer player); + +} diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index e2b8d7d7a..3a2d6ca95 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -33,7 +33,7 @@ public class TileInventoryAdapter extends InventoryAdapter { public boolean isUseableByPlayer(EntityPlayer player) { if (!Utils.isUseableByPlayer(player, tile)) return false; - return tile.allowsInteraction(player); + return tile.allowsViewing(player); } @Override @@ -44,11 +44,11 @@ public class TileInventoryAdapter extends InventoryAdapter { @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return tile.getAccess() == EnumAccess.SHARED; + return true; } @Override public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { - return tile.getAccess() == EnumAccess.SHARED; + return true; } } diff --git a/src/main/java/forestry/core/utils/PlayerUtil.java b/src/main/java/forestry/core/utils/PlayerUtil.java index 4e70d19cf..d36d473ec 100644 --- a/src/main/java/forestry/core/utils/PlayerUtil.java +++ b/src/main/java/forestry/core/utils/PlayerUtil.java @@ -3,6 +3,8 @@ package forestry.core.utils; import com.mojang.authlib.GameProfile; import java.util.UUID; +import forestry.core.interfaces.IOwnable; + public class PlayerUtil { //TODO: use null everywhere instead of an emptyUUID @@ -20,4 +22,12 @@ public class PlayerUtil { return player1.getName() != null && player1.getName().equals(player2.getName()); } + public static String getOwnerName(IOwnable ownable) { + GameProfile profile = ownable.getOwnerProfile(); + if (profile == null) + return StringUtil.localize("gui.derelict"); + else + return profile.getName(); + } + } diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 716503826..5117290fc 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -62,7 +62,7 @@ public class ContainerMoistener extends ContainerLiquidTanks implements IContain @Override public void onCraftMatrixChanged(IInventory iinventory, int slot) { - inventory.setInventorySlotContents(slot, iinventory.getStackInSlot(slot)); + tile.setInventorySlotContents(slot, iinventory.getStackInSlot(slot)); tile.checkRecipe(); } diff --git a/src/main/java/forestry/factory/gui/ContainerWorktable.java b/src/main/java/forestry/factory/gui/ContainerWorktable.java index ccf249c46..f843aa304 100755 --- a/src/main/java/forestry/factory/gui/ContainerWorktable.java +++ b/src/main/java/forestry/factory/gui/ContainerWorktable.java @@ -35,7 +35,7 @@ public class ContainerWorktable extends ContainerForestry implements IContainerC private long lastUpdate; public ContainerWorktable(EntityPlayer player, TileWorktable tile) { - super(tile.getInternalInventory()); + super(tile); this.tile = tile; IInventory craftingInventory = tile.getCraftingInventory(); diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 2db4c6b84..6fcffc577 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -31,7 +31,7 @@ public class ContainerFarm extends ContainerSocketed { private final TileFarmPlain tile; public ContainerFarm(InventoryPlayer playerinventory, TileFarmPlain tile) { - super(playerinventory, tile); + super(tile, tile); this.tile = tile; diff --git a/src/main/java/forestry/food/items/ItemInfuser.java b/src/main/java/forestry/food/items/ItemInfuser.java index f8bd67405..98bb93fb4 100755 --- a/src/main/java/forestry/food/items/ItemInfuser.java +++ b/src/main/java/forestry/food/items/ItemInfuser.java @@ -17,6 +17,7 @@ import forestry.api.food.IInfuserManager; import forestry.api.food.IIngredientManager; import forestry.core.CreativeTabForestry; import forestry.core.config.ForestryItem; +import forestry.core.inventory.ItemInventory; import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; @@ -227,7 +228,7 @@ public class ItemInfuser extends ItemForestry { } // / INVENTORY MANAGMENT - public static class InfuserInventory implements IInventory { + public static class InfuserInventory extends ItemInventory { private final ItemStack[] inventoryStacks = new ItemStack[6]; private final short inputSlot = 0; @@ -236,6 +237,7 @@ public class ItemInfuser extends ItemForestry { private final EntityPlayer player; public InfuserInventory(EntityPlayer player) { + super(ItemInfuser.class); this.player = player; } diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index ee4db10d8..4f929b4da 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -354,7 +354,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { public boolean isUseableByPlayer(EntityPlayer player) { if (!Utils.isUseableByPlayer(player, this)) return false; - return allowsInteraction(player); + return allowsViewing(player); } /* ISIDEDINVENTORY */ diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 939592dbe..344c9b1d8 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -10,13 +10,21 @@ ******************************************************************************/ package forestry.mail.gui; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Set; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostalState; import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; -import forestry.core.gui.ContainerForestry; import forestry.core.gui.IGuiSelectable; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; @@ -24,14 +32,8 @@ import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.mail.EnumStationState; import forestry.mail.network.PacketLetterInfo; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Set; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -public class ContainerCatalogue extends ContainerForestry implements IGuiSelectable { +public class ContainerCatalogue extends Container implements IGuiSelectable { private final EntityPlayer player; private final LinkedHashMap stations; @@ -53,7 +55,6 @@ public class ContainerCatalogue extends ContainerForestry implements IGuiSelecta }; public ContainerCatalogue(EntityPlayer player) { - super(player.inventory); this.player = player; // Filter out any trade stations which do not actually offer anything. @@ -227,6 +228,11 @@ public class ContainerCatalogue extends ContainerForestry implements IGuiSelecta } } + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } + @Override public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 78c24b5d5..642697792 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -10,6 +10,13 @@ ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.core.gui.ContainerForestry; @@ -18,10 +25,6 @@ import forestry.core.proxy.Proxies; import forestry.mail.POBox; import forestry.mail.gadgets.MachineMailbox; import forestry.plugins.PluginMail; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; public class ContainerMailbox extends ContainerForestry { @@ -32,7 +35,8 @@ public class ContainerMailbox extends ContainerForestry { private final POBox mailInventory; public ContainerMailbox(InventoryPlayer player, MachineMailbox tile) { - super(tile.getOrCreateMailInventory(player.player.worldObj, player.player.getGameProfile())); + super(tile); + IInventory inventory = tile.getOrCreateMailInventory(player.player.worldObj, player.player.getGameProfile()); // Mailbox contents this.mailbox = tile; diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index 95a63d41e..85922220c 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -10,24 +10,25 @@ ******************************************************************************/ package forestry.mail.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; + +import org.apache.commons.lang3.StringUtils; + import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; -import forestry.core.gui.ContainerForestry; -import forestry.core.inventory.InventoryAdapter; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; import forestry.mail.gadgets.MachineTrader; -import net.minecraft.entity.player.InventoryPlayer; -import org.apache.commons.lang3.StringUtils; -public class ContainerTradeName extends ContainerForestry { +public class ContainerTradeName extends Container { protected final MachineTrader machine; public ContainerTradeName(InventoryPlayer player, MachineTrader tile) { - super(new InventoryAdapter(0, "Empty")); machine = tile; } @@ -56,4 +57,8 @@ public class ContainerTradeName extends ContainerForestry { machine.setAddress(address); } + @Override + public boolean canInteractWith(EntityPlayer entityPlayer) { + return machine.isOwner(entityPlayer); + } } diff --git a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java index 6d8f847ef..35f27da81 100755 --- a/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java +++ b/src/main/java/forestry/pipes/gui/ContainerPropolisPipe.java @@ -8,19 +8,19 @@ */ package forestry.pipes.gui; -import forestry.core.gui.ContainerForestry; -import forestry.core.inventory.InventoryAdapter; -import forestry.pipes.PipeItemsPropolis; -import forestry.pipes.PipeLogicPropolis; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -public class ContainerPropolisPipe extends ContainerForestry { +import forestry.pipes.PipeItemsPropolis; +import forestry.pipes.PipeLogicPropolis; + +public class ContainerPropolisPipe extends Container { public final PipeLogicPropolis pipeLogic; public ContainerPropolisPipe(IInventory playerInventory, PipeItemsPropolis pipe) { - super(new InventoryAdapter(0, "Empty")); this.pipeLogic = pipe.pipeLogic; for (int l = 0; l < 3; l++) { @@ -34,4 +34,8 @@ public class ContainerPropolisPipe extends ContainerForestry { } } + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } } From 2b3b590cf48eed6ee46bbfb39379b51990f1ad2e Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 28 Dec 2014 18:04:40 -0800 Subject: [PATCH 129/175] Close #414 add better shift click for trade station --- src/main/java/forestry/mail/TradeStation.java | 6 +-- .../forestry/mail/gui/ContainerTrader.java | 52 +++++++++---------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index 4ce4df494..6b5a21f38 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -20,6 +20,7 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; import forestry.core.config.ForestryItem; +import forestry.core.interfaces.ICrafter; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StackUtils; @@ -553,10 +554,10 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide return itemStack.getItem() == Items.paper; if (slot >= SLOT_STAMPS_1 && slot < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT) - return IStamps.class.isAssignableFrom(itemStack.getItem().getClass()); + return itemStack.getItem() instanceof IStamps; if (slot >= SLOT_SEND_BUFFER && slot < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT) { - ItemStack item = new ItemStack(itemStack.getItem(), 1, itemStack.getItemDamage()); + ItemStack item = StackUtils.createSplitStack(itemStack, 1); return inventory.contains(item, SLOT_TRADEGOOD, SLOT_TRADEGOOD_COUNT); } @@ -603,5 +604,4 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide public boolean canExtractItem(int slot, ItemStack itemStack, int side, boolean permission) { return permission && slot >= SLOT_RECEIVE_BUFFER && slot < SLOT_RECEIVE_BUFFER + SLOT_RECEIVE_BUFFER_COUNT; } - } diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 7f67f748c..38fb66134 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -10,17 +10,20 @@ ******************************************************************************/ package forestry.mail.gui; -import forestry.api.mail.IMailAddress; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; -import forestry.mail.TradeStation; -import forestry.mail.gadgets.MachineTrader; -import forestry.mail.items.ItemStamps; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import forestry.api.mail.IMailAddress; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotClosed; +import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotForestry; +import forestry.mail.TradeStation; +import forestry.mail.gadgets.MachineTrader; +import forestry.mail.items.ItemStamps; + public class ContainerTrader extends ContainerForestry { private final MachineTrader machine; @@ -32,40 +35,40 @@ public class ContainerTrader extends ContainerForestry { IInventory inventory = machine.getOrCreateTradeInventory(); // Trade good - this.addSlotToContainer(new Slot(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109)); + this.addSlotToContainer(new SlotForestry(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109).blockShift()); // Exchange - for (int i = 0; i < 2; i++) { - for (int j = 0; j < 2; j++) { - addSlotToContainer(new Slot(inventory, TradeStation.SLOT_EXCHANGE_1 + j + i * 2, 69 + j * 18, 55 + i * 18)); + for (int row = 0; row < 2; row++) { + for (int col = 0; col < 2; col++) { + addSlotToContainer(new SlotForestry(inventory, TradeStation.SLOT_EXCHANGE_1 + col + row * 2, 69 + col * 18, 55 + row * 18).blockShift()); } } // Stamps - for (int i = 0; i < 2; i++) { - for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class)); + for (int row = 0; row < 2; row++) { + for (int col = 0; col < 2; col++) { + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + col + row * 2, 15 + col * 18, 37 + row * 18, ItemStamps.class)); } } // Letters - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper)); + for (int row = 0; row < 3; row++) { + for (int col = 0; col < 2; col++) { + addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + col + row * 2, 15 + col * 18, 73 + row * 18, Items.paper)); } } // Buffers final int bufCols = 5; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < bufCols; j++) { - addSlotToContainer(new Slot(inventory, TradeStation.SLOT_RECEIVE_BUFFER + j + i * bufCols, 123 + j * 18, 19 + i * 18)); + for (int row = 0; row < 3; row++) { + for (int col = 0; col < bufCols; col++) { + addSlotToContainer(new SlotClosed(inventory, TradeStation.SLOT_RECEIVE_BUFFER + col + row * bufCols, 123 + col * 18, 19 + row * 18)); } } - for (int i = 0; i < 2; i++) { - for (int j = 0; j < bufCols; j++) { - addSlotToContainer(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + j + i * bufCols, 123 + j * 18, (19 + (18 * 4)) + i * 18)); + for (int row = 0; row < 2; row++) { + for (int col = 0; col < bufCols; col++) { + addSlotToContainer(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + col + row * bufCols, 123 + col * 18, (19 + (18 * 4)) + row * 18)); } } @@ -79,11 +82,6 @@ public class ContainerTrader extends ContainerForestry { for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(player, i, 33 + i * 18, 196)); } - - } - - public boolean isLinked() { - return machine.isLinked(); } public IMailAddress getAddress() { From c54b7c40bb806b9b87750dcc0645f59fceae19b3 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 31 Dec 2014 04:22:10 -0800 Subject: [PATCH 130/175] Giant Inventory Refactor 2. Slots will only accept valid items Moved logic out of Containers, the old filtered slots were not always the same logic as the IInventory. Moved ISidedInventory logic up to TileForestry and use InventoryAdapters to override only the methods we need to. Tested a ton but there will be some new issues given the scope. --- api/forestry | 2 +- .../apiculture/GuiHandlerApiculture.java | 29 +- .../apiculture/gadgets/BlockBeehives.java | 3 +- .../apiculture/gadgets/TileAlveary.java | 38 ++- .../gadgets/TileAlvearyHygroregulator.java | 132 ++------ .../apiculture/gadgets/TileAlvearyPlain.java | 255 +++------------- .../apiculture/gadgets/TileAlvearySieve.java | 20 +- .../gadgets/TileAlvearySwarmer.java | 147 +-------- .../apiculture/gadgets/TileApiary.java | 38 +-- .../apiculture/gadgets/TileBeehouse.java | 151 +++------- .../apiculture/gadgets/TileSwarm.java | 3 +- .../apiculture/gui/ContainerAlveary.java | 28 +- .../gui/ContainerAlvearyHygroregulator.java | 11 +- .../apiculture/gui/ContainerAlvearySieve.java | 17 +- .../gui/ContainerAlvearySwarmer.java | 23 +- .../apiculture/gui/ContainerApiary.java | 37 ++- .../gui/ContainerHabitatLocator.java | 14 +- .../apiculture/gui/ContainerImprinter.java | 23 +- .../forestry/apiculture/gui/GuiBeealyzer.java | 20 +- .../apiculture/items/ItemBeealyzer.java | 32 +- .../apiculture/items/ItemBiomefinder.java | 16 +- .../apiculture/items/ItemImprinter.java | 75 +---- .../GuiHandlerArboriculture.java | 19 +- .../gui/ContainerTreealyzer.java | 32 -- .../arboriculture/gui/GuiTreealyzer.java | 24 +- .../arboriculture/items/ItemTreealyzer.java | 18 +- src/main/java/forestry/core/GuiHandler.java | 17 +- .../java/forestry/core/GuiHandlerBase.java | 9 +- .../core/circuits/ContainerSolderingIron.java | 42 +-- .../core/circuits/ItemSolderingIron.java | 37 ++- .../java/forestry/core/config/Defaults.java | 2 + .../forestry/core/fluids/FluidHelper.java | 3 +- .../forestry/core/fluids/TankManager.java | 3 + .../core/fluids/tanks/StandardTank.java | 2 +- .../forestry/core/gadgets/TileAnalyzer.java | 140 +++------ .../forestry/core/gadgets/TileEscritoire.java | 135 +++------ .../forestry/core/gadgets/TileForestry.java | 136 ++++++++- .../core/gadgets/TileNaturalistChest.java | 84 ++---- .../forestry/core/gui/ContainerAlyzer.java | 26 +- .../forestry/core/gui/ContainerAnalyzer.java | 24 +- .../core/gui/ContainerEscritoire.java | 27 +- .../forestry/core/gui/ContainerForestry.java | 6 +- .../core/gui/ContainerItemInventory.java | 30 +- .../core/gui/ContainerLiquidTanks.java | 2 +- .../gui/ContainerNaturalistInventory.java | 30 +- .../java/forestry/core/gui/GuiAlyzer.java | 24 +- .../forestry/core/gui/slots/SlotCustom.java | 138 --------- .../forestry/core/gui/slots/SlotFiltered.java | 38 +++ .../forestry/core/gui/slots/SlotForestry.java | 8 +- .../core/gui/slots/SlotItemInventory.java | 36 --- .../core/gui/slots/SlotLiquidContainer.java | 60 ---- .../forestry/core/gui/slots/SlotOutput.java | 60 ++-- .../forestry/core/gui/slots/SlotWatched.java | 66 ++++ .../IFilterSlotDelegate.java} | 52 ++-- .../core/inventory/AlyzerInventory.java | 46 +-- .../core/inventory/FakeInventoryAdapter.java | 134 +++++++++ .../core/inventory/IInventoryAdapter.java | 12 + .../forestry/core/inventory/InvTools.java | 251 ++++++++++++++++ .../core/inventory/InventoryAdapter.java | 282 ++---------------- .../core/inventory/ItemInventory.java | 69 ++--- .../core/inventory/ItemInventoryBackpack.java | 33 ++ .../core/inventory/TileInventoryAdapter.java | 20 +- .../forestry/core/network/PacketHandler.java | 4 - .../utils/GuiUtil.java} | 44 ++- .../java/forestry/core/utils/StackUtils.java | 23 +- src/main/java/forestry/core/utils/Utils.java | 49 ++- .../forestry/energy/gadgets/EngineBronze.java | 123 ++------ .../forestry/energy/gadgets/EngineCopper.java | 108 ++----- .../forestry/energy/gadgets/EngineTin.java | 92 ++---- .../energy/gadgets/MachineGenerator.java | 120 ++------ .../energy/gui/ContainerEngineBronze.java | 12 +- .../energy/gui/ContainerEngineCopper.java | 19 +- .../energy/gui/ContainerEngineTin.java | 9 +- .../energy/gui/ContainerGenerator.java | 12 +- .../factory/gadgets/MachineBottler.java | 164 ++++------ .../factory/gadgets/MachineCarpenter.java | 148 +++------ .../factory/gadgets/MachineCentrifuge.java | 100 ++----- .../factory/gadgets/MachineFabricator.java | 133 +++------ .../factory/gadgets/MachineFermenter.java | 165 ++++------ .../factory/gadgets/MachineMoistener.java | 187 ++++-------- .../factory/gadgets/MachineRaintank.java | 127 ++------ .../factory/gadgets/MachineSqueezer.java | 173 ++++------- .../factory/gadgets/MachineStill.java | 141 +++------ .../factory/gadgets/TileWorktable.java | 11 +- .../factory/gui/ContainerBottler.java | 18 +- .../factory/gui/ContainerCarpenter.java | 41 +-- .../factory/gui/ContainerCentrifuge.java | 12 +- .../factory/gui/ContainerFabricator.java | 7 +- .../factory/gui/ContainerFermenter.java | 21 +- .../factory/gui/ContainerMoistener.java | 21 +- .../factory/gui/ContainerRaintank.java | 15 +- .../factory/gui/ContainerSqueezer.java | 14 +- .../forestry/factory/gui/ContainerStill.java | 11 +- .../forestry/farming/gadgets/TileFarm.java | 7 +- .../farming/gadgets/TileFarmPlain.java | 113 ++++--- .../forestry/farming/gadgets/TileHatch.java | 173 ++--------- .../forestry/farming/gui/ContainerFarm.java | 66 +--- .../java/forestry/food/GuiHandlerFood.java | 11 +- .../forestry/food/gui/ContainerInfuser.java | 24 +- .../java/forestry/food/items/ItemInfuser.java | 81 +---- .../GuiHandlerLepidopterology.java | 19 +- .../gui/ContainerFlutterlyzer.java | 27 -- .../lepidopterology/gui/GuiFlutterlyzer.java | 3 +- .../items/ItemFlutterlyzer.java | 23 +- .../java/forestry/mail/GuiHandlerMail.java | 10 +- src/main/java/forestry/mail/Letter.java | 11 +- src/main/java/forestry/mail/POBox.java | 17 +- src/main/java/forestry/mail/PostRegistry.java | 3 + src/main/java/forestry/mail/TradeStation.java | 179 ++++++----- .../forestry/mail/gadgets/MachineMailbox.java | 6 +- .../mail/gadgets/MachinePhilatelist.java | 77 +---- .../forestry/mail/gadgets/MachineTrader.java | 130 +------- .../forestry/mail/gui/ContainerLetter.java | 43 +-- .../forestry/mail/gui/ContainerMailbox.java | 5 +- .../mail/gui/ContainerPhilatelist.java | 14 +- .../forestry/mail/gui/ContainerTrader.java | 20 +- .../java/forestry/mail/items/ItemLetter.java | 47 +-- .../forestry/storage/BackpackDefinition.java | 10 +- .../forestry/storage/GuiHandlerStorage.java | 40 ++- .../forestry/storage/ResupplyHandler.java | 3 +- .../storage/gui/ContainerBackpack.java | 40 +-- .../gui/ContainerNaturalistBackpack.java | 43 +-- .../forestry/storage/items/ItemBackpack.java | 9 +- .../storage/items/ItemNaturalistBackpack.java | 4 +- 124 files changed, 2414 insertions(+), 4259 deletions(-) delete mode 100755 src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java delete mode 100755 src/main/java/forestry/core/gui/slots/SlotCustom.java create mode 100644 src/main/java/forestry/core/gui/slots/SlotFiltered.java delete mode 100755 src/main/java/forestry/core/gui/slots/SlotItemInventory.java delete mode 100755 src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java create mode 100644 src/main/java/forestry/core/gui/slots/SlotWatched.java rename src/main/java/forestry/core/{gui/slots/SlotClosed.java => interfaces/IFilterSlotDelegate.java} (61%) mode change 100755 => 100644 create mode 100644 src/main/java/forestry/core/inventory/FakeInventoryAdapter.java create mode 100644 src/main/java/forestry/core/inventory/IInventoryAdapter.java create mode 100644 src/main/java/forestry/core/inventory/ItemInventoryBackpack.java rename src/main/java/forestry/{apiculture/gui/ContainerBeealyzer.java => core/utils/GuiUtil.java} (51%) mode change 100755 => 100644 delete mode 100755 src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java diff --git a/api/forestry b/api/forestry index 76ba9ef8a..c87f1fe97 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 76ba9ef8a474db454fdd3d5c1a187822a689d4a0 +Subproject commit c87f1fe97694408d5cfcd021a3e568ec7777ee12 diff --git a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java index fac85dfde..569932e52 100755 --- a/src/main/java/forestry/apiculture/GuiHandlerApiculture.java +++ b/src/main/java/forestry/apiculture/GuiHandlerApiculture.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.apiculture; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.apiculture.gadgets.TileAlvearyHygroregulator; import forestry.apiculture.gadgets.TileAlvearyPlain; import forestry.apiculture.gadgets.TileAlvearySieve; @@ -22,7 +26,6 @@ import forestry.apiculture.gui.ContainerAlvearyHygroregulator; import forestry.apiculture.gui.ContainerAlvearySieve; import forestry.apiculture.gui.ContainerAlvearySwarmer; import forestry.apiculture.gui.ContainerApiary; -import forestry.apiculture.gui.ContainerBeealyzer; import forestry.apiculture.gui.ContainerHabitatLocator; import forestry.apiculture.gui.ContainerImprinter; import forestry.apiculture.gui.GuiAlveary; @@ -37,11 +40,9 @@ import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; import forestry.apiculture.items.ItemImprinter.ImprinterInventory; import forestry.core.GuiHandlerBase; +import forestry.core.gui.ContainerAlyzer; import forestry.core.network.GuiId; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class GuiHandlerApiculture extends GuiHandlerBase { @@ -72,7 +73,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase { return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z)); case BeealyzerGUI: - equipped = getEquippedItem(player); + equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; @@ -82,7 +83,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase { return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z)); case HabitatLocatorGUI: - equipped = getEquippedItem(player); + equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; @@ -92,7 +93,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase { return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z)); case ImprinterGUI: - return new GuiImprinter(player.inventory, new ImprinterInventory(player)); + equipped = player.getCurrentEquippedItem(); + if (equipped == null) + return null; + return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped)); default: return null; @@ -129,19 +133,19 @@ public class GuiHandlerApiculture extends GuiHandlerBase { return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true); case BeealyzerGUI: - equipped = getEquippedItem(player); + equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; synchApiaristTracker(world, player); - return new ContainerBeealyzer(player.inventory, new BeealyzerInventory(player, equipped)); + return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player); case BeehouseGUI: synchApiaristTracker(world, player); return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false); case HabitatLocatorGUI: - equipped = getEquippedItem(player); + equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; @@ -152,7 +156,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase { case ImprinterGUI: synchApiaristTracker(world, player); - return new ContainerImprinter(player.inventory, new ImprinterInventory(player)); + equipped = player.getCurrentEquippedItem(); + if (equipped == null) + return null; + return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped)); default: return null; diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index 4eaccd7c5..c40cd2514 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -17,6 +17,7 @@ import forestry.api.apiculture.hives.HiveManager; import forestry.api.core.Tabs; import forestry.apiculture.MaterialBeehive; import forestry.core.config.Config; +import forestry.core.inventory.InvTools; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; import java.util.ArrayList; @@ -63,7 +64,7 @@ public class BlockBeehives extends BlockContainer { if (tile instanceof TileSwarm) { TileSwarm swarm = (TileSwarm) tile; if (swarm.containsBees()) - for (ItemStack beeStack : swarm.contained.getStacks()) + for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) if (beeStack != null) StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index 8985493cf..a44705bc8 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -10,8 +10,16 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; @@ -21,15 +29,13 @@ import forestry.apiculture.trigger.ApicultureTriggers; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.gadgets.TileForestry; +import forestry.core.inventory.FakeInventoryAdapter; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import java.util.Collection; -import java.util.LinkedList; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.ITriggerExternal; public abstract class TileAlveary extends TileForestry implements IAlvearyComponent { @@ -117,12 +123,16 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon } @Override - public void fromPacketPayload(PacketPayload payload) { + public PacketPayload getPacketPayload() { + PacketPayload payload = new PacketPayload(0, 1); + payload.shortPayload[0] = (short) (isMaster() ? 1 : 0); + return payload; } @Override - public PacketPayload getPacketPayload() { - return null; + public void fromPacketPayload(PacketPayload payload) { + if (payload.shortPayload[0] > 0) + makeMaster(); } /* ITILESTRUCTURE */ @@ -141,7 +151,7 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon setCentralTE(null); isMaster = true; - if (getInternalInventory() == null) + if (getInternalInventory() instanceof FakeInventoryAdapter) createInventory(); } @@ -208,12 +218,12 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon } @Override - public final IInventory getInventory() { + public final IInventoryAdapter getInventory() { return getStructureInventory(); } @Override - public ISidedInventory getStructureInventory() { + public IInventoryAdapter getStructureInventory() { return getInternalInventory(); } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java index 23e76f592..5a0c8d5bf 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java @@ -10,6 +10,18 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.apiculture.IAlvearyComponent; import forestry.api.core.ForestryAPI; import forestry.core.config.Defaults; @@ -18,20 +30,9 @@ import forestry.core.fluids.Fluids; import forestry.core.fluids.TankManager; import forestry.core.fluids.tanks.FilteredTank; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; -import forestry.core.proxy.Proxies; -import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer { @@ -54,6 +55,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory } } + public static final short SLOT_INPUT = 0; + private final HygroregulatorRecipe[] recipes; /* MEMBERS */ @@ -66,7 +69,16 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory public TileAlvearyHygroregulator() { super(BLOCK_META); - setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv")); + setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_INPUT) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return liquidTank.accepts(fluid); + } + return false; + } + }); Fluid water = Fluids.WATER.getFluid(); Fluid lava = Fluids.LAVA.getFluid(); @@ -85,11 +97,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory player.openGui(ForestryAPI.instance, GuiId.HygroregulatorGUI.ordinal(), worldObj, xCoord, yCoord, zCoord); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - /* UPDATING */ private HygroregulatorRecipe getRecipe(FluidStack liquid) { HygroregulatorRecipe recipe = null; @@ -131,7 +138,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - TileInventoryAdapter canInventory = getInternalInventory(); + IInventoryAdapter canInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (canInventory.getStackInSlot(0) != null) @@ -178,93 +185,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory return BlockAlveary.ALVEARY_HYGRO; } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - if (getInternalInventory() != null) - return getInternalInventory().getSizeInventory(); - else - return 0; - } - - @Override - public ItemStack getStackInSlot(int slotIndex) { - if (getInternalInventory() != null) - return getInternalInventory().getStackInSlot(slotIndex); - else - return null; - } - - @Override - public ItemStack decrStackSize(int slotIndex, int amount) { - if (getInternalInventory() != null) - return getInternalInventory().decrStackSize(slotIndex, amount); - else - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) { - if (getInternalInventory() != null) - return getInternalInventory().getStackInSlotOnClosing(slotIndex); - else - return null; - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - // Client side handling for container synch - if (getInternalInventory() == null && !Proxies.common.isSimulating(worldObj)) - createInventory(); - - if (getInternalInventory() != null) - getInternalInventory().setInventorySlotContents(slotIndex, itemstack); - } - - @Override - public int getInventoryStackLimit() { - if (getInternalInventory() != null) - return getInternalInventory().getInventoryStackLimit(); - else - return 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getInternalInventory(); - if (inv != null) - return inv.isUseableByPlayer(player); - return Utils.isUseableByPlayer(player, this); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == 0) { - FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack); - if (fluid == null || fluid.amount <= 0) - return false; - return liquidTank.accepts(fluid.getFluid()); - } - - return false; - } - /* ILIQUIDTANKCONTAINER */ @Override public TankManager getTankManager() { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java index 74d256b1b..2069e4ec1 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java @@ -10,7 +10,20 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import java.util.LinkedHashSet; +import java.util.Set; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import com.mojang.authlib.GameProfile; + import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; @@ -31,6 +44,8 @@ import forestry.core.config.Defaults; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; @@ -38,16 +53,6 @@ import forestry.core.network.PacketInventoryStack; import forestry.core.proxy.Proxies; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; -import java.util.LinkedHashSet; -import java.util.Set; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource { @@ -239,7 +244,21 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB /* STRUCTURE MANAGMENT */ @Override protected void createInventory() { - setInternalInventory(new TileInventoryAdapter(this, 9, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 9, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_QUEEN) { + return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack); + } else if (slotIndex == SLOT_DRONE) { + return PluginApiculture.beeInterface.isDrone(itemStack); + } + return false; + } + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE; + } + }); } @Override @@ -427,11 +446,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB @Override public boolean addProduct(ItemStack product, boolean all) { - TileInventoryAdapter inventory = getStructureInventory(); + IInventoryAdapter inventory = getStructureInventory(); if (inventory == null) return false; - return inventory.tryAddStack(product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all); + return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all); } @Override @@ -527,214 +546,18 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB /* IINVENTORY */ @Override - public TileInventoryAdapter getStructureInventory() { - TileInventoryAdapter inventory = getInternalInventory(); - if (inventory != null) { - if (isMaster() || !Proxies.common.isSimulating(worldObj)) - return inventory; + public IInventoryAdapter getInternalInventory() { + IInventoryAdapter inventory = super.getInternalInventory(); + if (isMaster()) { + return inventory; } else if (hasMaster()) { ITileStructure central = getCentralTE(); - if (central != null) - return (TileInventoryAdapter) central.getInventory(); + if (central instanceof TileAlveary) + return ((TileAlveary) central).getInternalInventory(); } - return null; + return inventory; } - @Override - public int getSizeInventory() { - IInventory inv = getStructureInventory(); - if (inv == null) - return 0; - - return inv.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int slotIndex) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.getStackInSlot(slotIndex); - } - - @Override - public ItemStack decrStackSize(int slotIndex, int amount) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.decrStackSize(slotIndex, amount); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.getStackInSlotOnClosing(slotIndex); - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - IInventory inv = getStructureInventory(); - - // Client side handling for container synch - if (inv == null && !Proxies.common.isSimulating(worldObj)) { - createInventory(); - inv = getInternalInventory(); - } - if (inv != null) - inv.setInventorySlotContents(slotIndex, itemstack); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public int getInventoryStackLimit() { - IInventory inv = getStructureInventory(); - if (inv == null) - return 0; - - return inv.getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getStructureInventory(); - if (inv != null) - return inv.isUseableByPlayer(player); - return Utils.isUseableByPlayer(player, this); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - ISidedInventory inventory = getStructureInventory(); - if (inventory == null) - return false; - - if (!inventory.isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) - && !PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - return slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack); - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - ISidedInventory inventory = getStructureInventory(); - if (inventory == null) - return false; - if (!inventory.canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - ISidedInventory inventory = getStructureInventory(); - if (inventory == null) - return Defaults.FACINGS_NONE; - return inventory.getAccessibleSlotsFromSide(side); - } - - /* ISPECIALINVENTORY */ -// @Override -// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) { -// -// IInventory inv = getStructureInventory(); -// if (inv == null) -// return 0; -// -// // Princesses && Queens -// if (ForestryItem.beePrincessGE.isItemEqual(stack) || ForestryItem.beeQueenGE.isItemEqual(stack)) -// if (inv.getStackInSlot(SLOT_QUEEN) == null) { -// if (doAdd) { -// inv.setInventorySlotContents(SLOT_QUEEN, stack.copy()); -// inv.getStackInSlot(SLOT_QUEEN).stackSize = 1; -// } -// return 1; -// } -// -// // Drones -// if (ForestryItem.beeDroneGE.isItemEqual(stack)) { -// -// ItemStack droneStack = inv.getStackInSlot(SLOT_DRONE); -// if (droneStack == null) { -// if (doAdd) -// inv.setInventorySlotContents(SLOT_DRONE, stack.copy()); -// return stack.stackSize; -// } else { -// if (!droneStack.isItemEqual(stack)) -// return 0; -// if (!ItemStack.areItemStackTagsEqual(droneStack, stack)) -// return 0; -// int space = droneStack.getMaxStackSize() - droneStack.stackSize; -// if (space <= 0) -// return 0; -// -// int added = space > stack.stackSize ? stack.stackSize : space; -// if (doAdd) -// droneStack.stackSize += added; -// return added; -// } -// } -// -// return 0; -// } -// -// @Override -// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) { -// -// IInventory inv = getStructureInventory(); -// if (inv == null) -// return new ItemStack[0]; -// -// ItemStack product = null; -// -// for (int i = SLOT_PRODUCT_1; i < inv.getSizeInventory(); i++) { -// if (inv.getStackInSlot(i) == null) -// continue; -// -// ItemStack stack = inv.getStackInSlot(i); -// -// if (doRemove) -// product = inv.decrStackSize(i, 1); -// else { -// product = stack.copy(); -// product.stackSize = 1; -// } -// break; -// } -// -// return new ItemStack[]{product}; -// } - /* SMP GUI */ public void getGUINetworkData(int i, int j) { switch (i) { diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java index 8987def65..c42a9f247 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySieve.java @@ -20,9 +20,12 @@ import forestry.api.arboriculture.EnumGermlingType; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; +import forestry.core.config.ForestryItem; import forestry.core.interfaces.ICrafter; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; +import forestry.core.utils.StackUtils; public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener { @@ -35,7 +38,12 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe public TileAlvearySieve() { super(BLOCK_META); - setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1)); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1) { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack); + } + }); } @Override @@ -80,19 +88,19 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } private void destroySieve() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); inventory.setInventorySlotContents(SLOT_SIEVE, null); } private void destroyPollen() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { inventory.setInventorySlotContents(i, null); } } private boolean canStorePollen() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if(inventory.getStackInSlot(SLOT_SIEVE) == null) return false; @@ -105,7 +113,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe } private void storePollenStack(ItemStack itemstack) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) { if(inventory.getStackInSlot(i) == null) { inventory.setInventorySlotContents(i, itemstack); @@ -122,7 +130,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe @Override public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if(slotIndex == SLOT_SIEVE) { destroyPollen(); return inventory.getStackInSlot(SLOT_SIEVE); diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index 7e68b4c09..e73518279 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -10,6 +10,15 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import java.util.Map.Entry; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IAlvearyComponent; @@ -18,25 +27,13 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.core.ForestryAPI; import forestry.apiculture.worldgen.HiveDecorator; import forestry.apiculture.worldgen.HiveSwarmer; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryItem; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; -import forestry.core.proxy.Proxies; import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; -import java.util.Map.Entry; -import java.util.Stack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { @@ -48,13 +45,12 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { public TileAlvearySwarmer() { super(BLOCK_META); - } - - @Override - public void initialize() { - super.initialize(); - if (getInternalInventory() == null) - createInventory(); + setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack); + } + }); } @Override @@ -184,8 +180,6 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { /* SAVING & LOADING */ @Override public void readFromNBT(NBTTagCompound nbttagcompound) { - if (getInternalInventory() == null) - createInventory(); super.readFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10); @@ -213,115 +207,4 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { nbttagcompound.setTag("PendingSpawns", nbttaglist); } - - @Override - protected void createInventory() { - setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv")); - } - - /* IINVENTORY */ - @Override - public int getSizeInventory() { - if (getInternalInventory() != null) - return getInternalInventory().getSizeInventory(); - else - return 0; - } - - @Override - public ItemStack getStackInSlot(int slotIndex) { - if (getInternalInventory() != null) - return getInternalInventory().getStackInSlot(slotIndex); - else - return null; - } - - @Override - public ItemStack decrStackSize(int slotIndex, int amount) { - if (getInternalInventory() != null) - return getInternalInventory().decrStackSize(slotIndex, amount); - else - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) { - if (getInternalInventory() != null) - return getInternalInventory().getStackInSlotOnClosing(slotIndex); - else - return null; - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - // Client side handling for container synch - if (getInternalInventory() == null && !Proxies.common.isSimulating(worldObj)) - createInventory(); - - if (getInternalInventory() != null) - getInternalInventory().setInventorySlotContents(slotIndex, itemstack); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public int getInventoryStackLimit() { - if (getInternalInventory() != null) - return getInternalInventory().getInventoryStackLimit(); - else - return 0; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getInternalInventory(); - if (inv != null) - return inv.isUseableByPlayer(player); - return Utils.isUseableByPlayer(player, this); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { - if (getInternalInventory() != null) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) - return false; - return StackUtils.isIdenticalItem(stack, ForestryItem.royalJelly.getItemStack()); - } - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - if (getInternalInventory() != null) - return getInternalInventory().getAccessibleSlotsFromSide(side); - return Defaults.FACINGS_NONE; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - if (getInternalInventory() != null) - return getInternalInventory().isItemValidForSlot(slot, stack); - return false; - } - - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - return false; - } } diff --git a/src/main/java/forestry/apiculture/gadgets/TileApiary.java b/src/main/java/forestry/apiculture/gadgets/TileApiary.java index c3cb94abb..7353a46c5 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileApiary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileApiary.java @@ -10,27 +10,31 @@ ******************************************************************************/ package forestry.apiculture.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.Collection; +import java.util.LinkedList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + import cpw.mods.fml.common.Optional; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IHiveFrame; import forestry.api.core.ForestryAPI; import forestry.apiculture.trigger.ApicultureTriggers; import forestry.core.gadgets.TileBase; -import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.network.GuiId; import forestry.plugins.PluginApiculture; -import java.util.Collection; -import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; + +import buildcraft.api.statements.ITriggerExternal; public class TileApiary extends TileBeehouse { - @Override - public String getInventoryName() { - return getUnlocalizedName(); + public TileApiary() { + setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items")); } @Override @@ -41,7 +45,7 @@ public class TileApiary extends TileBeehouse { /* IBEEHOUSING */ @Override public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -54,7 +58,7 @@ public class TileApiary extends TileBeehouse { @Override public float getProductionModifier(IBeeGenome genome, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 0.1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -67,7 +71,7 @@ public class TileApiary extends TileBeehouse { @Override public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -80,7 +84,7 @@ public class TileApiary extends TileBeehouse { @Override public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 1.0f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -93,7 +97,7 @@ public class TileApiary extends TileBeehouse { @Override public float getFloweringModifier(IBeeGenome genome, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -106,7 +110,7 @@ public class TileApiary extends TileBeehouse { @Override public float getGeneticDecay(IBeeGenome genome, float currentModifier) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); float mod = 1f; for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { if (inventory.getStackInSlot(i) == null) @@ -119,7 +123,7 @@ public class TileApiary extends TileBeehouse { @Override public void wearOutEquipment(int amount) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier()); for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) { diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 59dc13288..2586566dc 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -10,11 +10,21 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import com.mojang.authlib.GameProfile; + import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeekeepingLogic; +import forestry.api.apiculture.IHiveFrame; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; @@ -23,36 +33,53 @@ import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.config.ForestryItem; import forestry.core.gadgets.TileBase; +import forestry.core.gadgets.TileForestry; import forestry.core.interfaces.IClimatised; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketIds; import forestry.core.network.PacketInventoryStack; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; +import forestry.core.utils.GuiUtil; import forestry.core.utils.Utils; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, ISidedInventory { +public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { + + protected static class BeehouseInventoryAdapter extends TileInventoryAdapter { + public BeehouseInventoryAdapter(TileForestry tile, int size, String name) { + super(tile, size, name); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_QUEEN) { + return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack); + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) { + return itemStack.getItem() instanceof IHiveFrame; + } else if (slotIndex == SLOT_DRONE) { + return PluginApiculture.beeInterface.isDrone(itemStack); + } + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT); + } + } // CONSTANTS public static final int SLOT_QUEEN = 0; public static final int SLOT_DRONE = 1; - public static final int SLOT_INVENTORY_1 = 2; public static final int SLOT_PRODUCT_1 = 2; public static final int SLOT_PRODUCT_COUNT = 7; public static final int SLOT_FRAMES_1 = 9; public static final int SLOT_FRAMES_2 = 10; public static final int SLOT_FRAMES_3 = 11; - public static final int SLOT_INVENTORY_COUNT = 7; public static final int SLOT_FRAMES_COUNT = 3; private final IBeekeepingLogic logic; private BiomeGenBase biome; @@ -62,7 +89,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, public TileBeehouse() { setHints(Config.hints.get("apiary")); logic = PluginApiculture.beeInterface.createBeekeepingLogic(this); - setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); + setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation()); } @Override @@ -178,7 +205,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, @Override public boolean addProduct(ItemStack product, boolean all) { - return getInternalInventory().tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true); + return InvTools.tryAddStack(getInternalInventory(), product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true); } /* NETWORK SYNCH */ @@ -194,7 +221,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, /* STATE INFORMATION */ private int getHealthDisplay() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -207,7 +234,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, } private int getMaxHealthDisplay() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_QUEEN) == null) return 0; @@ -272,99 +299,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime()); } - /* INVENTORY MANAGMENT */ - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack decrStackSize(int slotIndex, int amount) { - return getInternalInventory().decrStackSize(slotIndex, amount); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) { - return getInternalInventory().getStackInSlotOnClosing(slotIndex); - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack stack) { - getInternalInventory().setInventorySlotContents(slotIndex, stack); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack) - && !PluginApiculture.beeInterface.isDrone(itemstack)) - return true; - - return slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(side, itemstack, side)) - return false; - - switch (slotIndex) { - case SLOT_QUEEN: - case SLOT_DRONE: - case SLOT_FRAMES_1: - case SLOT_FRAMES_2: - case SLOT_FRAMES_3: - return false; - default: - return true; - } - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { - return isItemValidForSlot(slotIndex, stack); - } - // / IBEEHOUSING @Override public int getXCoord() { @@ -508,5 +442,4 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, public GameProfile getOwnerName() { return this.getOwnerProfile(); } - } diff --git a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java index 7218eae58..e0bb93925 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileSwarm.java +++ b/src/main/java/forestry/apiculture/gadgets/TileSwarm.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.apiculture.gadgets; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -26,7 +27,7 @@ public class TileSwarm extends TileEntity { public TileSwarm setContained(ItemStack[] bees) { for (ItemStack itemstack : bees) - contained.addStack(itemstack, false, true); + InvTools.addStack(contained, itemstack, false, true); return this; } diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java index 3b54fba52..55d80f31d 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlveary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlveary.java @@ -10,15 +10,15 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.gadgets.TileAlvearyPlain; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; +import forestry.apiculture.gadgets.TileAlvearyPlain; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; + public class ContainerAlveary extends ContainerForestry { private final TileAlvearyPlain tile; @@ -30,19 +30,19 @@ public class ContainerAlveary extends ContainerForestry { tile.sendNetworkUpdate(); // Queen/Princess - this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39)); // Drone - this.addSlotToContainer(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65)); // Product Inventory - this.addSlotToContainer(new SlotClosed(tile, 2, 116, 52)); - this.addSlotToContainer(new SlotClosed(tile, 3, 137, 39)); - this.addSlotToContainer(new SlotClosed(tile, 4, 137, 65)); - this.addSlotToContainer(new SlotClosed(tile, 5, 116, 78)); - this.addSlotToContainer(new SlotClosed(tile, 6, 95, 65)); - this.addSlotToContainer(new SlotClosed(tile, 7, 95, 39)); - this.addSlotToContainer(new SlotClosed(tile, 8, 116, 26)); + this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52)); + this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39)); + this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65)); + this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78)); + this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65)); + this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39)); + this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26)); // Player inventory for (int i = 0; i < 3; i++) diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java index 0cf557808..3359f0913 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearyHygroregulator.java @@ -10,18 +10,19 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.gadgets.TileAlvearyHygroregulator; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import forestry.apiculture.gadgets.TileAlvearyHygroregulator; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; + public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks { public ContainerAlvearyHygroregulator(IInventory playerInventory, TileAlvearyHygroregulator tile) { - super(playerInventory, tile); + super(tile); - this.addSlotToContainer(new SlotLiquidContainer(tile, 0, 56, 38)); + this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.SLOT_INPUT, 56, 38)); for (int i = 0; i < 3; ++i) for (int var4 = 0; var4 < 9; ++var4) diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java index 9f2432e73..a1f3bd127 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySieve.java @@ -11,27 +11,24 @@ package forestry.apiculture.gui; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import forestry.apiculture.gadgets.TileAlvearySieve; -import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; public class ContainerAlvearySieve extends ContainerForestry { public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) { super(tile); - IInventory inventory = tile.getInternalInventory(); + addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setCrafter(tile)); + addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setCrafter(tile)); + addSlotToContainer(new SlotOutput(tile, 2, 73, 39).setCrafter(tile)); + addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setCrafter(tile)); - addSlotToContainer(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile)); - addSlotToContainer(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile)); - addSlotToContainer(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile)); - addSlotToContainer(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile)); - - addSlotToContainer(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile)); + addSlotToContainer(new SlotFiltered(tile, TileAlvearySieve.SLOT_SIEVE, 43, 39).setCrafter(tile)); // Player inventory for (int i = 0; i < 3; i++) { diff --git a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java index fcd304f79..a2093fb6f 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gui/ContainerAlvearySwarmer.java @@ -10,24 +10,22 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.api.apiculture.BeeManager; -import forestry.apiculture.gadgets.TileAlvearySwarmer; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; -import java.util.Set; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; + +import forestry.apiculture.gadgets.TileAlvearySwarmer; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; public class ContainerAlvearySwarmer extends ContainerForestry { public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) { super(tile); - this.addSlotToContainer(new SlotCustom(tile, 0, 79, 52, getInducerItems())); - this.addSlotToContainer(new SlotCustom(tile, 1, 100, 39, getInducerItems())); - this.addSlotToContainer(new SlotCustom(tile, 2, 58, 39, getInducerItems())); - this.addSlotToContainer(new SlotCustom(tile, 3, 79, 26, getInducerItems())); + this.addSlotToContainer(new SlotFiltered(tile, 0, 79, 52)); + this.addSlotToContainer(new SlotFiltered(tile, 1, 100, 39)); + this.addSlotToContainer(new SlotFiltered(tile, 2, 58, 39)); + this.addSlotToContainer(new SlotFiltered(tile, 3, 79, 26)); // Player inventory for (int i = 0; i < 3; i++) @@ -38,9 +36,4 @@ public class ContainerAlvearySwarmer extends ContainerForestry { addSlotToContainer(new Slot(player, i, 8 + i * 18, 145)); } - - private Object[] getInducerItems() { - Set inducers = BeeManager.inducers.keySet(); - return inducers.toArray(new Object[inducers.size()]); - } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerApiary.java b/src/main/java/forestry/apiculture/gui/ContainerApiary.java index a35dd2d5f..9506d28a5 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerApiary.java +++ b/src/main/java/forestry/apiculture/gui/ContainerApiary.java @@ -10,17 +10,15 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.api.apiculture.IHiveFrame; -import forestry.apiculture.gadgets.TileBeehouse; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import forestry.apiculture.gadgets.TileBeehouse; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; + public class ContainerApiary extends ContainerForestry { private final TileBeehouse tile; @@ -30,29 +28,28 @@ public class ContainerApiary extends ContainerForestry { this.tile = tile; tile.sendNetworkUpdate(); - IInventory inv = tile.getInternalInventory(); // Queen/Princess - this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE)); + this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_QUEEN, 29, 39)); // Drone - this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE)); + this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_DRONE, 29, 65)); // Frames if (hasFrames) { - this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class)); - this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class)); - this.addSlotToContainer(new SlotCustom(inv, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class)); + this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1, 66, 23)); + this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52)); + this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81)); } // Product Inventory - this.addSlotToContainer(new SlotClosed(inv, 2, 116, 52)); - this.addSlotToContainer(new SlotClosed(inv, 3, 137, 39)); - this.addSlotToContainer(new SlotClosed(inv, 4, 137, 65)); - this.addSlotToContainer(new SlotClosed(inv, 5, 116, 78)); - this.addSlotToContainer(new SlotClosed(inv, 6, 95, 65)); - this.addSlotToContainer(new SlotClosed(inv, 7, 95, 39)); - this.addSlotToContainer(new SlotClosed(inv, 8, 116, 26)); + this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52)); + this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39)); + this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65)); + this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78)); + this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65)); + this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39)); + this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26)); // Player inventory for (int i1 = 0; i1 < 3; i1++) { diff --git a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java index 2123148ad..6772a9fa6 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/ContainerHabitatLocator.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBiomefinder; import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory; import forestry.core.config.ForestryItem; import forestry.core.gui.ContainerItemInventory; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -31,12 +30,12 @@ public class ContainerHabitatLocator extends ContainerItemInventory { this.inventory = inventory; // Energy - this.addSlotToContainer(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop)); + this.addSlotToContainer(new SlotFiltered(inventory, 2, 152, 8)); // Bee to analyze - this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class)); + this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 32)); // Analyzed bee - this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class)); + this.addSlotToContainer(new SlotFiltered(inventory, 1, 152, 75)); // Player inventory for (int i1 = 0; i1 < 3; i1++) @@ -68,9 +67,4 @@ public class ContainerHabitatLocator extends ContainerItemInventory { } - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - return false; - } - } diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java index 44313e457..e7e14ac26 100755 --- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java +++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java @@ -10,21 +10,22 @@ ******************************************************************************/ package forestry.apiculture.gui; -import forestry.apiculture.items.ItemBeeGE; -import forestry.apiculture.items.ItemImprinter.ImprinterInventory; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.IGuiSelectable; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.network.PacketIds; -import forestry.core.network.PacketPayload; -import forestry.core.network.PacketUpdate; -import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.apiculture.items.ItemImprinter.ImprinterInventory; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.IGuiSelectable; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.core.network.PacketIds; +import forestry.core.network.PacketPayload; +import forestry.core.network.PacketUpdate; +import forestry.core.proxy.Proxies; + public class ContainerImprinter extends ContainerForestry implements IGuiSelectable { public final ImprinterInventory inventory; @@ -35,9 +36,9 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta this.inventory = inventory; // Input - this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class)); + this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 12)); // Output - this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class)); + this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 8f2babe5c..35efd1f78 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -10,36 +10,33 @@ ******************************************************************************/ package forestry.apiculture.gui; +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.IBee; import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleArea; -import forestry.api.genetics.IAlleleFlowers; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IAlleleTolerance; -import forestry.api.genetics.IChromosome; import forestry.apiculture.genetics.BeeGenome; import forestry.apiculture.items.ItemBeeGE; import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; import forestry.core.config.ForestryItem; -import forestry.core.genetics.AlleleArea; import forestry.core.genetics.AlleleBoolean; -import forestry.core.genetics.Chromosome; -import forestry.core.genetics.Genome; +import forestry.core.gui.ContainerAlyzer; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.core.vect.Vect; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class GuiBeealyzer extends GuiAlyzer { public GuiBeealyzer(EntityPlayer player, BeealyzerInventory inventory) { - super("rootBees", player, new ContainerBeealyzer(player.inventory, inventory), inventory, "gui.beealyzer"); + super("rootBees", player, new ContainerAlyzer(inventory, player), inventory, "gui.beealyzer"); ArrayList beeList = new ArrayList(); ((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false); @@ -54,7 +51,8 @@ public class GuiBeealyzer extends GuiAlyzer { int page = 0; IBee bee = null; EnumBeeType beeType = EnumBeeType.DRONE; - for (int k = 1; k < BeealyzerInventory.SLOT_ANALYZE_5 + 1; k++) { + + for (int k = BeealyzerInventory.SLOT_SPECIMEN; k <= BeealyzerInventory.SLOT_ANALYZE_5; k++) { if (k == BeealyzerInventory.SLOT_ENERGY) continue; diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index bbd2df988..544cc093e 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -10,12 +10,16 @@ ******************************************************************************/ package forestry.apiculture.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import forestry.api.apiculture.IBee; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.core.EnumErrorCode; import forestry.core.config.Config; -import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; import forestry.core.inventory.AlyzerInventory; @@ -23,39 +27,22 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginApiculture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ItemBeealyzer extends ItemInventoried { public static class BeealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource { - public BeealyzerInventory(EntityPlayer player) { - super(ItemBeealyzer.class, 7); - this.player = player; - } - public BeealyzerInventory(EntityPlayer player, ItemStack itemStack) { super(ItemBeealyzer.class, 7, itemStack); this.player = player; } - private boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) - return false; - - return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); + @Override + protected boolean isSpecimen(ItemStack itemStack) { + return PluginApiculture.beeInterface.isMember(itemStack); } private void tryAnalyze() { - - // Analyzed slot occupied, abort - if (inventoryStacks[SLOT_ANALYZE_1] != null || inventoryStacks[SLOT_ANALYZE_2] != null || inventoryStacks[SLOT_ANALYZE_3] != null - || inventoryStacks[SLOT_ANALYZE_4] != null || inventoryStacks[SLOT_ANALYZE_5] != null) - return; - // Source slot to analyze empty if (getStackInSlot(SLOT_SPECIMEN) == null) return; @@ -132,8 +119,7 @@ public class ItemBeealyzer extends ItemInventoried { @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { if (Proxies.common.isSimulating(world)) - entityplayer.openGui(ForestryAPI.instance, GuiId.BeealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, - (int) entityplayer.posZ); + entityplayer.openGui(ForestryAPI.instance, GuiId.BeealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ); return itemstack; } diff --git a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java index a8ac828fd..d665c9c5e 100755 --- a/src/main/java/forestry/apiculture/items/ItemBiomefinder.java +++ b/src/main/java/forestry/apiculture/items/ItemBiomefinder.java @@ -32,6 +32,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -49,10 +50,6 @@ public class ItemBiomefinder extends ItemInventoried { private final short specimenSlot = 0; private final short analyzeSlot = 1; - public BiomefinderInventory() { - super(ItemBiomefinder.class, 3); - } - public BiomefinderInventory(ItemStack itemstack) { super(ItemBiomefinder.class, 3, itemstack); } @@ -137,6 +134,17 @@ public class ItemBiomefinder extends ItemInventoried { return EnumErrorCode.OK; } + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == energySlot) { + Item item = itemStack.getItem(); + return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item(); + } else if (slotIndex == specimenSlot || slotIndex == analyzeSlot) { + return PluginApiculture.beeInterface.isMember(itemStack); + } + return false; + } + } public ItemBiomefinder() { diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 8cb647ba5..0f970e572 100755 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -30,7 +30,6 @@ public class ItemImprinter extends ItemForestry { public static class ImprinterInventory extends ItemInventory { - private final ItemStack[] inventoryStacks = new ItemStack[2]; private final short specimenSlot = 0; private final short imprintedSlot = 1; @@ -39,8 +38,8 @@ public class ItemImprinter extends ItemForestry { private final EntityPlayer player; - public ImprinterInventory(EntityPlayer player) { - super(ItemImprinter.class); + public ImprinterInventory(EntityPlayer player, ItemStack itemStack) { + super(ItemImprinter.class, 2, itemStack); this.player = player; } @@ -127,25 +126,6 @@ public class ItemImprinter extends ItemForestry { inventoryStacks[specimenSlot] = null; } - @Override - public ItemStack decrStackSize(int i, int j) { - if (inventoryStacks[i] == null) - return null; - - ItemStack product; - if (inventoryStacks[i].stackSize <= j) { - product = inventoryStacks[i]; - inventoryStacks[i] = null; - return product; - } else { - product = inventoryStacks[i].splitStack(j); - if (inventoryStacks[i].stackSize == 0) - inventoryStacks[i] = null; - - return product; - } - } - @Override public void markDirty() { if (!Proxies.common.isSimulating(player.worldObj)) @@ -153,61 +133,14 @@ public class ItemImprinter extends ItemForestry { tryImprint(); } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventoryStacks[i] = itemstack; - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventoryStacks[i]; - } - - @Override - public int getSizeInventory() { - return inventoryStacks.length; - } - @Override public String getInventoryName() { return "Imprinter"; } @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - if (inventoryStacks[slot] == null) - return null; - ItemStack toReturn = inventoryStacks[slot]; - inventoryStacks[slot] = null; - return toReturn; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return PluginApiculture.beeInterface.isMember(itemStack); } } diff --git a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java index 481604189..416038e0c 100755 --- a/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/GuiHandlerArboriculture.java @@ -10,16 +10,17 @@ ******************************************************************************/ package forestry.arboriculture; -import forestry.arboriculture.genetics.TreeHelper; -import forestry.arboriculture.gui.ContainerTreealyzer; -import forestry.arboriculture.gui.GuiTreealyzer; -import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; -import forestry.core.GuiHandlerBase; -import forestry.core.network.GuiId; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.arboriculture.genetics.TreeHelper; +import forestry.arboriculture.gui.GuiTreealyzer; +import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; +import forestry.core.GuiHandlerBase; +import forestry.core.gui.ContainerAlyzer; +import forestry.core.network.GuiId; + public class GuiHandlerArboriculture extends GuiHandlerBase { @Override @@ -35,11 +36,11 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { return this.getNaturalistChestContainer(TreeHelper.UID, player, world, x, y, z, decodeGuiData(id)); case TreealyzerGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; - return new ContainerTreealyzer(player.inventory, new TreealyzerInventory(player, equipped)); + return new ContainerAlyzer(new TreealyzerInventory(player, equipped), player); default: return null; @@ -61,7 +62,7 @@ public class GuiHandlerArboriculture extends GuiHandlerBase { return this.getNaturalistChestGui(TreeHelper.UID, player, world, x, y, z, decodeGuiData(id)); case TreealyzerGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; diff --git a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java b/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java deleted file mode 100755 index da83ef01b..000000000 --- a/src/main/java/forestry/arboriculture/gui/ContainerTreealyzer.java +++ /dev/null @@ -1,32 +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.arboriculture.gui; - -import net.minecraft.entity.player.InventoryPlayer; - -import org.apache.commons.lang3.ArrayUtils; - -import forestry.api.genetics.AlleleManager; -import forestry.arboriculture.items.ItemGermlingGE; -import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerAlyzer; - -public class ContainerTreealyzer extends ContainerAlyzer { - - private static final Object[] acceptedEnergy = new Object[] {ForestryItem.honeydew, ForestryItem.honeyDrop}; - private static final Object[] acceptedSpecimens = ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(), ItemGermlingGE.class); - - public ContainerTreealyzer(InventoryPlayer inventoryplayer, TreealyzerInventory inventory) { - super(inventoryplayer, inventory, acceptedEnergy, acceptedSpecimens); - } - -} diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index 30463833a..3a4bd1058 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -10,13 +10,23 @@ ******************************************************************************/ package forestry.arboriculture.gui; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import net.minecraftforge.common.EnumPlantType; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.arboriculture.IAlleleFruit; import forestry.api.arboriculture.IAlleleGrowth; import forestry.api.arboriculture.ITree; import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlleleFloat; import forestry.api.genetics.IAlleleInteger; import forestry.api.genetics.IFruitFamily; import forestry.arboriculture.genetics.TreeGenome; @@ -26,23 +36,15 @@ import forestry.core.config.ForestryItem; import forestry.core.genetics.Allele; import forestry.core.genetics.AlleleBoolean; import forestry.core.genetics.AllelePlantType; +import forestry.core.gui.ContainerAlyzer; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.plugins.PluginArboriculture; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import net.minecraftforge.common.EnumPlantType; public class GuiTreealyzer extends GuiAlyzer { public GuiTreealyzer(EntityPlayer player, TreealyzerInventory inventory) { - super("rootTrees", player, new ContainerTreealyzer(player.inventory, inventory), inventory, "gui.treealyzer"); + super("rootTrees", player, new ContainerAlyzer(inventory, player), inventory, "gui.treealyzer"); ArrayList treeList = new ArrayList(); ((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false); diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index a0fdfbc40..5b60e8604 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -18,37 +18,31 @@ import net.minecraft.world.World; import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; -import forestry.core.utils.GeneticsUtil; +import forestry.api.genetics.AlleleManager; import forestry.core.EnumErrorCode; import forestry.core.config.Config; -import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; import forestry.core.inventory.AlyzerInventory; import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; +import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.StackUtils; import forestry.plugins.PluginArboriculture; public class ItemTreealyzer extends ItemInventoried { public static class TreealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource { - public TreealyzerInventory(EntityPlayer player) { - super(ItemTreealyzer.class, 7); - this.player = player; - } - public TreealyzerInventory(EntityPlayer player, ItemStack itemStack) { super(ItemTreealyzer.class, 7, itemStack); this.player = player; } - private boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) - return false; - - return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); + @Override + protected boolean isSpecimen(ItemStack itemStack) { + return StackUtils.containsItemStack(AlleleManager.ersatzSaplings.keySet(), itemStack) || PluginArboriculture.treeInterface.isMember(itemStack); } private void tryAnalyze() { diff --git a/src/main/java/forestry/core/GuiHandler.java b/src/main/java/forestry/core/GuiHandler.java index d130c6a76..1b0d0d015 100755 --- a/src/main/java/forestry/core/GuiHandler.java +++ b/src/main/java/forestry/core/GuiHandler.java @@ -10,7 +10,12 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import cpw.mods.fml.common.network.IGuiHandler; + import forestry.core.circuits.ContainerSolderingIron; import forestry.core.circuits.GuiSolderingIron; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; @@ -22,8 +27,6 @@ import forestry.core.gui.GuiAnalyzer; import forestry.core.gui.GuiEscritoire; import forestry.core.network.GuiId; import forestry.plugins.PluginManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; public class GuiHandler extends GuiHandlerBase { @@ -41,7 +44,10 @@ public class GuiHandler extends GuiHandlerBase { return new GuiEscritoire(player, (TileEscritoire) getTileForestry(world, x, y, z)); case SolderingIronGUI: - return new GuiSolderingIron(player.inventory, new SolderingInventory()); + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == null) + return null; + return new GuiSolderingIron(player.inventory, new SolderingInventory(equipped)); default: for (IGuiHandler handler : PluginManager.guiHandlers) { @@ -70,7 +76,10 @@ public class GuiHandler extends GuiHandlerBase { return new ContainerEscritoire(player, (TileEscritoire) getTileForestry(world, x, y, z)); case SolderingIronGUI: - return new ContainerSolderingIron(player.inventory, new SolderingInventory()); + ItemStack equipped = player.getCurrentEquippedItem(); + if (equipped == null) + return null; + return new ContainerSolderingIron(player.inventory, new SolderingInventory(equipped)); default: for (IGuiHandler handler : PluginManager.guiHandlers) { diff --git a/src/main/java/forestry/core/GuiHandlerBase.java b/src/main/java/forestry/core/GuiHandlerBase.java index 8b0af8053..620f52c2b 100755 --- a/src/main/java/forestry/core/GuiHandlerBase.java +++ b/src/main/java/forestry/core/GuiHandlerBase.java @@ -37,18 +37,13 @@ public abstract class GuiHandlerBase implements IGuiHandler { public GuiNaturalistInventory getNaturalistChestGui(String rootUID, EntityPlayer player, World world, int x, int y, int z, int page) { TileNaturalistChest tile = (TileNaturalistChest) getTileForestry(world, x, y, z); ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(rootUID); - return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistInventory(speciesRoot, player.inventory, tile, page, 25), tile, page, 5); + return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistInventory(player.inventory, tile, page, 25), tile, page, 5); } public ContainerNaturalistInventory getNaturalistChestContainer(String rootUID, EntityPlayer player, World world, int x, int y, int z, int page) { ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(rootUID); speciesRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player); - return new ContainerNaturalistInventory(speciesRoot, - player.inventory, (TileNaturalistChest) getTileForestry(world, x, y, z), page, 25); - } - - public ItemStack getEquippedItem(EntityPlayer player) { - return player.getCurrentEquippedItem(); + return new ContainerNaturalistInventory(player.inventory, (TileNaturalistChest) getTileForestry(world, x, y, z), page, 25); } public static int encodeGuiData(int guiId, int data) { diff --git a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java index 8b723d63b..be414af19 100755 --- a/src/main/java/forestry/core/circuits/ContainerSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ContainerSolderingIron.java @@ -10,20 +10,20 @@ ******************************************************************************/ package forestry.core.circuits; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.world.World; + import forestry.api.circuits.ICircuitLayout; import forestry.core.circuits.ItemSolderingIron.SolderingInventory; import forestry.core.gui.ContainerItemInventory; import forestry.core.gui.IGuiSelectable; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class ContainerSolderingIron extends ContainerItemInventory implements IGuiSelectable { @@ -34,16 +34,16 @@ public class ContainerSolderingIron extends ContainerItemInventory implements IG this.inventory = inventory; // Input - this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 12)); // Output - this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 92, ItemCircuitBoard.class)); + this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 92)); // Ingredients - this.addSlotToContainer(new Slot(inventory, 2, 12, 32)); - this.addSlotToContainer(new Slot(inventory, 3, 12, 52)); - this.addSlotToContainer(new Slot(inventory, 4, 12, 72)); - this.addSlotToContainer(new Slot(inventory, 5, 12, 92)); + this.addSlotToContainer(new SlotFiltered(inventory, 2, 12, 32)); + this.addSlotToContainer(new SlotFiltered(inventory, 3, 12, 52)); + this.addSlotToContainer(new SlotFiltered(inventory, 4, 12, 72)); + this.addSlotToContainer(new SlotFiltered(inventory, 5, 12, 92)); // Player inventory for (int i1 = 0; i1 < 3; i1++) @@ -55,24 +55,6 @@ public class ContainerSolderingIron extends ContainerItemInventory implements IG } - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - return false; - } - - /* - * @Override public void onCraftGuiClosed(EntityPlayer entityplayer) { - * - * if (!Proxies.common.isSimulating(entityplayer.worldObj)) return; - * - * // Drop everything still in there. for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack stack = inventory.getStackInSlot(i); if (stack == - * null) { continue; } - * - * Proxies.common.dropItemPlayer(entityplayer, stack); inventory.setInventorySlotContents(i, null); } - * - * } - */ - public ICircuitLayout getLayout() { return inventory.getLayout(); } diff --git a/src/main/java/forestry/core/circuits/ItemSolderingIron.java b/src/main/java/forestry/core/circuits/ItemSolderingIron.java index 5fb8c6f61..0034fb1d2 100755 --- a/src/main/java/forestry/core/circuits/ItemSolderingIron.java +++ b/src/main/java/forestry/core/circuits/ItemSolderingIron.java @@ -23,9 +23,12 @@ import forestry.core.items.ItemForestry; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.RevolvingList; +import forestry.plugins.PluginApiculture; + import java.util.ArrayList; import java.util.Collection; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -89,15 +92,16 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { private final short blankSlot = 0; private final short finishedSlot = 1; private final short ingredientSlot1 = 2; + private final short ingredientSlotCount = 4; - public SolderingInventory() { - super(ItemSolderingIron.class, 6); + public SolderingInventory(ItemStack itemStack) { + super(ItemSolderingIron.class, 6, itemStack); init(); } - public SolderingInventory(ItemStack itemstack) { - super(ItemSolderingIron.class, 6, itemstack); - init(); + @Override + public int getInventoryStackLimit() { + return 1; } private void init() { @@ -190,14 +194,6 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { return count; } - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - } - @Override public void markDirty() { errorState = EnumErrorCode.OK; @@ -222,6 +218,21 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron { return EnumErrorCode.OK; } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (itemStack == null) + return false; + + Item item = itemStack.getItem(); + if (slotIndex == blankSlot) { + return item instanceof ItemCircuitBoard; + } else if (slotIndex >= ingredientSlot1 && slotIndex < ingredientSlot1 + ingredientSlotCount) { + CircuitRecipe recipe = SolderManager.getMatchingRecipe(layouts.getCurrent(), itemStack); + return recipe != null; + } + return false; + } } public ItemSolderingIron() { diff --git a/src/main/java/forestry/core/config/Defaults.java b/src/main/java/forestry/core/config/Defaults.java index 2cfad766a..6de0dd57b 100755 --- a/src/main/java/forestry/core/config/Defaults.java +++ b/src/main/java/forestry/core/config/Defaults.java @@ -43,6 +43,8 @@ public class Defaults { public static final int[] FACING_WESTEAST = { FACING_WEST, FACING_EAST }; public static final int[] FACINGS_NONE = new int[0]; + public static final int[] SLOTS_NONE = new int[0]; + // Textures public static final String TEXTURE_PATH_GUI = "textures/gui"; public static final String TEXTURE_PATH_BLOCKS = "textures/blocks"; diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 663a3e7bd..bca36b95c 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -212,7 +212,8 @@ public final class FluidHelper { return false; } - public static boolean isFillableContainer(ItemStack empty, FluidStack liquid) { + public static boolean isFillableContainer(ItemStack stack, FluidStack liquid) { + ItemStack empty = StackUtils.createSplitStack(stack, 1); Item item = empty.getItem(); if (item instanceof IFluidContainerItem) { IFluidContainerItem containerItem = (IFluidContainerItem) item; diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index 9510e8508..b035dff35 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -351,6 +351,9 @@ public class TankManager extends ForwardingList implements IFluidH } public boolean accepts(Fluid fluid) { + if (fluid == null) + return false; + for (StandardTank tank : tanks) { if (tank.accepts(fluid)) return true; diff --git a/src/main/java/forestry/core/fluids/tanks/StandardTank.java b/src/main/java/forestry/core/fluids/tanks/StandardTank.java index d2dae22b1..bfcbc5675 100644 --- a/src/main/java/forestry/core/fluids/tanks/StandardTank.java +++ b/src/main/java/forestry/core/fluids/tanks/StandardTank.java @@ -104,7 +104,7 @@ public class StandardTank extends FluidTank { } public boolean accepts(Fluid fluid) { - return true; + return fluid != null; } public boolean canBeFilledExternally() { diff --git a/src/main/java/forestry/core/gadgets/TileAnalyzer.java b/src/main/java/forestry/core/gadgets/TileAnalyzer.java index 985cc7eda..cfe7ca335 100755 --- a/src/main/java/forestry/core/gadgets/TileAnalyzer.java +++ b/src/main/java/forestry/core/gadgets/TileAnalyzer.java @@ -10,6 +10,22 @@ ******************************************************************************/ package forestry.core.gadgets; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; @@ -27,19 +43,7 @@ import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; -import java.util.Stack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; +import forestry.core.utils.GuiUtil; public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -50,7 +54,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public static final short SLOT_ANALYZE = 0; public static final short SLOT_CAN = 1; public static final short SLOT_INPUT_1 = 2; + public static final short SLOT_INPUT_COUNT = 6; public static final short SLOT_OUTPUT_1 = 8; + public static final short SLOT_OUTPUT_COUNT = 4; /* MEMBER */ private int analyzeTime; @@ -66,17 +72,29 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui /* CONSTRUCTOR */ public TileAnalyzer() { super(800, 40, Defaults.MACHINE_MAX_ENERGY); - setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOT_INPUT_COUNT)) { + return AlleleManager.alleleRegistry.isIndividual(itemStack); + } else if (slotIndex == SLOT_CAN) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return resourceTank.accepts(fluid); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_OUTPUT_1, SLOT_OUTPUT_COUNT); + } + }); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.getFluid()); tankManager = new TankManager(resourceTank); invInput = new InventoryMapper(getInternalInventory(), SLOT_INPUT_1, 6); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - /* GUI */ @Override public void openGui(EntityPlayer player, TileBase tile) { @@ -239,7 +257,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui return false; ItemStack next = pendingProducts.peek(); - if (getInternalInventory().tryAddStack(next, SLOT_OUTPUT_1, getInternalInventory().getSizeInventory() - SLOT_OUTPUT_1, true)) { + if (InvTools.tryAddStack(getInternalInventory(), next, SLOT_OUTPUT_1, getInternalInventory().getSizeInventory() - SLOT_OUTPUT_1, true)) { pendingProducts.pop(); return true; } @@ -293,87 +311,6 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui } - /* ISIDEDINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - if (!getInternalInventory().isItemValidForSlot(slot, stack)) - return false; - - if (slot >= SLOT_INPUT_1 && slot < SLOT_INPUT_1 + 6) - return AlleleManager.alleleRegistry.isIndividual(stack); - - if (slot == SLOT_CAN) - return Fluids.HONEY.isContained(stack); - - return false; - } - - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - return isItemValidForSlot(slot, stack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, stack, side)) - return false; - - return slotIndex >= SLOT_OUTPUT_1 && slotIndex < SLOT_OUTPUT_1 + 4; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILIQUIDCONTAINER */ @Override public TankManager getTankManager() { @@ -409,5 +346,4 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui public FluidTankInfo[] getTankInfo(ForgeDirection from) { return tankManager.getTankInfo(from); } - } diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 813d1a9be..78e79e28d 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -20,9 +20,9 @@ import com.mojang.authlib.GameProfile; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; -import forestry.core.utils.GeneticsUtil; import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.IRenderableMachine; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.ForestryPacket; import forestry.core.network.GuiId; @@ -31,6 +31,8 @@ import forestry.core.network.PacketTileNBT; import forestry.core.network.PacketTileUpdate; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; +import forestry.core.utils.GeneticsUtil; +import forestry.core.utils.GuiUtil; public class TileEscritoire extends TileBase implements ISidedInventory, IRenderableMachine, ICrafter { @@ -43,13 +45,43 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender /* MEMBER */ private final NaturalistGame game = new NaturalistGame(); - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - public TileEscritoire() { - setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT)) { + ItemStack specimen = getStackInSlot(SLOT_ANALYZE); + if (specimen == null) + return false; + IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen); + return individual != null && individual.getGenome().getPrimary().getResearchSuitability(itemStack) > 0; + } + + if (slotIndex == SLOT_ANALYZE) { + return AlleleManager.alleleRegistry.isIndividual(itemStack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT); + } + + @Override + public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { + super.setInventorySlotContents(slotIndex, itemstack); + if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { + if (!AlleleManager.alleleRegistry.isIndividual(getStackInSlot(SLOT_ANALYZE)) && getStackInSlot(SLOT_ANALYZE) != null) { + ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_ANALYZE)); + if (ersatz != null) + setInventorySlotContents(SLOT_ANALYZE, ersatz); + } + game.initialize(getStackInSlot(SLOT_ANALYZE)); + } + } + }); } /* GUI */ @@ -87,7 +119,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender return; for (ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel())) { - getInternalInventory().addStack(itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true); + InvTools.addStack(getInternalInventory(), itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true); } } @@ -123,92 +155,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender Proxies.net.sendToPlayer(new PacketTileNBT(PacketIds.TILE_NBT, this), player); } - /* ISIDEDINVENTORY */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + SLOTS_INPUT_COUNT) - return slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT); - - return true; - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex >= SLOT_RESULTS_1 && slotIndex < SLOT_RESULTS_1 + SLOTS_RESULTS_COUNT; - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - TileInventoryAdapter inventory = getInternalInventory(); - inventory.setInventorySlotContents(slotIndex, itemstack); - if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) { - if (!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE)) - && inventory.getStackInSlot(SLOT_ANALYZE) != null) { - ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(inventory.getStackInSlot(SLOT_ANALYZE)); - if (ersatz != null) - inventory.setInventorySlotContents(SLOT_ANALYZE, ersatz); - } - game.initialize(inventory.getStackInSlot(SLOT_ANALYZE)); - } - } - - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - @Override public EnumTankLevel getPrimaryLevel() { return EnumTankLevel.EMPTY; @@ -235,5 +181,4 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender public boolean canTakeStack(int slotIndex) { return true; } - } diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 98a2710d0..3888caae3 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -15,6 +15,7 @@ import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; @@ -32,9 +33,12 @@ import cpw.mods.fml.common.Optional; import forestry.api.core.IErrorState; import forestry.core.EnumErrorCode; import forestry.core.config.Config; +import forestry.core.config.Defaults; import forestry.core.interfaces.IErrorSource; +import forestry.core.interfaces.IFilterSlotDelegate; import forestry.core.interfaces.IRestrictedAccess; -import forestry.core.inventory.TileInventoryAdapter; +import forestry.core.inventory.FakeInventoryAdapter; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.network.ForestryPacket; import forestry.core.network.INetworkedEntity; import forestry.core.network.PacketPayload; @@ -43,6 +47,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.EnumAccess; import forestry.core.utils.PlayerUtil; +import forestry.core.utils.Utils; import forestry.core.vect.Vect; import buildcraft.api.statements.IStatementContainer; @@ -51,11 +56,11 @@ import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.statements.ITriggerProvider; @Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public abstract class TileForestry extends TileEntity implements INetworkedEntity, IRestrictedAccess, IErrorSource, ITriggerProvider { +public abstract class TileForestry extends TileEntity implements INetworkedEntity, IRestrictedAccess, IErrorSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate { protected final AdjacentTileCache tileCache = new AdjacentTileCache(this); protected boolean isInited = false; - private TileInventoryAdapter inventory; + private IInventoryAdapter inventory = FakeInventoryAdapter.instance(); public AdjacentTileCache getTileCache() { return tileCache; @@ -81,10 +86,6 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit return new Vect(xCoord, yCoord, zCoord); } - public World getWorld() { - return this.getWorldObj(); - } - public void openGui(EntityPlayer player) { } @@ -118,8 +119,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); - if (inventory != null) - inventory.readFromNBT(data); + inventory.readFromNBT(data); if (data.hasKey("Access")) access = EnumAccess.values()[data.getInteger("Access")]; @@ -138,8 +138,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit @Override public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); - if (inventory != null) - inventory.writeToNBT(data); + inventory.writeToNBT(data); data.setInteger("Access", access.ordinal()); if (this.owner != null) { NBTTagCompound nbt = new NBTTagCompound(); @@ -254,6 +253,10 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit return allowsAlteration(player) || getAccess() == EnumAccess.VIEWABLE; } + private boolean allowsPipeConnections() { + return access == EnumAccess.SHARED; + } + @Override public EnumAccess getAccess() { return access; @@ -291,11 +294,20 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit if (!isOwner(player)) return false; + boolean couldPipesConnect = allowsPipeConnections(); + int ordinal = (access.ordinal() + 1) % EnumAccess.values().length; access = EnumAccess.values()[ordinal]; if (!this.worldObj.isRemote) sendNetworkUpdate(); + boolean canPipesConnect = allowsPipeConnections(); + if (couldPipesConnect != canPipesConnect) { + // pipes connected to this need to update + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType); + markDirty(); + } + return true; } @@ -309,11 +321,109 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit } /* INVENTORY BASICS */ - public final TileInventoryAdapter getInternalInventory() { + public IInventoryAdapter getInternalInventory() { return inventory; } - public final void setInternalInventory(TileInventoryAdapter inv) { + public final void setInternalInventory(IInventoryAdapter inv) { + if (inv == null) { + throw new NullPointerException("Inventory cannot be null"); + } this.inventory = inv; } + + /* ISidedInventory */ + @Override + public final int getSizeInventory() { + return getInternalInventory().getSizeInventory(); + } + + @Override + public final ItemStack getStackInSlot(int slotIndex) { + return getInternalInventory().getStackInSlot(slotIndex); + } + + @Override + public final ItemStack decrStackSize(int slotIndex, int amount) { + return getInternalInventory().decrStackSize(slotIndex, amount); + } + + @Override + public final ItemStack getStackInSlotOnClosing(int slotIndex) { + return getInternalInventory().getStackInSlotOnClosing(slotIndex); + } + + @Override + public final void setInventorySlotContents(int slotIndex, ItemStack itemstack) { + getInternalInventory().setInventorySlotContents(slotIndex, itemstack); + } + + @Override + public final int getInventoryStackLimit() { + return getInternalInventory().getInventoryStackLimit(); + } + + @Override + public final void openInventory() { + getInternalInventory().openInventory(); + } + + @Override + public final void closeInventory() { + getInternalInventory().closeInventory(); + } + + @Override + public final String getInventoryName() { + return getUnlocalizedName(); + } + + @Override + public final boolean isUseableByPlayer(EntityPlayer player) { + if (!Utils.isUseableByPlayer(player, this) || !allowsViewing(player)) + return false; + return getInternalInventory().isUseableByPlayer(player); + } + + @Override + public final boolean hasCustomInventoryName() { + return getInternalInventory().hasCustomInventoryName(); + } + + @Override + public final boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (itemStack == null || !allowsPipeConnections()) + return false; + + if (!canSlotAccept(slotIndex, itemStack)) + return false; + + return getInternalInventory().isItemValidForSlot(slotIndex, itemStack); + } + + @Override + public final boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return getInternalInventory().canSlotAccept(slotIndex, itemStack); + } + + @Override + public final int[] getAccessibleSlotsFromSide(int side) { + if (!allowsPipeConnections()) + return Defaults.SLOTS_NONE; + return getInternalInventory().getAccessibleSlotsFromSide(side); + } + + @Override + public final boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + if (itemStack == null || !allowsPipeConnections()) + return false; + return isItemValidForSlot(slotIndex, itemStack); + } + + @Override + public final boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + if (itemStack == null || !allowsPipeConnections()) + return false; + return getInternalInventory().canExtractItem(slotIndex, itemStack, side); + } } diff --git a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java index 1b9d5eba2..2450070b8 100755 --- a/src/main/java/forestry/core/gadgets/TileNaturalistChest.java +++ b/src/main/java/forestry/core/gadgets/TileNaturalistChest.java @@ -10,33 +10,39 @@ ******************************************************************************/ package forestry.core.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + import forestry.api.core.ForestryAPI; import forestry.api.genetics.ISpeciesRoot; import forestry.core.GuiHandler; import forestry.core.config.Config; import forestry.core.gui.IPagedInventory; import forestry.core.inventory.TileInventoryAdapter; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -public abstract class TileNaturalistChest extends TileBase implements IInventory, IPagedInventory { +public abstract class TileNaturalistChest extends TileBase implements IPagedInventory { + + private static class NaturalistInventoryAdapter extends TileInventoryAdapter { + private final ISpeciesRoot speciesRoot; + public NaturalistInventoryAdapter(TileNaturalistChest tile, int size, String name, ISpeciesRoot speciesRoot) { + super(tile, size, name); + this.speciesRoot = speciesRoot; + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemstack) { + return speciesRoot.isMember(itemstack); + } + } - private final ISpeciesRoot speciesRoot; private final int guiID; public TileNaturalistChest(ISpeciesRoot speciesRoot, int guiId) { - setInternalInventory(new TileInventoryAdapter(this, 125, "Items")); + setInternalInventory(new NaturalistInventoryAdapter(this, 125, "Items", speciesRoot)); setHints(Config.hints.get("apiarist.chest")); - this.speciesRoot = speciesRoot; this.guiID = guiId; } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, guiID, player.worldObj, xCoord, yCoord, zCoord); @@ -57,58 +63,4 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory public boolean throwsErrors() { return false; } - - /* IINVENTORY */ - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return itemstack == null || speciesRoot.isMember(itemstack); - } - - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int slotIndex) { - return getInternalInventory().getStackInSlot(slotIndex); - } - - @Override - public ItemStack decrStackSize(int slotIndex, int count) { - return getInternalInventory().decrStackSize(slotIndex, count); - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(slotIndex, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } } diff --git a/src/main/java/forestry/core/gui/ContainerAlyzer.java b/src/main/java/forestry/core/gui/ContainerAlyzer.java index e9a7dc8ac..403423d62 100644 --- a/src/main/java/forestry/core/gui/ContainerAlyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAlyzer.java @@ -1,6 +1,6 @@ package forestry.core.gui; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.inventory.AlyzerInventory; import forestry.core.proxy.Proxies; import net.minecraft.entity.player.EntityPlayer; @@ -11,25 +11,26 @@ public class ContainerAlyzer extends ContainerItemInventory { private final AlyzerInventory inventory; - protected ContainerAlyzer(InventoryPlayer inventoryplayer, AlyzerInventory inventory, Object[] acceptedEnergy, Object... acceptedSpecimens) { - super(inventory, inventoryplayer.player); + public ContainerAlyzer(AlyzerInventory inventory, EntityPlayer player) { + super(inventory, player); + InventoryPlayer inventoryplayer = player.inventory; this.inventory = inventory; final int xPosLeftSlots = 223; // Energy - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ENERGY, xPosLeftSlots, 8)); // Bee to analyze - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_SPECIMEN, xPosLeftSlots, 26)); // Analyzed bee - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens)); - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens)); - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens)); - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens)); - this.addSlotToContainer(new SlotCustom(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ANALYZE_1, xPosLeftSlots, 57)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ANALYZE_2, xPosLeftSlots, 75)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ANALYZE_3, xPosLeftSlots, 93)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ANALYZE_4, xPosLeftSlots, 111)); + this.addSlotToContainer(new SlotFiltered(inventory, AlyzerInventory.SLOT_ANALYZE_5, xPosLeftSlots, 129)); final int xPosPlayerInv = 43; final int xSpacePlayerInv = 18; @@ -74,9 +75,4 @@ public class ContainerAlyzer extends ContainerItemInventory { inventory.onGuiSaved(entityplayer); } - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - return true; - } - } diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzer.java b/src/main/java/forestry/core/gui/ContainerAnalyzer.java index 3b9434171..f53f955dd 100755 --- a/src/main/java/forestry/core/gui/ContainerAnalyzer.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzer.java @@ -12,40 +12,26 @@ package forestry.core.gui; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import forestry.core.config.ForestryItem; -import forestry.core.fluids.Fluids; import forestry.core.gadgets.TileAnalyzer; -import forestry.core.genetics.ItemGE; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.gui.slots.SlotLiquidContainer; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.gui.slots.SlotOutput; public class ContainerAnalyzer extends ContainerLiquidTanks { public ContainerAnalyzer(InventoryPlayer player, TileAnalyzer tile) { - super(tile, tile); + super(tile); // Input buffer for (int i = 0; i < 3; i++) for (int k = 0; k < 2; k++) - addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18, ItemGE.class)); + addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_INPUT_1 + i * 2 + k, 8 + k * 18, 28 + i * 18)); // Analyze slot - addSlotToContainer(new SlotCustom(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); + addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_ANALYZE, 73, 59)); // Can slot - addSlotToContainer(new SlotLiquidContainer(tile, TileAnalyzer.SLOT_CAN, 143, 24, false, Fluids.HONEY.getFluid()) { - - @Override - public boolean isItemValid(ItemStack stack) { - if (ForestryItem.honeyDrop.isItemEqual(stack)) - return true; - return super.isItemValid(stack); - } - - }); + addSlotToContainer(new SlotFiltered(tile, TileAnalyzer.SLOT_CAN, 143, 24)); // Output buffer for (int i = 0; i < 2; i++) diff --git a/src/main/java/forestry/core/gui/ContainerEscritoire.java b/src/main/java/forestry/core/gui/ContainerEscritoire.java index 8a56349db..a1e7d9db4 100755 --- a/src/main/java/forestry/core/gui/ContainerEscritoire.java +++ b/src/main/java/forestry/core/gui/ContainerEscritoire.java @@ -10,19 +10,16 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.api.genetics.AlleleManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; + import forestry.core.gadgets.TileEscritoire; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import java.util.ArrayList; -import java.util.Collection; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.Slot; public class ContainerEscritoire extends ContainerForestry implements IGuiSelectable { @@ -37,20 +34,18 @@ public class ContainerEscritoire extends ContainerForestry implements IGuiSelect this.player = player; this.tile = t; - Collection filters = new ArrayList(); - filters.add(Blocks.sapling); - filters.addAll(AlleleManager.alleleRegistry.getSpeciesRoot().values()); // Analyze slot - addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_ANALYZE, 97, 67, filters.toArray()).setCrafter(tile)); + addSlotToContainer(new SlotFiltered(tile, TileEscritoire.SLOT_ANALYZE, 97, 67).setCrafter(tile)); for (int i = 0; i < TileEscritoire.SLOTS_INPUT_COUNT; i++) { - addSlotToContainer(new SlotCustom(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setExclusion(true).setBlockedTexture("slots/blocked_2")); + addSlotToContainer(new SlotFiltered(tile, TileEscritoire.SLOT_INPUT_1 + i, 17, 49 + i * 18).setBlockedTexture("slots/blocked_2")); } - for(int i = 0; i < 3; i++) - for(int j = 0; j < 2; j++) { - addSlotToContainer(new SlotClosed(tile, TileEscritoire.SLOT_RESULTS_1 + (i * 2) + j, 177 + j * 18, 85 + i * 18)); + for(int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + addSlotToContainer(new SlotOutput(tile, TileEscritoire.SLOT_RESULTS_1 + (i * 2) + j, 177 + j * 18, 85 + i * 18)); } + } // Player inventory for (int i = 0; i < 3; i++) diff --git a/src/main/java/forestry/core/gui/ContainerForestry.java b/src/main/java/forestry/core/gui/ContainerForestry.java index 0fe0c6a61..7f63c8eb3 100755 --- a/src/main/java/forestry/core/gui/ContainerForestry.java +++ b/src/main/java/forestry/core/gui/ContainerForestry.java @@ -29,11 +29,7 @@ public class ContainerForestry extends Container { protected final IRestrictedAccess restrictedAccess; public ContainerForestry(TileForestry tileForestry) { - if (tileForestry instanceof IInventory) - this.inventoryAccess = (IInventory) tileForestry; - else - this.inventoryAccess = tileForestry.getInternalInventory(); - + this.inventoryAccess = tileForestry; this.restrictedAccess = tileForestry; } diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index 4c043a8b6..6f4f6c8d2 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.core.gui; -import forestry.core.gui.slots.SlotItemInventory; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + import forestry.core.gui.slots.SlotLocked; import forestry.core.inventory.ItemInventory; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; +import forestry.core.utils.StackUtils; public abstract class ContainerItemInventory extends ContainerForestry { @@ -29,26 +31,20 @@ public abstract class ContainerItemInventory extends ContainerForestry { this.player = player; } - public ItemInventory getItemInventory() { - return inventory; - } - protected void addSecuredSlot(IInventory other, int slot, int x, int y) { - if (other.getStackInSlot(slot) != null && inventory.itemClass.isAssignableFrom(other.getStackInSlot(slot).getItem().getClass())) + ItemStack stackInSlot = other.getStackInSlot(slot); + if (StackUtils.isIdenticalItem(inventory.parent, stackInSlot)) addSlotToContainer(new SlotLocked(other, slot, x, y)); else - addSlotToContainer(new SlotItemInventory(this, other, player, slot, x, y)); + addSlotToContainer(new Slot(other, slot, x, y)); } - protected abstract boolean isAcceptedItem(EntityPlayer player, ItemStack stack); - public void purgeBag(EntityPlayer player) { - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) - continue; + for (int i = 0; i < inventorySlots.size() - 9 * 4; i++) { + Slot slot = (Slot) inventorySlots.get(i); + ItemStack stack = slot.getStack(); - if (isAcceptedItem(player, stack)) + if (stack == null || slot.isItemValid(stack)) continue; Proxies.common.dropItemPlayer(player, stack); diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 5ce1d2784..435097c51 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -29,7 +29,7 @@ public class ContainerLiquidTanks extends ContainerForestry { private final ILiquidTankContainer tile; - public ContainerLiquidTanks(IInventory playerInventory, T tile) { + public ContainerLiquidTanks(T tile) { super(tile); this.tile = tile; } diff --git a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java index 318bac49d..0bbf2f84d 100755 --- a/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java +++ b/src/main/java/forestry/core/gui/ContainerNaturalistInventory.java @@ -13,28 +13,23 @@ package forestry.core.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import forestry.api.genetics.ISpeciesRoot; import forestry.core.gadgets.TileNaturalistChest; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.network.PacketUpdate; -import forestry.core.proxy.Proxies; public class ContainerNaturalistInventory extends ContainerForestry implements IGuiSelectable { private final IPagedInventory inv; - private final ISpeciesRoot speciesRoot; - public ContainerNaturalistInventory(ISpeciesRoot speciesRoot, InventoryPlayer player, TileNaturalistChest inventory, int page, int pageSize) { - super(inventory); - this.inv = inventory; - this.speciesRoot = speciesRoot; + public ContainerNaturalistInventory(InventoryPlayer player, TileNaturalistChest tile, int page, int pageSize) { + super(tile); + this.inv = tile; // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotFiltered(tile, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18)); } } @@ -50,21 +45,6 @@ public class ContainerNaturalistInventory extends ContainerForestry implements I } } - public void purgeBag(EntityPlayer player) { - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (stack == null) - continue; - - if (speciesRoot.isMember(stack)) - continue; - - Proxies.common.dropItemPlayer(player, stack); - inv.setInventorySlotContents(i, null); - } - } - @Override public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { inv.flipPage(player, packet.payload.intPayload[0]); diff --git a/src/main/java/forestry/core/gui/GuiAlyzer.java b/src/main/java/forestry/core/gui/GuiAlyzer.java index 5cc02a966..a3e250c55 100755 --- a/src/main/java/forestry/core/gui/GuiAlyzer.java +++ b/src/main/java/forestry/core/gui/GuiAlyzer.java @@ -10,6 +10,19 @@ ******************************************************************************/ package forestry.core.gui; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.opengl.GL11; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.EnumTolerance; @@ -26,19 +39,8 @@ import forestry.api.genetics.ISpeciesRoot; import forestry.core.config.Defaults; import forestry.core.gadgets.TileForestry; import forestry.core.genetics.EnumMutateChance; -import forestry.core.genetics.Genome; import forestry.core.proxy.Proxies; import forestry.core.utils.StringUtil; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Stack; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.StringUtils; -import org.lwjgl.opengl.GL11; public abstract class GuiAlyzer extends GuiForestry { diff --git a/src/main/java/forestry/core/gui/slots/SlotCustom.java b/src/main/java/forestry/core/gui/slots/SlotCustom.java deleted file mode 100755 index 24fc06233..000000000 --- a/src/main/java/forestry/core/gui/slots/SlotCustom.java +++ /dev/null @@ -1,138 +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.gui.slots; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.config.ForestryItem; -import forestry.core.interfaces.ICrafter; -import forestry.core.render.TextureManager; -import forestry.core.utils.StackUtils; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -/** - * Slot which only specific items. (With permission by RichardG.) - * - * @author Richard - */ -public class SlotCustom extends SlotForestry { - - protected final Object[] items; - private boolean exclusion; - private ICrafter crafter; - private String blockedTexture = "slots/blocked"; - - public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, Object... items) { - super(iinventory, slotIndex, xPos, yPos); - this.items = items; - } - - public SlotCustom setCrafter(ICrafter crafter) { - this.crafter = crafter; - return this; - } - - public SlotCustom setExclusion(boolean exclusion) { - this.exclusion = exclusion; - return this; - } - - @Override - public boolean isItemValid(ItemStack itemstack) { - if (itemstack == null) - return false; - if (!inventory.isItemValidForSlot(getSlotIndex(), itemstack)) - return false; - - if (exclusion) - return !determineValidity(itemstack); - else - return determineValidity(itemstack); - } - - @Override - public boolean getHasStack() { - if (crafter != null && !crafter.canTakeStack(getSlotIndex())) - return false; - else - return super.getHasStack(); - } - - @Override - public ItemStack decrStackSize(int i) { - if (crafter != null && !crafter.canTakeStack(getSlotIndex())) - return null; - else - return super.decrStackSize(i); - } - - @Override - public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) { - if (crafter != null) - crafter.takenFromSlot(getSlotIndex(), true, player); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private boolean determineValidity(ItemStack itemstack) { - for (Object filter : items) { - if (filter == null) - continue; - if (filter instanceof Class) { - Block block = StackUtils.getBlock(itemstack); - - if (block != null && ((Class) filter).isAssignableFrom(block.getClass())) return true; - if (((Class) filter).isAssignableFrom(itemstack.getItem().getClass())) return true; - } else if (filter instanceof ItemStack) { - if (((ItemStack) filter).getItemDamage() == Defaults.WILDCARD && itemstack.getItem() == ((ItemStack) filter).getItem()) - return true; - else if (itemstack.isItemEqual((ItemStack) filter)) - return true; - } else if (filter instanceof Block) { - if (StackUtils.equals((Block) filter, itemstack)) return true; - } else if (filter instanceof Item) { - if (itemstack.getItem() == filter) return true; - } else if (filter instanceof ForestryItem) { - if (((ForestryItem) filter).isItemEqual(itemstack)) return true; - } else if (filter instanceof ForestryBlock) { - if (((ForestryBlock) filter).isItemEqual(itemstack)) return true; - } else if (filter instanceof ISpeciesRoot) { - if (((ISpeciesRoot) filter).isMember(itemstack)) return true; - } else { - throw new RuntimeException("invalid filter item specified: "+filter+" ("+filter.getClass()+")"); - } - } - - return false; - } - - public SlotCustom setBlockedTexture(String ident) { - blockedTexture = ident; - return this; - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getBackgroundIconIndex() { - ItemStack stack = getStack(); - if (stack != null && !inventory.isItemValidForSlot(getSlotIndex(), stack)) - return TextureManager.getInstance().getDefault(blockedTexture); - else - return null; - } -} diff --git a/src/main/java/forestry/core/gui/slots/SlotFiltered.java b/src/main/java/forestry/core/gui/slots/SlotFiltered.java new file mode 100644 index 000000000..752cd39fd --- /dev/null +++ b/src/main/java/forestry/core/gui/slots/SlotFiltered.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.gui.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import forestry.core.interfaces.IFilterSlotDelegate; + +/** + * Slot which only takes specific items, specified by the ICustomSlotInventory. + */ +public class SlotFiltered extends SlotWatched { + + protected final IFilterSlotDelegate filterSlotDelegate; + + public SlotFiltered(T filterSlotDelegateInventory, int slotIndex, int xPos, int yPos) { + this(filterSlotDelegateInventory, filterSlotDelegateInventory, slotIndex, xPos, yPos); + } + + public SlotFiltered(IFilterSlotDelegate filterSlotDelegate, IInventory inventory, int slotIndex, int xPos, int yPos) { + super(inventory, slotIndex, xPos, yPos); + this.filterSlotDelegate = filterSlotDelegate; + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return itemstack != null && filterSlotDelegate.canSlotAccept(getSlotIndex(), itemstack); + } +} diff --git a/src/main/java/forestry/core/gui/slots/SlotForestry.java b/src/main/java/forestry/core/gui/slots/SlotForestry.java index 2c6807e46..306c731c2 100755 --- a/src/main/java/forestry/core/gui/slots/SlotForestry.java +++ b/src/main/java/forestry/core/gui/slots/SlotForestry.java @@ -27,12 +27,10 @@ public class SlotForestry extends Slot implements IToolTipProvider{ private ToolTip toolTips; public SlotForestry(IInventory inventory, int slotIndex, int xPos, int yPos) { - this(inventory, slotIndex, xPos, yPos, -1); - } - - public SlotForestry(IInventory inventory, int slotIndex, int xPos, int yPos, int stackLimit) { super(inventory, slotIndex, xPos, yPos); - this.stackLimit = stackLimit; + if (inventory == null) + throw new IllegalArgumentException("Inventory must not be null"); + this.stackLimit = -1; } public SlotForestry setInfinite() { diff --git a/src/main/java/forestry/core/gui/slots/SlotItemInventory.java b/src/main/java/forestry/core/gui/slots/SlotItemInventory.java deleted file mode 100755 index d4a6e05f1..000000000 --- a/src/main/java/forestry/core/gui/slots/SlotItemInventory.java +++ /dev/null @@ -1,36 +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.gui.slots; - -import forestry.core.gui.ContainerItemInventory; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class SlotItemInventory extends Slot { - - private final EntityPlayer player; - private final ContainerItemInventory container; - - public SlotItemInventory(ContainerItemInventory container, IInventory inventory, EntityPlayer player, int par2, int par3, int par4) { - super(inventory, par2, par3, par4); - this.container = container; - this.player = player; - } - - @Override - public void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack) { - super.onSlotChange(par1ItemStack, par2ItemStack); - container.saveInventory(player); - } - -} diff --git a/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java b/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java deleted file mode 100755 index 0637d577e..000000000 --- a/src/main/java/forestry/core/gui/slots/SlotLiquidContainer.java +++ /dev/null @@ -1,60 +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.gui.slots; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import forestry.core.fluids.FluidHelper; -import forestry.core.render.TextureManager; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.Fluid; - -public class SlotLiquidContainer extends SlotForestry { - - private final boolean allowEmpty; - private final Fluid[] fluids; - - public SlotLiquidContainer(IInventory iinventory, int slotIndex, int xPos, int yPos) { - this(iinventory, slotIndex, xPos, yPos, false); - } - - public SlotLiquidContainer(IInventory iinventory, int slotIndex, int xPos, int yPos, boolean allowEmpty, Fluid... fluids) { - super(iinventory, slotIndex, xPos, yPos); - - this.allowEmpty = allowEmpty; - this.fluids = fluids; - } - - @Override - public boolean isItemValid(ItemStack stack) { - if (allowEmpty) - return FluidHelper.isEmptyContainer(stack); - if (fluids.length > 0) { - for (Fluid fluid : fluids) - if (FluidHelper.containsFluid(stack, fluid)) - return true; - return false; - } - return FluidHelper.isFilledContainer(stack); - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getBackgroundIconIndex() { - if (allowEmpty) - return TextureManager.getInstance().getDefault("slots/container"); - else - return TextureManager.getInstance().getDefault("slots/liquid"); - } - -} diff --git a/src/main/java/forestry/core/gui/slots/SlotOutput.java b/src/main/java/forestry/core/gui/slots/SlotOutput.java index 3f7760d1a..76965a800 100755 --- a/src/main/java/forestry/core/gui/slots/SlotOutput.java +++ b/src/main/java/forestry/core/gui/slots/SlotOutput.java @@ -1,30 +1,30 @@ -/******************************************************************************* - * 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.gui.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -/** - * - * @author CovertJaguar - */ -public class SlotOutput extends SlotForestry { - - public SlotOutput(IInventory iinventory, int slotIndex, int posX, int posY) { - super(iinventory, slotIndex, posX, posY); - } - - @Override - public boolean isItemValid(ItemStack itemstack) { - return false; - } -} +/******************************************************************************* + * 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.gui.slots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +/** + * + * @author CovertJaguar + */ +public class SlotOutput extends SlotWatched { + + public SlotOutput(IInventory iinventory, int slotIndex, int posX, int posY) { + super(iinventory, slotIndex, posX, posY); + } + + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } +} diff --git a/src/main/java/forestry/core/gui/slots/SlotWatched.java b/src/main/java/forestry/core/gui/slots/SlotWatched.java new file mode 100644 index 000000000..dcbc23b0a --- /dev/null +++ b/src/main/java/forestry/core/gui/slots/SlotWatched.java @@ -0,0 +1,66 @@ +package forestry.core.gui.slots; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.core.interfaces.ICrafter; +import forestry.core.render.TextureManager; + +/** + * Slot with an ICrafter callback. + */ +public abstract class SlotWatched extends SlotForestry { + private ICrafter crafter; + private String blockedTexture = "slots/blocked"; + + public SlotWatched(IInventory inventory, int slotIndex, int xPos, int yPos) { + super(inventory, slotIndex, xPos, yPos); + } + + public SlotWatched setCrafter(ICrafter crafter) { + this.crafter = crafter; + return this; + } + + @Override + public boolean getHasStack() { + if (crafter != null && !crafter.canTakeStack(getSlotIndex())) + return false; + else + return super.getHasStack(); + } + + @Override + public ItemStack decrStackSize(int i) { + if (crafter != null && !crafter.canTakeStack(getSlotIndex())) + return null; + else + return super.decrStackSize(i); + } + + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) { + if (crafter != null) + crafter.takenFromSlot(getSlotIndex(), true, player); + } + + public SlotWatched setBlockedTexture(String ident) { + blockedTexture = ident; + return this; + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getBackgroundIconIndex() { + ItemStack stack = getStack(); + if (stack != null && !inventory.isItemValidForSlot(getSlotIndex(), stack)) + return TextureManager.getInstance().getDefault(blockedTexture); + else + return null; + } +} diff --git a/src/main/java/forestry/core/gui/slots/SlotClosed.java b/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java old mode 100755 new mode 100644 similarity index 61% rename from src/main/java/forestry/core/gui/slots/SlotClosed.java rename to src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java index 98b907272..e410aa810 --- a/src/main/java/forestry/core/gui/slots/SlotClosed.java +++ b/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java @@ -1,27 +1,25 @@ -/******************************************************************************* - * 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.gui.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotClosed extends SlotForestry { - - public SlotClosed(IInventory par1iInventory, int par2, int par3, int par4) { - super(par1iInventory, par2, par3, par4); - } - - @Override - public boolean isItemValid(ItemStack par1ItemStack) { - return false; - } - -} +/******************************************************************************* + * 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.interfaces; + +import net.minecraft.item.ItemStack; + +public interface IFilterSlotDelegate { + + /** + * Non-automation version of IInventory's isItemValidForSlot. + * Used to determine if a player can place a stack in a slot. + * + * Combine this with Forestry's access permissions to implement isItemValidForSlot. + */ + boolean canSlotAccept(int slotIndex, ItemStack itemStack); + +} diff --git a/src/main/java/forestry/core/inventory/AlyzerInventory.java b/src/main/java/forestry/core/inventory/AlyzerInventory.java index 3423427c1..20a9ffe51 100644 --- a/src/main/java/forestry/core/inventory/AlyzerInventory.java +++ b/src/main/java/forestry/core/inventory/AlyzerInventory.java @@ -3,10 +3,10 @@ package forestry.core.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -public class AlyzerInventory extends ItemInventory { +import forestry.core.config.ForestryItem; + +public abstract class AlyzerInventory extends ItemInventory { public static final int SLOT_SPECIMEN = 0; public static final int SLOT_ANALYZE_1 = 1; @@ -18,28 +18,38 @@ public class AlyzerInventory extends ItemInventory { protected EntityPlayer player; - public AlyzerInventory(Class itemClass, int slots) { - super(itemClass, slots); - } - public AlyzerInventory(Class itemClass, int size, ItemStack itemstack) { super(itemClass, size, itemstack); } - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { + protected boolean isEnergy(ItemStack itemstack) { + if (itemstack == null || itemstack.stackSize <= 0) + return false; - NBTTagList nbttaglist = new NBTTagList(); - for (int i = SLOT_ENERGY; i < SLOT_ENERGY + 1; i++) { - if (inventoryStacks[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - inventoryStacks[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } + return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); + } + + protected boolean hasSpecimen() { + for (int i = SLOT_SPECIMEN; i <= SLOT_ANALYZE_5; i++) { + if (i == SLOT_ENERGY) + continue; + + ItemStack itemStack = getStackInSlot(i); + if (itemStack != null) + return true; } - nbttagcompound.setTag("Items", nbttaglist); + return false; + } + protected abstract boolean isSpecimen(ItemStack itemStack); + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_ENERGY) { + return isEnergy(itemStack); + } else { + return !hasSpecimen() && isSpecimen(itemStack); + } } } diff --git a/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java b/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java new file mode 100644 index 000000000..30cd570d3 --- /dev/null +++ b/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * 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.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import forestry.core.config.Defaults; +import forestry.core.utils.StackUtils; + +public class FakeInventoryAdapter implements IInventoryAdapter { + + private static FakeInventoryAdapter instance; + + public static FakeInventoryAdapter instance() { + if (instance == null) { + instance = new FakeInventoryAdapter(); + } + return instance; + } + + private FakeInventoryAdapter() { + + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return Defaults.SLOTS_NONE; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public void markDirty() { + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + + } + + @Override + public IInventoryAdapter configureSided(int[] sides, int[] slots) { + return this; + } +} diff --git a/src/main/java/forestry/core/inventory/IInventoryAdapter.java b/src/main/java/forestry/core/inventory/IInventoryAdapter.java new file mode 100644 index 000000000..218257b03 --- /dev/null +++ b/src/main/java/forestry/core/inventory/IInventoryAdapter.java @@ -0,0 +1,12 @@ +package forestry.core.inventory; + +import net.minecraft.inventory.ISidedInventory; + +import forestry.api.core.INBTTagable; +import forestry.core.interfaces.IFilterSlotDelegate; + +public interface IInventoryAdapter extends ISidedInventory, IFilterSlotDelegate, INBTTagable { + + /* Sided */ + public IInventoryAdapter configureSided(int[] sides, int[] slots); +} diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index 5cdad4e87..bedc8b679 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -20,6 +20,7 @@ import java.util.TreeMap; import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -35,6 +36,7 @@ import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.Optional; +import forestry.core.config.Defaults; import forestry.core.inventory.filters.ArrayStackFilter; import forestry.core.inventory.filters.IStackFilter; import forestry.core.inventory.filters.InvertedStackFilter; @@ -48,6 +50,7 @@ import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.inventory.wrappers.SidedInventoryMapper; import forestry.core.utils.AdjacentTileCache; import forestry.core.utils.PlainInventory; +import forestry.core.utils.StackUtils; import forestry.plugins.PluginManager; import buildcraft.api.transport.IPipeTile; @@ -830,4 +833,252 @@ public abstract class InvTools { stack.stackSize = 127; stack.writeToNBT(data); } + + public static IInventoryAdapter configureSidedUp(IInventoryAdapter inventory, int startSlot, int count) { + return configureSided(inventory, Defaults.FACING_UP, startSlot, count); + } + + public static IInventoryAdapter configureSidedDown(IInventoryAdapter inventory, int startSlot, int count) { + return configureSided(inventory, Defaults.FACING_DOWN, startSlot, count); + } + + public static IInventoryAdapter configureSidedNorthSouth(IInventoryAdapter inventory, int startSlot, int count) { + return configureSided(inventory, Defaults.FACING_NORTHSOUTH, startSlot, count); + } + + public static IInventoryAdapter configureSidedWestEast(IInventoryAdapter inventory, int startSlot, int count) { + return configureSided(inventory, Defaults.FACING_WESTEAST, startSlot, count); + } + + public static IInventoryAdapter configureSidedSides(IInventoryAdapter inventory, int startSlot, int count) { + return configureSided(inventory, Defaults.FACING_SIDES, startSlot, count); + } + + public static IInventoryAdapter configureSided(IInventoryAdapter inventory, int side, int startSlot, int count) { + return configureSided(inventory, new int[]{side}, startSlot, count); + } + + public static IInventoryAdapter configureSided(IInventoryAdapter inventory, int[] sides, int startSlot, int count) { + int[] slots = new int[count]; + for (int i = 0; i < count; i++) { + slots[i] = startSlot + i; + } + + return inventory.configureSided(sides, slots); + } + + /* REMOVAL */ + /** + * Removes a set of items from an inventory. + * Removes the exact items first if they exist, and then removes crafting equivalents. + * If the inventory doesn't have all the required items, returns false without removing anything. + * If stowContainer is true, items with containers will have their container stowed. + */ + public static boolean removeSets(IInventory inventory, int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { + + ItemStack[] condensedSet = StackUtils.condenseStacks(set, -1, false); + + ItemStack[] stock = getStacks(inventory, firstSlotIndex, slotCount); + if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count) + return false; + + for (ItemStack stackToRemove : condensedSet) { + stackToRemove.stackSize *= count; + + // try to remove the exact stack first + removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, false, false); + + // remove crafting equivalents next + if (stackToRemove.stackSize > 0) + removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, craftingTools); + } + return true; + } + + /** + * Private Helper for removeSetsFromInventory. Assumes removal is possible. + */ + private static void removeStack(IInventory inventory, ItemStack stackToRemove, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { + for (int j = firstSlotIndex; j < firstSlotIndex + slotCount; j++) { + ItemStack stackInSlot = inventory.getStackInSlot(j); + if (stackInSlot == null) + continue; + + if (!StackUtils.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictionary, craftingTools)) + continue; + + ItemStack removed = inventory.decrStackSize(j, stackToRemove.stackSize); + stackToRemove.stackSize -= removed.stackSize; + + if (stowContainer && stackToRemove.getItem().hasContainerItem(stackToRemove)) + StackUtils.stowContainerItem(removed, inventory, j, player); + + if (stackToRemove.stackSize == 0) + return; + } + } + + /* CONTAINS */ + public static boolean contains(IInventory inventory, ItemStack query, int startSlot, int slots) { + ItemStack[] queryArray = new ItemStack[]{query}; + return contains(inventory, queryArray, startSlot, slots); + } + + public static boolean contains(IInventory inventory, ItemStack[] query, int startSlot, int slots) { + ItemStack[] stock = getStacks(inventory, startSlot, slots); + return StackUtils.containsSets(query, stock) > 0; + } + + public static boolean containsPercent(IInventory inventory, float percent, int slot1, int length) { + int amount = 0; + int stackMax = 0; + for (ItemStack itemStack : getStacks(inventory, slot1, length)) { + if (itemStack == null) { + stackMax += 64; + continue; + } + + amount += itemStack.stackSize; + stackMax += itemStack.getMaxStackSize(); + } + if (stackMax == 0) + return false; + return ((float) amount / (float) stackMax) >= percent; + } + + public static boolean containsAmount(IInventory inventory, int amount, int slot1, int length) { + int total = 0; + for (ItemStack itemStack : getStacks(inventory, slot1, length)) { + if (itemStack == null) + continue; + + total += itemStack.stackSize; + if (total >= amount) + return true; + } + return false; + } + + public static ItemStack[] getStacks(IInventory inventory) { + ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()]; + for (int i = 0; i < inventory.getSizeInventory(); i++) { + stacks[i] = inventory.getStackInSlot(i); + } + return stacks; + } + + public static ItemStack[] getStacks(IInventory inventory, int slot1, int length) { + ItemStack[] result = new ItemStack[length]; + for (int i = slot1; i < slot1 + length; i++) { + result[i - slot1] = inventory.getStackInSlot(i); + } + return result; + } + + public static boolean tryAddStacksCopy(IInventory inventory, ItemStack[] stacks, boolean all) { + return tryAddStacksCopy(inventory, stacks, 0, inventory.getSizeInventory(), all); + } + + public static boolean tryAddStacksCopy(IInventory inventory, ItemStack[] stacks, int startSlot, int slots, boolean all) { + + for (ItemStack stack : stacks) { + if (stack == null) + continue; + + if (!tryAddStack(inventory, stack.copy(), startSlot, slots, all)) + return false; + } + + return true; + } + + public static boolean tryAddStacks(IInventory inventory, ItemStack[] stacks, boolean all) { + + boolean addedAll = true; + for (ItemStack stack : stacks) { + if (stack == null) + continue; + + if (!tryAddStack(inventory, stack, all)) + addedAll = false; + } + + return addedAll; + } + + public static boolean tryAddStack(IInventory inventory, ItemStack stack, boolean all) { + return tryAddStack(inventory, stack, 0, inventory.getSizeInventory(), all); + } + + /** + * Tries to add a stack to the specified slot range. + */ + public static boolean tryAddStack(IInventory inventory, ItemStack stack, int startSlot, int slots, boolean all) { + return tryAddStack(inventory, stack, startSlot, slots, all, true); + } + + public static boolean tryAddStack(IInventory inventory, ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) { + int added = addStack(inventory, stack, startSlot, slots, all, doAdd); + if (all) + return added == stack.stackSize; + else + return added > 0; + } + + public static int addStack(IInventory inventory, ItemStack stack, boolean all, boolean doAdd) { + return addStack(inventory, stack, 0, inventory.getSizeInventory(), all, doAdd); + } + + public static int addStack(IInventory inventory, ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) { + + int added = 0; + // Add to existing stacks first + for (int i = startSlot; i < startSlot + slots; i++) { + + // Empty slot. Add + if (inventory.getStackInSlot(i) == null) + continue; + + // Already occupied by different item, skip this slot. + if (!inventory.getStackInSlot(i).isItemEqual(stack)) + continue; + if (!ItemStack.areItemStackTagsEqual(inventory.getStackInSlot(i), stack)) + continue; + + int remain = stack.stackSize - added; + int space = inventory.getStackInSlot(i).getMaxStackSize() - inventory.getStackInSlot(i).stackSize; + // No space left, skip this slot. + if (space <= 0) + continue; + // Enough space + if (space >= remain) { + if (doAdd) + inventory.getStackInSlot(i).stackSize += remain; + return stack.stackSize; + } + + // Not enough space + if (doAdd) + inventory.getStackInSlot(i).stackSize = inventory.getStackInSlot(i).getMaxStackSize(); + + added += space; + } + + if (added >= stack.stackSize) + return added; + + for (int i = startSlot; i < startSlot + slots; i++) { + if (inventory.getStackInSlot(i) != null) + continue; + + if (doAdd) { + inventory.setInventorySlotContents(i, stack.copy()); + inventory.getStackInSlot(i).stackSize = stack.stackSize - added; + } + return stack.stackSize; + + } + + return added; + } } diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index 1cdbf5359..7ff63cc36 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -10,23 +10,24 @@ ******************************************************************************/ package forestry.core.inventory; -import forestry.api.core.INBTTagable; -import forestry.core.config.Defaults; -import forestry.core.utils.PlainInventory; -import forestry.core.utils.StackUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import forestry.core.config.Defaults; +import forestry.core.utils.PlainInventory; +import forestry.core.utils.StackUtils; + /** * With permission from Krapht. */ -public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagable { +public class InventoryAdapter implements IInventoryAdapter { + + protected final IInventory inventory; + private boolean allowAutomation = true; - private final IInventory inventory; //private boolean debug = false; public InventoryAdapter(int size, String name) { @@ -42,6 +43,11 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl configureSided(); } + public InventoryAdapter disableAutomation() { + this.allowAutomation = false; + return this; + } + // public InventoryAdapter enableDebug() { // this.debug = true; // return this; @@ -60,221 +66,7 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl return copy; } - public ItemStack[] getStacks() { - ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()]; - for (int i = 0; i < inventory.getSizeInventory(); i++) { - stacks[i] = inventory.getStackInSlot(i); - } - return stacks; - } - public ItemStack[] getStacks(int slot1, int length) { - ItemStack[] result = new ItemStack[length]; - for (int i = slot1; i < slot1 + length; i++) { - result[i - slot1] = inventory.getStackInSlot(i); - } - return result; - } - - public boolean tryAddStacksCopy(ItemStack[] stacks, boolean all) { - return tryAddStacksCopy(stacks, 0, this.getSizeInventory(), all); - } - - public boolean tryAddStacksCopy(ItemStack[] stacks, int startSlot, int slots, boolean all) { - - for (ItemStack stack : stacks) { - if (stack == null) - continue; - - if (!tryAddStack(stack.copy(), startSlot, slots, all)) - return false; - } - - return true; - } - - public boolean tryAddStacks(ItemStack[] stacks, boolean all) { - - boolean addedAll = true; - for (ItemStack stack : stacks) { - if (stack == null) - continue; - - if (!tryAddStack(stack, all)) - addedAll = false; - } - - return addedAll; - } - - public boolean tryAddStack(ItemStack stack, boolean all) { - return tryAddStack(stack, 0, this.getSizeInventory(), all); - } - - /** - * Tries to add a stack to the specified slot range. - */ - public boolean tryAddStack(ItemStack stack, int startSlot, int slots, boolean all) { - return tryAddStack(stack, startSlot, slots, all, true); - } - - public boolean tryAddStack(ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) { - int added = addStack(stack, startSlot, slots, all, doAdd); - if (all) - return added == stack.stackSize; - else - return added > 0; - } - - public int addStack(ItemStack stack, boolean all, boolean doAdd) { - return addStack(stack, 0, this.getSizeInventory(), all, doAdd); - } - - public int addStack(ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) { - - int added = 0; - // Add to existing stacks first - for (int i = startSlot; i < startSlot + slots; i++) { - - // Empty slot. Add - if (inventory.getStackInSlot(i) == null) - continue; - - // Already occupied by different item, skip this slot. - if (!inventory.getStackInSlot(i).isItemEqual(stack)) - continue; - if (!ItemStack.areItemStackTagsEqual(inventory.getStackInSlot(i), stack)) - continue; - - int remain = stack.stackSize - added; - int space = inventory.getStackInSlot(i).getMaxStackSize() - inventory.getStackInSlot(i).stackSize; - // No space left, skip this slot. - if (space <= 0) - continue; - // Enough space - if (space >= remain) { - if (doAdd) - inventory.getStackInSlot(i).stackSize += remain; - return stack.stackSize; - } - - // Not enough space - if (doAdd) - inventory.getStackInSlot(i).stackSize = inventory.getStackInSlot(i).getMaxStackSize(); - - added += space; - } - - if (added >= stack.stackSize) - return added; - - for (int i = startSlot; i < startSlot + slots; i++) { - if (inventory.getStackInSlot(i) != null) - continue; - - if (doAdd) { - setInventorySlotContents(i, stack.copy()); - inventory.getStackInSlot(i).stackSize = stack.stackSize - added; - } - return stack.stackSize; - - } - - return added; - - } - - /* CONTAINS */ - public boolean contains(ItemStack query, int startSlot, int slots) { - ItemStack[] queryArray = new ItemStack[]{query}; - return contains(queryArray, startSlot, slots); - } - - public boolean contains(ItemStack[] query, int startSlot, int slots) { - ItemStack[] stock = getStacks(startSlot, slots); - return StackUtils.containsSets(query, stock) > 0; - } - - public boolean containsPercent(float percent, int slot1, int length) { - int amount = 0; - int stackMax = 0; - for (ItemStack itemStack : getStacks(slot1, length)) { - if (itemStack == null) { - stackMax += 64; - continue; - } - - amount += itemStack.stackSize; - stackMax += itemStack.getMaxStackSize(); - } - if (stackMax == 0) - return false; - return ((float) amount / (float) stackMax) >= percent; - } - - public boolean containsAmount(int amount, int slot1, int length) { - int total = 0; - for (ItemStack itemStack : getStacks(slot1, length)) { - if (itemStack == null) - continue; - - total += itemStack.stackSize; - if (total >= amount) - return true; - } - return false; - } - - /* REMOVAL */ - /** - * Removes a set of items from an inventory. - * Removes the exact items first if they exist, and then removes crafting equivalents. - * If the inventory doesn't have all the required items, returns false without removing anything. - * If stowContainer is true, items with containers will have their container stowed. - */ - public boolean removeSets(int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { - - ItemStack[] condensedSet = StackUtils.condenseStacks(set, -1, false); - - ItemStack[] stock = getStacks(firstSlotIndex, slotCount); - if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count) - return false; - - for (ItemStack stackToRemove : condensedSet) { - stackToRemove.stackSize *= count; - - // try to remove the exact stack first - removeStack(stackToRemove, firstSlotIndex, slotCount, player, stowContainer, false, false); - - // remove crafting equivalents next - if (stackToRemove.stackSize > 0) - removeStack(stackToRemove, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, craftingTools); - } - return true; - } - - /** - * Private Helper for removeSetsFromInventory. Assumes removal is possible. - */ - private void removeStack(ItemStack stackToRemove, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) { - for (int j = firstSlotIndex; j < firstSlotIndex + slotCount; j++) { - ItemStack stackInSlot = getStackInSlot(j); - if (stackInSlot == null) - continue; - - if (!StackUtils.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictionary, craftingTools)) - continue; - - ItemStack removed = decrStackSize(j, stackToRemove.stackSize); - stackToRemove.stackSize -= removed.stackSize; - - if (stowContainer && stackToRemove.getItem().hasContainerItem(stackToRemove)) - StackUtils.stowContainerItem(removed, this, j, player); - - if (stackToRemove.stackSize == 0) - return; - } - } /* IINVENTORY */ @Override @@ -332,6 +124,11 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl return true; } + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return true; + } + @Override public void openInventory() { } @@ -345,47 +142,17 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl @Override public int[] getAccessibleSlotsFromSide(int side) { - return slotMap[side]; + if (allowAutomation) + return slotMap[side]; + return Defaults.SLOTS_NONE; } private void configureSided() { slotMap = new int[6][0]; - configureSided(Defaults.FACINGS, 0, getSizeInventory()); - } - - public InventoryAdapter configureSidedUp(int startSlot, int count) { - return configureSided(Defaults.FACING_UP, startSlot, count); - } - - public InventoryAdapter configureSidedDown(int startSlot, int count) { - return configureSided(Defaults.FACING_DOWN, startSlot, count); - } - - public InventoryAdapter configureSidedNorthSouth(int startSlot, int count) { - return configureSided(Defaults.FACING_NORTHSOUTH, startSlot, count); - } - - public InventoryAdapter configureSidedWestEast(int startSlot, int count) { - return configureSided(Defaults.FACING_WESTEAST, startSlot, count); - } - - public InventoryAdapter configureSidedSides(int startSlot, int count) { - return configureSided(Defaults.FACING_SIDES, startSlot, count); - } - - public InventoryAdapter configureSided(int side, int startSlot, int count) { - return configureSided(new int[]{side}, startSlot, count); - } - - public InventoryAdapter configureSided(int[] sides, int startSlot, int count) { - int[] slots = new int[count]; - for (int i = 0; i < count; i++) { - slots[i] = startSlot + i; - } - - return configureSided(sides, slots); + InvTools.configureSided(this, Defaults.FACINGS, 0, getSizeInventory()); } + @Override public InventoryAdapter configureSided(int[] sides, int[] slots) { for (int side : sides) { slotMap[side] = slots; @@ -401,7 +168,7 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl @Override public boolean canExtractItem(int slot, ItemStack stack, int side) { - return true; + return false; } /* SAVING & LOADING */ @@ -432,5 +199,4 @@ public class InventoryAdapter implements IInventory, ISidedInventory, INBTTagabl } nbttagcompound.setTag(inventory.getInventoryName(), nbttaglist); } - } diff --git a/src/main/java/forestry/core/inventory/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java index 267d099da..fac014e21 100755 --- a/src/main/java/forestry/core/inventory/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.core.inventory; -import forestry.api.core.INBTTagable; -import forestry.core.utils.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -19,24 +17,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class ItemInventory implements IInventory, INBTTagable { +import forestry.api.core.INBTTagable; +import forestry.core.interfaces.IFilterSlotDelegate; +import forestry.core.utils.StackUtils; +import forestry.core.utils.Utils; + +public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagable { public final Class itemClass; - public boolean isItemInventory = false; + public final boolean isItemInventory; public ItemStack parent; protected ItemStack[] inventoryStacks; - protected ItemInventory(Class itemClass) { - this.itemClass = itemClass; - } - - public ItemInventory(Class itemClass, int slots) { - this(itemClass); - inventoryStacks = new ItemStack[slots]; - } - public ItemInventory(Class itemClass, int size, ItemStack itemstack) { - this(itemClass, size); + this.itemClass = itemClass; + + inventoryStacks = new ItemStack[size]; parent = itemstack; isItemInventory = true; @@ -77,46 +73,18 @@ public class ItemInventory implements IInventory, INBTTagable { } public void onGuiSaved(EntityPlayer player) { - parent = findParent(player); + parent = findParentInInventory(player); if (parent != null) save(); } - public ItemStack findParent(EntityPlayer player) { - if (parent == null) - return null; - - NBTTagCompound parentNBT = parent.getTagCompound(); - if (parentNBT == null) - return null; - - int uid = parentNBT.getInteger("UID"); - + public ItemStack findParentInInventory(EntityPlayer player) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if (stack == null) - continue; - if(stack.getItem() != parent.getItem()) - continue; - NBTTagCompound slotNBT = stack.getTagCompound(); - if (slotNBT == null) - continue; - if (uid == slotNBT.getInteger("UID")) - return player.inventory.getStackInSlot(i); + if (StackUtils.isIdenticalItem(stack, parent)) + return stack; } - return null; - } - - public boolean matchesUID(int otherId) { - if (parent == null) - return false; - - NBTTagCompound nbt = parent.getTagCompound(); - if (nbt == null) - return false; - - int uid = nbt.getInteger("UID"); - return uid == otherId; + return parent; } public void save() { @@ -220,7 +188,12 @@ public class ItemInventory implements IInventory, INBTTagable { } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + return canSlotAccept(slotIndex, itemStack); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { return true; } diff --git a/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java b/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java new file mode 100644 index 000000000..fc38a1149 --- /dev/null +++ b/src/main/java/forestry/core/inventory/ItemInventoryBackpack.java @@ -0,0 +1,33 @@ +package forestry.core.inventory; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import forestry.api.storage.IBackpackDefinition; +import forestry.storage.items.ItemBackpack; + +public class ItemInventoryBackpack extends ItemInventory { + + private final IBackpackDefinition backpackDefinition; + + public ItemInventoryBackpack(Class itemClass, int size, ItemStack itemstack) { + super(itemClass, size, itemstack); + + if (parent == null) + throw new IllegalArgumentException("Parent cannot be null."); + + Item item = parent.getItem(); + if (!(item instanceof ItemBackpack)) + throw new IllegalArgumentException("Parent must be a backpack."); + + this.backpackDefinition = ((ItemBackpack) item).getDefinition(); + + if (this.backpackDefinition == null) + throw new IllegalArgumentException("Backpack must have a backpack definition."); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return backpackDefinition.isValidItem(null, itemStack); + } +} diff --git a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java index 3a2d6ca95..6708a738f 100755 --- a/src/main/java/forestry/core/inventory/TileInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/TileInventoryAdapter.java @@ -10,12 +10,10 @@ ******************************************************************************/ package forestry.core.inventory; -import forestry.core.gadgets.TileForestry; -import forestry.core.utils.EnumAccess; -import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import forestry.core.gadgets.TileForestry; + public class TileInventoryAdapter extends InventoryAdapter { private final TileForestry tile; @@ -29,26 +27,14 @@ public class TileInventoryAdapter extends InventoryAdapter { this.tile = tile; } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (!Utils.isUseableByPlayer(player, tile)) - return false; - return tile.allowsViewing(player); - } - @Override public void markDirty() { super.markDirty(); tile.markDirty(); } - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return true; - } - @Override public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { - return true; + return false; } } diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index fb7014aa5..b25c6fb4c 100755 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -227,10 +227,6 @@ public class PacketHandler { if (tile instanceof IInventory) { ((IInventory) tile).setInventorySlotContents(packet.slotIndex, packet.itemstack); - } else if (tile instanceof TileForestry) { - IInventory inventory = ((TileForestry) tile).getInternalInventory(); - - if (inventory != null) inventory.setInventorySlotContents(packet.slotIndex, packet.itemstack); } } diff --git a/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java b/src/main/java/forestry/core/utils/GuiUtil.java old mode 100755 new mode 100644 similarity index 51% rename from src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java rename to src/main/java/forestry/core/utils/GuiUtil.java index cec92c298..e5234b8a1 --- a/src/main/java/forestry/apiculture/gui/ContainerBeealyzer.java +++ b/src/main/java/forestry/core/utils/GuiUtil.java @@ -1,25 +1,19 @@ -/******************************************************************************* - * 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.apiculture.gui; - -import forestry.apiculture.items.ItemBeeGE; -import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerAlyzer; -import net.minecraft.entity.player.InventoryPlayer; - -public class ContainerBeealyzer extends ContainerAlyzer { - - public ContainerBeealyzer(InventoryPlayer inventoryplayer, BeealyzerInventory inventory) { - super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, ItemBeeGE.class); - } - -} +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +public class GuiUtil { + + public static boolean isIndexInRange(int index, int start, int count) { + return (index >= start) && (index < start + count); + } + +} diff --git a/src/main/java/forestry/core/utils/StackUtils.java b/src/main/java/forestry/core/utils/StackUtils.java index 93a5d0215..144977116 100755 --- a/src/main/java/forestry/core/utils/StackUtils.java +++ b/src/main/java/forestry/core/utils/StackUtils.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.utils; -import forestry.core.config.Defaults; -import forestry.core.inventory.InventoryAdapter; import java.util.ArrayList; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -23,10 +22,14 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; + import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.oredict.OreDictionary; +import forestry.core.config.Defaults; +import forestry.core.inventory.InvTools; + public class StackUtils { public static final ItemStack[] EMPTY_STACK_ARRAY = new ItemStack[0]; @@ -225,6 +228,14 @@ public class StackUtils { return condensed.toArray(new ItemStack[condensed.size()]); } + public static boolean containsItemStack(Iterable list, ItemStack itemStack) { + for (ItemStack listStack : list) { + if (isIdenticalItem(listStack, itemStack)) + return true; + } + return false; + } + /** * Counts how many full sets are contained in the passed stock */ @@ -323,7 +334,7 @@ public class StackUtils { return isCraftingTool(phantom) && phantom.getItem() == actual.getItem(); } - public static void stowContainerItem(ItemStack itemstack, InventoryAdapter stowing, int slotIndex, EntityPlayer player) { + public static void stowContainerItem(ItemStack itemstack, IInventory stowing, int slotIndex, EntityPlayer player) { if (!itemstack.getItem().hasContainerItem(itemstack)) return; @@ -337,12 +348,12 @@ public class StackUtils { if (container != null) { if (itemstack.getItem().doesContainerItemLeaveCraftingGrid(itemstack)) { - if (!stowing.tryAddStack(container, true)) + if (!InvTools.tryAddStack(stowing, container, true)) if (!player.inventory.addItemStackToInventory(container)) player.dropPlayerItemWithRandomChoice(container, true); } else { - if (!stowing.tryAddStack(container, slotIndex, 1, true)) - if (!stowing.tryAddStack(container, true)) + if (!InvTools.tryAddStack(stowing, container, slotIndex, 1, true)) + if (!InvTools.tryAddStack(stowing, container, true)) player.dropPlayerItemWithRandomChoice(container, true); } } diff --git a/src/main/java/forestry/core/utils/Utils.java b/src/main/java/forestry/core/utils/Utils.java index 9869e0cd5..4d7bf0567 100755 --- a/src/main/java/forestry/core/utils/Utils.java +++ b/src/main/java/forestry/core/utils/Utils.java @@ -71,41 +71,34 @@ public class Utils { } } else { - IInventory inventory; - if (tile instanceof IInventory) - inventory = (IInventory) tile; - else - inventory = tile.getInternalInventory(); + for (int slot = 0; slot < tile.getSizeInventory(); slot++) { - if (inventory != null) { - for (int slot = 0; slot < inventory.getSizeInventory(); slot++) { + ItemStack itemstack = tile.getStackInSlot(slot); - ItemStack itemstack = inventory.getStackInSlot(slot); + if (itemstack == null) + continue; - if (itemstack == null) - continue; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; - float f = world.rand.nextFloat() * 0.8F + 0.1F; - float f1 = world.rand.nextFloat() * 0.8F + 0.1F; - float f2 = world.rand.nextFloat() * 0.8F + 0.1F; + while (itemstack.stackSize > 0) { - while (itemstack.stackSize > 0) { + int stackPartial = world.rand.nextInt(21) + 10; + if (stackPartial > itemstack.stackSize) + stackPartial = itemstack.stackSize; + ItemStack drop = itemstack.splitStack(stackPartial); + EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, drop); + float accel = 0.05F; + entityitem.motionX = (float) world.rand.nextGaussian() * accel; + entityitem.motionY = (float) world.rand.nextGaussian() * accel + 0.2F; + entityitem.motionZ = (float) world.rand.nextGaussian() * accel; + world.spawnEntityInWorld(entityitem); - int stackPartial = world.rand.nextInt(21) + 10; - if (stackPartial > itemstack.stackSize) - stackPartial = itemstack.stackSize; - ItemStack drop = itemstack.splitStack(stackPartial); - EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, drop); - float accel = 0.05F; - entityitem.motionX = (float) world.rand.nextGaussian() * accel; - entityitem.motionY = (float) world.rand.nextGaussian() * accel + 0.2F; - entityitem.motionZ = (float) world.rand.nextGaussian() * accel; - world.spawnEntityInWorld(entityitem); - - } - - inventory.setInventorySlotContents(slot, null); } + + tile.setInventorySlotContents(slot, null); + } } diff --git a/src/main/java/forestry/energy/gadgets/EngineBronze.java b/src/main/java/forestry/energy/gadgets/EngineBronze.java index 7af2eb3b0..0f969f272 100755 --- a/src/main/java/forestry/energy/gadgets/EngineBronze.java +++ b/src/main/java/forestry/energy/gadgets/EngineBronze.java @@ -10,6 +10,20 @@ ******************************************************************************/ package forestry.energy.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.core.ForestryAPI; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; @@ -24,21 +38,10 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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; public class EngineBronze extends Engine implements ISidedInventory, ILiquidTankContainer { @@ -79,7 +82,17 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank super(Defaults.ENGINE_BRONZE_HEAT_MAX, 300000, 5000); setHints(Config.hints.get("engine.bronze")); - setInternalInventory(new TileInventoryAdapter(this, 1, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 1, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_CAN) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return tankManager.accepts(fluid); + } + + return false; + } + }); fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet()); fuelTank.tankMode = StandardTank.TankMode.INPUT; @@ -104,7 +117,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (inventory.getStackInSlot(SLOT_CAN) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); @@ -340,88 +353,6 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank iCrafting.sendProgressBarUpdate(containerEngine, i + 5, currentFluidId); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (slotIndex == SLOT_CAN) { - FluidStack fluid = FluidHelper.getFluidStackInContainer(itemstack); - if (fluid == null || fluid.amount <= 0) - return false; - return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid()); - } - - return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - return false; - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { - return isItemValidForSlot(slotIndex, stack); - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - // IFluidHandler @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/energy/gadgets/EngineCopper.java b/src/main/java/forestry/energy/gadgets/EngineCopper.java index 2afdfc453..febd882a9 100755 --- a/src/main/java/forestry/energy/gadgets/EngineCopper.java +++ b/src/main/java/forestry/energy/gadgets/EngineCopper.java @@ -38,10 +38,12 @@ import forestry.core.config.ForestryItem; import forestry.core.gadgets.Engine; import forestry.core.gadgets.TileBase; import forestry.core.inventory.AdjacentInventoryCache; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; +import forestry.core.utils.GuiUtil; import forestry.factory.triggers.FactoryTriggers; import buildcraft.api.statements.ITriggerExternal; @@ -67,7 +69,17 @@ public class EngineCopper extends Engine implements ISidedInventory { setHints(Config.hints.get("engine.copper")); ashForItem = Defaults.ENGINE_COPPER_ASH_FOR_ITEM; - setInternalInventory(new TileInventoryAdapter(this, 5, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemStack); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_WASTE_1, SLOT_WASTE_COUNT); + } + }); } @Override @@ -76,7 +88,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } private int getFuelSlot() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_FUEL) == null) return -1; @@ -87,7 +99,7 @@ public class EngineCopper extends Engine implements ISidedInventory { } private int getFreeWasteSlot() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_WASTE_1; i <= SLOT_WASTE_COUNT; i++) { if (inventory.getStackInSlot(i) == null) return i; @@ -143,7 +155,7 @@ public class EngineCopper extends Engine implements ISidedInventory { int wasteslot = getFreeWasteSlot(); if (fuelslot >= 0 && wasteslot >= 0) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); burnTime = totalBurnTime = determineBurnDuration(inventory.getStackInSlot(fuelslot)); if (burnTime > 0) { fuelItem = inventory.getStackInSlot(fuelslot).getItem(); @@ -195,7 +207,7 @@ public class EngineCopper extends Engine implements ISidedInventory { // If we have reached the necessary amount, we need to add ash int wasteslot = getFreeWasteSlot(); if (wasteslot >= 0) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(wasteslot) == null) inventory.setInventorySlotContents(wasteslot, ForestryItem.ash.getItemStack()); else @@ -229,7 +241,7 @@ public class EngineCopper extends Engine implements ISidedInventory { /* AUTO-EJECTING */ private IInventory getWasteInventory() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory == null) return null; @@ -265,7 +277,7 @@ public class EngineCopper extends Engine implements ISidedInventory { if (fuelSlot < 0) return false; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); return ((float) inventory.getStackInSlot(fuelSlot).stackSize / (float) inventory.getStackInSlot(fuelSlot).getMaxStackSize()) > percentage; } @@ -331,88 +343,6 @@ public class EngineCopper extends Engine implements ISidedInventory { iCrafting.sendProgressBarUpdate(containerEngine, 4, heat); } - // / IINVENTORY - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack); - } - - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex >= SLOT_WASTE_1 && slotIndex < SLOT_WASTE_1 + SLOT_WASTE_COUNT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ITRIGGERPROVIDER */ @Optional.Method(modid = "BuildCraftAPI|statements") @Override diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index 47e9d0c57..ba782cca4 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -10,6 +10,13 @@ ******************************************************************************/ package forestry.energy.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.ForestryAPI; @@ -26,13 +33,9 @@ import forestry.core.network.GuiId; import forestry.core.utils.DelayTimer; import forestry.core.utils.EnumTankLevel; import forestry.plugins.PluginIC2; + import ic2.api.energy.prefab.BasicSink; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import ic2.api.item.ElectricItem; public class EngineTin extends Engine implements ISocketable, IInventory { @@ -50,7 +53,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { } } - private static final short batterySlot = 0; + public static final short SLOT_BATTERY = 0; private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(Defaults.ENGINE_TIN_EU_FOR_CYCLE, Defaults.ENGINE_TIN_ENERGY_PER_CYCLE, Defaults.ENGINE_TIN_MAX_EU_STORED); @@ -62,7 +65,15 @@ public class EngineTin extends Engine implements ISocketable, IInventory { super(Defaults.ENGINE_TIN_HEAT_MAX, 100000, 4000); setHints(Config.hints.get("engine.tin")); - setInternalInventory(new TileInventoryAdapter(this, 1, "electrical")); + setInternalInventory(new TileInventoryAdapter(this, 1, "electrical") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_BATTERY) { + return ElectricItem.manager.getCharge(itemStack) > 0; + } + return false; + } + }); if (PluginIC2.instance.isAvailable()) ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); @@ -166,8 +177,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory { return; } - if (getInternalInventory().getStackInSlot(batterySlot) != null) - replenishFromBattery(batterySlot); + if (getInternalInventory().getStackInSlot(SLOT_BATTERY) != null) + replenishFromBattery(SLOT_BATTERY); // Updating of gui delayed to prevent it from going crazy if (!delayUpdateTimer.delayPassed(worldObj, 80)) @@ -270,67 +281,6 @@ public class EngineTin extends Engine implements ISocketable, IInventory { ic2EnergySink.setCapacity(euConfig.euStorage); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); - } - - //TODO: Add ISideInventory and clarify allowed items - /* ISOCKETABLE */ @Override public int getSocketCount() { diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index 4c6e7146b..faf2f23f6 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -10,6 +10,18 @@ ******************************************************************************/ package forestry.energy.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.fuels.GeneratorFuel; @@ -22,22 +34,14 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; import forestry.plugins.PluginIC2; + import ic2.api.energy.prefab.BasicSource; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class MachineGenerator extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine { @@ -54,7 +58,17 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu public MachineGenerator() { setHints(Config.hints.get("generator")); - setInternalInventory(new TileInventoryAdapter(this, 1, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 1, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_CAN) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return tankManager.accepts(fluid); + } + + return false; + } + }); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet()); tankManager = new TankManager(resourceTank); @@ -63,11 +77,6 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu ic2EnergySource = new BasicSource(this, maxEnergy, 1); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.GeneratorGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -114,7 +123,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu // Check inventory slots for fuel // Check if we have suitable items waiting in the item slot - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_CAN) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); @@ -189,83 +198,6 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu iCrafting.sendProgressBarUpdate(container, firstMessageId, (short) ic2EnergySource.getEnergyStored()); } - /* IINVENTORY */ - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) - return false; - - if (slotIndex == SLOT_CAN) { - Fluid fluid = FluidHelper.getFluidInContainer(stack); - return fluid != null && FuelManager.generatorFuel.containsKey(fluid); - } - return false; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { - return false; - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { - return isItemValidForSlot(slotIndex, stack); - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILiquidTankContainer */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java index dc964ac24..32876b6c8 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineBronze.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineBronze.java @@ -10,21 +10,23 @@ ******************************************************************************/ package forestry.energy.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.energy.gadgets.EngineBronze; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.energy.gadgets.EngineBronze; + public class ContainerEngineBronze extends ContainerLiquidTanks { protected final EngineBronze engine; public ContainerEngineBronze(InventoryPlayer player, EngineBronze engine) { - super(engine, engine); + super(engine); this.engine = engine; - this.addSlotToContainer(new SlotLiquidContainer(engine, EngineBronze.SLOT_CAN, 143, 40)); + + this.addSlotToContainer(new SlotFiltered(engine, EngineBronze.SLOT_CAN, 143, 40)); int i; for (i = 0; i < 3; ++i) { diff --git a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java index 0d75f1d80..ef6e5e31c 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineCopper.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineCopper.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.energy.gui; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.energy.gadgets.EngineCopper; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.energy.gadgets.EngineCopper; + public class ContainerEngineCopper extends ContainerForestry { protected final EngineCopper engine; @@ -25,12 +27,13 @@ public class ContainerEngineCopper extends ContainerForestry { super(tile); this.engine = tile; - this.addSlotToContainer(new Slot(tile, 0, 44, 46)); - this.addSlotToContainer(new SlotClosed(tile, 1, 98, 35)); - this.addSlotToContainer(new SlotClosed(tile, 2, 98, 53)); - this.addSlotToContainer(new SlotClosed(tile, 3, 116, 35)); - this.addSlotToContainer(new SlotClosed(tile, 4, 116, 53)); + this.addSlotToContainer(new SlotFiltered(tile, 0, 44, 46)); + + this.addSlotToContainer(new SlotOutput(tile, 1, 98, 35)); + this.addSlotToContainer(new SlotOutput(tile, 2, 98, 53)); + this.addSlotToContainer(new SlotOutput(tile, 3, 116, 35)); + this.addSlotToContainer(new SlotOutput(tile, 4, 116, 53)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { diff --git a/src/main/java/forestry/energy/gui/ContainerEngineTin.java b/src/main/java/forestry/energy/gui/ContainerEngineTin.java index 4ffdcc26c..1ba9796ad 100755 --- a/src/main/java/forestry/energy/gui/ContainerEngineTin.java +++ b/src/main/java/forestry/energy/gui/ContainerEngineTin.java @@ -10,12 +10,14 @@ ******************************************************************************/ package forestry.energy.gui; -import forestry.core.gui.ContainerSocketed; -import forestry.energy.gadgets.EngineTin; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerSocketed; +import forestry.core.gui.slots.SlotFiltered; +import forestry.energy.gadgets.EngineTin; + public class ContainerEngineTin extends ContainerSocketed { protected final EngineTin tile; @@ -24,7 +26,8 @@ public class ContainerEngineTin extends ContainerSocketed { super(tile, tile); this.tile = tile; - this.addSlotToContainer(new Slot(tile, 0, 84, 53)); + + this.addSlotToContainer(new SlotFiltered(tile, EngineTin.SLOT_BATTERY, 84, 53)); int i; for (i = 0; i < 3; ++i) diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index 7b5cd5b19..e78b0f858 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -10,21 +10,23 @@ ******************************************************************************/ package forestry.energy.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.energy.gadgets.MachineGenerator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.energy.gadgets.MachineGenerator; + public class ContainerGenerator extends ContainerLiquidTanks { protected final MachineGenerator tile; public ContainerGenerator(InventoryPlayer player, MachineGenerator tile) { - super(tile, tile); + super(tile); this.tile = tile; - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineGenerator.SLOT_CAN, 22, 38)); + + this.addSlotToContainer(new SlotFiltered(tile, MachineGenerator.SLOT_CAN, 22, 38)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 221f58457..76799a2ac 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -10,8 +10,31 @@ ******************************************************************************/ package forestry.factory.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import cpw.mods.fml.common.Optional; + import forestry.api.core.ForestryAPI; import forestry.api.recipes.ICraftingProvider; import forestry.core.EnumErrorCode; @@ -23,31 +46,15 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Stack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; + +import buildcraft.api.statements.ITriggerExternal; public class MachineBottler extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -146,18 +153,29 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq public MachineBottler() { super(1100, 50, 4000); - setInternalInventory(new TileInventoryAdapter(this, 3, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 3, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_RESOURCE) { + return FluidContainerRegistry.isEmptyContainer(itemStack); + } else if (slotIndex == SLOT_CAN) { + FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemStack); + return RecipeManager.isInput(fluidStack); + } + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_PRODUCT; + } + }); setHints(Config.hints.get("bottler")); resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY); tankManager = new TankManager(resourceTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.BottlerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -211,7 +229,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (inventory.getStackInSlot(SLOT_CAN) != null) @@ -257,7 +275,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq // We are done, add products to queue and remove resources pendingProducts.push(currentRecipe.bottled.copy()); - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); inventory.decrStackSize(SLOT_RESOURCE, 1); resourceTank.drain(currentRecipe.input.amount, true); checkRecipe(); @@ -269,7 +287,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } public void checkRecipe() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), inventory.getStackInSlot(SLOT_RESOURCE)); if (sameRec == null) @@ -307,7 +325,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq } private boolean addProduct(ItemStack product, boolean all) { - return getInternalInventory().tryAddStack(product, SLOT_PRODUCT, 1, all); + return InvTools.tryAddStack(getInternalInventory(), product, SLOT_PRODUCT, 1, all); } // / STATE INFORMATION @@ -318,7 +336,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public boolean hasResourcesMin(float percentage) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; @@ -368,88 +386,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq iCrafting.sendProgressBarUpdate(container, i + 1, fillingTotalTime); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_RESOURCE) - return FluidContainerRegistry.isEmptyContainer(itemstack); - - if (slotIndex == SLOT_CAN) { - FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); - return RecipeManager.isInput(fluidStack); - } - - return false; - } - - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - return getInternalInventory().canExtractItem(side, itemstack, side) && slotIndex == SLOT_PRODUCT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILIQUIDCONTAINER */ @Override public TankManager getTankManager() { diff --git a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java index 4e344902b..f20c3a415 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCarpenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineCarpenter.java @@ -27,7 +27,6 @@ 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.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.oredict.OreDictionary; @@ -45,11 +44,14 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; +import forestry.core.utils.GuiUtil; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; @@ -59,6 +61,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL /* CONSTANTS */ public final static int SLOT_CRAFTING_1 = 0; + public final static int SLOT_CRAFTING_COUNT = 9; public final static int SLOT_BOX = 9; public final static int SLOT_PRODUCT = 10; public final static int SLOT_CAN_INPUT = 11; @@ -216,17 +219,38 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL setHints(Config.hints.get("carpenter")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids); craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems"); - setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); - getInternalInventory().configureSided(Defaults.FACINGS, SLOT_BOX, 20); + setInternalInventory(new TileInventoryAdapter(this, 30, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_CAN_INPUT) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return tankManager.accepts(fluid); + } else if (slotIndex == SLOT_BOX) { + return MachineCarpenter.RecipeManager.isBox(itemStack); + } + + return true; + } + + @Override + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) { + if (lastRecipe != null) + return lastRecipe.isIngredient(itemStack); + } + return true; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_PRODUCT; + } + }); + InvTools.configureSided(getInternalInventory(), Defaults.FACINGS, SLOT_BOX, 20); tankManager = new TankManager(resourceTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.CarpenterGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -296,7 +320,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (worldObj.getTotalWorldTime() % 20 != 0) return; - TileInventoryAdapter accessibleInventory = getInternalInventory(); + IInventoryAdapter accessibleInventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (accessibleInventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidHelper.drainContainers(tankManager, accessibleInventory, SLOT_CAN_INPUT); @@ -381,15 +405,15 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (resourceTank.getFluidAmount() < currentRecipe.liquid.amount) return false; - TileInventoryAdapter accessibleInventory = getInternalInventory(); + IInventoryAdapter accessibleInventory = getInternalInventory(); // Check whether boxes are available if (currentRecipe.box != null) if (accessibleInventory.getStackInSlot(SLOT_BOX) == null) return false; // Need at least one matched set - ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, 9); - ItemStack[] stock = accessibleInventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ItemStack[] set = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + ItemStack[] stock = InvTools.getStacks(accessibleInventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);; return StackUtils.containsSets(set, stock, true, false) > 0; } @@ -409,17 +433,16 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (removed == null || removed.stackSize == 0) return false; } - - return removeSets(1, craftingInventory.getStacks(SLOT_CRAFTING_1, 9)); + return removeSets(1, InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT)); } private boolean removeSets(int count, ItemStack[] set) { EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); - return getInternalInventory().removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); + return InvTools.removeSets(getInternalInventory(), count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); } private boolean tryAddPending() { - TileInventoryAdapter accessibleInventory = getInternalInventory(); + IInventoryAdapter accessibleInventory = getInternalInventory(); if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) == null) { accessibleInventory.setInventorySlotContents(SLOT_PRODUCT, pendingProduct.copy()); pendingProduct = null; @@ -448,7 +471,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL if (currentRecipe == null) return false; - TileInventoryAdapter accessibleInventory = getInternalInventory(); + IInventoryAdapter accessibleInventory = getInternalInventory(); // Stop working if the output slot cannot take more if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) != null && accessibleInventory.getStackInSlot(SLOT_PRODUCT).getMaxStackSize() - accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize < currentRecipe @@ -475,97 +498,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL return Utils.rateTankLevel(getResourceScaled(100)); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_PRODUCT) - return false; - - if (slotIndex == SLOT_BOX) - return RecipeManager.isBox(itemstack); - - if (slotIndex == SLOT_CAN_INPUT) - return FluidContainerRegistry.isContainer(itemstack); - - if (slotIndex >= SLOT_INVENTORY_1 && slotIndex < SLOT_INVENTORY_1 + SLOT_INVENTORY_COUNT) { - if (lastRecipe == null) - return true; - return lastRecipe.isIngredient(itemstack); - } - - return false; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_PRODUCT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* SMP GUI */ @Override public void getGUINetworkData(int i, int j) { diff --git a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java index c02a9734c..2e57edc2c 100755 --- a/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java +++ b/src/main/java/forestry/factory/gadgets/MachineCentrifuge.java @@ -38,8 +38,11 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; +import forestry.core.utils.GuiUtil; import forestry.factory.triggers.FactoryTriggers; import buildcraft.api.statements.ITriggerExternal; @@ -49,6 +52,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { /* CONSTANTS */ public static final int SLOT_RESOURCE = 0; public static final int SLOT_PRODUCT_1 = 1; + public static final int SLOT_PRODUCT_COUNT = 9; /* RECIPE MANAGMENT */ public static class Recipe { @@ -146,13 +150,18 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { public MachineCentrifuge() { super(800, 40, Defaults.MACHINE_MAX_ENERGY); - setInternalInventory(new TileInventoryAdapter(this, 10, "Items")); - setHints(Config.hints.get("centrifuge")); - } + setInternalInventory(new TileInventoryAdapter(this, 10, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemStack) != null; + } - @Override - public String getInventoryName() { - return getUnlocalizedName(); + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT); + } + }); + setHints(Config.hints.get("centrifuge")); } @Override @@ -293,7 +302,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { } private boolean addProduct(ItemStack product, boolean all) { - return getInternalInventory().tryAddStack(product, 1, getSizeInventory() - 1, all); + return InvTools.tryAddStack(getInternalInventory(), product, 1, getSizeInventory() - 1, all); } @Override @@ -303,7 +312,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { @Override public boolean hasResourcesMin(float percentage) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; @@ -339,81 +348,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory { iCrafting.sendProgressBarUpdate(container, 1, timePerItem); } - /* IINVENTORY */ - - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - return slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemstack) != null; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - return slotIndex >= SLOT_PRODUCT_1 && slotIndex < SLOT_PRODUCT_1 + 9; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ITRIGGERPROVIDER */ @Optional.Method(modid = "BuildCraftAPI|statements") @Override diff --git a/src/main/java/forestry/factory/gadgets/MachineFabricator.java b/src/main/java/forestry/factory/gadgets/MachineFabricator.java index 0dc646413..aba79452b 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFabricator.java +++ b/src/main/java/forestry/factory/gadgets/MachineFabricator.java @@ -41,11 +41,14 @@ import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ICrafter; import forestry.core.interfaces.ICraftingPlan; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.network.GuiId; +import forestry.core.utils.GuiUtil; import forestry.core.utils.ShapedRecipeCustom; import forestry.core.utils.StackUtils; @@ -161,6 +164,15 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT return null; } + public static boolean isPlan(ItemStack plan) { + for (Recipe recipe : recipes) { + if (StackUtils.isIdenticalItem(recipe.getPlan(), plan)) + return true; + } + + return false; + } + public static boolean isResourceLiquid(FluidStack liquid) { for (Recipe recipe : recipes) { if (recipe.hasLiquid(liquid)) @@ -228,18 +240,28 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT public MachineFabricator() { super(1100, 50, 3300); - setInternalInventory(new TileInventoryAdapter(this, 30, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 30, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_METAL) { + return RecipeManager.findMatchingSmelting(itemStack) != null; + } else if (slotIndex == SLOT_PLAN) { + return RecipeManager.isPlan(itemStack); + } + return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + return slotIndex == SLOT_RESULT; + } + }); invCrafting = new InventoryMapper(getInternalInventory(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.getFluid()); moltenTank.tankMode = StandardTank.TankMode.INTERNAL; tankManager = new TankManager(moltenTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.FabricatorGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -283,7 +305,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT /* UPDATING */ @Override public void updateServerSide() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Add pending smelt if (pendingSmelt != null) { @@ -339,9 +361,9 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } private Recipe getRecipe() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); - ItemStack[] crafting = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + ItemStack[] crafting = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), crafting); } @@ -372,10 +394,11 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT FluidStack liquid = myRecipe.molten; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Remove resources - if (removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, false)) { - removeFromInventory(1, inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT), player, true); + ItemStack[] crafting = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + if (removeFromInventory(1, crafting, player, false)) { + removeFromInventory(1, crafting, player, true); moltenTank.drain(liquid.amount, true); } else if (consumeRecipe) { removeFromCraftMatrix(myRecipe); @@ -405,11 +428,11 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT } private boolean removeFromInventory(int count, ItemStack[] set, EntityPlayer player, boolean doRemove) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (doRemove) - return inventory.removeSets(count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); + return InvTools.removeSets(inventory, count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); else { - ItemStack[] stock = inventory.getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ItemStack[] stock = InvTools.getStacks(inventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); return StackUtils.containsSets(set, stock) >= count; } } @@ -421,14 +444,14 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT @Override public boolean hasWork() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); ItemStack itemToMelt = inventory.getStackInSlot(SLOT_METAL); Smelting smelting = RecipeManager.findMatchingSmelting(itemToMelt); if (smelting != null && moltenTank.fill(smelting.getProduct(), false) > 0) return true; ItemStack plan = inventory.getStackInSlot(SLOT_PLAN); - ItemStack[] resources = inventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + ItemStack[] resources = InvTools.getStacks(inventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); return RecipeManager.findMatchingRecipe(plan, moltenTank.getFluid(), resources) != null; } @@ -482,82 +505,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT iCrafting.sendProgressBarUpdate(container, messageId + 1, getMeltingPoint()); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack stack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, stack)) - return false; - if (slotIndex == SLOT_METAL && RecipeManager.findMatchingSmelting(stack) == null) - return false; - return slotIndex >= SLOT_INVENTORY_1 && slotIndex < SLOT_INVENTORY_1 + SLOT_INVENTORY_COUNT; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack stack, int side) { - return isItemValidForSlot(slotIndex, stack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, stack, side)) - return false; - return slotIndex == SLOT_RESULT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILIQUIDCONTAINER */ @Override public TankManager getTankManager() { diff --git a/src/main/java/forestry/factory/gadgets/MachineFermenter.java b/src/main/java/forestry/factory/gadgets/MachineFermenter.java index fa1ae1989..160fb366f 100755 --- a/src/main/java/forestry/factory/gadgets/MachineFermenter.java +++ b/src/main/java/forestry/factory/gadgets/MachineFermenter.java @@ -10,8 +10,28 @@ ******************************************************************************/ package forestry.factory.gadgets; -import buildcraft.api.statements.ITriggerExternal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import cpw.mods.fml.common.Optional; + import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.recipes.IFermenterManager; @@ -27,29 +47,15 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.factory.triggers.FactoryTriggers; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Map; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; + +import buildcraft.api.statements.ITriggerExternal; public class MachineFermenter extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -191,7 +197,27 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL public MachineFermenter() { super(2000, 150, 8000); - setInternalInventory(new TileInventoryAdapter(this, 5, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 5, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_RESOURCE) { + return RecipeManager.isResource(itemStack); + } else if (slotIndex == SLOT_INPUT) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return resourceTank.accepts(fluid); + } else if (slotIndex == SLOT_CAN_INPUT) { + return FluidHelper.isEmptyContainer(itemStack); + } else if (slotIndex == SLOT_FUEL) { + return FuelManager.fermenterFuel.containsKey(itemStack); + } + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_CAN_OUTPUT; + } + }); setHints(Config.hints.get("fermenter")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs); resourceTank.tankMode = StandardTank.TankMode.INPUT; @@ -200,11 +226,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL tankManager = new TankManager(resourceTank, productTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.FermenterGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -243,7 +264,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL if (worldObj.getTotalWorldTime() % 20 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (inventory.getStackInSlot(SLOT_INPUT) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_INPUT); @@ -275,7 +296,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL checkRecipe(); resetRecipe(); - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (currentRecipe != null) { currentResourceModifier = determineResourceMod(inventory.getStackInSlot(SLOT_RESOURCE)); decrStackSize(SLOT_RESOURCE, 1); @@ -337,7 +358,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL } private void checkRecipe() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); Recipe sameRec = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()); if (currentRecipe != sameRec) @@ -387,7 +408,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean isWorking() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (currentRecipe == null && RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) return false; @@ -415,7 +436,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL @Override public boolean hasWork() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (this.getFuelStack() == null && fuelBurnTime <= 0) return false; else if (fuelBurnTime <= 0) @@ -502,92 +523,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL iCrafting.sendProgressBarUpdate(container, firstMessageId + 3, fermentationTotalTime); } - /* INVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_RESOURCE && RecipeManager.isResource(itemstack)) - return true; - - if (slotIndex == SLOT_INPUT) { - FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemstack); - return RecipeManager.isLiquidResource(fluidStack); - } - - if (slotIndex == SLOT_CAN_INPUT && FluidHelper.isEmptyContainer(itemstack)) - return true; - return slotIndex == SLOT_FUEL && FuelManager.fermenterFuel.containsKey(itemstack); - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_CAN_OUTPUT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILiquidTankContainer */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/factory/gadgets/MachineMoistener.java b/src/main/java/forestry/factory/gadgets/MachineMoistener.java index 47cc42913..a3a809a57 100755 --- a/src/main/java/forestry/factory/gadgets/MachineMoistener.java +++ b/src/main/java/forestry/factory/gadgets/MachineMoistener.java @@ -10,6 +10,23 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.fuels.MoistenerFuel; @@ -23,36 +40,25 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ILiquidTankContainer; import forestry.core.interfaces.IRenderableMachine; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; +import forestry.core.utils.GuiUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class MachineMoistener extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine { /* CONSTANTS */ private static final short SLOT_STASH_1 = 0; + private static final short SLOT_STASH_COUNT = 6; private static final short SLOT_RESERVOIR_1 = 6; + private static final short SLOT_RESERVOIR_COUNT = 3; private static final short SLOT_WORKING = 9; private static final short SLOT_PRODUCT = 10; private static final short SLOT_RESOURCE = 11; - private static final short SLOTS_COUNT_RESERVOIR = 3; - private static final short SLOTS_COUNT_STASH = 6; /* RECIPE MANAGMENT */ public static class Recipe { @@ -120,7 +126,6 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu public final FilteredTank resourceTank; private final TankManager tankManager; - //private ItemStack[] inventoryStacks = new ItemStack[12]; public MachineMoistener.Recipe currentRecipe; public int burnTime = 0; @@ -131,17 +136,39 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu private ItemStack pendingProduct; public MachineMoistener() { - setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_RESOURCE) + return RecipeManager.isResource(itemStack); + + if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) + return FuelManager.moistenerResource.containsKey(itemStack); + + if (slotIndex == SLOT_PRODUCT) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return resourceTank.accepts(fluid); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + if (slotIndex == SLOT_PRODUCT) + return true; + + if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) + return !FuelManager.moistenerResource.containsKey(itemstack); + + return false; + } + }); setHints(Config.hints.get("moistener")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); tankManager = new TankManager(resourceTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.MoistenerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -197,7 +224,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu @Override public void updateServerSide() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable water container waiting in the item slot if (inventory.getStackInSlot(SLOT_PRODUCT) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_PRODUCT); @@ -272,8 +299,8 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu if (pendingProduct == null) return false; - TileInventoryAdapter inventory = getInternalInventory(); - if (inventory.tryAddStack(pendingProduct, SLOT_PRODUCT, 1, true)) { + IInventoryAdapter inventory = getInternalInventory(); + if (InvTools.tryAddStack(inventory, pendingProduct, SLOT_PRODUCT, 1, true)) { pendingProduct = null; return true; } @@ -306,7 +333,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu private int getFreeSlot(ItemStack deposit, int startSlot, int endSlot, boolean emptyOnly) { int slot = -1; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for (int i = startSlot; i < endSlot; i++) { ItemStack slotStack = inventory.getStackInSlot(i); // Empty slots are okay. @@ -334,7 +361,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } private int getFreeReservoirSlot(ItemStack deposit) { - return getFreeSlot(deposit, SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOTS_COUNT_RESERVOIR, false); + return getFreeSlot(deposit, SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT, false); } @@ -343,7 +370,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu int stage = -1; int resourceSlot = -1; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for (int i = startSlot; i < endSlot; i++) { ItemStack slotStack = inventory.getStackInSlot(i); if (slotStack == null) @@ -363,7 +390,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } private boolean rotateWorkingSlot() { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Put working slot contents into inventory if space is available if (inventory.getStackInSlot(SLOT_WORKING) != null) { // Get the result of the consumed item in the working slot @@ -391,7 +418,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu return true; // Let's look for a new resource to put into the working slot. - int resourceSlot = getNextResourceSlot(SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOTS_COUNT_RESERVOIR); + int resourceSlot = getNextResourceSlot(SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT); // Nothing found, stop. if (resourceSlot < 0) return false; @@ -403,9 +430,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu private void rotateReservoir() { ArrayList slotsToShift = new ArrayList(); - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); - for (int i = SLOT_RESERVOIR_1; i < SLOT_RESERVOIR_1 + SLOTS_COUNT_RESERVOIR; i++) { + for (int i = SLOT_RESERVOIR_1; i < SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT; i++) { if (inventory.getStackInSlot(i) == null) continue; @@ -455,7 +482,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu public boolean hasFuelMin(float percentage) { int max = 0; int avail = 0; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for (int i = SLOT_STASH_1; i < SLOT_RESERVOIR_1; i++) { if (inventory.getStackInSlot(i) == null) { @@ -475,7 +502,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu } public boolean hasResourcesMin(float percentage) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_RESOURCE) == null) return false; @@ -517,96 +544,6 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu return EnumTankLevel.EMPTY; } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_RESOURCE) - return RecipeManager.isResource(itemstack); - - if (slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH - 2) - return FuelManager.moistenerResource.containsKey(itemstack); - - return false; - } - - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - if (slotIndex == SLOT_PRODUCT) - return true; - - if (slotIndex >= SLOT_STASH_1 && slotIndex < SLOT_STASH_1 + SLOTS_COUNT_STASH) - return !FuelManager.moistenerResource.containsKey(itemstack); - - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILiquidTankContainer */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/factory/gadgets/MachineRaintank.java b/src/main/java/forestry/factory/gadgets/MachineRaintank.java index 14fd000f9..de3c2ceab 100755 --- a/src/main/java/forestry/factory/gadgets/MachineRaintank.java +++ b/src/main/java/forestry/factory/gadgets/MachineRaintank.java @@ -10,6 +10,20 @@ ******************************************************************************/ package forestry.factory.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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 net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.BiomeHelper; import forestry.api.core.ForestryAPI; import forestry.core.EnumErrorCode; @@ -21,22 +35,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.GuiId; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -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 net.minecraftforge.fluids.FluidTankInfo; public class MachineRaintank extends TileBase implements ISidedInventory, ILiquidTankContainer { @@ -53,7 +56,19 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui private ItemStack usedEmpty; public MachineRaintank() { - setInternalInventory(new TileInventoryAdapter(this, 3, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 3, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_RESOURCE) { + return FluidHelper.isFillableContainer(itemStack, Fluids.WATER.getFluid(1000)); + } + return false; + } + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_PRODUCT; + } + }); setHints(Config.hints.get("raintank")); resourceTank = new FilteredTank(Defaults.RAINTANK_TANK_CAPACITY, FluidRegistry.WATER); @@ -74,11 +89,6 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui super.validate(); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.RaintankGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -118,7 +128,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui if (worldObj.getTotalWorldTime() % 16 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (!StackUtils.isIdenticalItem(usedEmpty, inventory.getStackInSlot(SLOT_RESOURCE))) { fillingTime = 0; usedEmpty = null; @@ -152,85 +162,6 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui return (fillingTime * i) / Defaults.RAINTANK_FILLING_TIME; } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex != SLOT_RESOURCE) - return false; - - return FluidHelper.isFillableContainer(itemstack, STACK_WATER); - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_PRODUCT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* SMP GUI */ @Override public void getGUINetworkData(int i, int j) { diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index 600edd4c6..bda1cdf88 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -10,6 +10,26 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ForestryAPI; import forestry.api.recipes.ISqueezerManager; import forestry.core.EnumErrorCode; @@ -22,38 +42,23 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Stack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class MachineSqueezer extends TilePowered implements ISidedInventory, ILiquidTankContainer { /* CONSTANTS */ - private static final short SLOT_RESOURCE_1 = 0; - private static final short SLOTS_RESOURCE_COUNT = 9; - private static final short SLOT_REMNANT = 9; - private static final short SLOT_CAN_INPUT = 10; - private static final short SLOT_CAN_OUTPUT = 11; + public static final short SLOT_RESOURCE_1 = 0; + public static final short SLOTS_RESOURCE_COUNT = 9; + public static final short SLOT_REMNANT = 9; + public static final short SLOT_CAN_INPUT = 10; + public static final short SLOT_CAN_OUTPUT = 11; /* RECIPE MANAGMENT */ public static class Recipe { @@ -141,18 +146,34 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi public MachineSqueezer() { super(1100, 50, 4000); - setInternalInventory(new TileInventoryAdapter(this, 12, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 12, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_CAN_INPUT) + return FluidHelper.isEmptyContainer(itemStack); + + if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { + if (FluidHelper.isEmptyContainer(itemStack)) + return false; + + if (RecipeManager.canUse(itemStack)) + return true; + } + + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_REMNANT || slotIndex == SLOT_CAN_OUTPUT; + } + }); setHints(Config.hints.get("squeezer")); productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids); productTank.tankMode = StandardTank.TankMode.OUTPUT; tankManager = new TankManager(productTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.SqueezerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -228,7 +249,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi if (worldObj.getTotalWorldTime() % 20 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Can/capsule input/output needs to be handled here. if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) { FluidStack fluidStack = productTank.getFluid(); @@ -288,7 +309,8 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi } private void checkRecipe() { - Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStacks(SLOT_RESOURCE_1, 9)); + ItemStack[] resources = InvTools.getStacks(getInternalInventory(), SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT); + Recipe sameRec = RecipeManager.findMatchingRecipe(resources); if (sameRec == null) setErrorState(EnumErrorCode.NORECIPE); @@ -340,12 +362,12 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi } private boolean addRemnant(ItemStack stack) { - return getInternalInventory().tryAddStack(stack, SLOT_REMNANT, 1, true); + return InvTools.tryAddStack(getInternalInventory(), stack, SLOT_REMNANT, 1, true); } private boolean removeResources(ItemStack[] stacks) { EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); - return getInternalInventory().removeSets(1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true); + return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true); } @Override @@ -395,93 +417,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi iCrafting.sendProgressBarUpdate(container, i + 1, timePerItem); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_CAN_INPUT) - return FluidHelper.isEmptyContainer(itemstack); - - if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) { - if (FluidHelper.isEmptyContainer(itemstack)) - return false; - - if (RecipeManager.canUse(itemstack)) - return true; - } - - return false; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_REMNANT || slotIndex == SLOT_CAN_OUTPUT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* ILIQUIDCONTAINER IMPLEMENTATION */ @Override public TankManager getTankManager() { diff --git a/src/main/java/forestry/factory/gadgets/MachineStill.java b/src/main/java/forestry/factory/gadgets/MachineStill.java index 92fff756a..7f8554312 100755 --- a/src/main/java/forestry/factory/gadgets/MachineStill.java +++ b/src/main/java/forestry/factory/gadgets/MachineStill.java @@ -10,6 +10,23 @@ ******************************************************************************/ package forestry.factory.gadgets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.ISidedInventory; +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.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import forestry.api.core.ForestryAPI; import forestry.api.recipes.IStillManager; import forestry.core.EnumErrorCode; @@ -22,24 +39,11 @@ import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileBase; import forestry.core.gadgets.TilePowered; import forestry.core.interfaces.ILiquidTankContainer; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.EnumTankLevel; import forestry.core.utils.Utils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -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.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; public class MachineStill extends TilePowered implements ISidedInventory, ILiquidTankContainer { @@ -123,7 +127,23 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui public MachineStill() { super(1100, 50, 8000); - setInternalInventory(new TileInventoryAdapter(this, 3, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 3, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == SLOT_RESOURCE) { + return FluidHelper.isEmptyContainer(itemStack); + } else if (slotIndex == SLOT_CAN) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return resourceTank.accepts(fluid); + } + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { + return slotIndex == SLOT_PRODUCT; + } + }); setHints(Config.hints.get("still")); resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs); resourceTank.tankMode = StandardTank.TankMode.INPUT; @@ -132,11 +152,6 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui tankManager = new TankManager(resourceTank, productTank); } - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - @Override public void openGui(EntityPlayer player, TileBase tile) { player.openGui(ForestryAPI.instance, GuiId.StillGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord); @@ -170,7 +185,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui if (worldObj.getTotalWorldTime() % 20 * 10 != 0) return; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); // Check if we have suitable items waiting in the item slot if (inventory.getStackInSlot(SLOT_CAN) != null) FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); @@ -310,90 +325,6 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui iCrafting.sendProgressBarUpdate(container, i + 1, distillationTotalTime); } - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int slot) { - return getInternalInventory().getStackInSlot(slot); - } - - @Override - public ItemStack decrStackSize(int slot, int value) { - return getInternalInventory().decrStackSize(slot, value); - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(slot, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack)) - return false; - - if (slotIndex == SLOT_RESOURCE) - return FluidHelper.isEmptyContainer(itemstack); - - if (slotIndex == SLOT_CAN) { - Fluid fluid = FluidHelper.getFluidInContainer(itemstack); - return fluid != null && resourceTank.accepts(fluid); - } - - return false; - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex == SLOT_PRODUCT; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - return getInternalInventory().getAccessibleSlotsFromSide(side); - } - /* IFluidHandler */ @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { diff --git a/src/main/java/forestry/factory/gadgets/TileWorktable.java b/src/main/java/forestry/factory/gadgets/TileWorktable.java index cbe34cfa1..1e06ee8b2 100755 --- a/src/main/java/forestry/factory/gadgets/TileWorktable.java +++ b/src/main/java/forestry/factory/gadgets/TileWorktable.java @@ -13,6 +13,7 @@ package forestry.factory.gadgets; import forestry.api.core.ForestryAPI; import forestry.core.gadgets.TileBase; import forestry.core.interfaces.ICrafter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.ForestryPacket; @@ -48,7 +49,7 @@ public class TileWorktable extends TileBase implements ICrafter { public TileWorktable() { craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems"); - setInternalInventory(new TileInventoryAdapter(this, 18, "Items")); + setInternalInventory(new TileInventoryAdapter(this, 18, "Items").disableAutomation()); memorized = new RecipeMemory(); } @@ -151,16 +152,16 @@ public class TileWorktable extends TileBase implements ICrafter { if (currentRecipe == null) return false; - ItemStack[] recipeItems = craftingInventory.getStacks(SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); - ItemStack[] inventory = getInternalInventory().getStacks(SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); + ItemStack[] recipeItems = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + ItemStack[] inventory = InvTools.getStacks(getInternalInventory(), SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT); ItemStack recipeOutput = currentRecipe.getRecipeOutput(worldObj); return RecipeUtil.canCraftRecipe(worldObj, recipeItems, recipeOutput, inventory); } private boolean removeResources(EntityPlayer player) { - ItemStack[] set = craftingInventory.getStacks(SLOT_CRAFTING_1, 9); - return getInternalInventory().removeSets(1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); + ItemStack[] set = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT); + return InvTools.removeSets(getInternalInventory(), 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true); } @Override diff --git a/src/main/java/forestry/factory/gui/ContainerBottler.java b/src/main/java/forestry/factory/gui/ContainerBottler.java index 8a2026287..8a31d4d38 100755 --- a/src/main/java/forestry/factory/gui/ContainerBottler.java +++ b/src/main/java/forestry/factory/gui/ContainerBottler.java @@ -10,24 +10,26 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.factory.gadgets.MachineBottler; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.factory.gadgets.MachineBottler; + public class ContainerBottler extends ContainerLiquidTanks { protected final MachineBottler tile; public ContainerBottler(InventoryPlayer player, MachineBottler tile) { - super(tile, tile); + super(tile); this.tile = tile; - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_RESOURCE, 116, 19, true)); - this.addSlotToContainer(new SlotClosed(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineBottler.SLOT_CAN, 26, 38)); + + this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_RESOURCE, 116, 19)); + this.addSlotToContainer(new SlotOutput(tile, MachineBottler.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotFiltered(tile, MachineBottler.SLOT_CAN, 26, 38)); int var3; for (var3 = 0; var3 < 3; ++var3) { diff --git a/src/main/java/forestry/factory/gui/ContainerCarpenter.java b/src/main/java/forestry/factory/gui/ContainerCarpenter.java index a036ba011..43434d124 100755 --- a/src/main/java/forestry/factory/gui/ContainerCarpenter.java +++ b/src/main/java/forestry/factory/gui/ContainerCarpenter.java @@ -10,46 +10,33 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCraftAuto; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.core.gui.slots.SlotLocked; -import forestry.core.gui.slots.SlotOutput; -import forestry.core.interfaces.IContainerCrafting; -import forestry.core.proxy.Proxies; -import forestry.factory.gadgets.MachineCarpenter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; + +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotLocked; +import forestry.core.gui.slots.SlotOutput; +import forestry.core.interfaces.IContainerCrafting; +import forestry.core.proxy.Proxies; +import forestry.factory.gadgets.MachineCarpenter; public class ContainerCarpenter extends ContainerLiquidTanks implements IContainerCrafting { - private class SlotCrate extends SlotCraftAuto { - - public SlotCrate(IContainerCrafting container, IInventory iinventory, int slotNumber, int x, int y) { - super(container, iinventory, slotNumber, x, y); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return MachineCarpenter.RecipeManager.isBox(stack); - } - } private MachineCarpenter machine; private final IInventory craftingInventory; public final InventoryCraftingAuto craftMatrix; public final InventoryCraftResult craftResult; public ContainerCarpenter(InventoryPlayer inventoryplayer, MachineCarpenter tile) { - super(tile.getInternalInventory(), tile); + super(tile); machine = tile; machine.activeContainer = this; craftingInventory = machine.getCraftingInventory(); - IInventory internalInventory = machine.getInternalInventory(); craftMatrix = new InventoryCraftingAuto(this, 3, 3); craftResult = new InventoryCraftResult(); @@ -57,16 +44,16 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain // Internal inventory for (int i = 0; i < 2; i++) { for (int k = 0; k < 9; k++) { - addSlotToContainer(new Slot(internalInventory, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); + addSlotToContainer(new Slot(machine, MachineCarpenter.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 90 + i * 18)); } } // Liquid Input - this.addSlotToContainer(new SlotLiquidContainer(internalInventory, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); + this.addSlotToContainer(new SlotFiltered(machine, MachineCarpenter.SLOT_CAN_INPUT, 120, 20)); // Boxes - this.addSlotToContainer(new SlotCrate(this, internalInventory, MachineCarpenter.SLOT_BOX, 83, 20)); + this.addSlotToContainer(new SlotFiltered(machine, MachineCarpenter.SLOT_BOX, 83, 20)); // Product - this.addSlotToContainer(new SlotOutput(internalInventory, MachineCarpenter.SLOT_PRODUCT, 120, 56)); + this.addSlotToContainer(new SlotOutput(machine, MachineCarpenter.SLOT_PRODUCT, 120, 56)); // CraftResult display addSlotToContainer(new SlotLocked(craftResult, 0, 80, 51)); @@ -96,7 +83,7 @@ public class ContainerCarpenter extends ContainerLiquidTanks implements IContain } public ContainerCarpenter(MachineCarpenter tile) { - super(tile.getInternalInventory(), tile); + super(tile); craftMatrix = new InventoryCraftingAuto(this, 3, 3); craftResult = new InventoryCraftResult(); craftingInventory = tile.getCraftingInventory(); diff --git a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java index c522a0c9f..d567731d4 100755 --- a/src/main/java/forestry/factory/gui/ContainerCentrifuge.java +++ b/src/main/java/forestry/factory/gui/ContainerCentrifuge.java @@ -10,13 +10,15 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.factory.gadgets.MachineCentrifuge; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.factory.gadgets.MachineCentrifuge; + public class ContainerCentrifuge extends ContainerForestry { protected final MachineCentrifuge tile; @@ -27,12 +29,12 @@ public class ContainerCentrifuge extends ContainerForestry { this.tile = tile; // Resource - this.addSlotToContainer(new Slot(tile, 0, 34, 37)); + this.addSlotToContainer(new SlotFiltered(tile, 0, 34, 37)); // Product Inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlotToContainer(new SlotClosed(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); + addSlotToContainer(new SlotOutput(tile, 1 + k + l * 3, 98 + k * 18, 19 + l * 18)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 12eb4c7eb..a59e8133f 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -15,12 +15,13 @@ import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerLiquidTanks; import forestry.core.gui.slots.SlotCrafter; +import forestry.core.gui.slots.SlotFiltered; import forestry.factory.gadgets.MachineFabricator; public class ContainerFabricator extends ContainerLiquidTanks { public ContainerFabricator(InventoryPlayer playerInventory, MachineFabricator tile) { - super(tile, tile); + super(tile); // Internal inventory for (int i = 0; i < 2; i++) @@ -28,10 +29,10 @@ public class ContainerFabricator extends ContainerLiquidTanks { addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_INVENTORY_1 + k + i * 9, 8 + k * 18, 84 + i * 18)); // Molten resource - this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_METAL, 26, 21)); + this.addSlotToContainer(new SlotFiltered(tile, MachineFabricator.SLOT_METAL, 26, 21)); // Plan - this.addSlotToContainer(new Slot(tile, MachineFabricator.SLOT_PLAN, 139, 17)); + this.addSlotToContainer(new SlotFiltered(tile, MachineFabricator.SLOT_PLAN, 139, 17)); // Result this.addSlotToContainer(new SlotCrafter(playerInventory.player, tile, tile, MachineFabricator.SLOT_RESULT, 139, 53)); diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index a31643f90..7f09a2758 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -10,27 +10,28 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.core.gui.slots.SlotOutput; -import forestry.factory.gadgets.MachineFermenter; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.factory.gadgets.MachineFermenter; + public class ContainerFermenter extends ContainerLiquidTanks { protected final MachineFermenter fermenter; public ContainerFermenter(InventoryPlayer player, MachineFermenter fermenter) { - super(fermenter, fermenter); + super(fermenter); this.fermenter = fermenter; - this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23).setExclusion(true)); - this.addSlotToContainer(new SlotCustom(fermenter, MachineFermenter.SLOT_FUEL, 75, 57).setExclusion(true)); + + this.addSlotToContainer(new SlotFiltered(fermenter, MachineFermenter.SLOT_RESOURCE, 85, 23)); + this.addSlotToContainer(new SlotFiltered(fermenter, MachineFermenter.SLOT_FUEL, 75, 57)); this.addSlotToContainer(new SlotOutput(fermenter, MachineFermenter.SLOT_CAN_OUTPUT, 150, 58)); - this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22, true)); - this.addSlotToContainer(new SlotLiquidContainer(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); + this.addSlotToContainer(new SlotFiltered(fermenter, MachineFermenter.SLOT_CAN_INPUT, 150, 22)); + this.addSlotToContainer(new SlotFiltered(fermenter, MachineFermenter.SLOT_INPUT, 10, 40)); for (int i = 0; i < 3; ++i) { for (int var4 = 0; var4 < 9; ++var4) { diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 5117290fc..0841c4daa 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -10,39 +10,42 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotCraftAuto; -import forestry.core.gui.slots.SlotWorking; -import forestry.core.interfaces.IContainerCrafting; -import forestry.factory.gadgets.MachineMoistener; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotCraftAuto; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotWorking; +import forestry.core.interfaces.IContainerCrafting; +import forestry.factory.gadgets.MachineMoistener; + public class ContainerMoistener extends ContainerLiquidTanks implements IContainerCrafting { protected final MachineMoistener tile; public ContainerMoistener(InventoryPlayer player, MachineMoistener tile) { - super(tile, tile); + super(tile); this.tile = tile; + // Stash for (int l = 0; l < 2; l++) { for (int k1 = 0; k1 < 3; k1++) { - addSlotToContainer(new Slot(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); + addSlotToContainer(new SlotFiltered(tile, k1 + l * 3, 39 + k1 * 18, 16 + l * 18)); } } // Reservoir for (int k1 = 0; k1 < 3; k1++) { - addSlotToContainer(new Slot(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); + addSlotToContainer(new SlotFiltered(tile, k1 + 6, 39 + k1 * 18, 22 + 36)); } // Working slot this.addSlotToContainer(new SlotWorking(tile, 9, 105, 37)); // Product slot - this.addSlotToContainer(new Slot(tile, 10, 143, 55)); + this.addSlotToContainer(new SlotFiltered(tile, 10, 143, 55)); // Boxes this.addSlotToContainer(new SlotCraftAuto(this, tile, 11, 143, 19)); diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index f0408977c..84e2ae3c0 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -10,20 +10,21 @@ ******************************************************************************/ package forestry.factory.gui; -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotLiquidContainer; -import forestry.factory.gadgets.MachineRaintank; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.factory.gadgets.MachineRaintank; + public class ContainerRaintank extends ContainerLiquidTanks { public ContainerRaintank(InventoryPlayer player, MachineRaintank tile) { - super(tile, tile); + super(tile); - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineRaintank.SLOT_RESOURCE, 116, 19, true)); - this.addSlotToContainer(new SlotClosed(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); + this.addSlotToContainer(new SlotFiltered(tile, MachineRaintank.SLOT_RESOURCE, 116, 19)); + this.addSlotToContainer(new SlotOutput(tile, MachineRaintank.SLOT_PRODUCT, 116, 55)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { diff --git a/src/main/java/forestry/factory/gui/ContainerSqueezer.java b/src/main/java/forestry/factory/gui/ContainerSqueezer.java index 5e30fde2e..a67e31e23 100755 --- a/src/main/java/forestry/factory/gui/ContainerSqueezer.java +++ b/src/main/java/forestry/factory/gui/ContainerSqueezer.java @@ -14,27 +14,27 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotLiquidContainer; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; import forestry.factory.gadgets.MachineSqueezer; public class ContainerSqueezer extends ContainerLiquidTanks { public ContainerSqueezer(InventoryPlayer player, MachineSqueezer tile) { - super(tile, tile); + super(tile); // Resource inventory for (int l = 0; l < 3; l++) for (int k = 0; k < 3; k++) - addSlotToContainer(new Slot(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); + addSlotToContainer(new SlotFiltered(tile, k + l * 3, 19 + k * 18, 18 + l * 18)); // Remnants slot - this.addSlotToContainer(new SlotClosed(tile, 9, 123, 19)); + this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_REMNANT, 123, 19)); // Can slot - this.addSlotToContainer(new SlotLiquidContainer(tile, 10, 106, 55, true)); + this.addSlotToContainer(new SlotFiltered(tile, MachineSqueezer.SLOT_CAN_INPUT, 106, 55)); // Output slot - this.addSlotToContainer(new SlotClosed(tile, 11, 140, 55)); + this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_CAN_OUTPUT, 140, 55)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/factory/gui/ContainerStill.java b/src/main/java/forestry/factory/gui/ContainerStill.java index 6984eae12..68ecffa7a 100755 --- a/src/main/java/forestry/factory/gui/ContainerStill.java +++ b/src/main/java/forestry/factory/gui/ContainerStill.java @@ -14,17 +14,18 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotLiquidContainer; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; import forestry.factory.gadgets.MachineStill; public class ContainerStill extends ContainerLiquidTanks { public ContainerStill(InventoryPlayer player, MachineStill tile) { - super(tile, tile); + super(tile); - this.addSlotToContainer(new Slot(tile, MachineStill.SLOT_PRODUCT, 150, 54)); - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_RESOURCE, 150, 18, true)); - this.addSlotToContainer(new SlotLiquidContainer(tile, MachineStill.SLOT_CAN, 10, 36)); + this.addSlotToContainer(new SlotOutput(tile, MachineStill.SLOT_PRODUCT, 150, 54)); + this.addSlotToContainer(new SlotFiltered(tile, MachineStill.SLOT_RESOURCE, 150, 18)); + this.addSlotToContainer(new SlotFiltered(tile, MachineStill.SLOT_CAN, 10, 36)); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 00af4add6..07ade1966 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -27,6 +27,8 @@ import forestry.api.farming.Farmables; import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmListener; import forestry.core.gadgets.TileForestry; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; @@ -187,6 +189,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { public void makeMaster() { setCentralTE(null); this.isMaster = true; + + if (worldObj != null && !worldObj.isRemote) + sendNetworkUpdate(); } @Override @@ -251,7 +256,7 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { } @Override - public ISidedInventory getStructureInventory() { + public IInventoryAdapter getStructureInventory() { return getInternalInventory(); } diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 5aebd7df8..7665a1ac9 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -10,6 +10,29 @@ ******************************************************************************/ package forestry.farming.gadgets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.TreeMap; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuitBoard; import forestry.api.core.BiomeHelper; @@ -32,48 +55,35 @@ import forestry.core.fluids.tanks.FilteredTank; import forestry.core.interfaces.IClimatised; import forestry.core.interfaces.IHintSource; import forestry.core.interfaces.ISocketable; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.proxy.Proxies; import forestry.core.utils.DelayTimer; +import forestry.core.utils.GuiUtil; import forestry.core.utils.StackUtils; import forestry.core.utils.Utils; import forestry.core.vect.Vect; import forestry.farming.FarmTarget; import forestry.farming.logic.FarmLogicArboreal; import forestry.plugins.PluginFarming; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable, IClimatised, IHintSource { public static final int SLOT_RESOURCES_1 = 0; + public static final int SLOT_RESOURCES_COUNT = 6; public static final int SLOT_GERMLINGS_1 = 6; + public static final int SLOT_GERMLINGS_COUNT = 6; public static final int SLOT_PRODUCTION_1 = 12; - public static final int SLOT_COUNT_RESERVOIRS = 6; - public static final int SLOT_COUNT_PRODUCTION = 8; + public static final int SLOT_PRODUCTION_COUNT = 8; public static final int SLOT_FERTILIZER = 20; + public static final int SLOT_FERTILIZER_COUNT = 1; public static final int SLOT_CAN = 21; + public static final int SLOT_CAN_COUNT = 1; - public static final int SLOT_COUNT = 22; + public static final int SLOT_COUNT = SLOT_RESOURCES_COUNT + SLOT_GERMLINGS_COUNT + SLOT_PRODUCTION_COUNT + SLOT_FERTILIZER_COUNT + SLOT_CAN_COUNT; private static final int DELAY_HYDRATION = 100; private static final float RAINFALL_MODIFIER_CAP = 15f; @@ -348,7 +358,22 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } protected void createInventory() { - setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items")); + setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (GuiUtil.isIndexInRange(slotIndex, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT)) { + return acceptsAsFertilizer(itemStack); + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT)) { + return acceptsAsGermling(itemStack); + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) { + return acceptsAsResource(itemStack); + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) { + Fluid fluid = FluidHelper.getFluidInContainer(itemStack); + return tankManager.accepts(fluid); + } + return false; + } + }); FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); tankManager = new TankManager(liquidTank); } @@ -362,9 +387,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } else if (checkTimer.delayPassed(worldObj, 400)) setExtents(); - if (getInternalInventory() == null) - createInventory(); - // System.out.println("Targets set"); if (tryAddPending()) return true; @@ -524,21 +546,21 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } private void addProduceToInventory(ItemStack produce) { - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); for (IFarmLogic logic : getFarmLogics()) { // Germlings try to go into germling slots first. if (logic.isAcceptedGermling(produce)) - produce.stackSize -= inventory.addStack(produce, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS, false, true); + produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT, false, true); if (produce.stackSize <= 0) return; if (logic.isAcceptedResource(produce)) - produce.stackSize -= inventory.addStack(produce, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS, false, true); + produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT, false, true); if (produce.stackSize <= 0) return; } - produce.stackSize -= inventory.addStack(produce, SLOT_PRODUCTION_1, SLOT_COUNT_PRODUCTION, false, true); + produce.stackSize -= InvTools.addStack(inventory, produce, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, false, true); } private boolean cullCrop(ICrop crop, IFarmLogic provider) { @@ -574,8 +596,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable // Let event handlers handle the harvest first. for (IFarmListener listener : eventHandlers) listener.afterCropHarvest(harvested, crop); - - TileInventoryAdapter inventory = getInternalInventory(); + + IInventoryAdapter inventory = getInternalInventory(); // Stow harvest. for (ItemStack harvest : harvested) { @@ -583,7 +605,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable // Special case germlings for (IFarmLogic logic : farmLogics) if (logic.isAcceptedGermling(harvest)) { - harvest.stackSize -= inventory.addStack(harvest, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS, false, true); + harvest.stackSize -= InvTools.addStack(inventory, harvest, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT, false, true); break; } @@ -591,7 +613,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable if (harvest.stackSize <= 0) continue; - harvest.stackSize -= inventory.addStack(harvest, SLOT_PRODUCTION_1, SLOT_COUNT_PRODUCTION, false, true); + harvest.stackSize -= InvTools.addStack(inventory, harvest, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, false, true); if (harvest.stackSize <= 0) continue; @@ -606,7 +628,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return false; ItemStack next = pendingProduce.peek(); - if (getInternalInventory().tryAddStack(next, SLOT_PRODUCTION_1, SLOT_COUNT_PRODUCTION, true, true)) { + if (InvTools.tryAddStack(getInternalInventory(), next, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, true, true)) { pendingProduce.pop(); return true; } @@ -622,7 +644,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable return; } - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); ItemStack fertilizer = inventory.getStackInSlot(SLOT_FERTILIZER); if (fertilizer == null || fertilizer.stackSize <= 0) return; @@ -742,25 +764,25 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable @Override public boolean hasResources(ItemStack[] resources) { - return getInternalInventory().contains(resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); + return InvTools.contains(getInternalInventory(), resources, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT); } public boolean hasResourcesAmount(int amount) { - return getInternalInventory().containsAmount(amount, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS); + return InvTools.containsAmount(getInternalInventory(), amount, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT); } public boolean hasGermlingsPercent(float percent) { - return getInternalInventory().containsPercent(percent, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); + return InvTools.containsPercent(getInternalInventory(), percent, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT); } public boolean hasFertilizerPercent(float percent) { - return getInternalInventory().containsPercent(percent, SLOT_FERTILIZER, 1); + return InvTools.containsPercent(getInternalInventory(), percent, SLOT_FERTILIZER, 1); } @Override public void removeResources(ItemStack[] resources) { EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); - getInternalInventory().removeSets(1, resources, SLOT_RESOURCES_1, SLOT_COUNT_RESERVOIRS, player, false, true, true); + InvTools.removeSets(getInternalInventory(), 1, resources, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT, player, false, true, true); } @Override @@ -774,13 +796,13 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } public boolean hasGermlings(ItemStack[] germlings) { - return getInternalInventory().contains(germlings, SLOT_GERMLINGS_1, SLOT_COUNT_RESERVOIRS); + return InvTools.contains(getInternalInventory(), germlings, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT); } @Override public boolean plantGermling(IFarmable germling, World world, int x, int y, int z) { - TileInventoryAdapter inventory = getInternalInventory(); - for (int i = SLOT_GERMLINGS_1; i < SLOT_GERMLINGS_1 + SLOT_COUNT_RESERVOIRS; i++) { + IInventoryAdapter inventory = getInternalInventory(); + for (int i = SLOT_GERMLINGS_1; i < SLOT_GERMLINGS_1 + SLOT_GERMLINGS_COUNT; i++) { if (inventory.getStackInSlot(i) == null) continue; if (!germling.isGermling(inventory.getStackInSlot(i))) @@ -877,7 +899,8 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable /* NETWORK GUI */ public void getGUINetworkData(int i, int j) { - i -= tankManager.maxMessageId() + 1; + if (tankManager != null) + i -= tankManager.maxMessageId() + 1; switch (i) { case 0: storedFertilizer = j; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index 52a456e57..b06fae332 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -10,26 +10,28 @@ ******************************************************************************/ package forestry.farming.gadgets; -import buildcraft.api.statements.ITriggerExternal; -import cpw.mods.fml.common.Optional; -import forestry.api.core.ITileStructure; -import forestry.core.config.Defaults; -import forestry.core.inventory.AdjacentInventoryCache; -import forestry.core.inventory.ITileFilter; -import forestry.core.inventory.InvTools; -import forestry.core.inventory.TileInventoryAdapter; -import forestry.core.inventory.wrappers.InventoryMapper; -import forestry.core.utils.Utils; -import forestry.farming.triggers.FarmingTriggers; import java.util.Collection; import java.util.LinkedList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; + import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidContainerRegistry; + +import cpw.mods.fml.common.Optional; + +import forestry.api.core.ITileStructure; +import forestry.core.inventory.AdjacentInventoryCache; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.ITileFilter; +import forestry.core.inventory.InvTools; +import forestry.core.inventory.wrappers.InventoryMapper; +import forestry.farming.triggers.FarmingTriggers; + +import buildcraft.api.statements.ITriggerExternal; public class TileHatch extends TileFarm implements ISidedInventory { @@ -58,11 +60,8 @@ public class TileHatch extends TileFarm implements ISidedInventory { /* AUTO-EJECTING */ private IInventory getProductInventory() { - TileInventoryAdapter inventory = getStructureInventory(); - if (inventory == null) - return null; - - return new InventoryMapper(inventory, TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_COUNT_PRODUCTION); + IInventoryAdapter inventory = getStructureInventory(); + return new InventoryMapper(inventory, TileFarmPlain.SLOT_PRODUCTION_1, TileFarmPlain.SLOT_PRODUCTION_COUNT); } protected void dumpStash() { @@ -77,142 +76,12 @@ public class TileHatch extends TileFarm implements ISidedInventory { /* IINVENTORY */ @Override - public TileInventoryAdapter getStructureInventory() { - if (hasMaster()) { - ITileStructure central = getCentralTE(); - if (central != null) - return (TileInventoryAdapter) central.getInventory(); - } + public IInventoryAdapter getInternalInventory() { + ITileStructure central = getCentralTE(); + if (central instanceof TileFarmPlain) + return ((TileFarmPlain) central).getInternalInventory(); - return null; - } - - @Override - public int getSizeInventory() { - IInventory inv = getStructureInventory(); - if (inv == null) - return 0; - - return inv.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int slotIndex) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.getStackInSlot(slotIndex); - } - - @Override - public ItemStack decrStackSize(int slotIndex, int amount) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.decrStackSize(slotIndex, amount); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) { - IInventory inv = getStructureInventory(); - if (inv == null) - return null; - - return inv.getStackInSlotOnClosing(slotIndex); - } - - @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { - IInventory inv = getStructureInventory(); - if (inv != null) - inv.setInventorySlotContents(slotIndex, itemstack); - } - - @Override - public int getInventoryStackLimit() { - IInventory inv = getStructureInventory(); - if (inv == null) - return 0; - - return inv.getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - IInventory inv = getStructureInventory(); - if (inv != null) - return inv.isUseableByPlayer(player); - return Utils.isUseableByPlayer(player, this); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - if (!hasMaster()) - return false; - - ITileStructure struct = getCentralTE(); - if (!(struct instanceof TileFarmPlain)) - return false; - - TileInventoryAdapter inventory = getStructureInventory(); - if (inventory == null || !inventory.isItemValidForSlot(slotIndex, itemstack)) - return false; - - TileFarmPlain housing = (TileFarmPlain) struct; - if (slotIndex == TileFarmPlain.SLOT_FERTILIZER && housing.acceptsAsFertilizer(itemstack)) - return true; - if (slotIndex >= TileFarmPlain.SLOT_RESOURCES_1 && slotIndex < TileFarmPlain.SLOT_RESOURCES_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS - && housing.acceptsAsResource(itemstack)) - return true; - if (slotIndex >= TileFarmPlain.SLOT_GERMLINGS_1 && slotIndex < TileFarmPlain.SLOT_GERMLINGS_1 + TileFarmPlain.SLOT_COUNT_RESERVOIRS - && housing.acceptsAsGermling(itemstack)) - return true; - if (slotIndex == TileFarmPlain.SLOT_CAN) - return FluidContainerRegistry.isFilledContainer(itemstack); - - return false; - } - - @Override - public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) { - return isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { - TileInventoryAdapter inventory = getStructureInventory(); - if (inventory == null || !inventory.canExtractItem(slotIndex, itemstack, side)) - return false; - - return slotIndex >= TileFarmPlain.SLOT_PRODUCTION_1 && slotIndex < TileFarmPlain.SLOT_PRODUCTION_1 + TileFarmPlain.SLOT_COUNT_PRODUCTION; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) { - TileInventoryAdapter inventory = getStructureInventory(); - if (inventory == null) - return Defaults.FACINGS_NONE; - return inventory.getAccessibleSlotsFromSide(side); + return super.getInternalInventory(); } /* ITRIGGERPROVIDER */ diff --git a/src/main/java/forestry/farming/gui/ContainerFarm.java b/src/main/java/forestry/farming/gui/ContainerFarm.java index 6fcffc577..88ae85103 100755 --- a/src/main/java/forestry/farming/gui/ContainerFarm.java +++ b/src/main/java/forestry/farming/gui/ContainerFarm.java @@ -10,21 +10,16 @@ ******************************************************************************/ package forestry.farming.gui; -import forestry.api.farming.IFarmLogic; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + 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.SlotFiltered; import forestry.core.gui.slots.SlotOutput; import forestry.farming.gadgets.TileFarmPlain; -import forestry.plugins.PluginFarming; -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; public class ContainerFarm extends ContainerSocketed { @@ -35,40 +30,38 @@ public class ContainerFarm extends ContainerSocketed { this.tile = tile; - IInventory inv = tile.getInventory(); - // Resources for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotResources(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotFiltered(tile, TileFarmPlain.SLOT_RESOURCES_1 + j + i * 2, 123 + j * 18, 22 + i * 18)); } } // Germlings for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotGermlings(inv, tile.getFarmLogics(), TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); + addSlotToContainer(new SlotFiltered(tile, TileFarmPlain.SLOT_GERMLINGS_1 + j + i * 2, 164 + j * 18, 22 + i * 18)); } } // Production 1 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(tile, TileFarmPlain.SLOT_PRODUCTION_1 + j + i * 2, 123 + j * 18, 86 + i * 18)); } } // Production 2 for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { - addSlotToContainer(new SlotOutput(inv, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); + addSlotToContainer(new SlotOutput(tile, TileFarmPlain.SLOT_PRODUCTION_1 + 4 + j + i * 2, 164 + j * 18, 86 + i * 18)); } } // Fertilizer - addSlotToContainer(new SlotCustom(inv, TileFarmPlain.SLOT_FERTILIZER, 63, 95, PluginFarming.farmFertilizer)); + addSlotToContainer(new SlotFiltered(tile, TileFarmPlain.SLOT_FERTILIZER, 63, 95)); // Can Slot - addSlotToContainer(new SlotLiquidContainer(inv, TileFarmPlain.SLOT_CAN, 15, 95)); + addSlotToContainer(new SlotFiltered(tile, TileFarmPlain.SLOT_CAN, 15, 95)); // Player inventory for (int i = 0; i < 3; i++) { @@ -115,41 +108,4 @@ public class ContainerFarm extends ContainerSocketed { return tile.getTankManager().get(slot); } - private class SlotResources extends SlotForestry { - - private final IFarmLogic[] logics; - - public SlotResources(IInventory inventory, IFarmLogic[] logics, int slotIndex, int xPos, int yPos) { - super(inventory, slotIndex, xPos, yPos); - this.logics = logics; - } - - @Override - public boolean isItemValid(ItemStack stack) { - for (IFarmLogic logic : logics) { - if (logic != null && logic.isAcceptedResource(stack)) - return true; - } - return false; - } - } - - private class SlotGermlings extends SlotForestry { - - private final IFarmLogic[] logics; - - public SlotGermlings(IInventory inventory, IFarmLogic[] logics, int slotIndex, int xPos, int yPos) { - super(inventory, slotIndex, xPos, yPos); - this.logics = logics; - } - - @Override - public boolean isItemValid(ItemStack stack) { - for (IFarmLogic logic : logics) { - if (logic != null && logic.isAcceptedGermling(stack)) - return true; - } - return false; - } - } } diff --git a/src/main/java/forestry/food/GuiHandlerFood.java b/src/main/java/forestry/food/GuiHandlerFood.java index 0fe74e5d5..2f3c0f0ca 100755 --- a/src/main/java/forestry/food/GuiHandlerFood.java +++ b/src/main/java/forestry/food/GuiHandlerFood.java @@ -16,6 +16,7 @@ import forestry.food.gui.ContainerInfuser; import forestry.food.gui.GuiInfuser; import forestry.food.items.ItemInfuser.InfuserInventory; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class GuiHandlerFood extends GuiHandlerBase { @@ -28,7 +29,10 @@ public class GuiHandlerFood extends GuiHandlerBase { switch (GuiId.values()[id]) { case InfuserGUI: - return new GuiInfuser(player.inventory, new InfuserInventory(player)); + ItemStack infuser = player.getCurrentEquippedItem(); + if (infuser == null) + return null; + return new GuiInfuser(player.inventory, new InfuserInventory(player, infuser)); default: return null; @@ -44,7 +48,10 @@ public class GuiHandlerFood extends GuiHandlerBase { switch (GuiId.values()[id]) { case InfuserGUI: - return new ContainerInfuser(player.inventory, new InfuserInventory(player)); + ItemStack infuser = player.getCurrentEquippedItem(); + if (infuser == null) + return null; + return new ContainerInfuser(player.inventory, new InfuserInventory(player, infuser)); default: return null; diff --git a/src/main/java/forestry/food/gui/ContainerInfuser.java b/src/main/java/forestry/food/gui/ContainerInfuser.java index 6a7ec5a61..f780569e6 100755 --- a/src/main/java/forestry/food/gui/ContainerInfuser.java +++ b/src/main/java/forestry/food/gui/ContainerInfuser.java @@ -10,17 +10,17 @@ ******************************************************************************/ package forestry.food.gui; -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.proxy.Proxies; -import forestry.food.items.ItemBeverage; -import forestry.food.items.ItemInfuser.InfuserInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.core.proxy.Proxies; +import forestry.food.items.ItemInfuser.InfuserInventory; + public class ContainerInfuser extends ContainerForestry { private final InfuserInventory inventory; @@ -30,16 +30,16 @@ public class ContainerInfuser extends ContainerForestry { this.inventory = inventory; // Input - this.addSlotToContainer(new SlotCustom(inventory, 0, 152, 12, ForestryItem.beverage.getItemStack())); + this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 12)); // Output - this.addSlotToContainer(new SlotCustom(inventory, 1, 152, 72, ItemBeverage.class)); + this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72)); // Ingredients - this.addSlotToContainer(new Slot(inventory, 2, 12, 12)); - this.addSlotToContainer(new Slot(inventory, 3, 12, 32)); - this.addSlotToContainer(new Slot(inventory, 4, 12, 52)); - this.addSlotToContainer(new Slot(inventory, 5, 12, 72)); + this.addSlotToContainer(new SlotFiltered(inventory, 2, 12, 12)); + this.addSlotToContainer(new SlotFiltered(inventory, 3, 12, 32)); + this.addSlotToContainer(new SlotFiltered(inventory, 4, 12, 52)); + this.addSlotToContainer(new SlotFiltered(inventory, 5, 12, 72)); // Player inventory for (int i1 = 0; i1 < 3; i1++) diff --git a/src/main/java/forestry/food/items/ItemInfuser.java b/src/main/java/forestry/food/items/ItemInfuser.java index 98bb93fb4..4e1457a7b 100755 --- a/src/main/java/forestry/food/items/ItemInfuser.java +++ b/src/main/java/forestry/food/items/ItemInfuser.java @@ -230,14 +230,14 @@ public class ItemInfuser extends ItemForestry { // / INVENTORY MANAGMENT public static class InfuserInventory extends ItemInventory { - private final ItemStack[] inventoryStacks = new ItemStack[6]; private final short inputSlot = 0; private final short outputSlot = 1; private final short ingredientSlot1 = 2; + private final short ingredientSlotCount = 4; private final EntityPlayer player; - public InfuserInventory(EntityPlayer player) { - super(ItemInfuser.class); + public InfuserInventory(EntityPlayer player, ItemStack itemStack) { + super(ItemInfuser.class, 6, itemStack); this.player = player; } @@ -290,25 +290,6 @@ public class ItemInfuser extends ItemForestry { } - @Override - public ItemStack decrStackSize(int i, int j) { - if (inventoryStacks[i] == null) - return null; - - ItemStack product; - if (inventoryStacks[i].stackSize <= j) { - product = inventoryStacks[i]; - inventoryStacks[i] = null; - return product; - } else { - product = inventoryStacks[i].splitStack(j); - if (inventoryStacks[i].stackSize == 0) - inventoryStacks[i] = null; - - return product; - } - } - @Override public void markDirty() { if (!Proxies.common.isSimulating(player.worldObj)) @@ -316,61 +297,19 @@ public class ItemInfuser extends ItemForestry { trySeasoning(); } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - inventoryStacks[i] = itemstack; - } - - @Override - public ItemStack getStackInSlot(int i) { - return inventoryStacks[i]; - } - - @Override - public int getSizeInventory() { - return inventoryStacks.length; - } - @Override public String getInventoryName() { return "Infuser"; } @Override - public int getInventoryStackLimit() { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - if (inventoryStacks[slot] == null) - return null; - ItemStack toReturn = inventoryStacks[slot]; - inventoryStacks[slot] = null; - return toReturn; - } - - @Override - public boolean hasCustomInventoryName() { - return true; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (slotIndex == inputSlot) { + ForestryItem.beverage.isItemEqual(itemStack); + } else if (slotIndex >= ingredientSlot1 && slotIndex < ingredientSlot1 + ingredientSlotCount) { + BeverageManager.infuserManager.isIngredient(itemStack); + } + return false; } } diff --git a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java index 687af84fd..22a65e6e5 100755 --- a/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java +++ b/src/main/java/forestry/lepidopterology/GuiHandlerLepidopterology.java @@ -10,16 +10,17 @@ ******************************************************************************/ package forestry.lepidopterology; -import forestry.core.GuiHandlerBase; -import forestry.core.network.GuiId; -import forestry.lepidopterology.genetics.ButterflyHelper; -import forestry.lepidopterology.gui.ContainerFlutterlyzer; -import forestry.lepidopterology.gui.GuiFlutterlyzer; -import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import forestry.core.GuiHandlerBase; +import forestry.core.gui.ContainerAlyzer; +import forestry.core.network.GuiId; +import forestry.lepidopterology.genetics.ButterflyHelper; +import forestry.lepidopterology.gui.GuiFlutterlyzer; +import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; + public class GuiHandlerLepidopterology extends GuiHandlerBase { @Override @@ -32,11 +33,11 @@ public class GuiHandlerLepidopterology extends GuiHandlerBase { switch (GuiId.values()[cleanId]) { case FlutterlyzerGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; - return new ContainerFlutterlyzer(player.inventory, new FlutterlyzerInventory(player, equipped)); + return new ContainerAlyzer(new FlutterlyzerInventory(player, equipped), player); case LepidopteristChestGUI: return getNaturalistChestContainer(ButterflyHelper.UID, player, world, x, y, z, guiData); @@ -57,7 +58,7 @@ public class GuiHandlerLepidopterology extends GuiHandlerBase { switch (GuiId.values()[cleanId]) { case FlutterlyzerGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; diff --git a/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java deleted file mode 100755 index 5c23e09ff..000000000 --- a/src/main/java/forestry/lepidopterology/gui/ContainerFlutterlyzer.java +++ /dev/null @@ -1,27 +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.lepidopterology.gui; - -import forestry.core.config.ForestryItem; -import forestry.core.gui.ContainerAlyzer; -import forestry.lepidopterology.items.ItemButterflyGE; -import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory; -import net.minecraft.entity.player.InventoryPlayer; - -public class ContainerFlutterlyzer extends ContainerAlyzer { - - FlutterlyzerInventory inventory; - - public ContainerFlutterlyzer(InventoryPlayer inventoryplayer, FlutterlyzerInventory inventory) { - super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, ItemButterflyGE.class); - } - -} diff --git a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java index e04b5ebea..5c65cfca2 100755 --- a/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/gui/GuiFlutterlyzer.java @@ -21,6 +21,7 @@ import forestry.api.lepidopterology.IButterfly; import forestry.core.config.ForestryItem; import forestry.core.genetics.AlleleBoolean; import forestry.core.genetics.GenericRatings; +import forestry.core.gui.ContainerAlyzer; import forestry.core.gui.GuiAlyzer; import forestry.core.utils.StringUtil; import forestry.lepidopterology.genetics.ButterflyGenome; @@ -37,7 +38,7 @@ import net.minecraft.item.ItemStack; public class GuiFlutterlyzer extends GuiAlyzer { public GuiFlutterlyzer(EntityPlayer player, FlutterlyzerInventory inventory) { - super("rootButterflies", player, new ContainerFlutterlyzer(player.inventory, inventory), inventory, "gui.flutterlyzer"); + super("rootButterflies", player, new ContainerAlyzer(inventory, player), inventory, "gui.flutterlyzer"); ArrayList butterflyList = new ArrayList(); ((ItemButterflyGE) ForestryItem.butterflyGE.item()).addCreativeItems(butterflyList, false); diff --git a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java index 7b879591c..ac5ff30a3 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java +++ b/src/main/java/forestry/lepidopterology/items/ItemFlutterlyzer.java @@ -10,12 +10,16 @@ ******************************************************************************/ package forestry.lepidopterology.items; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; import forestry.api.lepidopterology.IButterfly; import forestry.core.EnumErrorCode; import forestry.core.config.Config; -import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; import forestry.core.inventory.AlyzerInventory; @@ -23,30 +27,19 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.plugins.PluginLepidopterology; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; public class ItemFlutterlyzer extends ItemInventoried { public static class FlutterlyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource { - public FlutterlyzerInventory(EntityPlayer player) { - super(ItemFlutterlyzer.class, 7); - this.player = player; - } - public FlutterlyzerInventory(EntityPlayer player, ItemStack itemStack) { super(ItemFlutterlyzer.class, 7, itemStack); this.player = player; } - private boolean isEnergy(ItemStack itemstack) { - if (itemstack == null || itemstack.stackSize <= 0) - return false; - - return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack); + @Override + protected boolean isSpecimen(ItemStack itemStack) { + return PluginLepidopterology.butterflyInterface.isMember(itemStack); } private void tryAnalyze() { diff --git a/src/main/java/forestry/mail/GuiHandlerMail.java b/src/main/java/forestry/mail/GuiHandlerMail.java index eee2a1c7f..e32d8c0f0 100755 --- a/src/main/java/forestry/mail/GuiHandlerMail.java +++ b/src/main/java/forestry/mail/GuiHandlerMail.java @@ -44,7 +44,7 @@ public class GuiHandlerMail extends GuiHandlerBase { switch (GuiId.values()[id]) { case CatalogueGUI: - ItemStack cata = getEquippedItem(player); + ItemStack cata = player.getCurrentEquippedItem(); if (cata == null) return null; @@ -54,7 +54,7 @@ public class GuiHandlerMail extends GuiHandlerBase { return null; case LetterGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; @@ -85,7 +85,7 @@ public class GuiHandlerMail extends GuiHandlerBase { switch (GuiId.values()[id]) { case CatalogueGUI: - ItemStack cata = getEquippedItem(player); + ItemStack cata = player.getCurrentEquippedItem(); if (cata == null) return null; @@ -95,12 +95,12 @@ public class GuiHandlerMail extends GuiHandlerBase { return null; case LetterGUI: - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; if (equipped.getItem() instanceof ItemLetter) - return new ContainerLetter(player, new LetterInventory(getEquippedItem(player))); + return new ContainerLetter(player, new LetterInventory(equipped)); else return null; diff --git a/src/main/java/forestry/mail/Letter.java b/src/main/java/forestry/mail/Letter.java index f296ed577..4dec87f0f 100755 --- a/src/main/java/forestry/mail/Letter.java +++ b/src/main/java/forestry/mail/Letter.java @@ -14,6 +14,7 @@ import forestry.api.core.INBTTagable; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.StringUtil; import java.util.List; @@ -26,7 +27,9 @@ public class Letter implements ILetter, INBTTagable { // CONSTANTS public static final short SLOT_ATTACHMENT_1 = 0; + public static final short SLOT_ATTACHMENT_COUNT = 18; public static final short SLOT_POSTAGE_1 = 18; + public static final short SLOT_POSTAGE_COUNT = 4; private boolean isProcessed = false; @@ -86,12 +89,12 @@ public class Letter implements ILetter, INBTTagable { @Override public ItemStack[] getPostage() { - return inventory.getStacks(SLOT_POSTAGE_1, 4); + return InvTools.getStacks(inventory, SLOT_POSTAGE_1, SLOT_POSTAGE_COUNT); } @Override public ItemStack[] getAttachments() { - return inventory.getStacks(SLOT_ATTACHMENT_1, 18); + return InvTools.getStacks(inventory, SLOT_ATTACHMENT_1, SLOT_ATTACHMENT_COUNT); } @Override @@ -108,7 +111,7 @@ public class Letter implements ILetter, INBTTagable { @Override public void addAttachment(ItemStack itemstack) { - inventory.tryAddStack(itemstack, false); + InvTools.tryAddStack(inventory, itemstack, false); } @Override @@ -170,7 +173,7 @@ public class Letter implements ILetter, INBTTagable { @Override public void addStamps(ItemStack stamps) { - this.inventory.tryAddStack(stamps, SLOT_POSTAGE_1, 4, false); + InvTools.tryAddStack(inventory, stamps, SLOT_POSTAGE_1, 4, false); } @Override diff --git a/src/main/java/forestry/mail/POBox.java b/src/main/java/forestry/mail/POBox.java index 851cf1b3e..ee4eea106 100755 --- a/src/main/java/forestry/mail/POBox.java +++ b/src/main/java/forestry/mail/POBox.java @@ -10,23 +10,25 @@ ******************************************************************************/ package forestry.mail; -import forestry.api.mail.ILetter; -import forestry.api.mail.IMailAddress; -import forestry.api.mail.PostManager; -import forestry.core.inventory.InventoryAdapter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.WorldSavedData; +import forestry.api.mail.ILetter; +import forestry.api.mail.IMailAddress; +import forestry.api.mail.PostManager; +import forestry.core.inventory.InvTools; +import forestry.core.inventory.InventoryAdapter; + public class POBox extends WorldSavedData implements IInventory { public static final String SAVE_NAME = "POBox_"; public static final short SLOT_SIZE = 84; private IMailAddress address; - private final InventoryAdapter letters = new InventoryAdapter(SLOT_SIZE, "Letters"); + private final InventoryAdapter letters = new InventoryAdapter(SLOT_SIZE, "Letters").disableAutomation(); public POBox(IMailAddress address) { super(SAVE_NAME + address); @@ -69,7 +71,8 @@ public class POBox extends WorldSavedData implements IInventory { letterstack.setTagCompound(nbttagcompound); this.markDirty(); - return this.letters.tryAddStack(letterstack, true); + + return InvTools.tryAddStack(letters, letterstack, true); } public POBoxInfo getPOBoxInfo() { @@ -151,7 +154,7 @@ public class POBox extends WorldSavedData implements IInventory { @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; + return letters.isItemValidForSlot(i, itemstack); } } diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 467680f20..c5e929806 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -92,6 +92,9 @@ public class PostRegistry implements IPostRegistry { @Override public TradeStation getTradeStation(World world, IMailAddress address) { + if (address.getName() == null) + return null; + if (cachedTradeStations.containsKey(address)) return (TradeStation) cachedTradeStations.get(address); diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index 6b5a21f38..00822f0ef 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -10,7 +10,19 @@ ******************************************************************************/ package forestry.mail; +import java.util.ArrayList; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; + import com.mojang.authlib.GameProfile; + import forestry.api.mail.EnumPostage; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -20,22 +32,67 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; import forestry.core.config.ForestryItem; -import forestry.core.interfaces.ICrafter; +import forestry.core.inventory.IInventoryAdapter; +import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; +import forestry.core.utils.GuiUtil; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StackUtils; import forestry.mail.items.ItemLetter; -import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.world.World; -import net.minecraft.world.WorldSavedData; -public class TradeStation extends WorldSavedData implements ITradeStation, ISidedInventory { +public class TradeStation extends WorldSavedData implements ITradeStation, IInventoryAdapter { + + public static class TradeStationInventory extends InventoryAdapter { + + public TradeStationInventory(int size, String name) { + super(size, name); + } + + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + + ArrayList slots = new ArrayList(); + + for (int i = SLOT_LETTERS_1; i < SLOT_LETTERS_1 + SLOT_LETTERS_COUNT; i++) + slots.add(i); + for (int i = SLOT_STAMPS_1; i < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; i++) + slots.add(i); + for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) + slots.add(i); + + int[] slotsInt = new int[slots.size()]; + for (int i = 0; i < slots.size(); i++) + slotsInt[i] = slots.get(i); + + return slotsInt; + } + + @Override + public boolean canExtractItem(int slot, ItemStack itemStack, int side) { + return GuiUtil.isIndexInRange(slot, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (GuiUtil.isIndexInRange(slotIndex, SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) { + for (int i = 0; i < SLOT_TRADEGOOD_COUNT; i++) { + ItemStack tradeGood = getStackInSlot(SLOT_TRADEGOOD + i); + if (StackUtils.isIdenticalItem(tradeGood, itemStack)) + return true; + } + return false; + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_LETTERS_1, SLOT_LETTERS_COUNT)) { + Item item = itemStack.getItem(); + return item == Items.paper; + } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { + Item item = itemStack.getItem(); + return item instanceof IStamps; + } + + return false; + } + } // / CONSTANTS public static final String SAVE_NAME = "TradePO_"; @@ -58,7 +115,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide private IMailAddress address; private boolean isVirtual = false; private boolean isInvalid = false; - private final InventoryAdapter inventory = new InventoryAdapter(SLOT_SIZE, "INV"); + private final InventoryAdapter inventory = new TradeStationInventory(SLOT_SIZE, "INV"); // / CONSTRUCTORS public TradeStation(GameProfile owner, IMailAddress address) { @@ -139,7 +196,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide @Override public TradeStationInfo getTradeInfo() { - ItemStack[] condensedRequired = StackUtils.condenseStacks(inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); + ItemStack[] condensedRequired = StackUtils.condenseStacks(InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); // Set current state EnumStationState state = EnumStationState.OK; @@ -171,7 +228,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide if (!isVirtual() && !hasPaper(sendOwnerNotice ? 2 : 1)) return EnumStationState.INSUFFICIENT_PAPER; - int ordersToFill = StackUtils.containsSets(inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT), letter.getAttachments()); + int ordersToFill = StackUtils.containsSets(InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT), letter.getAttachments()); // Not a single match. if (ordersToFill <= 0) @@ -188,7 +245,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide ordersToFill = fillable; // Check for sufficient output buffer - int storable = countStorablePayment(ordersToFill, inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); + int storable = countStorablePayment(ordersToFill, InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); if (storable <= 0) return EnumStationState.INSUFFICIENT_BUFFER; @@ -233,11 +290,11 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide // Store received items for (int i = 0; i < ordersToFill; i++) { - for (ItemStack stack : inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)) { + for (ItemStack stack : InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)) { if (stack == null) continue; - - inventory.tryAddStack(stack.copy(), SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, false); + + InvTools.tryAddStack(inventory, stack.copy(), SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, false); } } @@ -277,7 +334,8 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide // How many orders are fillable? int itemCount = 0; - for (ItemStack stack : inventory.getStacks(SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) { + + for (ItemStack stack : InvTools.getStacks(inventory, SLOT_SEND_BUFFER, SLOT_SEND_BUFFER_COUNT)) { if (stack != null && stack.isItemEqual(tradegood) && ItemStack.areItemStackTagsEqual(stack, tradegood)) itemCount += stack.stackSize; } @@ -287,9 +345,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide public boolean canReceivePayment() { InventoryAdapter test = inventory.copy(); - ItemStack [] payment = inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT); + ItemStack [] payment = InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT); - return test.tryAddStacksCopy(payment, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true); + return InvTools.tryAddStacksCopy(test, payment, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true); } private int countStorablePayment(int max, ItemStack[] exchange) { @@ -298,7 +356,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide int count = 0; for (int i = 0; i < max; i++) { - if (test.tryAddStacksCopy(exchange, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true)) + if (InvTools.tryAddStacksCopy(test, exchange, SLOT_RECEIVE_BUFFER, SLOT_RECEIVE_BUFFER_COUNT, true)) count++; else break; @@ -335,8 +393,8 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide private boolean hasPaper(int amountRequired) { int amountFound = 0; - - for (ItemStack stack : inventory.getStacks(SLOT_LETTERS_1, SLOT_LETTERS_COUNT)) { + + for (ItemStack stack : InvTools.getStacks(inventory, SLOT_LETTERS_1, SLOT_LETTERS_COUNT)) { if (stack != null) amountFound += stack.stackSize; @@ -360,8 +418,8 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide private boolean canPayPostage(int postage) { int posted = 0; - - for (ItemStack stamp : inventory.getStacks(SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { + + for (ItemStack stamp : InvTools.getStacks(inventory, SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { if (stamp == null) continue; @@ -405,7 +463,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide private int getNumStamps(EnumPostage postage) { int count = 0; - for (ItemStack stamp : inventory.getStacks(SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { + for (ItemStack stamp : InvTools.getStacks(inventory, SLOT_STAMPS_1, SLOT_STAMPS_COUNT)) { if (stamp == null) continue; if (!(stamp.getItem() instanceof IStamps)) @@ -456,7 +514,8 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide // Remove stuff until we are only left with the remnants for (int i = 0; i < filled; i++) { - ItemStack[] condensedRequired = StackUtils.condenseStacks(inventory.getStacks(SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT)); + ItemStack[] required = InvTools.getStacks(inventory, SLOT_EXCHANGE_1, SLOT_EXCHANGE_COUNT); + ItemStack[] condensedRequired = StackUtils.condenseStacks(required); for (ItemStack req : condensedRequired) { for (int j = 0; j < pool.length; j++) { ItemStack pol = pool[j]; @@ -529,7 +588,7 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide @Override public boolean isUseableByPlayer(EntityPlayer player) { - return PlayerUtil.isSameGameProfile(owner, player.getGameProfile()); + return true; } @Override @@ -540,68 +599,38 @@ public class TradeStation extends WorldSavedData implements ITradeStation, ISide public void closeInventory() { } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemStack) { + return inventory.isItemValidForSlot(i, itemStack); + } + @Override public boolean hasCustomInventoryName() { return true; } - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemStack) { - if (itemStack == null || itemStack.getItem() == null) - return false; - - if (slot >= SLOT_LETTERS_1 && slot < SLOT_LETTERS_1 + SLOT_LETTERS_COUNT) - return itemStack.getItem() == Items.paper; - - if (slot >= SLOT_STAMPS_1 && slot < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT) - return itemStack.getItem() instanceof IStamps; - - if (slot >= SLOT_SEND_BUFFER && slot < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT) { - ItemStack item = StackUtils.createSplitStack(itemStack, 1); - return inventory.contains(item, SLOT_TRADEGOOD, SLOT_TRADEGOOD_COUNT); - } - - return false; - } - @Override public int[] getAccessibleSlotsFromSide(int side) { - return getAccessibleSlotsFromSide(side, false); - } - - public int[] getAccessibleSlotsFromSide(int side, boolean permission) { - - ArrayList slots = new ArrayList(); - - for (int i = SLOT_LETTERS_1; i < SLOT_LETTERS_1 + SLOT_LETTERS_COUNT; i++) - slots.add(i); - for (int i = SLOT_STAMPS_1; i < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; i++) - slots.add(i); - if (permission) { - for (int i = SLOT_RECEIVE_BUFFER; i < SLOT_RECEIVE_BUFFER + SLOT_RECEIVE_BUFFER_COUNT; i++) - slots.add(i); - } - for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) - slots.add(i); - - int[] slotsInt = new int[slots.size()]; - for (int i = 0; i < slots.size(); i++) - slotsInt[i] = slots.get(i); - - return slotsInt; + return inventory.getAccessibleSlotsFromSide(side); } @Override public boolean canInsertItem(int slot, ItemStack itemStack, int side) { - return isItemValidForSlot(slot, itemStack); + return inventory.canInsertItem(slot, itemStack, side); } @Override public boolean canExtractItem(int slot, ItemStack itemStack, int side) { - return canExtractItem(slot, itemStack, side, false); + return inventory.canExtractItem(slot, itemStack, side); } - public boolean canExtractItem(int slot, ItemStack itemStack, int side, boolean permission) { - return permission && slot >= SLOT_RECEIVE_BUFFER && slot < SLOT_RECEIVE_BUFFER + SLOT_RECEIVE_BUFFER_COUNT; + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return inventory.canSlotAccept(slotIndex, itemStack); + } + + @Override + public IInventoryAdapter configureSided(int[] sides, int[] slots) { + return inventory.configureSided(sides, slots); } } diff --git a/src/main/java/forestry/mail/gadgets/MachineMailbox.java b/src/main/java/forestry/mail/gadgets/MachineMailbox.java index 27a8ea980..87d3c704d 100755 --- a/src/main/java/forestry/mail/gadgets/MachineMailbox.java +++ b/src/main/java/forestry/mail/gadgets/MachineMailbox.java @@ -50,6 +50,7 @@ public class MachineMailbox extends TileBase implements IMailContainer { public MachineMailbox() { setHints(Config.hints.get("mailbox")); + setInternalInventory(new InventoryAdapter(POBox.SLOT_SIZE, "Letters").disableAutomation()); } /* GUI */ @@ -83,8 +84,9 @@ public class MachineMailbox extends TileBase implements IMailContainer { /* MAIL HANDLING */ public IInventory getOrCreateMailInventory(World world, GameProfile playerProfile) { - if (!Proxies.common.isSimulating(world)) - return new InventoryAdapter(POBox.SLOT_SIZE, "Letters"); + if (!Proxies.common.isSimulating(world)) { + return getInternalInventory(); + } IMailAddress address = PostManager.postRegistry.getMailAddress(playerProfile); return PostRegistry.getOrCreatePOBox(worldObj, address); diff --git a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java index 3d885e651..95499f49b 100755 --- a/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java +++ b/src/main/java/forestry/mail/gadgets/MachinePhilatelist.java @@ -10,16 +10,18 @@ ******************************************************************************/ package forestry.mail.gadgets; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + import forestry.api.core.ForestryAPI; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.core.gadgets.TileBase; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.utils.StackUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; public class MachinePhilatelist extends TileBase implements IInventory { @@ -29,12 +31,12 @@ public class MachinePhilatelist extends TileBase implements IInventory { public static final short SLOT_BUFFER_COUNT = 27; public MachinePhilatelist() { - setInternalInventory(new TileInventoryAdapter(this, 28, "INV")); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); + setInternalInventory(new TileInventoryAdapter(this, 28, "INV") { + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + return itemStack.getItem() instanceof IStamps; + } + }); } @Override @@ -50,7 +52,7 @@ public class MachinePhilatelist extends TileBase implements IInventory { ItemStack stamp = null; - TileInventoryAdapter inventory = getInternalInventory(); + IInventoryAdapter inventory = getInternalInventory(); if (inventory.getStackInSlot(SLOT_FILTER) == null) stamp = PostManager.postRegistry.getPostOffice(worldObj).getAnyStamp(1); else { @@ -65,59 +67,4 @@ public class MachinePhilatelist extends TileBase implements IInventory { // Store it. StackUtils.stowInInventory(stamp, inventory, true, SLOT_BUFFER_1, SLOT_BUFFER_COUNT); } - - /* IINVENTORY */ - @Override - public int getSizeInventory() { - return getInternalInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getInternalInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getInternalInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getInternalInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getInternalInventory().getStackInSlotOnClosing(slot); - } - - @Override - public int getInventoryStackLimit() { - return getInternalInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return getInternalInventory().isUseableByPlayer(player); - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return getInternalInventory().isItemValidForSlot(slotIndex, itemstack); - } - } diff --git a/src/main/java/forestry/mail/gadgets/MachineTrader.java b/src/main/java/forestry/mail/gadgets/MachineTrader.java index 4f929b4da..a56fef9b7 100755 --- a/src/main/java/forestry/mail/gadgets/MachineTrader.java +++ b/src/main/java/forestry/mail/gadgets/MachineTrader.java @@ -16,7 +16,6 @@ import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -30,32 +29,25 @@ import forestry.api.mail.IMailAddress; import forestry.api.mail.IStamps; import forestry.api.mail.PostManager; import forestry.core.EnumErrorCode; -import forestry.core.config.Defaults; import forestry.core.gadgets.TileBase; -import forestry.core.inventory.InventoryAdapter; +import forestry.core.inventory.IInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; -import forestry.core.utils.EnumAccess; import forestry.core.utils.StackUtils; -import forestry.core.utils.Utils; import forestry.mail.MailAddress; import forestry.mail.TradeStation; import forestry.mail.triggers.MailTriggers; import buildcraft.api.statements.ITriggerExternal; -public class MachineTrader extends TileBase implements ISidedInventory { +public class MachineTrader extends TileBase { private IMailAddress address; public MachineTrader() { address = new MailAddress(); - } - - @Override - public String getInventoryName() { - return getUnlocalizedName(); + setInternalInventory(new TradeStation.TradeStationInventory(TradeStation.SLOT_SIZE, "INV")); } @Override @@ -94,7 +86,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { @Override public PacketPayload getPacketPayload() { - if (address == null) + if (address == null || address.getName() == null) return null; PacketPayload payload = new PacketPayload(0, 0, 1); @@ -140,7 +132,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { return; } - IInventory inventory = getOrCreateTradeInventory(); + IInventory inventory = getInternalInventory(); ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD); if (tradeGood == null) { @@ -181,7 +173,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { private boolean hasItemCount(int startSlot, int countSlots, ItemStack item, int itemCount) { int count = 0; - IInventory tradeInventory = this.getOrCreateTradeInventory(); + IInventory tradeInventory = this.getInternalInventory(); for (int i = startSlot; i < startSlot + countSlots; i++) { ItemStack itemInSlot = tradeInventory.getStackInSlot(i); if (itemInSlot == null) @@ -203,7 +195,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { int count = 0; int total = 0; - IInventory tradeInventory = this.getOrCreateTradeInventory(); + IInventory tradeInventory = this.getInternalInventory(); for (int i = startSlot; i < startSlot + countSlots; i++) { ItemStack itemInSlot = tradeInventory.getStackInSlot(i); if (itemInSlot == null) @@ -223,7 +215,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { } public boolean hasInputBufMin(float percentage) { - IInventory inventory = getOrCreateTradeInventory(); + IInventory inventory = getInternalInventory(); ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD); if (tradeGood == null) return true; @@ -238,7 +230,7 @@ public class MachineTrader extends TileBase implements ISidedInventory { int posted = 0; - IInventory tradeInventory = this.getOrCreateTradeInventory(); + IInventory tradeInventory = this.getInternalInventory(); for (int i = TradeStation.SLOT_STAMPS_1; i < TradeStation.SLOT_STAMPS_1 + TradeStation.SLOT_STAMPS_COUNT; i++) { ItemStack stamp = tradeInventory.getStackInSlot(i); if (stamp == null) @@ -283,107 +275,14 @@ public class MachineTrader extends TileBase implements ISidedInventory { } } - /* TRADING */ - public IInventory getOrCreateTradeInventory() { - + @Override + public IInventoryAdapter getInternalInventory() { // Handle client side - if (!Proxies.common.isSimulating(worldObj)) - return new InventoryAdapter(TradeStation.SLOT_SIZE, "INV"); - - if (!address.isValid()) - return new InventoryAdapter(TradeStation.SLOT_SIZE, "INV"); - - return PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); - } - - /* ISIDEDINVENTORY */ - @Override - public int getSizeInventory() { - return getOrCreateTradeInventory().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) { - return getOrCreateTradeInventory().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) { - return getOrCreateTradeInventory().decrStackSize(i, j); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - getOrCreateTradeInventory().setInventorySlotContents(i, itemstack); - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return getOrCreateTradeInventory().getStackInSlotOnClosing(slot); - } - - @Override - public void markDirty() { - getOrCreateTradeInventory().markDirty(); - } - - @Override - public int getInventoryStackLimit() { - return getOrCreateTradeInventory().getInventoryStackLimit(); - } - - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - - @Override - public boolean hasCustomInventoryName() { - return getOrCreateTradeInventory().hasCustomInventoryName(); - } - - @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { - return getOrCreateTradeInventory().isItemValidForSlot(slotIndex, itemstack); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - if (!Utils.isUseableByPlayer(player, this)) - return false; - return allowsViewing(player); - } - - /* ISIDEDINVENTORY */ - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - IInventory inventory = getOrCreateTradeInventory(); - if (inventory instanceof TradeStation) - return ((TradeStation) inventory).canInsertItem(i, itemstack, j); - return false; - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - IInventory inventory = getOrCreateTradeInventory(); - if (inventory instanceof TradeStation) { - boolean permission = (getAccess() == EnumAccess.SHARED); - return ((TradeStation) inventory).canExtractItem(i, itemstack, j, permission); + if (!Proxies.common.isSimulating(worldObj) || !address.isValid()) { + return super.getInternalInventory(); } - return false; - } - @Override - public int[] getAccessibleSlotsFromSide(int side) { - IInventory inventory = getOrCreateTradeInventory(); - if (inventory instanceof TradeStation) { - boolean permission = (getAccess() == EnumAccess.SHARED); - return ((TradeStation) inventory).getAccessibleSlotsFromSide(side, permission); - } - return Defaults.FACINGS_NONE; + return (TradeStation)PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address); } /* ITRIGGERPROVIDER */ @@ -401,5 +300,4 @@ public class MachineTrader extends TileBase implements ISidedInventory { res.add(MailTriggers.highBuffer75); return res; } - } diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index 6dfe3946c..da9a6555e 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -10,7 +10,18 @@ ******************************************************************************/ package forestry.mail.gui; +import java.util.Iterator; +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; + import com.mojang.authlib.GameProfile; + +import org.apache.commons.lang3.StringUtils; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -19,8 +30,7 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.api.mail.TradeStationInfo; import forestry.core.gui.ContainerItemInventory; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; @@ -28,15 +38,7 @@ import forestry.core.proxy.Proxies; import forestry.mail.Letter; import forestry.mail.items.ItemLetter; import forestry.mail.items.ItemLetter.LetterInventory; -import forestry.mail.items.ItemStamps; import forestry.mail.network.PacketLetterInfo; -import java.util.Iterator; -import java.util.UUID; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; -import org.apache.commons.lang3.StringUtils; public class ContainerLetter extends ContainerItemInventory { @@ -55,23 +57,15 @@ public class ContainerLetter extends ContainerItemInventory { inventory.parent.setItemDamage(ItemLetter.encodeMeta(2, ItemLetter.getSize(inventory.parent.getItemDamage()))); // Init slots - Object[] validStamps = new Object[] { ItemStamps.class }; - if (letterInventory.getLetter().isProcessed()) - validStamps = new Object[] {}; // Stamps for (int i = 0; i < 4; i++) - addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19, validStamps).setStackLimit(1)); + addSlotToContainer(new SlotFiltered(inventory, Letter.SLOT_POSTAGE_1 + i, 150, 14 + i * 19).setStackLimit(1)); // Attachments - if (!letterInventory.getLetter().isProcessed()) - for (int i = 0; i < 2; i++) - for (int j = 0; j < 9; j++) - addSlotToContainer(new SlotCustom(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18, ItemLetter.class).setExclusion(true)); - else - for (int i = 0; i < 2; i++) - for (int j = 0; j < 9; j++) - addSlotToContainer(new SlotClosed(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); + for (int i = 0; i < 2; i++) + for (int j = 0; j < 9; j++) + addSlotToContainer(new SlotFiltered(inventory, Letter.SLOT_ATTACHMENT_1 + j + i * 9, 17 + j * 18, 98 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) @@ -102,11 +96,6 @@ public class ContainerLetter extends ContainerItemInventory { super.onContainerClosed(entityplayer); } - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - return true; - } - public ILetter getLetter() { return letterInventory.getLetter(); } diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 642697792..0fdf59bf3 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -12,7 +12,6 @@ package forestry.mail.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -20,7 +19,7 @@ import net.minecraft.item.ItemStack; import forestry.api.mail.IMailAddress; import forestry.api.mail.PostManager; import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; +import forestry.core.gui.slots.SlotOutput; import forestry.core.proxy.Proxies; import forestry.mail.POBox; import forestry.mail.gadgets.MachineMailbox; @@ -48,7 +47,7 @@ public class ContainerMailbox extends ContainerForestry { for (int i = 0; i < 7; i++) for (int j = 0; j < 12; j++) - addSlotToContainer(new SlotClosed(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); + addSlotToContainer(new SlotOutput(inventory, j + i * 9, 8 + j * 18, 8 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) diff --git a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java index 6ab9b9972..5adf0b062 100755 --- a/src/main/java/forestry/mail/gui/ContainerPhilatelist.java +++ b/src/main/java/forestry/mail/gui/ContainerPhilatelist.java @@ -10,26 +10,26 @@ ******************************************************************************/ package forestry.mail.gui; -import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; -import forestry.mail.gadgets.MachinePhilatelist; -import forestry.mail.items.ItemStamps; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import forestry.core.gui.ContainerForestry; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotOutput; +import forestry.mail.gadgets.MachinePhilatelist; + public class ContainerPhilatelist extends ContainerForestry { public ContainerPhilatelist(InventoryPlayer player, MachinePhilatelist tile) { super(tile); // Filter - addSlotToContainer(new SlotCustom(tile, MachinePhilatelist.SLOT_FILTER, 80, 19, ItemStamps.class)); + addSlotToContainer(new SlotFiltered(tile, MachinePhilatelist.SLOT_FILTER, 80, 19)); // Collected Stamps for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) - addSlotToContainer(new SlotClosed(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); + addSlotToContainer(new SlotOutput(tile, j + i * 9 + MachinePhilatelist.SLOT_BUFFER_1, 8 + j * 18, 46 + i * 18)); // Player inventory for (int i = 0; i < 3; i++) diff --git a/src/main/java/forestry/mail/gui/ContainerTrader.java b/src/main/java/forestry/mail/gui/ContainerTrader.java index 38fb66134..eec4eaf5f 100755 --- a/src/main/java/forestry/mail/gui/ContainerTrader.java +++ b/src/main/java/forestry/mail/gui/ContainerTrader.java @@ -11,18 +11,15 @@ package forestry.mail.gui; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import forestry.api.mail.IMailAddress; import forestry.core.gui.ContainerForestry; -import forestry.core.gui.slots.SlotClosed; -import forestry.core.gui.slots.SlotCustom; +import forestry.core.gui.slots.SlotFiltered; import forestry.core.gui.slots.SlotForestry; +import forestry.core.gui.slots.SlotOutput; import forestry.mail.TradeStation; import forestry.mail.gadgets.MachineTrader; -import forestry.mail.items.ItemStamps; public class ContainerTrader extends ContainerForestry { @@ -32,29 +29,28 @@ public class ContainerTrader extends ContainerForestry { super(tile); machine = tile; - IInventory inventory = machine.getOrCreateTradeInventory(); // Trade good - this.addSlotToContainer(new SlotForestry(inventory, TradeStation.SLOT_TRADEGOOD, 78, 109).blockShift()); + this.addSlotToContainer(new SlotForestry(machine, TradeStation.SLOT_TRADEGOOD, 78, 109).blockShift()); // Exchange for (int row = 0; row < 2; row++) { for (int col = 0; col < 2; col++) { - addSlotToContainer(new SlotForestry(inventory, TradeStation.SLOT_EXCHANGE_1 + col + row * 2, 69 + col * 18, 55 + row * 18).blockShift()); + addSlotToContainer(new SlotForestry(machine, TradeStation.SLOT_EXCHANGE_1 + col + row * 2, 69 + col * 18, 55 + row * 18).blockShift()); } } // Stamps for (int row = 0; row < 2; row++) { for (int col = 0; col < 2; col++) { - addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + col + row * 2, 15 + col * 18, 37 + row * 18, ItemStamps.class)); + addSlotToContainer(new SlotFiltered(machine, TradeStation.SLOT_STAMPS_1 + col + row * 2, 15 + col * 18, 37 + row * 18)); } } // Letters for (int row = 0; row < 3; row++) { for (int col = 0; col < 2; col++) { - addSlotToContainer(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + col + row * 2, 15 + col * 18, 73 + row * 18, Items.paper)); + addSlotToContainer(new SlotFiltered(machine, TradeStation.SLOT_LETTERS_1 + col + row * 2, 15 + col * 18, 73 + row * 18)); } } @@ -62,13 +58,13 @@ public class ContainerTrader extends ContainerForestry { final int bufCols = 5; for (int row = 0; row < 3; row++) { for (int col = 0; col < bufCols; col++) { - addSlotToContainer(new SlotClosed(inventory, TradeStation.SLOT_RECEIVE_BUFFER + col + row * bufCols, 123 + col * 18, 19 + row * 18)); + addSlotToContainer(new SlotOutput(machine, TradeStation.SLOT_RECEIVE_BUFFER + col + row * bufCols, 123 + col * 18, 19 + row * 18)); } } for (int row = 0; row < 2; row++) { for (int col = 0; col < bufCols; col++) { - addSlotToContainer(new Slot(inventory, TradeStation.SLOT_SEND_BUFFER + col + row * bufCols, 123 + col * 18, (19 + (18 * 4)) + row * 18)); + addSlotToContainer(new SlotFiltered(machine, TradeStation.SLOT_SEND_BUFFER + col + row * bufCols, 123 + col * 18, (19 + (18 * 4)) + row * 18)); } } diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index b155adb12..a616492f0 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -10,12 +10,25 @@ ******************************************************************************/ package forestry.mail.items; +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.ForestryAPI; import forestry.api.mail.ILetter; import forestry.core.EnumErrorCode; import forestry.core.config.Config; +import forestry.core.config.ForestryItem; import forestry.core.interfaces.IErrorSource; import forestry.core.interfaces.IHintSource; import forestry.core.inventory.ItemInventory; @@ -23,16 +36,9 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; +import forestry.core.utils.GuiUtil; import forestry.core.utils.StringUtil; import forestry.mail.Letter; -import java.util.List; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; public class ItemLetter extends ItemInventoried { @@ -41,9 +47,7 @@ public class ItemLetter extends ItemInventoried { ILetter letter; public LetterInventory(ItemStack itemstack) { - super(ItemLetter.class); - this.parent = itemstack; - this.isItemInventory = true; + super(ItemLetter.class, 0, itemstack); // Set an uid to identify the itemstack on SMP setUID(true); @@ -132,19 +136,24 @@ public class ItemLetter extends ItemInventoried { return letter.isUseableByPlayer(entityplayer); } - @Override - public void openInventory() { - } - - @Override - public void closeInventory() { - } - @Override public ItemStack getStackInSlotOnClosing(int slot) { return letter.getStackInSlotOnClosing(slot); } + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (letter.isProcessed()) { + return false; + } else if (GuiUtil.isIndexInRange(slotIndex, Letter.SLOT_POSTAGE_1, Letter.SLOT_POSTAGE_COUNT)) { + Item item = itemStack.getItem(); + return item instanceof ItemStamps; + } else if (GuiUtil.isIndexInRange(slotIndex, Letter.SLOT_ATTACHMENT_1, Letter.SLOT_ATTACHMENT_COUNT)) { + return !ForestryItem.letters.isItemEqual(itemStack); + } + return false; + } + // / IERRORSOURCE @Override public boolean throwsErrors() { diff --git a/src/main/java/forestry/storage/BackpackDefinition.java b/src/main/java/forestry/storage/BackpackDefinition.java index b46a1cb64..fc37a28f8 100755 --- a/src/main/java/forestry/storage/BackpackDefinition.java +++ b/src/main/java/forestry/storage/BackpackDefinition.java @@ -85,17 +85,21 @@ public class BackpackDefinition implements IBackpackDefinition { addValidItem(validItem); } - public ArrayList getValidItems(EntityPlayer player) { + public ArrayList getValidItems() { return validItems; } @Override public boolean isValidItem(EntityPlayer player, ItemStack itemstack) { - for (ItemStack stack : getValidItems(player)) + return isValidItem(itemstack); + } + + @Override + public boolean isValidItem(ItemStack itemstack) { + for (ItemStack stack : getValidItems()) if (StackUtils.isCraftingEquivalent(stack, itemstack, true, false)) return true; return false; } - } diff --git a/src/main/java/forestry/storage/GuiHandlerStorage.java b/src/main/java/forestry/storage/GuiHandlerStorage.java index 8624dc305..34692d6a4 100755 --- a/src/main/java/forestry/storage/GuiHandlerStorage.java +++ b/src/main/java/forestry/storage/GuiHandlerStorage.java @@ -10,6 +10,11 @@ ******************************************************************************/ package forestry.storage; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.ISpeciesRoot; @@ -18,25 +23,22 @@ import forestry.core.config.Defaults; import forestry.core.gui.GuiNaturalistInventory; import forestry.core.gui.IPagedInventory; import forestry.core.inventory.ItemInventory; +import forestry.core.inventory.ItemInventoryBackpack; import forestry.core.network.GuiId; import forestry.storage.gui.ContainerBackpack; import forestry.storage.gui.ContainerNaturalistBackpack; import forestry.storage.gui.GuiBackpack; import forestry.storage.gui.GuiBackpackT2; import forestry.storage.items.ItemBackpack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class GuiHandlerStorage extends GuiHandlerBase { - public static class PagedInventory extends ItemInventory implements IPagedInventory { + public static class PagedBackpackInventory extends ItemInventoryBackpack implements IPagedInventory { //private final int x, y, z; private final int guiId; - public PagedInventory(Class itemClass, int size, ItemStack itemstack, int x, int y, int z, int guiId) { + public PagedBackpackInventory(Class itemClass, int size, ItemStack itemstack, int x, int y, int z, int guiId) { super(itemClass, size, itemstack); /*this.x = x; this.y = y; @@ -67,28 +69,28 @@ public class GuiHandlerStorage extends GuiHandlerBase { if (equipped == null) return null; ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); - PagedInventory inventory = new PagedInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId); - return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(speciesRoot, player.inventory, inventory, guiData, 25), inventory, guiData, 5); + PagedBackpackInventory inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId); + return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); case BackpackGUI: equipped = getBackpackItem(player); if (equipped == null) return null; - return new GuiBackpack(new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped))); + return new GuiBackpack(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped))); case BackpackT2GUI: equipped = getBackpackItem(player); if (equipped == null) return null; - return new GuiBackpackT2(new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped))); + return new GuiBackpackT2(new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped))); case LepidopteristBackpackGUI: equipped = getBackpackItem(player); if (equipped == null) return null; speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); - inventory = new PagedInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, id); - return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(speciesRoot, player.inventory, inventory, guiData, 25), inventory, guiData, 5); + inventory = new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, id); + return new GuiNaturalistInventory(speciesRoot, player, new ContainerNaturalistBackpack(player.inventory, inventory, guiData, 25), inventory, guiData, 5); default: return null; @@ -97,7 +99,7 @@ public class GuiHandlerStorage extends GuiHandlerBase { } private ItemStack getBackpackItem(EntityPlayer player) { - ItemStack equipped = getEquippedItem(player); + ItemStack equipped = player.getCurrentEquippedItem(); if (equipped == null) return null; if (equipped.getItem() instanceof ItemBackpack) @@ -121,32 +123,28 @@ public class GuiHandlerStorage extends GuiHandlerBase { if (equipped == null) return null; - ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); - speciesRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player); - return new ContainerNaturalistBackpack(speciesRoot, player.inventory, new PagedInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); + return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); case BackpackGUI: equipped = getBackpackItem(player); if (equipped == null) return null; - return new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped)); + return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_DEFAULT, equipped)); case BackpackT2GUI: equipped = getBackpackItem(player); if (equipped == null) return null; - return new ContainerBackpack(player, new ItemInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped)); + return new ContainerBackpack(player, new ItemInventoryBackpack(ItemBackpack.class, Defaults.SLOTS_BACKPACK_T2, equipped)); case LepidopteristBackpackGUI: equipped = getBackpackItem(player); if (equipped == null) return null; - speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); - speciesRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player); - return new ContainerNaturalistBackpack(speciesRoot, player.inventory, new PagedInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); + return new ContainerNaturalistBackpack(player.inventory, new PagedBackpackInventory(ItemBackpack.class, Defaults.SLOTS_BACKPACK_APIARIST, equipped, x, y, z, cleanId), guiData, 25); default: return null; diff --git a/src/main/java/forestry/storage/ResupplyHandler.java b/src/main/java/forestry/storage/ResupplyHandler.java index ee44c5c30..52d26fb77 100755 --- a/src/main/java/forestry/storage/ResupplyHandler.java +++ b/src/main/java/forestry/storage/ResupplyHandler.java @@ -16,6 +16,7 @@ import forestry.api.storage.BackpackResupplyEvent; import forestry.api.storage.IBackpackDefinition; import forestry.core.interfaces.IResupplyHandler; import forestry.core.inventory.ItemInventory; +import forestry.core.inventory.ItemInventoryBackpack; import forestry.storage.items.ItemBackpack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ContainerPlayer; @@ -59,7 +60,7 @@ public class ResupplyHandler implements IResupplyHandler { // Load their inventory ItemBackpack packItem = ((ItemBackpack) backpack.getItem()); - ItemInventory backpackinventory = new ItemInventory(ItemBackpack.class, packItem.getBackpackSize(), backpack); + ItemInventory backpackinventory = new ItemInventoryBackpack(ItemBackpack.class, packItem.getBackpackSize(), backpack); Event event = new BackpackResupplyEvent(player, packItem.getDefinition(), backpackinventory); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) diff --git a/src/main/java/forestry/storage/gui/ContainerBackpack.java b/src/main/java/forestry/storage/gui/ContainerBackpack.java index 727d0e92d..a456b4886 100755 --- a/src/main/java/forestry/storage/gui/ContainerBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerBackpack.java @@ -10,17 +10,16 @@ ******************************************************************************/ package forestry.storage.gui; +import net.minecraft.entity.player.EntityPlayer; + import forestry.core.config.Defaults; import forestry.core.gui.ContainerItemInventory; -import forestry.core.gui.slots.SlotForestry; -import forestry.core.inventory.ItemInventory; -import forestry.storage.items.ItemBackpack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.inventory.ItemInventoryBackpack; public class ContainerBackpack extends ContainerItemInventory { - public ContainerBackpack(final EntityPlayer player, ItemInventory inventory) { + public ContainerBackpack(final EntityPlayer player, ItemInventoryBackpack inventory) { super(inventory, player); int lines = 0; @@ -40,18 +39,12 @@ public class ContainerBackpack extends ContainerItemInventory { } // Inventory - for (int j = 0; j < lines; j++) + for (int j = 0; j < lines; j++) { for (int k = 0; k < columns; k++) { int slot = k + j * columns; - addSlotToContainer(new SlotForestry(inventory, slot, startX + k * 18, startY + j * 18) { - - @Override - public boolean isItemValid(ItemStack stack) { - return isAcceptedItem(player, stack); - } - - }); + addSlotToContainer(new SlotFiltered(inventory, slot, startX + k * 18, startY + j * 18)); } + } // Player inventory for (int i = 0; i < 3; i++) @@ -62,21 +55,4 @@ public class ContainerBackpack extends ContainerItemInventory { addSecuredSlot(player.inventory, i, 8 + i * 18, 11 + startY + lines * 18 + 58); } - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - // FIXME: This is incorrect. - // However, if we return false here, even valid items will be dropped - // while being kept inside the backpack, leading to duping. - // inventory.parent will turn null with the current implementation if - // something is put inside a backpack and the backpack is then - // moved from the action bar into the player's inventory. - if (inventory.parent == null) - return true; - - if (!(inventory.parent.getItem() instanceof ItemBackpack)) - return false; - - return ((ItemBackpack) inventory.parent.getItem()).getDefinition().isValidItem(player, stack); - } - } diff --git a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java index e93141cdc..f5e6c7b19 100755 --- a/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java +++ b/src/main/java/forestry/storage/gui/ContainerNaturalistBackpack.java @@ -10,32 +10,28 @@ ******************************************************************************/ package forestry.storage.gui; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.gui.ContainerItemInventory; -import forestry.core.gui.IGuiSelectable; -import forestry.core.gui.slots.SlotCustom; -import forestry.core.network.PacketUpdate; -import forestry.core.proxy.Proxies; -import forestry.storage.GuiHandlerStorage.PagedInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; + +import forestry.core.gui.ContainerItemInventory; +import forestry.core.gui.IGuiSelectable; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.network.PacketUpdate; +import forestry.storage.GuiHandlerStorage.PagedBackpackInventory; public class ContainerNaturalistBackpack extends ContainerItemInventory implements IGuiSelectable { - private final PagedInventory inv; - private final ISpeciesRoot speciesRoot; + private final PagedBackpackInventory inv; - public ContainerNaturalistBackpack(ISpeciesRoot speciesRoot, InventoryPlayer player, PagedInventory inventory, int page, int pageSize) { + public ContainerNaturalistBackpack(InventoryPlayer player, PagedBackpackInventory inventory, int page, int pageSize) { super(inventory, player.player); this.inv = inventory; - this.speciesRoot = speciesRoot; // Inventory for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { - addSlotToContainer(new SlotCustom(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18, speciesRoot)); + addSlotToContainer(new SlotFiltered(inventory, y + page * pageSize + x * 5, 100 + y * 18, 21 + x * 18)); } } @@ -51,27 +47,6 @@ public class ContainerNaturalistBackpack extends ContainerItemInventory implemen } } - @Override - public void purgeBag(EntityPlayer player) { - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack stack = inventory.getStackInSlot(i); - if (stack == null) - continue; - - if (speciesRoot.isMember(stack)) - continue; - - Proxies.common.dropItemPlayer(player, stack); - inventory.setInventorySlotContents(i, null); - } - } - - @Override - protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) { - // TODO Auto-generated method stub - return false; - } - @Override public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) { inv.flipPage(player, packet.payload.intPayload[0]); diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index 825bdc2b3..9fbba383f 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -21,6 +21,7 @@ import forestry.core.config.Config; import forestry.core.config.Defaults; import forestry.core.inventory.InvTools; import forestry.core.inventory.ItemInventory; +import forestry.core.inventory.ItemInventoryBackpack; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; import forestry.core.items.ItemInventoried; @@ -101,7 +102,7 @@ public class ItemBackpack extends ItemInventoried { public ItemStack tryStowing(EntityPlayer player, ItemStack backpackStack, ItemStack stack) { ItemBackpack backpack = ((ItemBackpack) backpackStack.getItem()); - ItemInventory inventory = new ItemInventory(ItemBackpack.class, backpack.getBackpackSize(), backpackStack); + ItemInventory inventory = new ItemInventoryBackpack(ItemBackpack.class, backpack.getBackpackSize(), backpackStack); if (backpackStack.getItemDamage() == 1) return stack; @@ -147,7 +148,7 @@ public class ItemBackpack extends ItemInventoried { return true; // Create our own backpack inventory - ItemInventory backpackInventory = new ItemInventory(ItemBackpack.class, getBackpackSize(), stack); + ItemInventoryBackpack backpackInventory = new ItemInventoryBackpack(ItemBackpack.class, getBackpackSize(), stack); BackpackMode mode = getMode(stack); if (mode == BackpackMode.RECEIVE) @@ -163,7 +164,7 @@ public class ItemBackpack extends ItemInventoried { return false; } - private void tryChestTransfer(ItemInventory backpackInventory, IInventory target) { + private void tryChestTransfer(ItemInventoryBackpack backpackInventory, IInventory target) { for (IInvSlot slot : InventoryIterator.getIterable(backpackInventory)) { ItemStack packStack = slot.getStackInSlot(); @@ -175,7 +176,7 @@ public class ItemBackpack extends ItemInventoried { } } - private void tryChestReceive(EntityPlayer player, ItemInventory backpackInventory, IInventory target) { + private void tryChestReceive(EntityPlayer player, ItemInventoryBackpack backpackInventory, IInventory target) { for (IInvSlot slot : InventoryIterator.getIterable(target)) { ItemStack targetStack = slot.getStackInSlot(); diff --git a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java index 3397e9fa1..edd69ccdd 100755 --- a/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java +++ b/src/main/java/forestry/storage/items/ItemNaturalistBackpack.java @@ -27,7 +27,7 @@ public class ItemNaturalistBackpack extends ItemBackpack { } @Override - public boolean isValidItem(EntityPlayer player, ItemStack stack) { + public boolean isValidItem(ItemStack stack) { return PluginApiculture.beeInterface.isMember(stack); } } @@ -39,7 +39,7 @@ public class ItemNaturalistBackpack extends ItemBackpack { } @Override - public boolean isValidItem(EntityPlayer player, ItemStack stack) { + public boolean isValidItem(ItemStack stack) { return PluginLepidopterology.butterflyInterface.isMember(stack); } } From a9fbfbbe7453d12787ba7c32ccb093e13e3540f1 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 31 Dec 2014 05:17:47 -0800 Subject: [PATCH 131/175] Don't register fluids that are not Forestry's. #420 #422 --- src/main/java/forestry/core/fluids/Fluids.java | 2 ++ src/main/java/forestry/plugins/PluginFluids.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/core/fluids/Fluids.java b/src/main/java/forestry/core/fluids/Fluids.java index d4c178690..0e91266bb 100644 --- a/src/main/java/forestry/core/fluids/Fluids.java +++ b/src/main/java/forestry/core/fluids/Fluids.java @@ -317,6 +317,8 @@ public enum Fluids { // Thermal Expansion COAL, PYROTHEUM; + public static final Fluids[] forestryFluids = {ETHANOL, BIOMASS, GLASS, HONEY, LEGACY_HONEY, ICE, JUICE, MILK, SEEDOIL, SHORT_MEAD}; + private final String tag; private final int density, viscosity; private final Color color; diff --git a/src/main/java/forestry/plugins/PluginFluids.java b/src/main/java/forestry/plugins/PluginFluids.java index a27950d84..a523853ce 100644 --- a/src/main/java/forestry/plugins/PluginFluids.java +++ b/src/main/java/forestry/plugins/PluginFluids.java @@ -82,7 +82,7 @@ public class PluginFluids extends ForestryPlugin { @Override public void preInit() { - for (Fluids fluidType : Fluids.values()) { + for (Fluids fluidType : Fluids.forestryFluids) { createFluid(fluidType); } MinecraftForge.EVENT_BUS.register(getTextureHook()); @@ -145,7 +145,7 @@ public class PluginFluids extends ForestryPlugin { @Override public void postInit() { - for (Fluids fluidType : Fluids.values()) { + for (Fluids fluidType : Fluids.forestryFluids) { if (fluidType.getFluid() == null) throw new MissingFluidException(fluidType.getTag()); } From e8fa5ebca90b7f0d120f637bacad01f6f19934f0 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 31 Dec 2014 15:30:32 -0800 Subject: [PATCH 132/175] Fix #423 Mushroom growth crashes in rare cases --- .../farming/gadgets/BlockMushroom.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/forestry/farming/gadgets/BlockMushroom.java b/src/main/java/forestry/farming/gadgets/BlockMushroom.java index 40a56e8f8..6c9c4b73d 100755 --- a/src/main/java/forestry/farming/gadgets/BlockMushroom.java +++ b/src/main/java/forestry/farming/gadgets/BlockMushroom.java @@ -101,21 +101,16 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { @Override public void func_149878_d(World world, int i, int j, int k, Random random) { - int type = world.getBlockMetadata(i, j, k) & 0x03; - - if(type >= generators.length) - return; + MushroomType type = getTypeFromMeta(world.getBlockMetadata(i, j, k)); world.setBlockToAir(i, j, k); - if (!generators[type].generate(world, random, i, j, k)) - world.setBlock(i, j, k, this, type, 0); + if (!generators[type.ordinal()].generate(world, random, i, j, k)) + world.setBlock(i, j, k, this, type.ordinal(), 0); } @Override public MushroomType getTypeFromMeta(int meta) { - meta %= 3; - if (meta >= MushroomType.values().length) - return null; + meta %= MushroomType.values().length; return MushroomType.values()[meta]; } @@ -138,12 +133,11 @@ public class BlockMushroom extends BlockSapling implements IItemTyped { public IIcon getIcon(int side, int meta) { MushroomType type = getTypeFromMeta(meta); - if (type == MushroomType.BROWN) - return Blocks.brown_mushroom.getIcon(side, meta); - else if (type == MushroomType.RED) - return Blocks.red_mushroom.getIcon(side, meta); - else - return null; + switch (type) { + case BROWN: return Blocks.brown_mushroom.getIcon(side, meta); + case RED: return Blocks.red_mushroom.getIcon(side, meta); + default: return null; + } } } From 9af62513e5cf4a07de4a9c65de2071e45825bd8a Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 1 Jan 2015 19:39:36 -0800 Subject: [PATCH 133/175] Add grammars for wood products, generalize for new trees --- lang | 2 +- .../java/forestry/arboriculture/WoodType.java | 5 ++ .../arboriculture/gadgets/BlockArbFence.java | 16 ++-- .../arboriculture/gadgets/BlockLog.java | 15 ++-- .../arboriculture/gadgets/BlockPlanks.java | 16 ++-- .../arboriculture/gadgets/BlockSlab.java | 18 +++-- .../arboriculture/items/ItemStairs.java | 24 +++++- .../arboriculture/items/ItemWoodBlock.java | 12 ++- .../java/forestry/core/utils/StringUtil.java | 4 + .../forestry/plugins/PluginArboriculture.java | 78 ++++++++++--------- 10 files changed, 123 insertions(+), 67 deletions(-) diff --git a/lang b/lang index cc1783de4..d6aa63fdc 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit cc1783de445988c1855a04ceca120995259d82a1 +Subproject commit d6aa63fdce7c72de79dade4a5ff703e8080ff588 diff --git a/src/main/java/forestry/arboriculture/WoodType.java b/src/main/java/forestry/arboriculture/WoodType.java index 1e6420c98..623429af3 100755 --- a/src/main/java/forestry/arboriculture/WoodType.java +++ b/src/main/java/forestry/arboriculture/WoodType.java @@ -92,4 +92,9 @@ public enum WoodType { return WoodType.LARCH; } + @Override + public String toString() { + return super.toString().toLowerCase(Locale.ENGLISH); + } + } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index aeee54181..7a1ec78f9 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -35,6 +35,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { CAT0, CAT1 } + public static final int fencesPerCat = 16; private final FenceCat cat; public BlockArbFence(FenceCat cat) { @@ -49,7 +50,8 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int count = (cat == FenceCat.CAT0 ? 16 : 8); + int totalWoods = WoodType.values().length; + int count = Math.min(totalWoods - (cat.ordinal() * fencesPerCat), fencesPerCat); for (int i = 0; i < count; i++) itemList.add(new ItemStack(this, 1, i)); } @@ -88,7 +90,10 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { - return getWoodType(meta).getPlankIcon(); + WoodType woodType = getWoodType(meta); + if (woodType == null) + return null; + return woodType.getPlankIcon(); } public boolean isFence(IBlockAccess world, int x, int y, int z) { @@ -119,10 +124,11 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { @Override public WoodType getWoodType(int meta) { - if(cat.ordinal() * 16 + meta < WoodType.VALUES.length) - return WoodType.VALUES[cat.ordinal() * 16 + meta]; + int woodOrdinal = cat.ordinal() * fencesPerCat + meta; + if(woodOrdinal < WoodType.VALUES.length) + return WoodType.VALUES[woodOrdinal]; else - return WoodType.LARCH; + return null; } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java index 97ab2f49a..bab6b6521 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockLog.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockLog.java @@ -33,6 +33,7 @@ public class BlockLog extends Block implements IWoodTyped { public enum LogCat { CAT0, CAT1, CAT2, CAT3, CAT4, CAT5, CAT6, CAT7 } + public static final short logsPerCat = 4; protected final LogCat cat; @@ -100,12 +101,9 @@ public class BlockLog extends Block implements IWoodTyped { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - if(cat == LogCat.CAT6) { - itemList.add(new ItemStack(this, 1, 0)); - return; - } - - for (int i = 0; i < 4; i++) + int totalWoods = WoodType.values().length; + int count = Math.min(totalWoods - (cat.ordinal() * logsPerCat), logsPerCat); + for (int i = 0; i < count; i++) itemList.add(new ItemStack(this, 1, i)); } @@ -195,8 +193,9 @@ public class BlockLog extends Block implements IWoodTyped { @Override public WoodType getWoodType(int meta) { meta = getTypeFromMeta(meta); - if(meta + cat.ordinal() * 4 < WoodType.VALUES.length) - return WoodType.VALUES[meta + cat.ordinal() * 4]; + int woodOrdinal = meta + cat.ordinal() * logsPerCat; + if(woodOrdinal < WoodType.VALUES.length) + return WoodType.VALUES[woodOrdinal]; else return null; } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java index d46cbaea0..6ebb7f3c4 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockPlanks.java @@ -33,6 +33,7 @@ public class BlockPlanks extends Block implements IWoodTyped { CAT0, CAT1 } + public static final int planksPerCat = 16; protected final PlankCat cat; public BlockPlanks(PlankCat cat) { @@ -50,7 +51,8 @@ public class BlockPlanks extends Block implements IWoodTyped { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - int count = (cat == PlankCat.CAT0 ? 16 : 8); + int totalWoods = WoodType.values().length; + int count = Math.min(totalWoods - (cat.ordinal() * planksPerCat), planksPerCat); for (int i = 0; i < count; i++) itemList.add(new ItemStack(this, 1, i)); } @@ -65,7 +67,10 @@ public class BlockPlanks extends Block implements IWoodTyped { @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int meta) { - return getWoodType(meta).getPlankIcon(); + WoodType woodType = getWoodType(meta); + if (woodType == null) + return null; + return woodType.getPlankIcon(); } @Override @@ -101,10 +106,11 @@ public class BlockPlanks extends Block implements IWoodTyped { @Override public WoodType getWoodType(int meta) { - if(cat.ordinal() * 16 + meta < WoodType.VALUES.length) - return WoodType.VALUES[cat.ordinal() * 16 + meta]; + int woodOrdinal = cat.ordinal() * planksPerCat + meta; + if(woodOrdinal < WoodType.VALUES.length) + return WoodType.VALUES[woodOrdinal]; else - return WoodType.LARCH; + return null; } @Override diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index fea77be91..f4c865c31 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -38,6 +38,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp CAT0, CAT1, CAT2 } + public static final int slabsPerCat = 8; private final SlabCat cat; public BlockSlab(SlabCat cat) { @@ -64,7 +65,9 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @Override public IIcon getIcon(int side, int meta) { - WoodType type = WoodType.VALUES[(8 * cat.ordinal()) + (meta & 7)]; + WoodType type = getWoodType(meta); + if (type == null) + return null; return type.getPlankIcon(); } @@ -86,8 +89,10 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { - for (int i = 0; i < 8; ++i) - itemList.add(new ItemStack(item, 1, i)); + int totalWoods = WoodType.values().length; + int count = Math.min(totalWoods - (cat.ordinal() * slabsPerCat), slabsPerCat); + for (int i = 0; i < count; i++) + itemList.add(new ItemStack(this, 1, i)); } /* PROPERTIES */ @@ -108,10 +113,11 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @Override public WoodType getWoodType(int meta) { - if(meta + cat.ordinal() * 8 < WoodType.VALUES.length) - return WoodType.VALUES[meta + cat.ordinal() * 8]; + int woodOrdinal = meta + cat.ordinal() * slabsPerCat; + if(woodOrdinal < WoodType.VALUES.length) + return WoodType.VALUES[woodOrdinal]; else - return WoodType.LARCH; + return null; } @Override diff --git a/src/main/java/forestry/arboriculture/items/ItemStairs.java b/src/main/java/forestry/arboriculture/items/ItemStairs.java index 4be8db5c3..56d99ddfd 100755 --- a/src/main/java/forestry/arboriculture/items/ItemStairs.java +++ b/src/main/java/forestry/arboriculture/items/ItemStairs.java @@ -11,10 +11,13 @@ package forestry.arboriculture.items; import forestry.arboriculture.WoodType; +import forestry.arboriculture.gadgets.BlockArbStairs; import forestry.arboriculture.gadgets.TileStairs; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.items.ItemForestryBlock; +import forestry.core.utils.StringUtil; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -61,9 +64,24 @@ public class ItemStairs extends ItemForestryBlock { } @Override - public String getUnlocalizedName(ItemStack stack) { - WoodType type = WoodType.getFromCompound(stack.getTagCompound()); - return getBlock().getUnlocalizedName() + "." + type.ordinal(); //To change body of generated methods, choose Tools | Templates. + public String getItemStackDisplayName(ItemStack itemStack) { + BlockArbStairs block = (BlockArbStairs) getBlock(); + WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); + if (woodType == null) + return null; + + String displayName; + String customUnlocalizedName = "stairs." + woodType.ordinal() + ".name"; + if (StringUtil.canTranslateTile(customUnlocalizedName)) { + displayName = StringUtil.localizeTile(customUnlocalizedName); + } else { + String woodGrammar = StringUtil.localize("stairs.grammar"); + String woodTypeName = StringUtil.localize("trees.woodType." + woodType); + + displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); + } + + return displayName; } } diff --git a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java index 73c61e383..e7cacc288 100755 --- a/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java +++ b/src/main/java/forestry/arboriculture/items/ItemWoodBlock.java @@ -33,8 +33,16 @@ public class ItemWoodBlock extends ItemForestryBlock { if (woodType == null) return null; - String unlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name"; - String displayName = StringUtil.localizeTile(unlocalizedName); + String displayName; + String customUnlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name"; + if (StringUtil.canTranslateTile(customUnlocalizedName)) { + displayName = StringUtil.localizeTile(customUnlocalizedName); + } else { + String woodGrammar = StringUtil.localize(block.getBlockKind() + ".grammar"); + String woodTypeName = StringUtil.localize("trees.woodType." + woodType); + + displayName = woodGrammar.replaceAll("%TYPE", woodTypeName); + } if (this.getBlock() instanceof IWoodFireproof) displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName); diff --git a/src/main/java/forestry/core/utils/StringUtil.java b/src/main/java/forestry/core/utils/StringUtil.java index 75698486a..667ceae4d 100755 --- a/src/main/java/forestry/core/utils/StringUtil.java +++ b/src/main/java/forestry/core/utils/StringUtil.java @@ -22,6 +22,10 @@ public class StringUtil { return StatCollector.canTranslate("for." + key); } + public static boolean canTranslateTile(String key) { + return StatCollector.canTranslate("tile.for." + key); + } + public static String localize(String key) { return StatCollector.translateToLocal("for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@"); } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 43a15c5d5..d8bead8d5 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -10,6 +10,22 @@ ******************************************************************************/ package forestry.plugins; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.WeightedRandomChestContent; + +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; + import cpw.mods.fml.common.IFuelHandler; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -17,6 +33,7 @@ import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; + import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.ITree; import forestry.api.arboriculture.ITreeRoot; @@ -123,19 +140,6 @@ import forestry.core.items.ItemFruit.EnumFruit; import forestry.core.proxy.Proxies; import forestry.core.utils.RecipeUtil; import forestry.core.utils.ShapedRecipeCustom; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; @Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description") public class PluginArboriculture extends ForestryPlugin { @@ -178,7 +182,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.slabs3); private static final EnumSet fences = EnumSet.of( ForestryBlock.fences1, - ForestryBlock.fences1); + ForestryBlock.fences2); @Override public void preInit() { @@ -467,10 +471,15 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i), "###", '#', ForestryBlock.planks2.getItemStack(1, i)); // Fence recipes - for (int i = 0; i < 16; i++) - Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i)); - for (int i = 0; i < 8; i++) - Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i)); + for (WoodType woodType : WoodType.values()) { + int i = woodType.ordinal(); + if (i < 16) + Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i)); + else if (i < 32) + Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); + else + throw new RuntimeException("Wood type has no fences defined"); + } // Treealyzer RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", @@ -494,30 +503,25 @@ public class PluginArboriculture extends ForestryPlugin { RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); // Stairs - for (int i = 0; i < 16; i++) { - WoodType type = WoodType.VALUES[i]; - NBTTagCompound compound = new NBTTagCompound(); - type.saveToCompound(compound); + for (WoodType woodType : WoodType.values()) { + ForestryBlock planks; + int i = woodType.ordinal(); + if (i < 16) + planks = ForestryBlock.planks1; + else if (i < 32) + planks = ForestryBlock.planks2; + else + throw new RuntimeException("Wood type has no planks defined"); - ItemStack stairs = ForestryBlock.stairs.getItemStack(4, 0); + NBTTagCompound compound = new NBTTagCompound(); + woodType.saveToCompound(compound); + + ItemStack stairs = ForestryBlock.stairs.getItemStack(4); stairs.setTagCompound(compound); Proxies.common.addPriorityRecipe(stairs, "# ", "## ", - "###", '#', ForestryBlock.planks1.getItemStack(1, i)); - } - for (int i = 0; i < 8; i++) { - WoodType type = WoodType.VALUES[16 + i]; - NBTTagCompound compound = new NBTTagCompound(); - type.saveToCompound(compound); - - ItemStack stairs = ForestryBlock.stairs.getItemStack(4, 0); - stairs.setTagCompound(compound); - Proxies.common.addPriorityRecipe(stairs, - "# ", - "## ", - "###", - '#', ForestryBlock.planks2.getItemStack(1, i)); + "###", '#', planks.getItemStack(1, i % 16)); } // Grafter From f862485a055e199045a7a97d2f1d3acacd26dc1c Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 1 Jan 2015 19:43:23 -0800 Subject: [PATCH 134/175] Fix #298. xupaosso - Add Ipe, Padauk, Cocobolo, and Zebrawood trees --- .../gadgets/StructureLogicAlveary.java | 3 +- .../VillageHandlerArboriculture.java | 5 +- .../java/forestry/arboriculture/WoodType.java | 23 ++-- .../arboriculture/gadgets/BlockArbStairs.java | 2 - .../arboriculture/gadgets/BlockSlab.java | 2 +- .../arboriculture/genetics/TreeTemplates.java | 37 ++++++ .../worldgen/WorldGenArboriculture.java | 10 ++ .../worldgen/WorldGenCocobolo.java | 57 +++++++++ .../worldgen/WorldGenCrescentia.java | 97 +++++++++++++++ .../arboriculture/worldgen/WorldGenIpe.java | 53 ++++++++ .../worldgen/WorldGenPadauk.java | 77 ++++++++++++ .../worldgen/WorldGenZebrawood.java | 54 ++++++++ .../java/forestry/core/genetics/Allele.java | 5 + .../forestry/core/worldgen/BlockType.java | 8 ++ .../forestry/plugins/PluginArboriculture.java | 116 ++++++++++++++---- .../blocks/germlings/sapling.treeCocobolo.png | Bin 0 -> 423 bytes .../blocks/germlings/sapling.treeIpe.png | Bin 0 -> 1427 bytes .../blocks/germlings/sapling.treePadauk.png | Bin 0 -> 367 bytes .../germlings/sapling.treeZebrawood.png | Bin 0 -> 345 bytes .../textures/blocks/wood/bark.cocobolo.png | Bin 0 -> 881 bytes .../textures/blocks/wood/bark.ipe.png | Bin 0 -> 1465 bytes .../textures/blocks/wood/bark.padauk.png | Bin 0 -> 868 bytes .../textures/blocks/wood/bark.zebrawood.png | Bin 0 -> 920 bytes .../textures/blocks/wood/heart.cocobolo.png | Bin 0 -> 607 bytes .../textures/blocks/wood/heart.ipe.png | Bin 0 -> 1336 bytes .../textures/blocks/wood/heart.padauk.png | Bin 0 -> 652 bytes .../textures/blocks/wood/heart.zebrawood.png | Bin 0 -> 643 bytes .../textures/blocks/wood/planks.cocobolo.png | Bin 0 -> 761 bytes .../textures/blocks/wood/planks.giganteum.png | Bin 0 -> 1382 bytes .../textures/blocks/wood/planks.ipe.png | Bin 0 -> 1396 bytes .../textures/blocks/wood/planks.padauk.png | Bin 0 -> 348 bytes .../textures/blocks/wood/planks.zebrawood.png | Bin 0 -> 861 bytes 32 files changed, 502 insertions(+), 47 deletions(-) create mode 100644 src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java create mode 100644 src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java create mode 100644 src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java create mode 100644 src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java create mode 100644 src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java create mode 100644 src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeCocobolo.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeIpe.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treePadauk.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeZebrawood.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/bark.cocobolo.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/bark.ipe.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/bark.padauk.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/bark.zebrawood.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/heart.cocobolo.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/heart.ipe.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/heart.padauk.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/heart.zebrawood.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/planks.cocobolo.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/planks.giganteum.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/planks.ipe.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/planks.padauk.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/wood/planks.zebrawood.png diff --git a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java index b435e0308..fbe2fad36 100755 --- a/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/StructureLogicAlveary.java @@ -37,8 +37,7 @@ public class StructureLogicAlveary extends StructureLogic { slabBlocks.add(ForestryBlock.slabs1.block()); slabBlocks.add(ForestryBlock.slabs2.block()); slabBlocks.add(ForestryBlock.slabs3.block()); - if (ForestryBlock.slabs4.block() != null) - slabBlocks.add(ForestryBlock.slabs4.block()); + slabBlocks.add(ForestryBlock.slabs4.block()); } public StructureLogicAlveary(ITileStructure structure) { diff --git a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java index 14a2e7f79..bd8340ca7 100755 --- a/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/VillageHandlerArboriculture.java @@ -38,10 +38,7 @@ public class VillageHandlerArboriculture implements IVillageTradeHandler { WoodType sells = WoodType.VALUES[random.nextInt(WoodType.VALUES.length)]; Block plankBlock; int meta; - if(!sells.hasPlank) { - plankBlock = ForestryBlock.planks1.block(); - meta = 0; - } else if(sells.ordinal() > 15) { + if(sells.ordinal() > 15) { plankBlock = ForestryBlock.planks2.block(); meta = sells.ordinal() - 16; } else { diff --git a/src/main/java/forestry/arboriculture/WoodType.java b/src/main/java/forestry/arboriculture/WoodType.java index 623429af3..e9a60777b 100755 --- a/src/main/java/forestry/arboriculture/WoodType.java +++ b/src/main/java/forestry/arboriculture/WoodType.java @@ -19,24 +19,24 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; public enum WoodType { - LARCH, TEAK, ACACIA, LIME, CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f), KAPOK, EBONY, MAHOGANY, BALSA(1.0f), WILLOW, WALNUT, GREENHEART(7.5f), CHERRY, MAHOE, POPLAR, PALM, PAPAYA, PINE( - 3.0f), PLUM, MAPLE, CITRUS, GIGANTEUM(2.0f, false); + LARCH, TEAK, ACACIA, LIME, + CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f), + KAPOK, EBONY, MAHOGANY, BALSA(1.0f), + WILLOW, WALNUT, GREENHEART(7.5f), CHERRY, + MAHOE, POPLAR, PALM, PAPAYA, + PINE(3.0f), PLUM, MAPLE, CITRUS, + GIGANTEUM(2.0f), IPE, PADAUK, COCOBOLO, + ZEBRAWOOD; public static final WoodType[] VALUES = values(); private final float hardness; - public final boolean hasPlank; private WoodType() { - this(2.0f, true); + this(2.0f); } private WoodType(float hardness) { - this(hardness, true); - } - - private WoodType(float hardness, boolean hasPlank) { this.hardness = hardness; - this.hasPlank = hasPlank; } @SideOnly(Side.CLIENT) @@ -49,10 +49,7 @@ public enum WoodType { WoodType woodType = VALUES[i]; String woodName = woodType.toString().toLowerCase(Locale.ENGLISH); - if (woodType.hasPlank) - icons[0][i] = TextureManager.getInstance().registerTex(register, "wood/planks." + woodName); - else - icons[0][i] = null; + icons[0][i] = TextureManager.getInstance().registerTex(register, "wood/planks." + woodName); icons[1][i] = TextureManager.getInstance().registerTex(register, "wood/bark." + woodName); icons[2][i] = TextureManager.getInstance().registerTex(register, "wood/heart." + woodName); } diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index 6c2c5b554..5c9f4ef13 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -53,8 +53,6 @@ public class BlockArbStairs extends BlockStairs { @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (WoodType type : WoodType.VALUES) { - if(!type.hasPlank) - continue; ItemStack stack = new ItemStack(item, 1, 0); NBTTagCompound compound = new NBTTagCompound(); type.saveToCompound(compound); diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index f4c865c31..8126b60d4 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -35,7 +35,7 @@ import forestry.arboriculture.WoodType; public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped { public static enum SlabCat { - CAT0, CAT1, CAT2 + CAT0, CAT1, CAT2, CAT3 } public static final int slabsPerCat = 8; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java b/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java index 13e0d11ad..bfe6e893e 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeTemplates.java @@ -64,6 +64,11 @@ public class TreeTemplates { public static IMutation papayaA; public static IMutation dateA; + public static IMutation ipeA; + public static TreeMutation padaukA; + public static TreeMutation cocoboloA; + public static TreeMutation zebrawoodA; + /* TEMPLATES */ public static IAllele[] getDefaultTemplate() { IAllele[] alleles = new IAllele[EnumTreeChromosome.values().length]; @@ -376,6 +381,38 @@ public class TreeTemplates { return alleles; } + public static IAllele[] getIpeTemplate() { + IAllele[] alleles = getDefaultTemplate(); + alleles[EnumTreeChromosome.SPECIES.ordinal()] = Allele.treeIpe; + alleles[EnumTreeChromosome.SAPPINESS.ordinal()] = Allele.sappinessLower; + alleles[EnumTreeChromosome.HEIGHT.ordinal()] = Allele.heightLarge; + alleles[EnumTreeChromosome.GIRTH.ordinal()] = Allele.int2; + return alleles; + } + + public static IAllele[] getPadaukTemplate() { + IAllele[] alleles = getDefaultTemplate(); + alleles[EnumTreeChromosome.SPECIES.ordinal()] = Allele.treePadauk; + alleles[EnumTreeChromosome.SAPPINESS.ordinal()] = Allele.sappinessLower; + alleles[EnumTreeChromosome.HEIGHT.ordinal()] = Allele.heightLarge; + return alleles; + } + + public static IAllele[] getCocoboloTemplate() { + IAllele[] alleles = getDefaultTemplate(); + alleles[EnumTreeChromosome.SPECIES.ordinal()] = Allele.treeCocobolo; + alleles[EnumTreeChromosome.HEIGHT.ordinal()] = Allele.heightLargest; + return alleles; + } + + public static IAllele[] getZebrawoodTemplate() { + IAllele[] alleles = getDefaultTemplate(); + alleles[EnumTreeChromosome.SPECIES.ordinal()] = Allele.treeZebrawood; + alleles[EnumTreeChromosome.HEIGHT.ordinal()] = Allele.heightLarge; + alleles[EnumTreeChromosome.GIRTH.ordinal()] = Allele.int2; + return alleles; + } + // / HELPER FUNCTIONS public static Chromosome[] templateAsChromosomes(IAllele[] template) { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index e290f424d..0781aa7b3 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -160,7 +160,17 @@ public abstract class WorldGenArboriculture extends WorldGenBase { protected final void addWood(int x, int y, int z, EnumReplaceMode replace) { addBlock(x, y, z, wood, replace); } + + protected final void addXWood(int x, int y, int z, EnumReplaceMode replace) { + BlockType woodX = new BlockType(wood.getBlock(), wood.getMeta() + 4); + addBlock(x, y, z, woodX, replace); + } + protected final void addZWood(int x, int y, int z, EnumReplaceMode replace) { + BlockType woodZ = new BlockType(wood.getBlock(), wood.getMeta() + 8); + addBlock(x, y, z, woodZ, replace); + } + protected final void addLeaf(int x, int y, int z, EnumReplaceMode replace) { addBlock(x, y, z, leaf, replace); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java new file mode 100644 index 000000000..3c92f5fc5 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.arboriculture.worldgen; + +import forestry.api.world.ITreeGenData; + +public class WorldGenCocobolo extends WorldGenTree { + + public WorldGenCocobolo(ITreeGenData tree) { + super(tree); + } + + @Override + public void generate() { + generateTreeTrunk(height, girth); + + int leafSpawn = height; + + addLeaf(0, leafSpawn--, 0, EnumReplaceMode.NONE); + generateAdjustedCylinder(leafSpawn--, 1, 1, leaf); + + if (height > 10) + generateAdjustedCylinder(leafSpawn--, 2, 1, leaf); + generateAdjustedCylinder(leafSpawn, 0, 1, leaf); + + leafSpawn--; + + while (leafSpawn > 4) { + int offset = 1; + if (leafSpawn % 2 == 0) { + if (rand.nextBoolean()) + offset = -1; + generateAdjustedCylinder(leafSpawn, offset, 2, 1, leaf, EnumReplaceMode.NONE); + } else { + if (rand.nextBoolean()) + offset = -1; + generateAdjustedCylinder(leafSpawn, offset, 0, 1, leaf, EnumReplaceMode.NONE ); + } + leafSpawn--; + } + + } + + @Override + public void preGenerate() { + height = determineHeight(8, 8); + girth = determineGirth(tree.getGirth(world, startX, startY, startZ)); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java new file mode 100644 index 000000000..4743541a9 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.arboriculture.worldgen; + +import forestry.api.world.ITreeGenData; + +public class WorldGenCrescentia extends WorldGenTree { + + public WorldGenCrescentia(ITreeGenData tree) { + super(tree); + } + + @Override + public void generate() { + generateTreeTrunk(height, girth); + + int leafSpawn = height + 1; + + generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); + + generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + if (rand.nextBoolean()) + generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + + generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); + + } + + @Override + public void generateTreeTrunk(int height, int girth) { + + int offset = (girth - 1) / 2; + + + //Trunk generation + for (int x = 0; x < girth; x++) //offsets trunk in x direction + for (int z = 0; z < girth; z++) //offsets trunk in z direction + if (x==0 || x==girth-1) { //checks for edges in x direction + if (z==0 || z==girth-1) {//checks for corners + if (x==0 && z==0) {}//xz corner + if (x==girth-1 && z==0) {}//x-1z corner + if (x==0 && z==girth-1) {}//xz-1 corner + if (x==girth-1 && z==0) {} //x-1z-1 corner + } else { //these are the z only edges + if (x==0) { + + } else if (x==girth-1) { + + } + } + } else if (z==0 || z==girth-1) { //these are the x only edges + if (z==0) { + + } else if (z==girth-1) { + + } + } else { //these are center pieces + for (int i = 0; i < height; i++) { //grows trunk straight up in y direction to the correct height + addWood(x - offset, i, z - offset, EnumReplaceMode.ALL); + } + } + + //End trunk generation + + //Spawn pods + for (int y = minPodHeight; y < height; y++) + for (int x = 0; x < girth; x++) + for (int z = 0; z < girth; z++) { + + if ((x > 0 && x < girth) && (z > 0 && z < girth)) + continue; + + tree.trySpawnFruitBlock(world, startX + x + 1, startY + y, startZ + z); + tree.trySpawnFruitBlock(world, startX + x - 1, startY + y, startZ + z); + tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z + 1); + tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z - 1); + } + + + } + + @Override + public void preGenerate() { + height = determineHeight(6, 3); + girth = determineGirth(tree.getGirth(world, startX, startY, startZ)); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java new file mode 100644 index 000000000..e461240d6 --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.arboriculture.worldgen; + +import forestry.api.world.ITreeGenData; + +public class WorldGenIpe extends WorldGenTree { + + public WorldGenIpe(ITreeGenData tree) { + super(tree); + } + + @Override + public void generate() { + generateTreeTrunk(height, girth); + + int leafSpawn = height + 1; + float adjustedGirth = girth*.65f; + + generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.2f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.2f*adjustedGirth, 1, leaf); + + while (leafSpawn > 7) { + generateAdjustedCylinder(leafSpawn, (float) (1.25f*(adjustedGirth * .65)), 1, leaf); + leafSpawn--; + } + + generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.6f*adjustedGirth, 1, leaf); + + if (rand.nextBoolean()) + generateAdjustedCylinder(leafSpawn--, 1.25f*adjustedGirth, 1, leaf); + + generateAdjustedCylinder(leafSpawn--, 1f*adjustedGirth, 1, leaf); + + } + + @Override + public void preGenerate() { + height = determineHeight(8, 8); + girth = determineGirth(tree.getGirth(world, startX, startY, startZ)); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java new file mode 100644 index 000000000..c5463d9ee --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPadauk.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.arboriculture.worldgen; + +import java.util.Random; + +import forestry.api.world.ITreeGenData; + +public class WorldGenPadauk extends WorldGenTree { + + public WorldGenPadauk(ITreeGenData tree) { + super(tree); + + minHeight = 7; + } + + @Override + public void generate() { + generateTreeTrunk(height, girth); + + + int leafSpawn = height + 1; + + generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.5f, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 3f, 1, leaf); + + int count = 0; + int max = 3; + int min = 1; + int canopyHeight = rand.nextInt(max - min + 1) + min; + + while (leafSpawn > 3 && count < canopyHeight) { + generateAdjustedCylinder(leafSpawn--, 4.5f, 1, leaf); + count++; + //Random Trunk Branches + for (int i = 0; i < girth*4; i++) { + if (rand.nextBoolean()){ + + int[] offset = {-1, 1}; + int offsetValue = (offset[new Random().nextInt(offset.length)]); + int maxBranchLength = 3; + int branchLength = new Random().nextInt(maxBranchLength+1); + char[] direction = {'z', 'x'}; + char directionValue = (direction[new Random().nextInt(direction.length)]); + int branchSpawn = leafSpawn; + + for (int j = 1; j < branchLength+1; j++) { + if (j == branchLength && rand.nextBoolean()) { //Just adding a bit of variation to the ends for character + branchSpawn += 1; + } + if (directionValue == 'z') { + addZWood(0, branchSpawn, j*offsetValue, EnumReplaceMode.ALL); + } else if (directionValue == 'x'){ + addXWood(j*offsetValue, branchSpawn, 0, EnumReplaceMode.ALL); + } + } + + } + } + } + } + + @Override + public void preGenerate() { + height = determineHeight(6, 6); + girth = determineGirth(tree.getGirth(world, startX, startY, startZ)); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java new file mode 100644 index 000000000..259039f1c --- /dev/null +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.arboriculture.worldgen; + +import forestry.api.world.ITreeGenData; + +public class WorldGenZebrawood extends WorldGenTree { + + public WorldGenZebrawood(ITreeGenData tree) { + super(tree); + } + + @Override + public void generate() { + + generateTreeTrunk(height, girth); + + int leafSpawn = height + 1; + + generateAdjustedCylinder(leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 0.5f, 1, leaf); + + generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + + while (leafSpawn > height - 4) + generateAdjustedCylinder(leafSpawn--, 2.5f, 1, leaf); + generateAdjustedCylinder(leafSpawn--, 1.9f, 1, leaf); + + // Add some smaller twigs below for flavour + for (int times = 0; times < height / 4; times++) { + int h = 10 + rand.nextInt(Math.max(1, height - 10)); + if (rand.nextBoolean() && h < height / 2) + h = height / 2 + rand.nextInt(height / 2); + int x_off = -1 + rand.nextInt(3); + int y_off = -1 + rand.nextInt(3); + generateSphere(new Vector(x_off, h, y_off), 1 + rand.nextInt(1), leaf, EnumReplaceMode.NONE); + } + + } + + @Override + public void preGenerate() { + height = determineHeight(8, 8); + girth = determineGirth(tree.getGirth(world, startX, startY, startZ)); + } +} diff --git a/src/main/java/forestry/core/genetics/Allele.java b/src/main/java/forestry/core/genetics/Allele.java index f87886311..660a59dc2 100755 --- a/src/main/java/forestry/core/genetics/Allele.java +++ b/src/main/java/forestry/core/genetics/Allele.java @@ -168,6 +168,11 @@ public class Allele implements IAllele { public static AlleleSpecies treeMaple; + public static AlleleSpecies treeIpe; + public static AlleleSpecies treePadauk; + public static AlleleSpecies treeCocobolo; + public static AlleleSpecies treeZebrawood; + /// BUTTERFLIES // SPECIES // Moths public static AlleleSpecies mothBrimstone; diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java index 222d65467..5eb2a6327 100755 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ b/src/main/java/forestry/core/worldgen/BlockType.java @@ -36,4 +36,12 @@ public class BlockType { if (world.getTileEntity(x, y, z) != null) world.removeTileEntity(x, y, z); } + + public int getMeta() { + return this.meta; + } + + public Block getBlock() { + return this.block; + } } diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index d8bead8d5..f84ababe2 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -101,11 +101,13 @@ import forestry.arboriculture.worldgen.WorldGenBaobab; import forestry.arboriculture.worldgen.WorldGenBirch; import forestry.arboriculture.worldgen.WorldGenCherry; import forestry.arboriculture.worldgen.WorldGenChestnut; +import forestry.arboriculture.worldgen.WorldGenCocobolo; import forestry.arboriculture.worldgen.WorldGenDarkOak; import forestry.arboriculture.worldgen.WorldGenDate; import forestry.arboriculture.worldgen.WorldGenEbony; import forestry.arboriculture.worldgen.WorldGenGiganteum; import forestry.arboriculture.worldgen.WorldGenGreenheart; +import forestry.arboriculture.worldgen.WorldGenIpe; import forestry.arboriculture.worldgen.WorldGenJungle; import forestry.arboriculture.worldgen.WorldGenKapok; import forestry.arboriculture.worldgen.WorldGenLarch; @@ -115,6 +117,7 @@ import forestry.arboriculture.worldgen.WorldGenMahoe; import forestry.arboriculture.worldgen.WorldGenMahogany; import forestry.arboriculture.worldgen.WorldGenMaple; import forestry.arboriculture.worldgen.WorldGenOak; +import forestry.arboriculture.worldgen.WorldGenPadauk; import forestry.arboriculture.worldgen.WorldGenPapaya; import forestry.arboriculture.worldgen.WorldGenPine; import forestry.arboriculture.worldgen.WorldGenPlum; @@ -125,6 +128,7 @@ import forestry.arboriculture.worldgen.WorldGenTeak; import forestry.arboriculture.worldgen.WorldGenWalnut; import forestry.arboriculture.worldgen.WorldGenWenge; import forestry.arboriculture.worldgen.WorldGenWillow; +import forestry.arboriculture.worldgen.WorldGenZebrawood; import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; @@ -161,7 +165,8 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.log4, ForestryBlock.log5, ForestryBlock.log6, - ForestryBlock.log7); + ForestryBlock.log7, + ForestryBlock.log8); public static final EnumSet fireproofLogs = EnumSet.of( ForestryBlock.fireproofLog1, ForestryBlock.fireproofLog2, @@ -169,7 +174,8 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.fireproofLog4, ForestryBlock.fireproofLog5, ForestryBlock.fireproofLog6, - ForestryBlock.fireproofLog7); + ForestryBlock.fireproofLog7, + ForestryBlock.fireproofLog8); private static final EnumSet planks = EnumSet.of( ForestryBlock.planks1, ForestryBlock.planks2); @@ -179,7 +185,8 @@ public class PluginArboriculture extends ForestryPlugin { private static final EnumSet slabs = EnumSet.of( ForestryBlock.slabs1, ForestryBlock.slabs2, - ForestryBlock.slabs3); + ForestryBlock.slabs3, + ForestryBlock.slabs4); private static final EnumSet fences = EnumSet.of( ForestryBlock.fences1, ForestryBlock.fences2); @@ -195,6 +202,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.log5.registerBlock(new BlockLog(LogCat.CAT4), ItemWoodBlock.class, "log5"); ForestryBlock.log6.registerBlock(new BlockLog(LogCat.CAT5), ItemWoodBlock.class, "log6"); ForestryBlock.log7.registerBlock(new BlockLog(LogCat.CAT6), ItemWoodBlock.class, "log7"); + ForestryBlock.log8.registerBlock(new BlockLog(LogCat.CAT7), ItemWoodBlock.class, "log8"); for (ForestryBlock log : logs) { log.block().setHarvestLevel("axe", 0); @@ -208,6 +216,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.fireproofLog5.registerBlock(new BlockFireproofLog(LogCat.CAT4), ItemWoodBlock.class, "fireproofLog5"); ForestryBlock.fireproofLog6.registerBlock(new BlockFireproofLog(LogCat.CAT5), ItemWoodBlock.class, "fireproofLog6"); ForestryBlock.fireproofLog7.registerBlock(new BlockFireproofLog(LogCat.CAT6), ItemWoodBlock.class, "fireproofLog7"); + ForestryBlock.fireproofLog8.registerBlock(new BlockFireproofLog(LogCat.CAT7), ItemWoodBlock.class, "fireproofLog8"); for (ForestryBlock fireproofLog : fireproofLogs) { fireproofLog.block().setHarvestLevel("axe", 0); @@ -233,6 +242,7 @@ public class PluginArboriculture extends ForestryPlugin { ForestryBlock.slabs1.registerBlock(new BlockSlab(SlabCat.CAT0), ItemWoodBlock.class, "slabs1"); ForestryBlock.slabs2.registerBlock(new BlockSlab(SlabCat.CAT1), ItemWoodBlock.class, "slabs2"); ForestryBlock.slabs3.registerBlock(new BlockSlab(SlabCat.CAT2), ItemWoodBlock.class, "slabs3"); + ForestryBlock.slabs4.registerBlock(new BlockSlab(SlabCat.CAT3), ItemWoodBlock.class, "slabs4"); for (ForestryBlock plank : slabs) { plank.block().setHarvestLevel("axe", 0); @@ -394,6 +404,10 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, i), ForestryBlock.log5.getItemStack(1, i)); for (int i = 0; i < 4; i++) Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 4 + i), ForestryBlock.log6.getItemStack(1, i)); + for (int i = 0; i < 4; i++) + Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 8 + i), ForestryBlock.log7.getItemStack(1, i)); + for (int i = 0; i < 1; i++) + Proxies.common.addShapelessRecipe(ForestryBlock.planks2.getItemStack(4, 12 + i), ForestryBlock.log8.getItemStack(1, i)); // Fabricator recipes if (PluginManager.Module.FACTORY.isEnabled() && PluginManager.Module.APICULTURE.isEnabled()) { @@ -403,11 +417,8 @@ public class PluginArboriculture extends ForestryPlugin { BlockLog blockLog = (BlockLog) forestryBlock.block(); ForestryBlock fireproofLog = BlockFireproofLog.getFireproofLog(blockLog); - if (forestryBlock == ForestryBlock.log8) - continue; - for (int i = 0; i < 4; i++) { - if (forestryBlock == ForestryBlock.log7 && i > 0) + if (forestryBlock == ForestryBlock.log8 && i > 0) break; ItemStack logStack = forestryBlock.getItemStack(1, i); @@ -435,7 +446,7 @@ public class PluginArboriculture extends ForestryPlugin { 'X', plankStack}); } plank = ForestryBlock.planks2; - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 12; i++) { ForestryBlock fireproofPlank = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks)plank.block()); ItemStack plankStack = plank.getItemStack(1, i); ItemStack fireproofPlankStack = fireproofPlank.getItemStack(5, i); @@ -461,14 +472,25 @@ public class PluginArboriculture extends ForestryPlugin { Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, i), ForestryBlock.fireproofLog5.getItemStack(1, i)); for (int i = 0; i < 4; i++) Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 4 + i), ForestryBlock.fireproofLog6.getItemStack(1, i)); + for (int i = 0; i < 4; i++) + Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 8 + i), ForestryBlock.fireproofLog7.getItemStack(1, i)); + for (int i = 0; i < 1; i++) + Proxies.common.addShapelessRecipe(ForestryBlock.fireproofPlanks2.getItemStack(4, 12 + i), ForestryBlock.fireproofLog8.getItemStack(1, i)); // Slab recipes - for (int i = 0; i < 8; i++) - Proxies.common.addPriorityRecipe(ForestryBlock.slabs1.getItemStack(6, i), "###", '#', ForestryBlock.planks1.getItemStack(1, i)); - for (int i = 0; i < 8; i++) - Proxies.common.addPriorityRecipe(ForestryBlock.slabs2.getItemStack(6, i), "###", '#', ForestryBlock.planks1.getItemStack(1, 8 + i)); - for (int i = 0; i < 8; i++) - Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i), "###", '#', ForestryBlock.planks2.getItemStack(1, i)); + for (WoodType woodType : WoodType.values()) { + int i = woodType.ordinal(); + if (i < 8) + Proxies.common.addPriorityRecipe(ForestryBlock.slabs1.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); + else if (i < 16) + Proxies.common.addPriorityRecipe(ForestryBlock.slabs2.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); + else if (i < 24) + Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); + else if (i < 32) + Proxies.common.addPriorityRecipe(ForestryBlock.slabs4.getItemStack(6, i % 8), "###", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); + else + throw new RuntimeException("Wood type has no slabs defined"); + } // Fence recipes for (WoodType woodType : WoodType.values()) { @@ -629,6 +651,9 @@ public class PluginArboriculture extends ForestryPlugin { IClassification lamiaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( EnumClassLevel.FAMILY, "lamiaceae", "Lamiaceae"); lamiales.addMemberGroup(lamiaceae); + IClassification bignoniaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( + EnumClassLevel.FAMILY, "bignoniaceae", "Bignoniaceae"); + lamiales.addMemberGroup(bignoniaceae); IClassification ebenaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( EnumClassLevel.FAMILY, "ebenaceae", "Ebenaceae"); @@ -656,7 +681,11 @@ public class PluginArboriculture extends ForestryPlugin { IClassification sapindaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( EnumClassLevel.FAMILY, "sapindaceae", "Sapindaceae"); sapindales.addMemberGroup(sapindaceae); - + IClassification anacardiaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( + EnumClassLevel.FAMILY, "anacardiaceae", "Anacardiaceae"); + sapindales.addMemberGroup(anacardiaceae); + + IClassification caricaceae = AlleleManager.alleleRegistry.createAndRegisterClassification( EnumClassLevel.FAMILY, "caricaceae", "Caricaceae"); brassicales.addMemberGroup(caricaceae); @@ -705,7 +734,17 @@ public class PluginArboriculture extends ForestryPlugin { fabaceae.addMemberGroup(acacia); IClassification millettia = new BranchTrees("millettia", "Millettia"); fabaceae.addMemberGroup(millettia); - + IClassification dalbergia = new BranchTrees("dalbergia", "Dalbergia"); + fabaceae.addMemberGroup(dalbergia); + IClassification pterocarpus = new BranchTrees("pterocarpus", "Pterocarpus"); + fabaceae.addMemberGroup(pterocarpus); + + IClassification tabebuia = new BranchTrees("tabebuia", "Tabebuia"); + bignoniaceae.addMemberGroup(tabebuia); + + IClassification astronium = new BranchTrees("astronium", "Astronium"); + anacardiaceae.addMemberGroup(astronium); + IClassification ochroma = new BranchTrees("ochroma", "Ochroma"); malvaceae.addMemberGroup(ochroma); @@ -778,6 +817,11 @@ public class PluginArboriculture extends ForestryPlugin { final ItemStack lemonLog = ForestryBlock.log6.getItemStack(1, 3); final ItemStack giganteumLog = ForestryBlock.log7.getItemStack(1, 0); + final ItemStack ipeLog = ForestryBlock.log7.getItemStack(1, 1); + final ItemStack padaukLog = ForestryBlock.log7.getItemStack(1, 2); + final ItemStack cocoboloLog = ForestryBlock.log7.getItemStack(1, 3); + + final ItemStack zebrawoodLog = ForestryBlock.log8.getItemStack(1, 0); // Deciduous Allele.treeOak = new AlleleTreeSpecies("treeOak", false, "appleOak", quercus, "robur", @@ -843,8 +887,11 @@ public class PluginArboriculture extends ForestryPlugin { "tectona", proxy.getFoliageColorBasic(), 0x539d12, WorldGenJungle.class, jungleLog) .addFruitFamily(jungle).setLeafIndices("jungle").setVanillaMap(3); Allele.treeTeak = new AlleleTreeSpecies("treeTeak", true, "teak", tectona, "grandis", - 0xfeff8f, 0xffd98f, WorldGenTeak.class, teakLog).addFruitFamily(jungle).setLeafIndices( - "jungle"); + 0xfeff8f, 0xffd98f, WorldGenTeak.class, teakLog) + .addFruitFamily(jungle).setLeafIndices("jungle"); + Allele.treeIpe = new AlleleTreeSpecies("treeIpe", true, "ipe", tabebuia, "serratifolia", + 0xfdd207, 0xad8f04, WorldGenIpe.class, ipeLog) + .addFruitFamily(jungle).setLeafIndices("jungle").setGirth(2); Allele.treeKapok = new AlleleTreeSpecies("treeKapok", true, "kapok", ceiba, "pentandra", 0x89987b, 0x89aa9e, WorldGenKapok.class, kapokLog).addFruitFamily(jungle) .addFruitFamily(prunes).setLeafIndices("jungle"); @@ -853,6 +900,9 @@ public class PluginArboriculture extends ForestryPlugin { Allele.treeEbony = new AlleleTreeSpecies("treeEbony", true, "myrtleEbony", diospyros, "pentamera", 0xa2d24a, 0xc4d24a, WorldGenEbony.class, ebonyLog).addFruitFamily(jungle) .addFruitFamily(prunes).setGirth(3).setLeafIndices("jungle"); + Allele.treeZebrawood = new AlleleTreeSpecies("treeZebrawood", false, "zebrawood", astronium, + "graveolens", 0xa2d24a, 0xc4d24a, WorldGenZebrawood.class, zebrawoodLog) + .addFruitFamily(nux).setGirth(2).setLeafIndices("jungle"); // Diospyros mespiliformis, the Jackalberry (also known as African Ebony // The Gaub Tree, Malabar ebony, Black-and-white Ebony or Pale Moon @@ -883,8 +933,12 @@ public class PluginArboriculture extends ForestryPlugin { Allele.treeDesertAcacia = new AlleleTreeSpecies("treeAcacia", true, "desertAcacia", acacia, "erioloba", 0x748C1C, 0xb3b302, WorldGenAcacia.class, desertAcaciaLog).addFruitFamily(jungle) .addFruitFamily(nux); + Allele.treePadauk = new AlleleTreeSpecies("treePadauk", true, "padauk", pterocarpus, + "soyauxii", 0xd0df8c, 0x435c32, WorldGenPadauk.class, padaukLog).addFruitFamily(jungle); Allele.treeBalsa = new AlleleTreeSpecies("treeBalsa", true, "balsa", ochroma, "pyramidale", 0x59ac00, 0xfeff8f, WorldGenBalsa.class, balsaLog).addFruitFamily(jungle).addFruitFamily(nux); + Allele.treeCocobolo = new AlleleTreeSpecies("treeCocobolo", false, "cocobolo", dalbergia, "retusa", + 0x6aa17a, 0x487d4c, WorldGenCocobolo.class, cocoboloLog).addFruitFamily(jungle); Allele.treeWenge = new AlleleTreeSpecies("treeWenge", true, "wenge", millettia, "laurentii", 0xada157, 0xad8a57, WorldGenWenge.class, wengeLog).addFruitFamily(jungle) .addFruitFamily(nux).setGirth(2); @@ -965,10 +1019,14 @@ public class PluginArboriculture extends ForestryPlugin { treeInterface.registerTemplate(TreeTemplates.getDesertAcaciaTemplate()); treeInterface.registerTemplate(TreeTemplates.getWengeTemplate()); treeInterface.registerTemplate(TreeTemplates.getBaobabTemplate()); - + treeInterface.registerTemplate(TreeTemplates.getPadaukTemplate()); + treeInterface.registerTemplate(TreeTemplates.getCocoboloTemplate()); + treeInterface.registerTemplate(TreeTemplates.getTeakTemplate()); + treeInterface.registerTemplate(TreeTemplates.getIpeTemplate()); treeInterface.registerTemplate(TreeTemplates.getKapokTemplate()); treeInterface.registerTemplate(TreeTemplates.getEbonyTemplate()); + treeInterface.registerTemplate(TreeTemplates.getZebrawoodTemplate()); treeInterface.registerTemplate(TreeTemplates.getMahoganyTemplate()); treeInterface.registerTemplate(TreeTemplates.getWillowTemplate()); @@ -1019,7 +1077,7 @@ public class PluginArboriculture extends ForestryPlugin { // Decidious TreeTemplates.limeA = new TreeMutation(Allele.treeBirch, Allele.treeOak, TreeTemplates.getLimeTemplate(), 15); - TreeTemplates.mapleA = new TreeMutation(Allele.treeLime, Allele.treeLarch, + TreeTemplates.mapleA = new TreeMutation(Allele.treeSpruce, Allele.treeLarch, TreeTemplates.getMapleTemplate(), 5); // Fructifera @@ -1051,12 +1109,16 @@ public class PluginArboriculture extends ForestryPlugin { TreeTemplates.getSequoiaTemplate(), 5); // Tropical - TreeTemplates.teakA = new TreeMutation(Allele.treeLime, Allele.treeJungle, + TreeTemplates.teakA = new TreeMutation(Allele.treeDarkOak, Allele.treeJungle, TreeTemplates.getTeakTemplate(), 10); + TreeTemplates.ipeA = new TreeMutation(Allele.treeTeak, Allele.treeDarkOak, + TreeTemplates.getIpeTemplate(), 10); TreeTemplates.kapokA = new TreeMutation(Allele.treeJungle, Allele.treeTeak, TreeTemplates.getKapokTemplate(), 10); - TreeTemplates.ebonyA = new TreeMutation(Allele.treeKapok, Allele.treeTeak, + TreeTemplates.ebonyA = new TreeMutation(Allele.treeDarkOak, Allele.treeKapok, TreeTemplates.getEbonyTemplate(), 10); + TreeTemplates.zebrawoodA = new TreeMutation(Allele.treeEbony, Allele.treePoplar, + TreeTemplates.getZebrawoodTemplate(), 5); TreeTemplates.mahoganyA = new TreeMutation(Allele.treeKapok, Allele.treeEbony, TreeTemplates.getMahoganyTemplate(), 10); @@ -1066,15 +1128,19 @@ public class PluginArboriculture extends ForestryPlugin { TreeTemplates.getDateTemplate(), 5); // Malva - TreeTemplates.balsaA = new TreeMutation(Allele.treeTeak, Allele.treeLime, + TreeTemplates.balsaA = new TreeMutation(Allele.treeTeak, Allele.treeAcacia, TreeTemplates.getBalsaTemplate(), 10); TreeTemplates.acaciaA = new TreeMutation(Allele.treeTeak, Allele.treeBalsa, TreeTemplates.getDesertAcaciaTemplate(), 10); - TreeTemplates.wengeA = new TreeMutation(Allele.treeDesertAcacia, Allele.treeBalsa, + TreeTemplates.padaukA = new TreeMutation(Allele.treeAcacia, Allele.treeJungle, + TreeTemplates.getPadaukTemplate(), 10); + TreeTemplates.cocoboloA = new TreeMutation(Allele.treeDesertAcacia, Allele.treeDarkOak, + TreeTemplates.getCocoboloTemplate(), 10); + TreeTemplates.wengeA = new TreeMutation(Allele.treeCocobolo, Allele.treeBalsa, TreeTemplates.getWengeTemplate(), 10); TreeTemplates.baobabA = new TreeMutation(Allele.treeBalsa, Allele.treeWenge, TreeTemplates.getBaobabTemplate(), 10); - TreeTemplates.mahoeA = new TreeMutation(Allele.treeBirch, Allele.treeDesertAcacia, + TreeTemplates.mahoeA = new TreeMutation(Allele.treeBalsa, Allele.treeDesertAcacia, TreeTemplates.getMahoeTemplate(), 5); TreeTemplates.willowA = new TreeMutation(Allele.treeOak, Allele.treeBirch, diff --git a/src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeCocobolo.png b/src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeCocobolo.png new file mode 100644 index 0000000000000000000000000000000000000000..f017d5b9a4ac9f7edd1badb13d8723f5f7fd02fe GIT binary patch literal 423 zcmV;Y0a*TtP)3-r5QVo)X^}du zR*ESiqUJ1YG%1Y233e7XR)P^yshuE*T_8>VfxmI%H{63&ZUc%BhGA#-y?HZt?r!)v zbUaZQ6tc=WmdA}B9h2-70gogSW+MF={M*35gWa^}$H|lHty^9pk*I(!Ak z7H4lYvwBHV`6C=w7BU}Z#vkw9{Hwn-kfvX+Nhh^J=Muc-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z)ZE-iN5ROz&_v(BP~Xs4*U-|+#Kg+LKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD#PU%0_}#n6BP2AO_EVu8M)o`HUDF34YC)x{-2sR(CaRb3oXS&*t9 zlvryA&s6}2k5wiXH@KLZ znmL-88<`uqIfC79>f+>N>SpNVZ06`_Zswu{)tiFF?@+zQIQ8lS9itD5T%^c`2?0|O zhzU=+Kn^_dr{)1ud=W5d?^NEmgMopG+0(@_q~caf@Okf$K#_m%_P#&sqc5n$)fM$b zX;DV#1+UHWEUc}rEN@$;i3*0eY!fWLtmOE=Ws<@jO;OhiyPT9RhMYQ?b1bt+$Mtw& z+BxgH)#-C)elL2XbN=VP_chPwRI?f%Zm}0S{6FcN_{Y9nuPe_|BuwV2_$}!;{IjI3 z;*Iu)FO?g<^&go2-l1sSEyIaw{|vnL)UFnKS-IeKqDU!gT3YA&`@KnZj1@)^n`Zkk zFZ+D(v0z<*n!jIoEDMX>aYjX!y0kBTrzUXDt-kX5AkVrbEsIt3Vn1rhY`iDLFH?N; zI@i8+rg>cnTRp-Se7?tZ%TFTw$S(e#!wn8Lj%VyHY>DptyS7iX(s)90#LT=By}Z;C1rt33 zJ>#Bd(*uBN9(cMqhFJLTowSjc$xwjhuAq=AgQSq8(80+U7)=;h1tv_oz^HnGkx@2) z!Byf|QrxyD^|qYak?Hflf4ipMzW>ojn`7^{Nl(afDVpspy!`Br_>{fzYD(2dZG_{m zhi+#`;po1*=55OL&t)R{%RQs!>M7jU|Liis#bt_-V@H;^O#unGvP^H(_xntFU&+Z40g==>$sqLzXM19QWK7^H{#iz0sYG0>FVdQ I&MBb@0CS6o7XSbN literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeZebrawood.png b/src/main/resources/assets/forestry/textures/blocks/germlings/sapling.treeZebrawood.png new file mode 100644 index 0000000000000000000000000000000000000000..5c681b97ffb4c7fd5732ceb32ff5fedc7e546af8 GIT binary patch literal 345 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ>#Bd(*uBNPIQo+jI25b!6*=h@=|RvwAtPfZlO_eA^t k-EG;PrT1Ij?OZKGWXzQ-yp59-fWBhzboFyt=akR{0LguXLjV8( literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/bark.cocobolo.png b/src/main/resources/assets/forestry/textures/blocks/wood/bark.cocobolo.png new file mode 100644 index 0000000000000000000000000000000000000000..23c727615382e885b1f963a46c361cc64db06680 GIT binary patch literal 881 zcmV-%1CIQOP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0^&(TK~y+T4a?hil5hY3U|xIebX{w!+)YcJ zP8|Z`4MhYI1jVV~&nw{FP;<7;&CP1lZadx1>GIe^PyLDYy?>CL4vavU2|1P%AoJ+! zQU16iPrI_h!qYlgOzyW1F#Q1ILzZmBOzy4x4|rW>SvvG>0?I<*?S)Y)3ZG9)uZGQj zRaD}3Y-gK5EiZu^Fs`tB2jW?@l8G>J{CX@4(Txvt^>Wso8Q{Dt)dd11?1~th_KCK% zrgM&<^)}Q{#ZHB!DePPm3Q6nYw4CMf4CxwInZvrosYh)APQaVcKoyO$ zhooJvJKW{C`u?ObZc9ZDZ7Qq*c)`EH;68<1t0f%GTr9Y6gRbY#4>gQRcxF1?R;cB% zcGNGvP^AJJ9GCd0=OK-`=MA(%I!VORlUZmvZH?=2Ebcm0V<&xZ*vcnEjslGe5qMhV zE158{XTGS}bOw8Bx>u!a&|x=o*~QXQa5><#0@o>L{=Dt}x@ae({&S5U)>zEG{-$o$ z1^k(5)ezm#*$d^W=ZnUi6?%Kvs^nAD*HQZWICtEXIoxvE!k_gq?MfkB8ogyqnoJHG-<;VaZ}5qK-iVT7HB@meQ8_$*xtu}R!!|wA-E$aG{z%P zzQ6C9bi_OBI7XbQ2mHOVk8!O+1_%teHN>@Xr7>j=AuxNZ5EF@TS{y0g6>ID2KcOhKi00000NkvXX Hu0mjfb(y84 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/bark.ipe.png b/src/main/resources/assets/forestry/textures/blocks/wood/bark.ipe.png new file mode 100644 index 0000000000000000000000000000000000000000..dcc0e33aeb8697219dd5b9fcd3e90d66de19a72a GIT binary patch literal 1465 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nAI{vB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z)ZE-iN5ROz&_v(BP~Xs4*U-|+#Kg+LKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0!ZY(y z^2>`g!FqgstvvIJOA_;vQ$1a5m4K$`WoD*Wxi}e^IGUKcn44HQ85+8pI2yRRS~{CK znVA|ITR0jS!1TK0Czs}?=9R$orXcjX;?xUD4!H$Dn_W_iGRsm^+=}vZ6~NxM%Eav! zC!FR%^`_u)ze_-u_}^5$X{7Dzx&gaQ)K%{}=LyYP+g7Y&?7G-s)z z(=FGsW;MmAl+03_=r(7$xaFg|x9z*~G?!+IEK1yc+hlHtmwC|KT@NpLeaj7A=+`TC zj7!kHXP>Q$m88YJI+OL96ELR$N7zS-`B@H zJrJkW_g27w!);1JhS1`Jk4{!LvAvHuHrZKOf4S7;44(Ch&IhjY>g~%in7gy0{&}0+ iktSIKvG4zxco=3%CrnwC#l#0HOg&xwT-G@yGywq1xg~Z0 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/bark.padauk.png b/src/main/resources/assets/forestry/textures/blocks/wood/bark.padauk.png new file mode 100644 index 0000000000000000000000000000000000000000..e281270dbb989dce89f9bc356aee30de60a1c4d1 GIT binary patch literal 868 zcmV-q1DpJbP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0@X=GK~y+T9g^uz8etfP=YATiwICq-zRECw z+NKxLC8=ArR9e?4prULA24+L8nkt$`MchUf7j}k;F};<(Hu-*jPtG~-IS4uNnw}JH zdqn#){l`nn^A!!dt}lj7w=ru4M;nBzMGtbBA)Xn0q+L&x;~8Kkg*(%t?40z}r@C6x z6+(t`)O;Ve)lyiKa<`e`PG*?T3_dddf%Hf>G2Z)YT6{1g$p^Hhh`AWnm%{pL(q2zH z+w^c}^DRfYT9osNas6db1Rw2%xA|3=ofV%2RHc}u5Z1FnBVGHgvtsj0r-v(lplMb59e4C=1e^;fG(HmE9wb$4-dHH}sYM~!l}nE{S8 zBJ>m}NOrvaM+@?kWhhR49#DV+8&sEKrn`i-k{YOzSe+SaQT7(DMbcwE_~@%Gk0?7Y zKlN+!0riSlUK6FJtz1*4>?a#>$=Vdv+8e-)A@_ayE2km6WYcy131E9m>HabVw44 z8+#t?j#rYMmqBibak-{pHz0%QK546_9Z&^qsRLybb_9MC6N1cC-|lw_94hBmU94)^ ubzL!Hyo+0_DYQYt!rdJ0=4t06iT(pdahsloPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0|`k)K~y+T9gd18I)qZ-RQqxzaEw2eLir~+WYqR*`UG=3%y)e=A&o5{YG+2=KNC94R!O; zqnDh-`~Tl?ALK$ZANe5G6yWRSqlcxqlB0*r&??zbx0HsYw5O9Il?)-Lh%QIAlVm4N zb+Um*hEn*@K|ay}Zh^tuneA4b6le@;G3z3`p>R}-u}j>4k;q^Q@U&Qao5g#%=W>RS zQtM)h5ExX5+8`NhpLD8U{`x5MVS%>Scd!xI&5vvVA^DZPqtQ5Uy?itLJ3o+{~*fc<=2SRic-qfp|hI^a3QQ*M`wPMUN z<9>8!`;T#_{;qd%g82OgX}C?y{Sx|f9I9p#rm0bjW^8HV#`4%@YDE{cE?TCqF8%rw zsv8Sh9v{^!)XGESZ&!_~i>qT7A%}iqK{X1`sHbmU9=~*M^2+(CD?g}yK5v;*nRQc$ z_MQ(z?qB;+ed&Vs)`;f%2$aT6Sqgoxv?I1f&%)$}UcIipYuBor1~r4PdX{E=He=yA z4jc>d)k*5nZHRNiEILmkh9qW8*$qi_KKWG7ZS3(nU#s}h uc8>WZ31Zy!DzZ@vt?j2g$Bo@u!1^8Pjf<{TZdc|20000Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0nkZAK~y+TU6TE4QgIl?4@9tm5frVltt4qJ z7wxS~+ti#AW~o<~i?(s?R%xv@ ze-GQ^>V$ogi(OZ>yz=IpCZ#DUBL5+tl?rEk5+EjRhqQY0f|`vQ(zw(*ug~Fsa4_yi z%733eg@$XT#Iz0@wHG1313BwXG*E(QG83%E=k%+002@0Ikf2+7Xc!Ku!jO=+Zdu3O zmfd45TL$tetp1IWpfF90Y!~MAasLV1@cw&k-jvn~Ae)yS4NgqZuEq52eI3@AIUS5- z4gyZF&ImKp=i%a{`X6>#&URq?(E%~^PRzk2Mun7?E~($y;RBH{Paywc*j6_;tKQ)z zg?YCQ>`ekfG$0^_Z}8&nDYd-}3<0)Ki9YNaOl4lN6&LU(6}_yl%_@SCLHA+%StdFl zd=`EaQtQ&4$VIj5_pG&n4*1BQXRkI%fU9Gp+H&r`a}%Xhbno%<^GdSws^B@xuPZUH tlKR=qR?;(0e8Ndyar4*e4;C^Dkw2;ZgVB?DDeV9N002ovPDHLkV1hIg7OwyR literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/heart.ipe.png b/src/main/resources/assets/forestry/textures/blocks/wood/heart.ipe.png new file mode 100644 index 0000000000000000000000000000000000000000..8672a2d73153d88215d7c1f8102a9d4304814f0c GIT binary patch literal 1336 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nAI{vB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z)ZE-iN5ROz&_v(BP~Xs4*U-|+#Kg+LKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0!ZY(y z^2>`g!FqgstvvIJOA_;vQ$1a5m4K$`WoD*W8Ce(^xmmaX!`jWs(9qSy!qU{$&D_b% z(8$He#N5pQrq?AuximL5uLPzy1)5GC5)7sUz#T7cTxGy9}SpTdxYtAy9oOVU}QSSZ*>5L^gH{M!Jw)FYt{@Xw4 z2p?Nc{QPHX=evL3&U?pjFn)uHxMiPO)Jg{3j=neVj`~J>cl4=TS~j=0`GDAx(3HL) z9jPz-({=?n%IGxm|G%|X|Ek4;K#hW18z#K>TXj@x1t;sl1)V%kEL-zUe%#mj>D466 zC3INSau@3x?(E$+dBhgWgie-DSereVOgO_nD#mWzxu0AVt zG34*l>@L4ohDH377j4-QJR|Cs-iEIqDmKbhY4zrdG{_};tX#J8y_MoGsoC?+&bRxv zJJV8flY7yxW1+|IE_$pXqnQ4_a_LL=21bVC2i{Fl-1u!8s4Vkz^>bP0l+XkKOW5Gf literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/heart.padauk.png b/src/main/resources/assets/forestry/textures/blocks/wood/heart.padauk.png new file mode 100644 index 0000000000000000000000000000000000000000..02f58edb60d4c42474e076ee9a0cf1d8d729950d GIT binary patch literal 652 zcmV;70(1R|P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0sTotK~y+TU6SETQ(+Xw-@m7vj++~+)onU9 zsSPc^Xq0AQVuZFbH+4n?f_;gMpxo-ZySur}DVU~K<_P>^I6}-?IjuhRrGKK|IC2@m z;qbigdCz&y^W3X)qwY-1xisb}Jo2qQ)Hj~^KP5t+jpl8$c`F&-pS$#XvFrP*_PzXt za`xQc`F53!*Dpo93w_7Q)iHnFZC}0}YBS@D zWM@t8h8ti<`kMA8a;lsODKnOHj#HsVM)NQ5mu=|hrC0UhylEh`3s{>_FzZ^ ze6vDo=AH*NoHxhMOQ%o~w3*%7T(8US{FQG}v-c~t{7tXDk~m0kgLMMf8J<$MN#*W( z5GNW?pXjIoNUX<$G8mUw6;QGQ${KR=fhdS4fd8V}*4=bKC2lzw%vl)FO#wibpn(#; zfp?4s^(=De61Ff29<PEy z<1V3=fB_%*^W-?&Q`y9hgG^XiBd+9tmWpcABiizVlj{?Wg$dus$ESPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0rW{kK~y+TU6OB4QehazpRIR&1YfrC0m@R- za+a%EVQB-+1ffBp%V0ATm1eGUO8Mho2BfZZ>`o={(LUATF}e zz5~m=WGt*~g(4$IOljURwwoeDI zKm;cRzZAwLMuptyIH!Db73qcWS@=yzeKPJC{)>vAQCbV= zfRFrna@=`!(@g6ysyX_{45O`*E=MUXN`qgg55K-&(UL dADlM{|0%LeUH>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0%}P_K~y+T6;fGG6JZqn&iQ6Kowc2rw(Jjz z62xGLB0GeoC$Z$-KjVkNC9#St}%TQ+s<+hC( z74sTzeAav}MNl^JOvOzCf7+Rg<1z3u!i!dlNr~eaD>{Z1Oh!5%b_hXnaFeY&9htM>!>heS2P}F%ANBpR1RdMK9jX>jVoWP|0*tFT za5!hNnqx zr8uTR)C}GvxTE7KFs)+C43p$N7M+mOMWhARHRKvtY2r`>q8#OAf`@?^kc-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z)ZE-iN5ROz&_v(BP~Xs4*U-|+#Kg+LKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0!ZY(y z^2>`g!FqgstvvIJOA_;vQ$1a5m4K$`WoD*WIU1N-I2*XQnwy#$85+8pIGVY*IvKfG znmZb}8albT!1TK0Czs}?=9R$orXcjX;nWLC4!H$Dn_W_iGRsm^+=}vZ6~NxM%Eav! zXPo9i^`_upB%Qo8;1 z)z#JEX7T%L{90ArPR+RC_4v)4O;*`QC6q0vtET7cZoIweMY41jlgG^9Pv<-}?e(`W zkKO&+{$;l=U8ebMPWHP=-q zaj9o!y{(nzxf2wY5h~h!`Lcy|_LT+J6ANg*GPL4^7Z;sdlNY+yC>&7H?*_0Ni4kar175BMz=2#HkA@y zJa&<;+@=$ayxp$WW-M73WdFBTw&Bs1J<%KX@g$!;qyIPJVyoTB>;A|0*0R^mPMh-P z%EtcHUthDlVBfvq&%d&3hR3YLZ}Q}>&f{6Aw)d1(?~yfmhDx&*Cz+K#EV%mH_cm|+ z+VqHw+eRB_^ICl^ow4q8k$6*iSntc^KLWFozw(x>ssHoS{OpE+K>6JtF0k%6{Vc(& zckBAcN9J+1+&Xjc^}?H<%l7@XeVH0(Ab9y?we?&ST;Nj!FGJ#*QvSzDrhFW3LiD#6evpRo1xx9z;3lF!rC&t;ucLK6VPVFFnI literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/planks.ipe.png b/src/main/resources/assets/forestry/textures/blocks/wood/planks.ipe.png new file mode 100644 index 0000000000000000000000000000000000000000..5069aac839321dba529318bcd3db6320aced4b4b GIT binary patch literal 1396 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nAI{vB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z)ZE-iN5ROz&_v(BP~Xs4*U-|+#Kg+LKmiJrfVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr7I$IMft0!ZY(y z^2>`g!FqgstvvIJOA_;vQ$1a5m4K$`WoD*WnVT6~I2)Ono10iT8ydQrSU4HExS5z5 znz%T*xEQz^!t}c2Czs}?=9R$orXciM;M5CB4!H$Dn_W_iGRsm^+=}vZ6~NxM%Eav! zQ=H~O^`_uL^_&?P7@v5$ zIEGZ*@(DVaciVtxsmrOZw`psG6Q(EaerNyf|Mj_Tv1JjBW!bY8HYZ0e`L-nCFvsBy zs-HgYb>DSS8SRVXvt%0x*GGyVS{~cQkuno42GTdUle(m|)Jcm*>bM4CQO zPk!)5kxyzHoAvTN&jk{1U6MdVC9t)>POqF?{-g5B&_x43kvSe(+ql#0x41 NJzf1=);T3K0RS6C3Nioy literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/planks.padauk.png b/src/main/resources/assets/forestry/textures/blocks/wood/planks.padauk.png new file mode 100644 index 0000000000000000000000000000000000000000..050fa9ad67e8eb14db12cae6474294325f980754 GIT binary patch literal 348 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ>#Bd(*uBN&U(5yhFJLLPTa_Q$U%T*Kf94iH_yceWo0derA$gHM$4}_3AdOW-*YT# z-tkK>O80NC-#+d1@4A{ezDDgm>ylrI9r?vjaOU!Xm0Mj~KRg|c=dOFLYw-9Z3$&OM_s=tF><9Rv8+4Y=JA%fyUa%C pKcn38xsJMvg6Dsij{a;?!>}<(E<7#%X%x_744$rjF6*2UngGI@h=~9I literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/wood/planks.zebrawood.png b/src/main/resources/assets/forestry/textures/blocks/wood/planks.zebrawood.png new file mode 100644 index 0000000000000000000000000000000000000000..dd0b140e5feae2243897f8f0e0f6587688cad7b7 GIT binary patch literal 861 zcmV-j1ETziP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz0?tW9K~y+T6_Qy~+F%rh^Mh>b6t_;ja8#5m z5RyQmCwa`$7Eg_GM;odi{jVYdp_Rh@Tf?=VZ7G6r>JoMlFg7^cUN;hF!b z5UfS!u31D0jt|dQZsJr&a5P2aK11JVgf1YE5k*A*drNUQ6<06G{4It`;n{rHE(ONF zWtf|Ur^PSoJlsoqbjfKcPDtl4);DU%L_@}Pnfg=M$nVbdxi zRhRIZh(SgS=hwy?3S}xpT_S%Mwu*-f*-r~nXsVs?R0Z7N;4%yAlG{*-&ItuQo-y&D ztS@A{`k7~Tnv`? zXKEa(25q-#rlnDR8LNXYfskE8fo6Q|8h=GY-nr_EE77yB@ZH?3={5pn0 zmWapvW7e^!p%8`wENzw!?HA!iAu!oVdck9ZgDcTjXdSdrTu?QN3F{NOOailp;&~`+ zl_Col2e26WV8ww-ca3!vSr`o0q8pfner6c}U5g@D9Qyry^|=tp?M`1G!P>?|H|ed5 z&b|Z#=)08nKFb&)3|TyKM2~=$dJG+8eE%w&mGDd{vZ#h8?y^h06x|gZCJ3axEsZb) z7(gRO%$uf4wvGu<^rf<04A15E?P6g3_6yTXFEx1w_^Xour{Ss#D5Uck?|*Nql%*1e zO#RAl6vFfQ2*R$|x+%J;Q98R=K61Qnffd;W)j1HbS;t-gR29jG{6;xqzdUfL+taNC nRTbUfG_E+Lp^#M(Zzrh#mIi8amlx5h00000NkvXXu0mjfj Date: Thu, 1 Jan 2015 22:38:12 -0800 Subject: [PATCH 135/175] Fix #426 Throttle the speed of the Generator accepting liquid containers --- .../forestry/energy/gadgets/MachineGenerator.java | 13 +++++++------ .../forestry/factory/gadgets/MachineBottler.java | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/energy/gadgets/MachineGenerator.java b/src/main/java/forestry/energy/gadgets/MachineGenerator.java index faf2f23f6..f748338a3 100755 --- a/src/main/java/forestry/energy/gadgets/MachineGenerator.java +++ b/src/main/java/forestry/energy/gadgets/MachineGenerator.java @@ -120,12 +120,13 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu @Override public void updateServerSide() { - - // Check inventory slots for fuel - // Check if we have suitable items waiting in the item slot - IInventoryAdapter inventory = getInternalInventory(); - if (inventory.getStackInSlot(SLOT_CAN) != null) - FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + if (worldObj.getTotalWorldTime() % 20 == 0) { + // Check inventory slots for fuel + // Check if we have suitable items waiting in the item slot + IInventoryAdapter inventory = getInternalInventory(); + if (inventory.getStackInSlot(SLOT_CAN) != null) + FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN); + } // No work to be done if IC2 is unavailable. if (ic2EnergySource == null) { diff --git a/src/main/java/forestry/factory/gadgets/MachineBottler.java b/src/main/java/forestry/factory/gadgets/MachineBottler.java index 76799a2ac..6fc7bfbeb 100755 --- a/src/main/java/forestry/factory/gadgets/MachineBottler.java +++ b/src/main/java/forestry/factory/gadgets/MachineBottler.java @@ -226,7 +226,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq @Override public void updateServerSide() { - if (worldObj.getTotalWorldTime() % 20 * 10 != 0) + if (worldObj.getTotalWorldTime() % 20 != 0) return; IInventoryAdapter inventory = getInternalInventory(); From e00d96ff08c74d5c4cac07f6ec3b36763c7292da Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 1 Jan 2015 23:02:18 -0800 Subject: [PATCH 136/175] Fix #428 Electrical Engine shows "no fuel" when inactive --- src/main/java/forestry/energy/gadgets/EngineTin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/energy/gadgets/EngineTin.java b/src/main/java/forestry/energy/gadgets/EngineTin.java index ba782cca4..fbbf3931a 100755 --- a/src/main/java/forestry/energy/gadgets/EngineTin.java +++ b/src/main/java/forestry/energy/gadgets/EngineTin.java @@ -184,7 +184,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory { if (!delayUpdateTimer.delayPassed(worldObj, 80)) return; - if (currentOutput <= 0) + if (!ic2EnergySink.canUseEnergy(euConfig.euForCycle)) setErrorState(EnumErrorCode.NOFUEL); else setErrorState(EnumErrorCode.OK); From 8cbb94aed0a2399091e2a0a7f1a7714417a88e9c Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 1 Jan 2015 23:13:15 -0800 Subject: [PATCH 137/175] Fix #429 Filled capsules are placed in armor slot when inventory is full --- src/main/java/forestry/core/items/ItemLiquidContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/core/items/ItemLiquidContainer.java b/src/main/java/forestry/core/items/ItemLiquidContainer.java index 0b4bbf171..0df5416b5 100755 --- a/src/main/java/forestry/core/items/ItemLiquidContainer.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainer.java @@ -80,7 +80,7 @@ public class ItemLiquidContainer extends Item { private int getMatchingSlot(EntityPlayer player, ItemStack stack) { - for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) { + for (int slot = 0; slot < player.inventory.mainInventory.length; slot++) { ItemStack slotStack = player.inventory.getStackInSlot(slot); if (slotStack == null) From ca9c99c2832ba24a2519d78d1686dbf4604e829f Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 2 Jan 2015 00:08:35 -0800 Subject: [PATCH 138/175] Add info about disabled plugins on crash reports --- .../utils/ForestryModEnvWarningCallable.java | 37 +++++++++++++++---- .../java/forestry/plugins/PluginManager.java | 17 +++++++-- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java index b62cd4dc8..0d499da9c 100755 --- a/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java +++ b/src/main/java/forestry/core/utils/ForestryModEnvWarningCallable.java @@ -16,12 +16,15 @@ import cpw.mods.fml.common.ICrashCallable; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import forestry.core.config.Defaults; +import forestry.plugins.PluginManager; + import java.util.ArrayList; import java.util.List; public class ForestryModEnvWarningCallable implements ICrashCallable { private final List modIDs; + private final List disabledModules; public ForestryModEnvWarningCallable() { this.modIDs = new ArrayList(); @@ -41,22 +44,40 @@ public class ForestryModEnvWarningCallable implements ICrashCallable { } catch (Throwable ignored) {} // No need to do anything. - // Add other bad mods here. - if (modIDs.size() > 0) { + this.disabledModules = new ArrayList(); + for (PluginManager.Module module : PluginManager.configDisabledModules) { + disabledModules.add(module.configName()); + } + + if (modIDs.size() > 0 || disabledModules.size() > 0) { FMLCommonHandler.instance().registerCrashCallable(this); } } @Override public String call() throws Exception { - String message = "[" + Defaults.MOD + "] Warning: You have mods that change the behavior of Minecraft, ForgeModLoader, and/or Minecraft Forge to your client: \r\n"; - message = message + modIDs.get(0); - for (int i = 1; i < modIDs.size(); ++i) { - message = message + ", " + modIDs.get(i); + StringBuilder message = new StringBuilder(); + if (modIDs.size() > 0) { + message.append("Warning: You have mods that change the behavior of Minecraft, ForgeModLoader, and/or Minecraft Forge to your client: \r\n"); + message.append(modIDs.get(0)); + for (int i = 1; i < modIDs.size(); ++i) { + message.append(", ").append(modIDs.get(i)); + } + message.append("\r\nThese may have caused this error, and may not be supported. Try reproducing the crash WITHOUT these mods, and report it then."); } - message = message + "\r\nThese may have caused this error, and may not be supported. Try reproducing the crash WITHOUT these mods, and report it then."; - return message; + + if (disabledModules.size() > 0) { + if (message.length() > 0) + message.append("\r\n"); + message.append("Info: The following plugins have been disabled in the config: "); + message.append(disabledModules.get(0)); + for (int i = 1; i < disabledModules.size(); ++i) { + message.append(", ").append(disabledModules.get(i)); + } + } + + return message.toString(); } @Override diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 3be35f5ff..0cac19ba6 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -106,8 +106,14 @@ public class PluginManager { return canBeDisabled; } + public String configName() { + return toString().toLowerCase(Locale.ENGLISH).replace('_', '.'); + } + } + public static final EnumSet configDisabledModules = EnumSet.noneOf(Module.class); + public static Stage getStage() { return stage; } @@ -292,8 +298,13 @@ public class PluginManager { private static boolean isEnabled(Configuration config, Module m) { Plugin info = m.instance().getClass().getAnnotation(Plugin.class); - Property prop = config.get(CATEGORY_MODULES, m.toString().toLowerCase(Locale.ENGLISH).replace('_', '.'), true); - prop.comment = StatCollector.translateToLocal(info.unlocalizedDescription()); - return prop.getBoolean(true); + String comment = StatCollector.translateToLocal(info.unlocalizedDescription()); + Property prop = config.get(CATEGORY_MODULES, m.configName(), true, comment); + boolean enabled = prop.getBoolean(); + + if (!enabled) + configDisabledModules.add(m); + + return enabled; } } From f2395d27a83806c4d9707c350622955055b9a9b2 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 2 Jan 2015 02:26:54 -0800 Subject: [PATCH 139/175] Close #271. Improve usability of the Escritoire --- lang | 2 +- .../forestry/core/gadgets/TileEscritoire.java | 16 +++++ .../forestry/core/gadgets/TileForestry.java | 5 ++ .../forestry/core/genetics/AlleleSpecies.java | 2 +- .../java/forestry/core/gui/GuiEscritoire.java | 61 +++++++++++-------- .../forestry/core/gui/slots/SlotFiltered.java | 7 ++- .../forestry/core/gui/slots/SlotOutput.java | 10 +++ .../forestry/core/gui/slots/SlotWatched.java | 2 +- .../core/interfaces/IFilterSlotDelegate.java | 6 ++ .../core/inventory/FakeInventoryAdapter.java | 6 +- .../core/inventory/InventoryAdapter.java | 6 +- .../core/inventory/ItemInventory.java | 5 ++ src/main/java/forestry/mail/TradeStation.java | 6 +- 13 files changed, 103 insertions(+), 31 deletions(-) diff --git a/lang b/lang index d6aa63fdc..08740297c 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit d6aa63fdce7c72de79dade4a5ff703e8080ff588 +Subproject commit 08740297c4c5acd65a6666e26e139c6e0e1c178b diff --git a/src/main/java/forestry/core/gadgets/TileEscritoire.java b/src/main/java/forestry/core/gadgets/TileEscritoire.java index 78e79e28d..b98990bf7 100755 --- a/src/main/java/forestry/core/gadgets/TileEscritoire.java +++ b/src/main/java/forestry/core/gadgets/TileEscritoire.java @@ -64,6 +64,22 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender return false; } + @Override + public boolean isLocked(int slotIndex) { + if (slotIndex == SLOT_ANALYZE) + return false; + + if (getStackInSlot(SLOT_ANALYZE) == null) + return true; + + if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOTS_INPUT_COUNT)) { + if (slotIndex >= SLOT_INPUT_1 + game.getSampleSize()) + return true; + } + + return false; + } + @Override public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) { return GuiUtil.isIndexInRange(slotIndex, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT); diff --git a/src/main/java/forestry/core/gadgets/TileForestry.java b/src/main/java/forestry/core/gadgets/TileForestry.java index 3888caae3..918eba51c 100755 --- a/src/main/java/forestry/core/gadgets/TileForestry.java +++ b/src/main/java/forestry/core/gadgets/TileForestry.java @@ -406,6 +406,11 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit return getInternalInventory().canSlotAccept(slotIndex, itemStack); } + @Override + public boolean isLocked(int slotIndex) { + return getInternalInventory().isLocked(slotIndex); + } + @Override public final int[] getAccessibleSlotsFromSide(int side) { if (!allowsPipeConnections()) diff --git a/src/main/java/forestry/core/genetics/AlleleSpecies.java b/src/main/java/forestry/core/genetics/AlleleSpecies.java index c993de517..b8d64869c 100755 --- a/src/main/java/forestry/core/genetics/AlleleSpecies.java +++ b/src/main/java/forestry/core/genetics/AlleleSpecies.java @@ -73,7 +73,7 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpecies { return 0.7f; else if (ForestryItem.beeComb.isItemEqual(itemstack)) return 0.4f; - else if (AlleleManager.alleleRegistry.isIndividual(itemstack)) + else if (getRoot().isMember(itemstack)) return 1.0f; for (Map.Entry entry : getRoot().getResearchCatalysts().entrySet()) { diff --git a/src/main/java/forestry/core/gui/GuiEscritoire.java b/src/main/java/forestry/core/gui/GuiEscritoire.java index 99bc525a5..a029591a0 100755 --- a/src/main/java/forestry/core/gui/GuiEscritoire.java +++ b/src/main/java/forestry/core/gui/GuiEscritoire.java @@ -10,6 +10,19 @@ ******************************************************************************/ package forestry.core.gui; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; + +import java.util.List; + +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import org.lwjgl.opengl.GL11; + import forestry.core.config.Defaults; import forestry.core.gadgets.NaturalistGame; import forestry.core.gadgets.NaturalistGame.GameToken; @@ -19,24 +32,23 @@ import forestry.core.proxy.Proxies; import forestry.core.render.SpriteSheet; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import org.lwjgl.opengl.GL11; public class GuiEscritoire extends GuiForestry { - private static String[][] researchNotes = new String[][] { - new String[] { "I have found a curious specimen on my travels.", "This strange fellow needs further investigation.", "Elated, I wanted to start at once with my research." }, - new String[] { "I was amazed at the wondrous nature of it.", "The specimen twitched, while I inspected it more closely.", "Strange markings on the underside made me curious.", "This will be the talk of the society when I am done investigating." }, - new String[] { "After some prodding I discovered an interesting new lead.", "I scratched my head at this discovery and questioned everything.", "I thought my eyes deceived me, but there it was.", "A previously unseen dot led me to question the specimen's classification." }, - new String[] { "My screams of frustration had the housekeeper look into my study in worry.", "In a frenzy and on the verge of despair, I ripped up all the notes!", "This... just doesn't make any sense!", "It just cannot be. It didn't do that before!", "The sledgehammer barely made a dent, so I sent for the chainsaw.", "I swear it was looking at me, with its beady, cruel, little eyes.", "Is that laughter? Do I hear laughter? Who is laughing here?" }, - new String[] { "EUREKA!", "Wondrous! My name will go down in history!", "My colleagues will be impressed!", "I will be the envy of everyone at the society!", "Woot!" }, - new String[] { "All is lost.", "I consign my notes to the fire.", "Why? I had made such great strides at first...", "Failed. Again.", "Oh my..." } - }; + private static enum Notes { + level1, level2, level3, level4, success, failure + } + private static final ListMultimap researchNotes; + static { + researchNotes = ArrayListMultimap.create(); + for (Notes notesLevel : Notes.values()) { + int levelCount = Integer.valueOf(StringUtil.localize("gui.escritoire.notes." + notesLevel + ".count")); + for (int i = 1; i <= levelCount; i++) { + String note = StringUtil.localize("gui.escritoire.notes." + notesLevel + "." + i); + researchNotes.put(notesLevel, note); + } + } + } private class TokenSlot extends Widget { @@ -229,22 +241,22 @@ public class GuiEscritoire extends GuiForestry { return researchNote; if (!tile.getGame().isInited()) - researchNote = ""; + researchNote = StringUtil.localize("gui.escritoire.instructions"); else { if (tile.getGame().isWon()) { - researchNote = getRandomNote(researchNotes[4]); + researchNote = getRandomNote(researchNotes.get(Notes.success)); } else if (tile.getGame().isEnded()) { - researchNote = getRandomNote(researchNotes[5]); + researchNote = getRandomNote(researchNotes.get(Notes.failure)); } else { int bounty = tile.getGame().getBountyLevel(); if (bounty >= NaturalistGame.BOUNTY_MAX) { - researchNote = getRandomNote(researchNotes[0]); + researchNote = getRandomNote(researchNotes.get(Notes.level1)); } else if (bounty > NaturalistGame.BOUNTY_MAX / 2) { - researchNote = getRandomNote(researchNotes[1]); + researchNote = getRandomNote(researchNotes.get(Notes.level2)); } else if (bounty > NaturalistGame.BOUNTY_MAX / 4) { - researchNote = getRandomNote(researchNotes[2]); + researchNote = getRandomNote(researchNotes.get(Notes.level3)); } else - researchNote = getRandomNote(researchNotes[3]); + researchNote = getRandomNote(researchNotes.get(Notes.level4)); } } @@ -252,7 +264,8 @@ public class GuiEscritoire extends GuiForestry { return researchNote; } - private String getRandomNote(String[] candidates) { - return candidates[mc.theWorld.rand.nextInt(candidates.length)]; + private String getRandomNote(List candidates) { + int index = mc.theWorld.rand.nextInt(candidates.size()); + return candidates.get(index); } } diff --git a/src/main/java/forestry/core/gui/slots/SlotFiltered.java b/src/main/java/forestry/core/gui/slots/SlotFiltered.java index 752cd39fd..515b53de3 100644 --- a/src/main/java/forestry/core/gui/slots/SlotFiltered.java +++ b/src/main/java/forestry/core/gui/slots/SlotFiltered.java @@ -33,6 +33,11 @@ public class SlotFiltered extends SlotWatched { @Override public boolean isItemValid(ItemStack itemstack) { - return itemstack != null && filterSlotDelegate.canSlotAccept(getSlotIndex(), itemstack); + int slotIndex = getSlotIndex(); + if (filterSlotDelegate.isLocked(slotIndex)) + return false; + if (itemstack != null) + return filterSlotDelegate.canSlotAccept(slotIndex, itemstack); + return true; } } diff --git a/src/main/java/forestry/core/gui/slots/SlotOutput.java b/src/main/java/forestry/core/gui/slots/SlotOutput.java index 76965a800..cfe07db6a 100755 --- a/src/main/java/forestry/core/gui/slots/SlotOutput.java +++ b/src/main/java/forestry/core/gui/slots/SlotOutput.java @@ -12,6 +12,10 @@ package forestry.core.gui.slots; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * @@ -27,4 +31,10 @@ public class SlotOutput extends SlotWatched { public boolean isItemValid(ItemStack itemstack) { return false; } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getBackgroundIconIndex() { + return null; + } } diff --git a/src/main/java/forestry/core/gui/slots/SlotWatched.java b/src/main/java/forestry/core/gui/slots/SlotWatched.java index dcbc23b0a..014b33090 100644 --- a/src/main/java/forestry/core/gui/slots/SlotWatched.java +++ b/src/main/java/forestry/core/gui/slots/SlotWatched.java @@ -58,7 +58,7 @@ public abstract class SlotWatched extends SlotForestry { @Override public IIcon getBackgroundIconIndex() { ItemStack stack = getStack(); - if (stack != null && !inventory.isItemValidForSlot(getSlotIndex(), stack)) + if (!isItemValid(stack)) return TextureManager.getInstance().getDefault(blockedTexture); else return null; diff --git a/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java b/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java index e410aa810..ccacaf29b 100644 --- a/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java +++ b/src/main/java/forestry/core/interfaces/IFilterSlotDelegate.java @@ -22,4 +22,10 @@ public interface IFilterSlotDelegate { */ boolean canSlotAccept(int slotIndex, ItemStack itemStack); + /** + * Used to lock slots under special conditions. + * Locked slots will have an X over them. + */ + boolean isLocked(int slotIndex); + } diff --git a/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java b/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java index 30cd570d3..0aac42ff7 100644 --- a/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/FakeInventoryAdapter.java @@ -15,7 +15,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import forestry.core.config.Defaults; -import forestry.core.utils.StackUtils; public class FakeInventoryAdapter implements IInventoryAdapter { @@ -37,6 +36,11 @@ public class FakeInventoryAdapter implements IInventoryAdapter { return false; } + @Override + public boolean isLocked(int slotIndex) { + return false; + } + @Override public int[] getAccessibleSlotsFromSide(int p_94128_1_) { return Defaults.SLOTS_NONE; diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index 7ff63cc36..15c77c78b 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -18,7 +18,6 @@ import net.minecraft.nbt.NBTTagList; import forestry.core.config.Defaults; import forestry.core.utils.PlainInventory; -import forestry.core.utils.StackUtils; /** * With permission from Krapht. @@ -129,6 +128,11 @@ public class InventoryAdapter implements IInventoryAdapter { return true; } + @Override + public boolean isLocked(int slotIndex) { + return false; + } + @Override public void openInventory() { } diff --git a/src/main/java/forestry/core/inventory/ItemInventory.java b/src/main/java/forestry/core/inventory/ItemInventory.java index fac014e21..89eda851f 100755 --- a/src/main/java/forestry/core/inventory/ItemInventory.java +++ b/src/main/java/forestry/core/inventory/ItemInventory.java @@ -197,6 +197,11 @@ public class ItemInventory implements IInventory, IFilterSlotDelegate, INBTTagab return true; } + @Override + public boolean isLocked(int slotIndex) { + return false; + } + @Override public void openInventory() { } diff --git a/src/main/java/forestry/mail/TradeStation.java b/src/main/java/forestry/mail/TradeStation.java index 00822f0ef..e19ebbb2f 100755 --- a/src/main/java/forestry/mail/TradeStation.java +++ b/src/main/java/forestry/mail/TradeStation.java @@ -36,7 +36,6 @@ import forestry.core.inventory.IInventoryAdapter; import forestry.core.inventory.InvTools; import forestry.core.inventory.InventoryAdapter; import forestry.core.utils.GuiUtil; -import forestry.core.utils.PlayerUtil; import forestry.core.utils.StackUtils; import forestry.mail.items.ItemLetter; @@ -629,6 +628,11 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve return inventory.canSlotAccept(slotIndex, itemStack); } + @Override + public boolean isLocked(int slotIndex) { + return inventory.isLocked(slotIndex); + } + @Override public IInventoryAdapter configureSided(int[] sides, int[] slots) { return inventory.configureSided(sides, slots); From 5326e41c9f4849e404ce348bc1dc0410de4a2eab Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 2 Jan 2015 04:01:47 -0800 Subject: [PATCH 140/175] Fix #417 Villager Beekeeper House Crashes with Arboriculture disabled --- .../worldgen/ComponentVillageBeeHouse.java | 89 +++++++++++-------- 1 file changed, 52 insertions(+), 37 deletions(-) diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index a730f1d6e..c67d82fb4 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -10,6 +10,23 @@ ******************************************************************************/ package forestry.apiculture.worldgen; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; + +import net.minecraftforge.common.ChestGenHooks; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; @@ -20,63 +37,61 @@ import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.EnumTolerance; import forestry.apiculture.gadgets.TileBeehouse; +import forestry.arboriculture.gadgets.BlockFireproofLog; +import forestry.arboriculture.gadgets.BlockFireproofPlanks; +import forestry.arboriculture.gadgets.BlockLog; +import forestry.arboriculture.gadgets.BlockPlanks; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.utils.StackUtils; import forestry.plugins.PluginApiculture; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraftforge.common.ChestGenHooks; +import forestry.plugins.PluginManager; public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { - protected final ItemStack[] buildingBlocks = new ItemStack[]{ForestryBlock.planks1.getItemStack(1, 15), new ItemStack(Blocks.log, 1, 0),}; + protected final ItemStack[] buildingBlocks; protected int averageGroundLevel = -1; protected boolean isInDesert = false; protected boolean hasChest = false; - public ComponentVillageBeeHouse() { - // Populate buildingblocks with some defaults so it doesn't explode. - buildingBlocks[0] = ForestryBlock.planks1.getItemStack(); - buildingBlocks[1] = ForestryBlock.log1.getItemStack(); - } - public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, int coordBaseMode) { super(startPiece, componentType, random, boundingBox, coordBaseMode); isInDesert = startPiece.inDesert; - buildingBlocks[0] = ForestryBlock.planks1.getItemStack(1, random.nextInt(16)); + int plankMeta = random.nextInt(16); + int blockMeta = random.nextInt(4); + Block plankBlock = Blocks.planks; + Block woodBlock = Blocks.log; - Block woodBlock; - switch (random.nextInt(4)) { - case 1: - woodBlock = ForestryBlock.log2.block(); - break; - case 2: - woodBlock = ForestryBlock.log3.block(); - break; - case 3: - woodBlock = ForestryBlock.log4.block(); - break; - default: - woodBlock = ForestryBlock.log1.block(); - break; + if (PluginManager.Module.ARBORICULTURE.isEnabled()) { + switch (random.nextInt(4)) { + case 1: + woodBlock = ForestryBlock.log2.block(); + break; + case 2: + woodBlock = ForestryBlock.log3.block(); + break; + case 3: + woodBlock = ForestryBlock.log4.block(); + break; + default: + woodBlock = ForestryBlock.log1.block(); + break; + } + + plankBlock = ForestryBlock.planks1.block(); + + // chance for the house to have fireproof components + if (random.nextInt(4) == 0) { + woodBlock = BlockFireproofLog.getFireproofLog((BlockLog) woodBlock).block(); + plankBlock = BlockFireproofPlanks.getFireproofPlanks((BlockPlanks) plankBlock).block(); + } } - buildingBlocks[1] = new ItemStack(woodBlock, 1, random.nextInt(4)); + buildingBlocks = new ItemStack[]{new ItemStack(plankBlock, 1, plankMeta), new ItemStack(woodBlock, 1, blockMeta)}; + } /*@Override From e77f62d8e7cb78b6a29f30efcb4f66489936a890 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 2 Jan 2015 15:30:19 -0800 Subject: [PATCH 141/175] Fix #430 farm hatch should only automatically output downward --- src/main/java/forestry/core/inventory/InvTools.java | 11 ++++++++--- src/main/java/forestry/farming/gadgets/TileHatch.java | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index bedc8b679..e4774954b 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -13,6 +13,7 @@ package forestry.core.inventory; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; +import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -758,15 +759,19 @@ public abstract class InvTools { * @return true if an item was inserted, otherwise false. */ public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + return moveOneItemToPipe(source, tileCache, ForgeDirection.VALID_DIRECTIONS); + } + + public static boolean moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, ForgeDirection[] directions) { if (PluginManager.Module.BUILDCRAFT_TRANSPORT.isEnabled()) { - return internal_moveOneItemToPipe(source, tileCache); + return internal_moveOneItemToPipe(source, tileCache, directions); } return false; } @Optional.Method(modid = "BuildCraftAPI|transport") - private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache) { + private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, ForgeDirection[] directions) { IInventory invClone = new InventoryCopy(source); ItemStack stackToMove = removeOneItem(invClone); if (stackToMove == null) @@ -776,7 +781,7 @@ public abstract class InvTools { List> pipes = new ArrayList>(); boolean foundPipe = false; - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection side : directions) { TileEntity tile = tileCache.getTileOnSide(side); if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; diff --git a/src/main/java/forestry/farming/gadgets/TileHatch.java b/src/main/java/forestry/farming/gadgets/TileHatch.java index b06fae332..96570fcff 100755 --- a/src/main/java/forestry/farming/gadgets/TileHatch.java +++ b/src/main/java/forestry/farming/gadgets/TileHatch.java @@ -13,10 +13,8 @@ package forestry.farming.gadgets; import java.util.Collection; import java.util.LinkedList; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -35,11 +33,13 @@ import buildcraft.api.statements.ITriggerExternal; public class TileHatch extends TileFarm implements ISidedInventory { + private static final ForgeDirection[] dumpDirections = new ForgeDirection[] { ForgeDirection.DOWN }; + private final AdjacentInventoryCache inventoryCache = new AdjacentInventoryCache(this, getTileCache(), new ITileFilter() { @Override public boolean matches(TileEntity tile) { - return !(tile instanceof TileFarm); + return !(tile instanceof TileFarm) && tile.yCoord < yCoord; } }, null); @@ -69,7 +69,7 @@ public class TileHatch extends TileFarm implements ISidedInventory { if (productInventory == null) return; - if (!InvTools.moveOneItemToPipe(productInventory, tileCache)) { + if (!InvTools.moveOneItemToPipe(productInventory, tileCache, dumpDirections)) { InvTools.moveItemStack(productInventory, inventoryCache.getAdjacentInventories()); } } From 7981288250cc5d19d56b38168441fdd730653d48 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 2 Jan 2015 15:49:32 -0800 Subject: [PATCH 142/175] Fix #432 Client crash when crafting fence with new planks --- src/main/java/forestry/plugins/PluginArboriculture.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index f84ababe2..22fd4f5ee 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -496,9 +496,9 @@ public class PluginArboriculture extends ForestryPlugin { for (WoodType woodType : WoodType.values()) { int i = woodType.ordinal(); if (i < 16) - Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i)); + Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i % 16)); else if (i < 32) - Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); + Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i % 16), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16)); else throw new RuntimeException("Wood type has no fences defined"); } From 3850b1b1727d1da48b59a9061963bac6361e426e Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 3 Jan 2015 21:03:05 -0800 Subject: [PATCH 143/175] Fix #435 machines consume thermal expansion tanks on right click --- .../forestry/core/fluids/FluidHelper.java | 29 +++++++++++++++++-- .../java/forestry/core/gadgets/BlockBase.java | 10 ++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index bca36b95c..cec862084 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -57,7 +57,15 @@ public final class FluidHelper { if (used > 0) { if (!player.capabilities.isCreativeMode) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current)); + ItemStack drainedContainer = getDrainedContainer(current, used); + if (current.stackSize > 1) { + player.inventory.decrStackSize(player.inventory.currentItem, 1); + if (drainedContainer != null && !player.inventory.addItemStackToInventory(drainedContainer)) { + player.dropPlayerItemWithRandomChoice(drainedContainer, false); + } + } else { + player.inventory.setInventorySlotContents(player.inventory.currentItem, drainedContainer); + } player.inventory.markDirty(); } return true; @@ -251,8 +259,23 @@ public final class FluidHelper { return item.getContainerItem(container); } - public static ItemStack getFullyDrainedContainer(ItemStack container) { - return container.getItem().getContainerItem(container); + public static ItemStack getDrainedContainer(ItemStack container, int drainAmount) { + if (container == null) + return null; + + if (drainAmount == 0) + return container; + + Item item = container.getItem(); + if (item instanceof IFluidContainerItem) { + ItemStack drained = container.copy(); + drained.stackSize = 1; + IFluidContainerItem containerItem = (IFluidContainerItem) item; + containerItem.drain(drained, drainAmount, true); + return drained; + } + + return getEmptyContainer(container); } public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { diff --git a/src/main/java/forestry/core/gadgets/BlockBase.java b/src/main/java/forestry/core/gadgets/BlockBase.java index 53e9dd88c..562d88585 100755 --- a/src/main/java/forestry/core/gadgets/BlockBase.java +++ b/src/main/java/forestry/core/gadgets/BlockBase.java @@ -169,14 +169,8 @@ public class BlockBase extends BlockForestry { ItemStack current = player.getCurrentEquippedItem(); if (current != null && current.getItem() != Items.bucket && tile instanceof IFluidHandler && tile.allowsAlteration(player)) { - if (Proxies.common.isSimulating(world)) { - if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { - return true; - } - } else { - if (FluidContainerRegistry.isContainer(current)) { - return true; - } + if (FluidHelper.handleRightClick((IFluidHandler) tile, ForgeDirection.getOrientation(side), player, true, tile.canDrainWithBucket())) { + return true; } } From d536d5cf46feb36996bcb42b4f912e25d41086bf Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 4 Jan 2015 16:46:19 -0800 Subject: [PATCH 144/175] Fix #437 Warnings from bee villager house construction --- .../worldgen/ComponentVillageBeeHouse.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java index c67d82fb4..01c195fb4 100755 --- a/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java +++ b/src/main/java/forestry/apiculture/worldgen/ComponentVillageBeeHouse.java @@ -50,16 +50,25 @@ import forestry.plugins.PluginManager; public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { + private static final Random random = new Random(); protected final ItemStack[] buildingBlocks; protected int averageGroundLevel = -1; protected boolean isInDesert = false; protected boolean hasChest = false; + public ComponentVillageBeeHouse() { + buildingBlocks = createBuildingBlocks(random); + } + public ComponentVillageBeeHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, int coordBaseMode) { super(startPiece, componentType, random, boundingBox, coordBaseMode); isInDesert = startPiece.inDesert; + buildingBlocks = createBuildingBlocks(random); + } + + private static ItemStack[] createBuildingBlocks(Random random) { int plankMeta = random.nextInt(16); int blockMeta = random.nextInt(4); Block plankBlock = Blocks.planks; @@ -90,8 +99,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { } } - buildingBlocks = new ItemStack[]{new ItemStack(plankBlock, 1, plankMeta), new ItemStack(woodBlock, 1, blockMeta)}; - + return new ItemStack[]{new ItemStack(plankBlock, 1, plankMeta), new ItemStack(woodBlock, 1, blockMeta)}; } /*@Override @@ -108,7 +116,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 { @SuppressWarnings("rawtypes") public static ComponentVillageBeeHouse buildComponent(StructureVillagePieces.Start startPiece, List par1List, Random random, int par3, int par4, int par5, int par6, int par7) { - StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 9, 6, par6); + StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 9, 10, par6); return canVillageGoDeeper(bbox) && StructureComponent.findIntersecting(par1List, bbox) == null ? new ComponentVillageBeeHouse(startPiece, par7, random, bbox, par6) : null; } From 960b322e868163cdc7f9506094fb519fcdd29675 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 4 Jan 2015 17:39:25 -0800 Subject: [PATCH 145/175] Fix #439 Some Drones have GEN tag --- api/forestry | 2 +- .../forestry/apiculture/genetics/Bee.java | 62 ++++++++++++++----- .../apiculture/genetics/BeeHelper.java | 7 +-- .../core/genetics/IndividualLiving.java | 35 +---------- .../lepidopterology/genetics/Butterfly.java | 8 +-- 5 files changed, 53 insertions(+), 61 deletions(-) diff --git a/api/forestry b/api/forestry index c87f1fe97..2ad2ee6d7 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit c87f1fe97694408d5cfcd021a3e568ec7777ee12 +Subproject commit 2ad2ee6d7c4997cb463ca0a73b1463f1e6b47a2f diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index a856f7d0b..a8104fdef 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -58,6 +58,9 @@ import forestry.plugins.PluginApiculture; public class Bee extends IndividualLiving implements IBee { + protected int generation; + protected boolean isNatural = true; + public IBeeGenome genome; public IBeeGenome mate; @@ -66,28 +69,20 @@ public class Bee extends IndividualLiving implements IBee { readFromNBT(nbttagcompound); } - public Bee(World world, IBeeGenome genome, IBee mate) { - this(world, genome); + public Bee(IBeeGenome genome, IBee mate) { + this(genome); this.mate = mate.getGenome(); - this.isIrregularMating = mate.isNatural() != this.isNatural; - } - - public Bee(World world, IBeeGenome genome) { - this(world, genome, true, 0); } public Bee(IBeeGenome genome) { this(genome, true, 0); } - public Bee(World world, IBeeGenome genome, boolean isNatural, int generation) { - super(genome.getLifespan(), isNatural, generation); - this.genome = genome; - } - public Bee(IBeeGenome genome, boolean isNatural, int generation) { - super(genome.getLifespan(), isNatural, generation); + super(genome.getLifespan()); this.genome = genome; + this.isNatural = isNatural; + this.generation = generation; } /* SAVING & LOADING */ @@ -101,15 +96,51 @@ public class Bee extends IndividualLiving implements IBee { super.readFromNBT(nbttagcompound); + if (nbttagcompound.hasKey("NA")) + isNatural = nbttagcompound.getBoolean("NA"); + + if (nbttagcompound.hasKey("GEN")) + generation = nbttagcompound.getInteger("GEN"); + if (nbttagcompound.hasKey("Genome")) genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome")); else genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate()); + if (nbttagcompound.hasKey("Mate")) mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate")); } + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + + super.writeToNBT(nbttagcompound); + + if (!isNatural) + nbttagcompound.setBoolean("NA", false); + + if (generation > 0) + nbttagcompound.setInteger("GEN", generation); + } + + public void setIsNatural(boolean flag) { + this.isNatural = flag; + } + + @Override + public boolean isIrregularMating() { + return false; + } + + public boolean isNatural() { + return this.isNatural; + } + + public int getGeneration() { + return generation; + } + @Override public void mate(IIndividual individual) { if(!(individual instanceof IBee)) @@ -117,7 +148,6 @@ public class Bee extends IndividualLiving implements IBee { IBee drone = (IBee)individual; mate = drone.getGenome(); - this.isIrregularMating = drone.isNatural() != this.isNatural; } /* EFFECTS */ @@ -470,7 +500,7 @@ public class Bee extends IndividualLiving implements IBee { toCreate = 1; for (int i = 0; i < toCreate; i++) { - IBee offspring = createOffspring(housing, -1); + IBee offspring = createOffspring(housing, 0); if (offspring != null) { offspring.setIsNatural(true); bees.add(offspring); @@ -505,7 +535,7 @@ public class Bee extends IndividualLiving implements IBee { chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world); - IBee offspring = new Bee(world, new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation); + IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation); /* Disabling the mutation rate nerf // All mutation and no play makes queen a dull girl. diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index 6e5e03962..bcb490671 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -156,8 +156,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public IBee getMember(ItemStack stack) { - if (!ForestryItem.beeQueenGE.isItemEqual(stack) && !ForestryItem.beePrincessGE.isItemEqual(stack) - && !ForestryItem.beeDroneGE.isItemEqual(stack) && !ForestryItem.beeLarvaeGE.isItemEqual(stack)) + if (!isMember(stack)) return null; return new Bee(stack.getTagCompound()); @@ -170,12 +169,12 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { @Override public IBee getBee(World world, IBeeGenome genome) { - return new Bee(world, genome); + return new Bee(genome); } @Override public IBee getBee(World world, IBeeGenome genome, IBee mate) { - return new Bee(world, genome, mate); + return new Bee(genome, mate); } /* GENOME CONVERSIONS */ diff --git a/src/main/java/forestry/core/genetics/IndividualLiving.java b/src/main/java/forestry/core/genetics/IndividualLiving.java index 9781aa5db..bd62257a8 100755 --- a/src/main/java/forestry/core/genetics/IndividualLiving.java +++ b/src/main/java/forestry/core/genetics/IndividualLiving.java @@ -17,19 +17,13 @@ import net.minecraft.world.World; public abstract class IndividualLiving extends Individual implements IIndividualLiving { - protected int generation; - protected boolean isNatural; - protected boolean isIrregularMating; - protected int health; protected int maxHealth; public IndividualLiving() {} - public IndividualLiving(int newHealth, boolean isNatural, int generation) { + public IndividualLiving(int newHealth) { health = maxHealth = newHealth; - this.isNatural = isNatural; - this.generation = generation; } /* SAVING & LOADING */ @@ -38,13 +32,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual super.readFromNBT(nbttagcompound); - if (nbttagcompound.hasKey("NA")) - isNatural = nbttagcompound.getBoolean("NA"); - else - isNatural = true; - isIrregularMating = nbttagcompound.getBoolean("IM"); - generation = nbttagcompound.getInteger("GEN"); - health = nbttagcompound.getInteger("Health"); maxHealth = nbttagcompound.getInteger("MaxH"); @@ -55,10 +42,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual super.writeToNBT(nbttagcompound); - nbttagcompound.setBoolean("NA", isNatural); - nbttagcompound.setBoolean("IM", isIrregularMating); - nbttagcompound.setInteger("GEN", generation); - nbttagcompound.setInteger("Health", health); nbttagcompound.setInteger("MaxH", maxHealth); @@ -77,22 +60,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual /* GENERATION */ public abstract IGenome getMate(); - - public void setIsNatural(boolean flag) { - this.isNatural = flag; - } - - public boolean isIrregularMating() { - return this.isIrregularMating; - } - - public boolean isNatural() { - return this.isNatural; - } - - public int getGeneration() { - return generation; - } @Override public boolean isAlive() { diff --git a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java index 4bdcfb9c3..d3db40f39 100755 --- a/src/main/java/forestry/lepidopterology/genetics/Butterfly.java +++ b/src/main/java/forestry/lepidopterology/genetics/Butterfly.java @@ -54,11 +54,7 @@ public class Butterfly extends IndividualLiving implements IButterfly { } public Butterfly(IButterflyGenome genome) { - this(genome, true, 0); - } - - public Butterfly(IButterflyGenome genome, boolean isNatural, int generation) { - super(genome.getLifespan(), isNatural, generation); + super(genome.getLifespan()); this.genome = genome; } @@ -201,7 +197,7 @@ public class Butterfly extends IndividualLiving implements IButterfly { if (parent1[i] != null && parent2[i] != null) chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]); - return new Butterfly(new ButterflyGenome(chromosomes), true, generation); + return new Butterfly(new ButterflyGenome(chromosomes)); } private IChromosome[] mutateSpecies(IButterflyNursery nursery, IGenome genomeOne, IGenome genomeTwo) { From e5979367ee2bb7f0c7ab4902ca090386c18f435f Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 4 Jan 2015 22:58:10 -0800 Subject: [PATCH 146/175] Fix #431 Leaves become invisible when they start to decay --- .../forestry/apiculture/items/ItemBeeGE.java | 2 +- .../PacketHandlerArboriculture.java | 27 +++- .../gadgets/ForestryBlockLeaves.java | 6 + .../arboriculture/gadgets/TileLeaves.java | 28 ++-- .../arboriculture/genetics/TreeHelper.java | 20 +-- .../arboriculture/items/ItemGermlingGE.java | 2 +- .../arboriculture/items/ItemTreealyzer.java | 4 +- .../network/PacketLeafUpdate.java | 73 ++++------ .../network/PacketRipeningUpdate.java | 63 +++++++++ .../arboriculture/worldgen/BlockTypeVoid.java | 2 - .../worldgen/WorldGenArboriculture.java | 36 +++-- .../java/forestry/core/genetics/ItemGE.java | 2 +- .../java/forestry/core/network/PacketIds.java | 125 +++++++++--------- .../forestry/core/utils/GeneticsUtil.java | 46 +++---- .../forestry/core/worldgen/BlockType.java | 2 - .../forestry/farming/logic/FarmableGE.java | 2 +- .../farming/logic/FarmableVanillaSapling.java | 22 ++- .../items/ItemButterflyGE.java | 2 +- 18 files changed, 265 insertions(+), 199 deletions(-) create mode 100644 src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java index 0a7135150..fa746f871 100755 --- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java +++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java @@ -50,7 +50,7 @@ public class ItemBeeGE extends ItemGE { } @Override - protected IIndividual getIndividual(ItemStack itemstack) { + public IBee getIndividual(ItemStack itemstack) { return new Bee(itemstack.getTagCompound()); } diff --git a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java index a7588eb54..69388547d 100755 --- a/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java +++ b/src/main/java/forestry/arboriculture/PacketHandlerArboriculture.java @@ -12,9 +12,12 @@ package forestry.arboriculture; import forestry.arboriculture.gadgets.TileLeaves; import forestry.arboriculture.network.PacketLeafUpdate; +import forestry.arboriculture.network.PacketRipeningUpdate; import forestry.core.interfaces.IPacketHandler; import forestry.core.network.PacketIds; import forestry.core.proxy.Proxies; +import forestry.storage.proxy.ProxyStorage; + import java.io.DataInputStream; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; @@ -26,11 +29,18 @@ public class PacketHandlerArboriculture implements IPacketHandler { try { switch (packetID) { - case PacketIds.LEAF_UPDATE: - PacketLeafUpdate packet = new PacketLeafUpdate(); - packet.readData(data); - onLeafUpdate(packet); - break; + case PacketIds.LEAF_UPDATE: { + PacketLeafUpdate packet = new PacketLeafUpdate(); + packet.readData(data); + onLeafUpdate(packet); + break; + } + case PacketIds.RIPENING_UPDATE: { + PacketRipeningUpdate packet = new PacketRipeningUpdate(); + packet.readData(data); + onRipeningUpdate(packet); + break; + } } } catch(Exception ex) { @@ -46,5 +56,12 @@ public class PacketHandlerArboriculture implements IPacketHandler { } + private void onRipeningUpdate(PacketRipeningUpdate packet) { + + TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld()); + if (tile instanceof TileLeaves) + ((TileLeaves) tile).fromRipeningPacket(packet); + + } } diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index bf08afde0..2558ee9a3 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -181,6 +181,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv if (getLeafTile(world, x, y, z).isDecorative()) return; super.beginLeavesDecay(world, x, y, z); + world.markBlockForUpdate(x, y, z); } @Override @@ -191,6 +192,11 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv super.updateTick(world, x, y, z, random); + // check leaves tile again because they can decay in super.updateTick + tileLeaves = getLeafTile(world, x, y, z); + if (tileLeaves == null) + return; + if (world.rand.nextFloat() > 0.1) return; tileLeaves.onBlockTick(); diff --git a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java index 153aa33f6..095aeb2f8 100755 --- a/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/TileLeaves.java @@ -48,6 +48,7 @@ import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.lepidopterology.IButterflyRoot; import forestry.arboriculture.network.PacketLeafUpdate; +import forestry.arboriculture.network.PacketRipeningUpdate; import forestry.core.utils.GeneticsUtil; import forestry.core.EnumErrorCode; import forestry.core.genetics.Allele; @@ -312,27 +313,26 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } private void sendNetworkUpdateRipening() { - Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord); + Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord); } @Override public void fromPacket(ForestryPacket packetRaw) { + super.fromPacket(packetRaw); PacketLeafUpdate packet = (PacketLeafUpdate)packetRaw; - if(packet.isRipeningUpdate()) { - colourFruits = packet.colourFruits; - } else { - readFromNBT(packet.getTagCompound()); - isFruitLeaf = packet.isFruitLeaf(); - isPollinatedState = packet.isPollinated(); - textureIndexFancy = packet.textureIndexFancy; - textureIndexPlain = packet.textureIndexPlain; - textureIndexFruits = packet.textureIndexFruit; - colourLeaves = packet.colourLeaves; - colourFruits = packet.colourFruits; - } - worldObj.func_147479_m(xCoord, yCoord, zCoord); + isFruitLeaf = packet.isFruitLeaf(); + isPollinatedState = packet.isPollinated(); + textureIndexFancy = packet.textureIndexFancy; + textureIndexPlain = packet.textureIndexPlain; + textureIndexFruits = packet.textureIndexFruit; + colourLeaves = packet.colourLeaves; + colourFruits = packet.colourFruits; + } + + public void fromRipeningPacket(PacketRipeningUpdate packet) { + colourFruits = packet.colourFruits; } /** diff --git a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java index d5d7bc2d4..a1e7d6cdc 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreeHelper.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeHelper.java @@ -45,6 +45,7 @@ import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IMutation; import forestry.arboriculture.gadgets.BlockFruitPod; +import forestry.arboriculture.gadgets.ForestryBlockLeaves; import forestry.arboriculture.gadgets.TileFruitPod; import forestry.arboriculture.gadgets.TileLeaves; import forestry.arboriculture.gadgets.TileSapling; @@ -214,20 +215,19 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot { if (!ForestryBlock.leaves.isBlockEqual(world, x, y, z)) return false; - TileLeaves tileLeaves = new TileLeaves(); - tileLeaves.setTree((ITree) tree.copy()); - tileLeaves.setOwner(owner); - if (decorative) - tileLeaves.setDecorative(); - - world.setTileEntity(x, y, z, tileLeaves); - - TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileLeaves)) { + TileEntity tile = ForestryBlockLeaves.getLeafTile(world, x, y, z); + if (tile == null) { world.setBlockToAir(x, y, z); return false; } + TileLeaves tileLeaves = (TileLeaves) tile; + tileLeaves.setOwner(owner); + tileLeaves.setTree((ITree) tree.copy()); + if (decorative) + tileLeaves.setDecorative(); + world.markBlockForUpdate(x, y, z); + return true; } diff --git a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java index f153237b4..8db0b9e45 100755 --- a/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java +++ b/src/main/java/forestry/arboriculture/items/ItemGermlingGE.java @@ -51,7 +51,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable { } @Override - protected IIndividual getIndividual(ItemStack itemstack) { + public ITree getIndividual(ItemStack itemstack) { return new Tree(itemstack.getTagCompound()); } diff --git a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java index 5b60e8604..5cfb37cca 100755 --- a/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java +++ b/src/main/java/forestry/arboriculture/items/ItemTreealyzer.java @@ -18,7 +18,6 @@ import net.minecraft.world.World; import forestry.api.arboriculture.ITree; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; -import forestry.api.genetics.AlleleManager; import forestry.core.EnumErrorCode; import forestry.core.config.Config; import forestry.core.interfaces.IErrorSource; @@ -28,7 +27,6 @@ import forestry.core.items.ItemInventoried; import forestry.core.network.GuiId; import forestry.core.proxy.Proxies; import forestry.core.utils.GeneticsUtil; -import forestry.core.utils.StackUtils; import forestry.plugins.PluginArboriculture; public class ItemTreealyzer extends ItemInventoried { @@ -42,7 +40,7 @@ public class ItemTreealyzer extends ItemInventoried { @Override protected boolean isSpecimen(ItemStack itemStack) { - return StackUtils.containsItemStack(AlleleManager.ersatzSaplings.keySet(), itemStack) || PluginArboriculture.treeInterface.isMember(itemStack); + return GeneticsUtil.getGeneticEquivalent(itemStack) instanceof ITree; } private void tryAnalyze() { diff --git a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java index 11398d46b..0e1c2155a 100755 --- a/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java +++ b/src/main/java/forestry/arboriculture/network/PacketLeafUpdate.java @@ -10,17 +10,21 @@ ******************************************************************************/ package forestry.arboriculture.network; -import forestry.arboriculture.gadgets.TileLeaves; -import forestry.core.network.PacketIds; -import forestry.core.network.PacketTileNBT; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import net.minecraft.world.World; + +import forestry.arboriculture.gadgets.TileLeaves; +import forestry.core.network.PacketIds; +import forestry.core.network.PacketTileNBT; + public class PacketLeafUpdate extends PacketTileNBT { - public byte isRipeningUpdate = 0; - + private static short hasFruitFlag = 1; + private static short isPollinatedFlag = 1 << 1; + private byte leafState = 0; public short textureIndexFancy; public short textureIndexPlain; @@ -37,9 +41,9 @@ public class PacketLeafUpdate extends PacketTileNBT { leafState = 0; if(leaves.hasFruit()) - leafState |= 1 << 0; + leafState |= hasFruitFlag; if(leaves.isPollinated()) - leafState |= 1 << 1; + leafState |= isPollinatedFlag; textureIndexFancy = leaves.determineTextureIndex(true); textureIndexPlain = leaves.determineTextureIndex(false); textureIndexFruit = leaves.determineOverlayIndex(); @@ -47,56 +51,35 @@ public class PacketLeafUpdate extends PacketTileNBT { colourFruits = leaves.determineFruitColour(); } - public PacketLeafUpdate(TileLeaves leaves, int fruitColour) { - super(PacketIds.LEAF_UPDATE, leaves); - - isRipeningUpdate = 1; - colourFruits = fruitColour; - } - @Override public void writeData(DataOutputStream data) throws IOException { super.writeData(data); - data.writeByte(isRipeningUpdate); - - if(isRipeningUpdate()) { - data.writeInt(colourFruits); - } else { - data.writeByte(leafState); - data.writeShort(textureIndexFancy); - data.writeShort(textureIndexPlain); - data.writeShort(textureIndexFruit); - data.writeInt(colourLeaves); - data.writeInt(colourFruits); - } + data.writeByte(leafState); + data.writeShort(textureIndexFancy); + data.writeShort(textureIndexPlain); + data.writeShort(textureIndexFruit); + data.writeInt(colourLeaves); + data.writeInt(colourFruits); } @Override public void readData(DataInputStream data) throws IOException { super.readData(data); - - isRipeningUpdate = data.readByte(); - if(isRipeningUpdate()) { - colourFruits = data.readInt(); - } else { - leafState = data.readByte(); - textureIndexFancy = data.readShort(); - textureIndexPlain = data.readShort(); - textureIndexFruit = data.readShort(); - colourLeaves = data.readInt(); - colourFruits = data.readInt(); - } + + leafState = data.readByte(); + textureIndexFancy = data.readShort(); + textureIndexPlain = data.readShort(); + textureIndexFruit = data.readShort(); + colourLeaves = data.readInt(); + colourFruits = data.readInt(); } - - public boolean isRipeningUpdate() { - return isRipeningUpdate != 0; - } - + public boolean isFruitLeaf() { - return (leafState & (1 << 0)) > 0; + return (leafState & hasFruitFlag) > 0; } + public boolean isPollinated() { - return (leafState & (1 << 1)) > 0; + return (leafState & isPollinatedFlag) > 0; } } diff --git a/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java b/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java new file mode 100644 index 000000000..5f5db8d32 --- /dev/null +++ b/src/main/java/forestry/arboriculture/network/PacketRipeningUpdate.java @@ -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.arboriculture.network; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import forestry.arboriculture.gadgets.TileLeaves; +import forestry.core.network.ForestryPacket; +import forestry.core.network.PacketIds; + +public class PacketRipeningUpdate extends ForestryPacket { + + public int colourFruits; + private int posX, posY, posZ; + + public PacketRipeningUpdate() { + } + + public PacketRipeningUpdate(TileLeaves leaves, int fruitColour) { + super(PacketIds.RIPENING_UPDATE); + posX = leaves.xCoord; + posY = leaves.yCoord; + posZ = leaves.zCoord; + colourFruits = fruitColour; + } + + @Override + public void writeData(DataOutputStream data) throws IOException { + super.writeData(data); + + data.writeInt(posX); + data.writeInt(posY); + data.writeInt(posZ); + data.writeInt(colourFruits); + } + + @Override + public void readData(DataInputStream data) throws IOException { + super.readData(data); + + posX = data.readInt(); + posY = data.readInt(); + posZ = data.readInt(); + colourFruits = data.readInt(); + } + + public TileEntity getTarget(World world) { + return world.getTileEntity(posX, posY, posZ); + } +} diff --git a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java index 1f07fd2ac..6b9f06daf 100755 --- a/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java +++ b/src/main/java/forestry/arboriculture/worldgen/BlockTypeVoid.java @@ -24,8 +24,6 @@ public class BlockTypeVoid extends BlockType { @Override public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { world.setBlockToAir(x, y, z); - if (world.getTileEntity(x, y, z) != null) - world.removeTileEntity(x, y, z); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 0781aa7b3..3765ee6d8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -88,20 +88,14 @@ public abstract class WorldGenArboriculture extends WorldGenBase { protected void generateTreeTrunk(int height, int girth, float vines) { int offset = (girth - 1) / 2; - for (int x = 0; x < girth; x++) - for (int y = 0; y < girth; y++) - for (int i = 0; i < height; i++) { - addWood(x - offset, i, y - offset, EnumReplaceMode.ALL); - - if (rand.nextFloat() < vines) - addVine(x - offset - 1, i, y - offset); - if (rand.nextFloat() < vines) - addVine(x - offset + 1, i, y - offset); - if (rand.nextFloat() < vines) - addVine(x - offset, i, y - offset - 1); - if (rand.nextFloat() < vines) - addVine(x - offset, i, y - offset + 1); + for (int x = 0; x < girth; x++) { + for (int z = 0; z < girth; z++) { + for (int y = 0; y < height; y++) { + addWood(x - offset, y, z - offset, EnumReplaceMode.ALL); + addVines(x - offset, y, z - offset, vines); } + } + } if (!spawnPods) return; @@ -148,7 +142,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase { @Override protected void addBlock(int x, int y, int z, BlockType type, EnumReplaceMode replace) { if (replace == EnumReplaceMode.ALL - || replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z) + || (replace == EnumReplaceMode.SOFT && Utils.isReplaceableBlock(world, startX + x, startY + y, startZ + z)) || world.isAirBlock(startX + x, startY + y, startZ + z)) type.setBlock(world, tree, startX + x, startY + y, startZ + z); } @@ -179,4 +173,18 @@ public abstract class WorldGenArboriculture extends WorldGenBase { addBlock(x, y, z, vine, EnumReplaceMode.NONE); } + protected final void addVines(int x, int y, int z, float chance) { + if (chance <= 0) + return; + + if (rand.nextFloat() < chance) + addVine(x - 1, y, z); + if (rand.nextFloat() < chance) + addVine(x + 1, y, z); + if (rand.nextFloat() < chance) + addVine(x, y, z - 1); + if (rand.nextFloat() < chance) + addVine(x, y, z + 1); + } + } diff --git a/src/main/java/forestry/core/genetics/ItemGE.java b/src/main/java/forestry/core/genetics/ItemGE.java index 049c76bd8..a71dec25e 100755 --- a/src/main/java/forestry/core/genetics/ItemGE.java +++ b/src/main/java/forestry/core/genetics/ItemGE.java @@ -35,7 +35,7 @@ public abstract class ItemGE extends Item { protected abstract int getDefaultSecondaryColour(); - protected abstract IIndividual getIndividual(ItemStack itemstack); + public abstract IIndividual getIndividual(ItemStack itemstack); protected abstract IAlleleSpecies getSpecies(ItemStack itemStack); diff --git a/src/main/java/forestry/core/network/PacketIds.java b/src/main/java/forestry/core/network/PacketIds.java index b35aa1d58..32664f47e 100755 --- a/src/main/java/forestry/core/network/PacketIds.java +++ b/src/main/java/forestry/core/network/PacketIds.java @@ -1,62 +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; - -/** - * Valid ids: 0 - 127 - */ -public class PacketIds { - - public static final int TILE_FORESTRY_UPDATE = 0; - public static final int TILE_UPDATE = 1; - public static final int TILE_DESCRIPTION = 2; - public static final int IINVENTORY_STACK = 3; - public static final int FX_SIGNAL = 4; - public static final int TILE_NBT = 5; - - public static final int HABITAT_BIOME_POINTER = 20; - - public static final int GUI_SELECTION_CHANGE = 30; - public static final int IMPRINT_SELECTION_GET = 31; - public static final int GUI_SELECTION = 32; - - public static final int PIPETTE_CLICK = 40; - - public static final int ACCESS_SWITCH = 50; - - public static final int GENOME_TRACKER_UPDATE = 60; - public static final int GAME_TOKEN_SET = 61; - - public static final int CHIPSET_CLICK = 70; - public static final int SOLDERING_IRON_CLICK = 71; - public static final int SOCKET_UPDATE = 72; - - public static final int LETTER_RECIPIENT = 80; - public static final int LETTER_TEXT = 81; - public static final int TRADING_ADDRESS_SET = 82; - public static final int LETTER_INFO = 83; - public static final int POBOX_INFO = 85; - public static final int POBOX_INFO_REQUEST = 86; - - public static final int LEAF_UPDATE = 90; - - public static final int GUI_INTEGER = 92; - - // Propolis pipe - public static final int PROP_SEND_FILTER_SET = 100; - public static final int PROP_REQUEST_FILTER_SET = 101; - public static final int PROP_SEND_FILTER_CHANGE_GENOME = 102; - public static final int PROP_SEND_FILTER_CHANGE_TYPE = 103; - - - - -} +/******************************************************************************* + * 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; + +/** + * Valid ids: 0 - 127 + */ +public class PacketIds { + + public static final int TILE_FORESTRY_UPDATE = 0; + public static final int TILE_UPDATE = 1; + public static final int TILE_DESCRIPTION = 2; + public static final int IINVENTORY_STACK = 3; + public static final int FX_SIGNAL = 4; + public static final int TILE_NBT = 5; + + public static final int HABITAT_BIOME_POINTER = 20; + + public static final int GUI_SELECTION_CHANGE = 30; + public static final int IMPRINT_SELECTION_GET = 31; + public static final int GUI_SELECTION = 32; + + public static final int PIPETTE_CLICK = 40; + + public static final int ACCESS_SWITCH = 50; + + public static final int GENOME_TRACKER_UPDATE = 60; + public static final int GAME_TOKEN_SET = 61; + + public static final int CHIPSET_CLICK = 70; + public static final int SOLDERING_IRON_CLICK = 71; + public static final int SOCKET_UPDATE = 72; + + public static final int LETTER_RECIPIENT = 80; + public static final int LETTER_TEXT = 81; + public static final int TRADING_ADDRESS_SET = 82; + public static final int LETTER_INFO = 83; + public static final int POBOX_INFO = 85; + public static final int POBOX_INFO_REQUEST = 86; + + public static final int LEAF_UPDATE = 90; + public static final int RIPENING_UPDATE = 91; + + public static final int GUI_INTEGER = 92; + + // Propolis pipe + public static final int PROP_SEND_FILTER_SET = 100; + public static final int PROP_REQUEST_FILTER_SET = 101; + public static final int PROP_SEND_FILTER_CHANGE_GENOME = 102; + public static final int PROP_SEND_FILTER_CHANGE_TYPE = 103; + + + + +} diff --git a/src/main/java/forestry/core/utils/GeneticsUtil.java b/src/main/java/forestry/core/utils/GeneticsUtil.java index a1a28f67d..3b626a160 100644 --- a/src/main/java/forestry/core/utils/GeneticsUtil.java +++ b/src/main/java/forestry/core/utils/GeneticsUtil.java @@ -18,6 +18,7 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -30,6 +31,7 @@ import forestry.api.core.IArmorNaturalist; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IIndividual; import forestry.api.genetics.IPollinatable; +import forestry.core.genetics.ItemGE; import forestry.plugins.PluginArboriculture; public class GeneticsUtil { @@ -65,7 +67,7 @@ public class GeneticsUtil { return (IPollinatable) tile; } - IIndividual pollen = getErsatzPollen(world, x, y, z); + ITree pollen = getErsatzPollen(world, x, y, z); if (pollen != null) { PluginArboriculture.treeInterface.setLeaves(world, pollen, owner, x, y, z); return (IPollinatable) world.getTileEntity(x, y, z); @@ -74,7 +76,7 @@ public class GeneticsUtil { return null; } - public static IIndividual getErsatzPollen(World world, final int x, final int y, final int z) { + public static ITree getErsatzPollen(World world, final int x, final int y, final int z) { Block block = world.getBlock(x, y, z); if (!isErsatzMaterial(block)) return null; @@ -89,35 +91,33 @@ public class GeneticsUtil { } meta %= 3; } - - // Find the matching ersatz genome - for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) { - if (StackUtils.equals(block, meta, ersatzSpecimen)) { - return AlleleManager.ersatzSpecimen.get(ersatzSpecimen).copy(); - } - } + ItemStack itemStack = new ItemStack(block, meta); + IIndividual tree = getGeneticEquivalent(itemStack); + if (tree instanceof ITree) + return (ITree) tree; return null; } - public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) { - - ItemStack ersatz = null; - ITree tree = null; + public static IIndividual getGeneticEquivalent(ItemStack itemStack) { + Item item = itemStack.getItem(); + if (item instanceof ItemGE) + return ((ItemGE) item).getIndividual(itemStack); for (Map.Entry entry : AlleleManager.ersatzSaplings.entrySet()) { - if (entry.getKey().getItem() != foreign.getItem()) - continue; - if (entry.getKey().getItemDamage() != foreign.getItemDamage()) - continue; - - if (entry.getValue() instanceof ITree) - tree = (ITree) entry.getValue(); - - ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); - ersatz.stackSize = foreign.stackSize; + if (StackUtils.isIdenticalItem(itemStack, entry.getKey())) + return entry.getValue().copy(); } + return null; + } + public static ItemStack convertSaplingToGeneticEquivalent(ItemStack foreign) { + IIndividual tree = getGeneticEquivalent(foreign); + if (!(tree instanceof ITree)) + return null; + + ItemStack ersatz = PluginArboriculture.treeInterface.getMemberStack(tree, EnumGermlingType.SAPLING.ordinal()); + ersatz.stackSize = foreign.stackSize; return ersatz; } } diff --git a/src/main/java/forestry/core/worldgen/BlockType.java b/src/main/java/forestry/core/worldgen/BlockType.java index 5eb2a6327..7a9756b77 100755 --- a/src/main/java/forestry/core/worldgen/BlockType.java +++ b/src/main/java/forestry/core/worldgen/BlockType.java @@ -33,8 +33,6 @@ public class BlockType { public void setBlock(World world, ITreeGenData tree, int x, int y, int z) { world.setBlock(x, y, z, block, meta, Defaults.FLAG_BLOCK_SYNCH); - if (world.getTileEntity(x, y, z) != null) - world.removeTileEntity(x, y, z); } public int getMeta() { diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/FarmableGE.java index 358bf9465..b3be02ec4 100755 --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/FarmableGE.java @@ -36,7 +36,7 @@ public class FarmableGE implements IFarmable { public ICrop getCropAt(World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); - if (block.isAir(world, x, y, z) || !block.isWood(world, x, y, z)) + if (!block.isWood(world, x, y, z)) return null; return new CropBlock(world, block, world.getBlockMetadata(x, y, z), new Vect(x, y, z)); diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java index ab4168aaa..843d44b95 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java @@ -10,17 +10,17 @@ ******************************************************************************/ package forestry.farming.logic; -import forestry.api.arboriculture.ITree; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IIndividual; -import forestry.plugins.PluginArboriculture; -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; import net.minecraft.world.World; +import forestry.api.arboriculture.ITree; +import forestry.api.genetics.IIndividual; +import forestry.core.utils.GeneticsUtil; +import forestry.plugins.PluginArboriculture; + public class FarmableVanillaSapling extends FarmableGenericSapling { public FarmableVanillaSapling() { @@ -29,17 +29,11 @@ public class FarmableVanillaSapling extends FarmableGenericSapling { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z) { - ITree tree = null; - for (Map.Entry entry : AlleleManager.ersatzSaplings.entrySet()) - if (entry.getKey().isItemEqual(germling) && entry.getValue() instanceof ITree) { - tree = (ITree) entry.getValue(); - break; - } - - if (tree == null) + IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling); + if (!(tree instanceof ITree)) return false; - return PluginArboriculture.treeInterface.plantSapling(world, tree, player.getGameProfile(), x, y, z); + return PluginArboriculture.treeInterface.plantSapling(world, (ITree)tree, player.getGameProfile(), x, y, z); } } diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 41beb4bad..6aff66d0f 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -60,7 +60,7 @@ public class ItemButterflyGE extends ItemGE { } @Override - protected IIndividual getIndividual(ItemStack itemstack) { + public IButterfly getIndividual(ItemStack itemstack) { return PluginLepidopterology.butterflyInterface.getMember(itemstack); } From 080e026285d36cc8a6bde764212e97b43314551c Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 5 Jan 2015 20:37:00 -0800 Subject: [PATCH 147/175] Fix #433 Stairs have wrong pick-block and Waila name --- .../arboriculture/gadgets/BlockArbStairs.java | 21 +++++++++++++++++++ .../arboriculture/items/ItemStairs.java | 16 +++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index 5c9f4ef13..c75d86afe 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -12,6 +12,7 @@ package forestry.arboriculture.gadgets; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.Tabs; import forestry.arboriculture.WoodType; import forestry.core.proxy.Proxies; @@ -28,6 +29,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -104,6 +106,25 @@ public class BlockArbStairs extends BlockStairs { return new TileStairs(); } + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + ItemStack itemStack = super.getPickBlock(target, world, x, y, z); + NBTTagCompound stairsNBT = getTagCompoundForStairs(world, x, y, z); + itemStack.setTagCompound(stairsNBT); + return itemStack; + } + + private static NBTTagCompound getTagCompoundForStairs(IBlockAccess world, int x, int y, int z) { + TileStairs stairs = getStairTile(world, x, y, z); + + NBTTagCompound nbttagcompound = new NBTTagCompound(); + if (stairs == null || stairs.getType() == null) + return nbttagcompound; + + stairs.getType().saveToCompound(nbttagcompound); + return nbttagcompound; + } + /* ICONS */ @SideOnly(Side.CLIENT) @Override diff --git a/src/main/java/forestry/arboriculture/items/ItemStairs.java b/src/main/java/forestry/arboriculture/items/ItemStairs.java index 56d99ddfd..be32e9a67 100755 --- a/src/main/java/forestry/arboriculture/items/ItemStairs.java +++ b/src/main/java/forestry/arboriculture/items/ItemStairs.java @@ -10,20 +10,19 @@ ******************************************************************************/ package forestry.arboriculture.items; -import forestry.arboriculture.WoodType; -import forestry.arboriculture.gadgets.BlockArbStairs; -import forestry.arboriculture.gadgets.TileStairs; -import forestry.core.config.Defaults; -import forestry.core.config.ForestryBlock; -import forestry.core.items.ItemForestryBlock; -import forestry.core.utils.StringUtil; - 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; +import forestry.arboriculture.WoodType; +import forestry.arboriculture.gadgets.TileStairs; +import forestry.core.config.Defaults; +import forestry.core.config.ForestryBlock; +import forestry.core.items.ItemForestryBlock; +import forestry.core.utils.StringUtil; + public class ItemStairs extends ItemForestryBlock { public ItemStairs(Block block) { @@ -65,7 +64,6 @@ public class ItemStairs extends ItemForestryBlock { @Override public String getItemStackDisplayName(ItemStack itemStack) { - BlockArbStairs block = (BlockArbStairs) getBlock(); WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound()); if (woodType == null) return null; From 24ca3d20f3e357414240998895168cbc331d29ea Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 5 Jan 2015 20:58:27 -0800 Subject: [PATCH 148/175] Fix #436 Tooltip order for trees should match treealyzer order --- src/main/java/forestry/arboriculture/genetics/Tree.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 9921df7b9..022794d3b 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -281,11 +281,11 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable String maturation = EnumChatFormatting.RED + "M: " + genome.getActiveAllele(EnumTreeChromosome.MATURATION).getName(); String height = EnumChatFormatting.LIGHT_PURPLE + "H: " + genome.getActiveAllele(EnumTreeChromosome.HEIGHT).getName(); String girth = EnumChatFormatting.AQUA + "G: " + String.format("%sx%s", genome.getGirth(), genome.getGirth()); - String fertility = EnumChatFormatting.YELLOW + "S: " + genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName(); + String saplings = EnumChatFormatting.YELLOW + "S: " + genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName(); String yield = EnumChatFormatting.WHITE + "Y: " + genome.getActiveAllele(EnumTreeChromosome.YIELD).getName(); - list.add(String.format("%s, %s", sappiness, maturation)); + list.add(String.format("%s, %s", saplings, maturation)); list.add(String.format("%s, %s", height, girth)); - list.add(String.format("%s, %s", fertility, yield)); + list.add(String.format("%s, %s", yield, sappiness)); IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); if (primaryFireproof.getValue()) From 92d53626cea0414a77dea585e707e32151d3c431 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 5 Jan 2015 20:59:56 -0800 Subject: [PATCH 149/175] Add generation count to bee tooltips for bred bees. --- .../forestry/apiculture/genetics/Bee.java | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index a8104fdef..b181fd8cd 100755 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -355,22 +356,43 @@ public class Bee extends IndividualLiving implements IBee { if (!isPureBred(EnumBeeChromosome.SPECIES)) list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName())); - IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED); - String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", ""); - if (StringUtil.canTranslate(customWorker)) - list.add(StringUtil.localize(customWorker)); + if (generation > 0) { + EnumRarity rarity; + if (generation >= 1000) + rarity = EnumRarity.epic; + else if (generation >= 100) + rarity = EnumRarity.rare; + else if (generation >= 10) + rarity = EnumRarity.uncommon; + else + rarity = EnumRarity.common; + + String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation); + list.add(generationString); + } + + IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED); + IAlleleTolerance tempToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); + IAlleleTolerance humidToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); + + String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", ""); + String speed; + if (StringUtil.canTranslate(unlocalizedCustomSpeed)) + speed = StringUtil.localize(unlocalizedCustomSpeed); else - list.add(speed.getName() + " " + StringUtil.localize("gui.worker")); + speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker"); - list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life")); + String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life"); + String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName(); + String humidTolerance = EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidToleranceAllele.getName(); + String flowers = genome.getFlowerProvider().getDescription(); - IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); - list.add(EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName()); + list.add(lifespan); + list.add(speed); + list.add(tempTolerance); + list.add(humidTolerance); + list.add(flowers); - IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); - list.add(EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName()); - - list.add(genome.getFlowerProvider().getDescription()); if (genome.getNocturnal()) list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false)); } From 0fc61f46b05d4db144bdef89df38e27e094c8de2 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 07:07:45 -0800 Subject: [PATCH 150/175] Allow disabling Factory Module --- .../forestry/plugins/PluginApiculture.java | 162 +++++++++--------- .../forestry/plugins/PluginArboriculture.java | 38 ++-- .../java/forestry/plugins/PluginManager.java | 2 +- .../java/forestry/plugins/PluginStorage.java | 43 ++--- 4 files changed, 125 insertions(+), 120 deletions(-) diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 4c4b366bc..b8afe45e0 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -516,6 +516,7 @@ public class PluginApiculture extends ForestryPlugin { '#', "dustAsh", 'X', ForestryItem.peat, 'Y', ForestryItem.propolis); + // / TORCHES Proxies.common.addRecipe(new ItemStack(Blocks.torch, 3), " # ", " # ", " Y ", @@ -525,20 +526,6 @@ public class PluginApiculture extends ForestryPlugin { "# #", " # ", "# #", '#', ForestryItem.propolis.getItemStack(1, 2)); - // / CANDLES - RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.getFluid(600), null, ForestryBlock.candle.getItemStack(24), - " X ", - "###", - "###", - '#', ForestryItem.beeswax, - 'X', Items.string); - RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(200), null, ForestryBlock.candle.getItemStack(6), - "#X#", - '#', ForestryItem.beeswax, - 'X', ForestryItem.craftingMaterial.getItemStack(1, 2)); - Proxies.common.addShapelessRecipe(ForestryBlock.candle.getItemStack(), ForestryBlock.candle.getItemStack()); - Proxies.common.addShapelessRecipe(ForestryBlock.candle.getItemStack(1, 1), ForestryBlock.candle.getItemStack(1, 1)); - // / WAX CAST Proxies.common.addRecipe(ForestryItem.waxCast.getItemStack(), "###", @@ -601,76 +588,91 @@ public class PluginApiculture extends ForestryPlugin { 'I', Items.iron_ingot, 'W', ForestryItem.craftingMaterial.getItemStack(1, 3)); - // / SQUEEZER - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP), - ForestryItem.propolis.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, Fluids.LAVA.getFluid(2000)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, Fluids.LAVA.getFluid(1600)); + if (PluginManager.Module.FACTORY.isEnabled()) { + // / SQUEEZER + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeyDrop.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP), + ForestryItem.propolis.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.honeydew.getItemStack()}, Fluids.HONEY.getFluid(Defaults.FLUID_PER_HONEY_DROP)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.sand)}, Fluids.LAVA.getFluid(2000)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{ForestryItem.phosphor.getItemStack(2), new ItemStack(Blocks.dirt)}, Fluids.LAVA.getFluid(1600)); - // / CARPENTER - RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.beealyzer.getItemStack(), - "X#X", "X#X", "RDR", - '#', Blocks.glass_pane, - 'X', "ingotTin", - 'R', Items.redstone, - 'D', Items.diamond); - RecipeManagers.carpenterManager.addRecipe(50, Fluids.HONEY.getFluid(500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), - " J ", "###", "WPW", - '#', "plankWood", - 'J', ForestryItem.royalJelly, - 'W', ForestryItem.beeswax, - 'P', ForestryItem.pollenCluster); + // / CARPENTER + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.beealyzer.getItemStack(), + "X#X", "X#X", "RDR", + '#', Blocks.glass_pane, + 'X', "ingotTin", + 'R', Items.redstone, + 'D', Items.diamond); + RecipeManagers.carpenterManager.addRecipe(50, Fluids.HONEY.getFluid(500), null, ForestryItem.craftingMaterial.getItemStack(1, 6), + " J ", "###", "WPW", + '#', "plankWood", + 'J', ForestryItem.royalJelly, + 'W', ForestryItem.beeswax, + 'P', ForestryItem.pollenCluster); - // / CENTRIFUGE - // Honey combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 0), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); - // Cocoa combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 1), ForestryItem.beeswax.getItemStack(), new ItemStack(Items.dye, 1, 3), 50); - // Simmering combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 2), ForestryItem.refractoryWax.getItemStack(), ForestryItem.phosphor.getItemStack(2), 70); - // Stringy combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 3), ForestryItem.propolis.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 40); - // Drippig combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 5), ForestryItem.honeydew.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 40); - // Frozen combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 4), new ItemStack[]{ForestryItem.beeswax.getItemStack(), - ForestryItem.honeyDrop.getItemStack(), new ItemStack(Items.snowball), ForestryItem.pollenCluster.getItemStack(1, 1)}, new int[]{80, 70, 40, 20}); - // Silky combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 6), ForestryItem.honeyDrop.getItemStack(), ForestryItem.propolis.getItemStack(1, 3), 80); - // Parched combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 7), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); - // Mysterious combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 8), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), - ForestryItem.propolis.getItemStack(1, 2)}, new int[]{40, 100}); - // Irradiated combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 9), new ItemStack[]{}, new int[]{}); - // Powdery combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 10), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), - ForestryItem.beeswax.getItemStack(), new ItemStack(Items.gunpowder)}, new int[]{20, 20, 90}); - // Reddened Combs - RecipeManagers.centrifugeManager.addRecipe(80, ForestryItem.beeComb.getItemStack(1, 11), - new ItemStack[]{ForestryItem.honeyDrop.getItemStack(2, 1)}, new int[]{100}); - // Darkened Combs - RecipeManagers.centrifugeManager.addRecipe(80, ForestryItem.beeComb.getItemStack(1, 12), - new ItemStack[]{ForestryItem.honeyDrop.getItemStack(1, 1)}, new int[]{100}); - // Omega Combs - RecipeManagers.centrifugeManager.addRecipe(400, ForestryItem.beeComb.getItemStack(1, 13), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(1, 2)}, new int[]{100}); - // Wheaten Combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 14), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), - ForestryItem.beeswax.getItemStack(), new ItemStack(Items.wheat)}, new int[]{20, 20, 80}); - // Mossy Combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 15), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); - // Mellow Combs - RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 16), new ItemStack[]{ForestryItem.honeydew.getItemStack(), - ForestryItem.beeswax.getItemStack(), new ItemStack(Items.quartz)}, new int[]{60, 20, 30}); + RecipeManagers.carpenterManager.addRecipe(30, Fluids.WATER.getFluid(600), null, ForestryBlock.candle.getItemStack(24), + " X ", + "###", + "###", + '#', ForestryItem.beeswax, + 'X', Items.string); + RecipeManagers.carpenterManager.addRecipe(10, Fluids.WATER.getFluid(200), null, ForestryBlock.candle.getItemStack(6), + "#X#", + '#', ForestryItem.beeswax, + 'X', ForestryItem.craftingMaterial.getItemStack(1, 2)); + Proxies.common.addShapelessRecipe(ForestryBlock.candle.getItemStack(), ForestryBlock.candle.getItemStack()); + Proxies.common.addShapelessRecipe(ForestryBlock.candle.getItemStack(1, 1), ForestryBlock.candle.getItemStack(1, 1)); - // Silk - RecipeManagers.centrifugeManager.addRecipe(5, ForestryItem.propolis.getItemStack(1, 3), new ItemStack[]{ - ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10}); + // / CENTRIFUGE + // Honey combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 0), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); + // Cocoa combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 1), ForestryItem.beeswax.getItemStack(), new ItemStack(Items.dye, 1, 3), 50); + // Simmering combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 2), ForestryItem.refractoryWax.getItemStack(), ForestryItem.phosphor.getItemStack(2), 70); + // Stringy combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 3), ForestryItem.propolis.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 40); + // Drippig combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 5), ForestryItem.honeydew.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 40); + // Frozen combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 4), new ItemStack[]{ForestryItem.beeswax.getItemStack(), + ForestryItem.honeyDrop.getItemStack(), new ItemStack(Items.snowball), ForestryItem.pollenCluster.getItemStack(1, 1)}, new int[]{80, 70, 40, 20}); + // Silky combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 6), ForestryItem.honeyDrop.getItemStack(), ForestryItem.propolis.getItemStack(1, 3), 80); + // Parched combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 7), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); + // Mysterious combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 8), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), + ForestryItem.propolis.getItemStack(1, 2)}, new int[]{40, 100}); + // Irradiated combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 9), new ItemStack[]{}, new int[]{}); + // Powdery combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 10), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), + ForestryItem.beeswax.getItemStack(), new ItemStack(Items.gunpowder)}, new int[]{20, 20, 90}); + // Reddened Combs + RecipeManagers.centrifugeManager.addRecipe(80, ForestryItem.beeComb.getItemStack(1, 11), + new ItemStack[]{ForestryItem.honeyDrop.getItemStack(2, 1)}, new int[]{100}); + // Darkened Combs + RecipeManagers.centrifugeManager.addRecipe(80, ForestryItem.beeComb.getItemStack(1, 12), + new ItemStack[]{ForestryItem.honeyDrop.getItemStack(1, 1)}, new int[]{100}); + // Omega Combs + RecipeManagers.centrifugeManager.addRecipe(400, ForestryItem.beeComb.getItemStack(1, 13), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(1, 2)}, new int[]{100}); + // Wheaten Combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 14), new ItemStack[]{ForestryItem.honeyDrop.getItemStack(), + ForestryItem.beeswax.getItemStack(), new ItemStack(Items.wheat)}, new int[]{20, 20, 80}); + // Mossy Combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 15), ForestryItem.beeswax.getItemStack(), ForestryItem.honeyDrop.getItemStack(), 90); + // Mellow Combs + RecipeManagers.centrifugeManager.addRecipe(20, ForestryItem.beeComb.getItemStack(1, 16), new ItemStack[]{ForestryItem.honeydew.getItemStack(), + ForestryItem.beeswax.getItemStack(), new ItemStack(Items.quartz)}, new int[]{60, 20, 30}); - // / FERMENTER - RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.getFluid(1), Fluids.HONEY.getFluid(1)); + // Silk + RecipeManagers.centrifugeManager.addRecipe(5, ForestryItem.propolis.getItemStack(1, 3), new ItemStack[]{ + ForestryItem.craftingMaterial.getItemStack(1, 2), ForestryItem.propolis.getItemStack()}, new int[]{60, 10}); + + // / FERMENTER + RecipeManagers.fermenterManager.addRecipe(ForestryItem.honeydew.getItemStack(), 500, 1.0f, Fluids.SHORT_MEAD.getFluid(1), Fluids.HONEY.getFluid(1)); + } // ANALYZER definitionAnalyzer.recipes = createAlyzerRecipes(ForestryBlock.core.block(), Defaults.DEFINITION_ANALYZER_META); diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 22fd4f5ee..e7b5af342 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -503,26 +503,28 @@ public class PluginArboriculture extends ForestryPlugin { throw new RuntimeException("Wood type has no fences defined"); } - // Treealyzer - RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", - '#', Blocks.glass_pane, - 'X', "ingotCopper", - 'R', Items.redstone, - 'D', Items.diamond); + if (PluginManager.Module.FACTORY.isEnabled()) { + // Treealyzer + RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", + '#', Blocks.glass_pane, + 'X', "ingotCopper", + 'R', Items.redstone, + 'D', Items.diamond); - // SQUEEZER RECIPES - int seedOilMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); - int juiceMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); - int mulchMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); - RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{EnumFruit.CHERRY.getStack()}, Fluids.SEEDOIL.getFluid(5 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{EnumFruit.WALNUT.getStack()}, Fluids.SEEDOIL.getFluid(18 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); - RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{EnumFruit.CHESTNUT.getStack()}, Fluids.SEEDOIL.getFluid(22 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 2); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.LEMON.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PLUM.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.5f)), ForestryItem.mulch.getItemStack(), mulchMultiplier * 3); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PAPAYA.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); - RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.DATES.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.25)), ForestryItem.mulch.getItemStack(), mulchMultiplier); + // SQUEEZER RECIPES + int seedOilMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.seed"); + int juiceMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.liquid.apple"); + int mulchMultiplier = GameMode.getGameMode().getIntegerSetting("squeezer.mulch.apple"); + RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{EnumFruit.CHERRY.getStack()}, Fluids.SEEDOIL.getFluid(5 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(60, new ItemStack[]{EnumFruit.WALNUT.getStack()}, Fluids.SEEDOIL.getFluid(18 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 5); + RecipeManagers.squeezerManager.addRecipe(70, new ItemStack[]{EnumFruit.CHESTNUT.getStack()}, Fluids.SEEDOIL.getFluid(22 * seedOilMultiplier), ForestryItem.mulch.getItemStack(), 2); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.LEMON.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 2), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PLUM.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.5f)), ForestryItem.mulch.getItemStack(), mulchMultiplier * 3); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.PAPAYA.getStack()}, Fluids.JUICE.getFluid(juiceMultiplier * 3), ForestryItem.mulch.getItemStack(), (int) Math.floor(mulchMultiplier * 0.5f)); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{EnumFruit.DATES.getStack()}, Fluids.JUICE.getFluid((int) Math.floor(juiceMultiplier * 0.25)), ForestryItem.mulch.getItemStack(), mulchMultiplier); - RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); + RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); + } // Stairs for (WoodType woodType : WoodType.values()) { diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 0cac19ba6..463eb95d5 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -169,7 +169,7 @@ public class PluginManager { if (!toLoad.containsAll(deps)) { it.remove(); changed = true; - Proxies.log.warning("Module {0} is missing dependancies: {1}", m, deps); + Proxies.log.warning("Module {0} is missing dependencies: {1}", m, deps); continue; } } diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index 1d35eaa82..3a5c9b503 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -529,27 +529,28 @@ public class PluginStorage extends ForestryPlugin implements IOreDictionaryHandl Proxies.common.addRecipe(ForestryItem.builderBackpack.getItemStack(), "X#X", "VYV", "X#X", '#', Blocks.wool, 'X', Items.string, 'V', Items.clay_ball, 'Y', Blocks.chest); - // / CARPENTER - // / BACKPACKS T2 - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.minerBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.diggerBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.foresterBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.hunterBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack); - RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.builderBackpackT2.getItemStack(), - "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', - ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack); - + if (PluginManager.Module.FACTORY.isEnabled()) { + // / CARPENTER + // / BACKPACKS T2 + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.minerBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.minerBackpack); + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.diggerBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.diggerBackpack); + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.foresterBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.foresterBackpack); + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.hunterBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.hunterBackpack); + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.adventurerBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.adventurerBackpack); + RecipeManagers.carpenterManager.addRecipe(200, Fluids.WATER.getFluid(1000), null, ForestryItem.builderBackpackT2.getItemStack(), + "WXW", "WTW", "WWW", 'X', Items.diamond, 'W', + ForestryItem.craftingMaterial.getItemStack(1, 3), 'T', ForestryItem.builderBackpack); + } } @Override From 58a8b29bbf9d6ccffa079140a994cdd9781581c6 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 07:13:18 -0800 Subject: [PATCH 151/175] Minor render optimization for stopped engines --- src/main/java/forestry/energy/render/RenderEngine.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/energy/render/RenderEngine.java b/src/main/java/forestry/energy/render/RenderEngine.java index 0a2ab054d..b300be8b5 100755 --- a/src/main/java/forestry/energy/render/RenderEngine.java +++ b/src/main/java/forestry/energy/render/RenderEngine.java @@ -193,9 +193,11 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IBlockRen Proxies.common.bindTexture(textures[Textures.EXTENSION.ordinal()]); float chamberf = 2F / 16F; - for (int i = 0; i <= step + 2; i += 2) { - extension.render(factor); - GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf); + if (step > 0) { + for (int i = 0; i <= step + 2; i += 2) { + extension.render(factor); + GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf); + } } GL11.glPopAttrib(); From 852604e9d4e9ae168b19cfb1f2e90ecb2fe22556 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 07:49:27 -0800 Subject: [PATCH 152/175] Fix pipette display. Updates icon on click, shows fluid amount tooltip --- .../core/gui/ContainerLiquidTanks.java | 42 ++++++++++++------- .../forestry/core/gui/widgets/TankWidget.java | 2 +- .../java/forestry/core/items/ItemPipette.java | 3 +- .../forestry/core/network/PacketHandler.java | 4 +- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java index 435097c51..a92e744af 100755 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanks.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanks.java @@ -10,6 +10,17 @@ ******************************************************************************/ package forestry.core.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import forestry.api.core.IToolPipette; import forestry.core.fluids.tanks.StandardTank; import forestry.core.gadgets.TileForestry; @@ -18,12 +29,6 @@ import forestry.core.network.PacketIds; import forestry.core.network.PacketPayload; import forestry.core.network.PacketUpdate; import forestry.core.proxy.Proxies; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; public class ContainerLiquidTanks extends ContainerForestry { @@ -34,7 +39,18 @@ public class ContainerLiquidTanks extends ContainerForestry { this.tile = tile; } - public void handlePipetteClick(int slot, EntityPlayer player) { + @SideOnly(Side.CLIENT) + public void handlePipetteClickClient(int slot, EntityPlayer player) { + ItemStack itemstack = player.inventory.getItemStack(); + if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette)) + return; + + PacketPayload payload = new PacketPayload(1, 0, 0); + payload.intPayload[0] = slot; + Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload)); + } + + public void handlePipetteClick(int slot, EntityPlayerMP player) { ItemStack itemstack = player.inventory.getItemStack(); if (itemstack == null) @@ -44,13 +60,6 @@ public class ContainerLiquidTanks extends ContainerForestry { if (!(held instanceof IToolPipette)) 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; StandardTank tank = tile.getTankManager().get(slot); int liquidAmount = tank.getFluidAmount(); @@ -60,11 +69,14 @@ public class ContainerLiquidTanks extends ContainerForestry { FluidStack fillAmount = tank.drain(1000, false); int filled = pipette.fill(itemstack, fillAmount, true); tank.drain(filled, true); + player.updateHeldItem(); } } else { FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false); - if (potential != null) + if (potential != null) { pipette.drain(itemstack, tank.fill(potential, true), true); + player.updateHeldItem(); + } } } diff --git a/src/main/java/forestry/core/gui/widgets/TankWidget.java b/src/main/java/forestry/core/gui/widgets/TankWidget.java index 459ef0ab3..8a0d817c4 100755 --- a/src/main/java/forestry/core/gui/widgets/TankWidget.java +++ b/src/main/java/forestry/core/gui/widgets/TankWidget.java @@ -114,7 +114,7 @@ public class TankWidget extends Widget { Item held = itemstack.getItem(); if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof ContainerLiquidTanks) - ((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClick(slot, manager.minecraft.thePlayer); + ((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer); } } diff --git a/src/main/java/forestry/core/items/ItemPipette.java b/src/main/java/forestry/core/items/ItemPipette.java index 7d011cc13..e459ee0b5 100755 --- a/src/main/java/forestry/core/items/ItemPipette.java +++ b/src/main/java/forestry/core/items/ItemPipette.java @@ -60,8 +60,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette { return; String descr = contents.getFluid().getLocalizedName(contents); - if (Config.isDebug) - descr += " (" + contents.amount + ")"; + descr += " (" + contents.amount + " mb)"; list.add(descr); } diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index b25c6fb4c..fac5dbda4 100755 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -59,7 +59,7 @@ public class PacketHandler { null); } - public void onPacketData(InputStream is, EntityPlayer player) { + public void onPacketData(InputStream is, EntityPlayerMP player) { DataInputStream data = new DataInputStream(is); PacketUpdate packetU; @@ -263,7 +263,7 @@ public class PacketHandler { tile.switchAccessRule(playerEntity); } - private void onPipetteClick(PacketUpdate packet, EntityPlayer player) { + private void onPipetteClick(PacketUpdate packet, EntityPlayerMP player) { assert FMLCommonHandler.instance().getEffectiveSide().isServer(); if (!(player.openContainer instanceof ContainerLiquidTanks)) From 8edd081de6c3024c0cbb12af07a0846bf686097b Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 08:41:23 -0800 Subject: [PATCH 153/175] Update lang --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 08740297c..20c23dc2e 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 08740297c4c5acd65a6666e26e139c6e0e1c178b +Subproject commit 20c23dc2ec65b299f1a8a94364a7c9a07b7ce26b From ec111e38c3a7affe3d66c5b9b776a072075af363 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 08:49:24 -0800 Subject: [PATCH 154/175] #443 Squeezer should not squeeze if it has no room for the liquid --- .../java/forestry/core/EnumErrorCode.java | 1 + .../factory/gadgets/MachineSqueezer.java | 110 ++++-------------- 2 files changed, 23 insertions(+), 88 deletions(-) diff --git a/src/main/java/forestry/core/EnumErrorCode.java b/src/main/java/forestry/core/EnumErrorCode.java index c6d2b3820..0b910ed0b 100644 --- a/src/main/java/forestry/core/EnumErrorCode.java +++ b/src/main/java/forestry/core/EnumErrorCode.java @@ -33,6 +33,7 @@ public enum EnumErrorCode implements IErrorState { NODRONE("noDrone"), NOSKY("noSky"), NOSPACE("noSpace"), + NOSPACETANK("noSpaceTank", "noLiquid"), NORECIPE("noRecipe"), NOENERGYNET("noEnergyNet"), NOTHINGANALYZE("noSpecimen"), diff --git a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java index bda1cdf88..e05fb6097 100755 --- a/src/main/java/forestry/factory/gadgets/MachineSqueezer.java +++ b/src/main/java/forestry/factory/gadgets/MachineSqueezer.java @@ -57,6 +57,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi public static final short SLOT_RESOURCE_1 = 0; public static final short SLOTS_RESOURCE_COUNT = 9; public static final short SLOT_REMNANT = 9; + public static final short SLOT_REMNANT_COUNT = 1; public static final short SLOT_CAN_INPUT = 10; public static final short SLOT_CAN_OUTPUT = 11; @@ -139,8 +140,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi private Recipe currentRecipe; - private final Stack pendingLiquids = new Stack(); - private final Stack pendingRemnants = new Stack(); private int productionTime; private int timePerItem; @@ -187,32 +186,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi nbttagcompound.setInteger("ProductionTime", productionTime); nbttagcompound.setInteger("TimePerItem", timePerItem); - // Pending remnants - NBTTagList nbttaglist = new NBTTagList(); - ItemStack[] remnants = pendingRemnants.toArray(new ItemStack[pendingRemnants.size()]); - for (int i = 0; i < remnants.length; i++) { - if (remnants[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - remnants[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("PendingRemnants", nbttaglist); - - // Pending liquids - nbttaglist = new NBTTagList(); - FluidStack[] liquids = pendingLiquids.toArray(new FluidStack[pendingLiquids.size()]); - for (int i = 0; i < liquids.length; i++) { - if (liquids[i] != null) { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - liquids[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - nbttagcompound.setTag("PendingLiquids", nbttaglist); - tankManager.writeTanksToNBT(nbttagcompound); } @@ -222,21 +195,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi productionTime = nbttagcompound.getInteger("ProductionTime"); timePerItem = nbttagcompound.getInteger("TimePerItem"); - - // Pending remnants - NBTTagList nbttaglist = nbttagcompound.getTagList("PendingRemnants", 10); - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - pendingRemnants.add(ItemStack.loadItemStackFromNBT(nbttagcompound1)); - } - - // Pending liquids - nbttaglist = nbttagcompound.getTagList("PendingLiquids", 10); - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - pendingLiquids.add(FluidStack.loadFluidStackFromNBT(nbttagcompound1)); - } - tankManager.readTanksFromNBT(nbttagcompound); checkRecipe(); @@ -271,13 +229,24 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi checkRecipe(); - // If we add pending products, we skip to the next work cycle. - tryAddPending(); - - if (!pendingLiquids.isEmpty() || !pendingRemnants.isEmpty()) + if (getErrorState() == EnumErrorCode.NORECIPE) return false; - // Continue work if nothing needs to be added + FluidStack resultFluid = currentRecipe.liquid.copy(); + if (productTank.fill(resultFluid, false) < resultFluid.amount) { + setErrorState(EnumErrorCode.NOSPACETANK); + return false; + } + + ItemStack remnant = null; + if (currentRecipe.remnants != null) { + remnant = currentRecipe.remnants.copy(); + if (!InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, false)) { + setErrorState(EnumErrorCode.NOSPACE); + return false; + } + } + if (productionTime <= 0) return false; @@ -294,17 +263,15 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi if (!removeResources(currentRecipe.resources)) return false; - // We are done, add products to queue - pendingLiquids.push(currentRecipe.liquid.copy()); - if (currentRecipe.remnants != null && worldObj.rand.nextInt(100) < currentRecipe.chance) - pendingRemnants.push(currentRecipe.remnants.copy()); + productTank.fill(resultFluid, true); + if (remnant != null && worldObj.rand.nextInt(100) < currentRecipe.chance) + InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true); + + setErrorState(EnumErrorCode.OK); checkRecipe(); resetRecipe(); - tryAddPending(); - setErrorState(EnumErrorCode.OK); - return true; } @@ -332,39 +299,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi timePerItem = currentRecipe.timePerItem; } - private boolean tryAddPending() { - - if (!pendingLiquids.isEmpty()) { - FluidStack next = pendingLiquids.peek(); - if (addProduct(next)) { - pendingLiquids.pop(); - return true; - } - } - - if (!pendingRemnants.isEmpty()) { - ItemStack next = pendingRemnants.peek(); - if (addRemnant(next)) { - pendingRemnants.pop(); - return true; - } - } - - if (!pendingLiquids.isEmpty() || !pendingRemnants.isEmpty()) - setErrorState(EnumErrorCode.NOSPACE); - return false; - } - - private boolean addProduct(FluidStack stack) { - stack.amount -= productTank.fill(stack, true); - - return stack.amount <= 0; - } - - private boolean addRemnant(ItemStack stack) { - return InvTools.tryAddStack(getInternalInventory(), stack, SLOT_REMNANT, 1, true); - } - private boolean removeResources(ItemStack[] stacks) { EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwnerProfile()); return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true); From 8dc81b53d6d7dd4ea6ebe5cf9b56d1521aa580ec Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 7 Jan 2015 13:46:30 -0800 Subject: [PATCH 155/175] Improves #431 Calling markBlockForUpdate() on the server is unneccesary, plus other optimizations. --- .../gadgets/ForestryBlockLeaves.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 2558ee9a3..8649b7ad4 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -58,10 +58,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv public static TileLeaves getLeafTile(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if (!(tile instanceof TileLeaves)) - return null; - - return (TileLeaves) tile; + if (tile instanceof TileLeaves) + return (TileLeaves) tile; + return null; } private static NBTTagCompound getTagCompoundForTree(IBlockAccess world, int x, int y, int z) { @@ -152,9 +151,9 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { - ItemStack itemStack = super.getPickBlock(target, world, x, y, z); + ItemStack itemStack = super.getPickBlock(target, world, x, y, z, player); NBTTagCompound treeNBT = getTagCompoundForTree(world, x, y, z); itemStack.setTagCompound(treeNBT); return itemStack; @@ -178,10 +177,12 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void beginLeavesDecay(World world, int x, int y, int z) { - if (getLeafTile(world, x, y, z).isDecorative()) + TileLeaves tile = getLeafTile(world, x, y, z); + if (tile != null && tile.isDecorative()) return; - super.beginLeavesDecay(world, x, y, z); - world.markBlockForUpdate(x, y, z); + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); + if (world.isRemote) + world.markBlockForUpdate(x, y, z); } @Override @@ -193,8 +194,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv super.updateTick(world, x, y, z, random); // check leaves tile again because they can decay in super.updateTick - tileLeaves = getLeafTile(world, x, y, z); - if (tileLeaves == null) + if (tileLeaves.isInvalid()) return; if (world.rand.nextFloat() > 0.1) @@ -292,7 +292,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv ItemStack heldItem = player.getHeldItem(); TileEntity tile = world.getTileEntity(x, y, z); IButterfly caterpillar = tile instanceof TileLeaves ? ((TileLeaves) tile).getCaterpillar() : null; - if(heldItem != null && (heldItem.getItem() instanceof IToolScoop) && caterpillar != null) { + if (heldItem != null && (heldItem.getItem() instanceof IToolScoop) && caterpillar != null) { ItemStack butterfly = PluginLepidopterology.butterflyInterface.getMemberStack(caterpillar, EnumFlutterType.CATERPILLAR.ordinal()); StackUtils.dropItemStackAsEntity(butterfly, world, x, y, z); ((TileLeaves) tile).setCaterpillar(null); From b41646540c64f95cac756961a493c027bbdff06a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 7 Jan 2015 16:01:12 -0800 Subject: [PATCH 156/175] Issue #431 Restore mezz's original fix, with a TODO comment --- .../arboriculture/gadgets/ForestryBlockLeaves.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 8649b7ad4..1d18bd47a 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -178,12 +178,16 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv @Override public void beginLeavesDecay(World world, int x, int y, int z) { TileLeaves tile = getLeafTile(world, x, y, z); - if (tile != null && tile.isDecorative()) + if (tile == null || tile.isDecorative()) return; - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); - if (world.isRemote) - world.markBlockForUpdate(x, y, z); + super.beginLeavesDecay(world, x, y, z); + + // TODO: Remove the following line when/if the following Forge PR is accepted + // This work around is very costly in terms of both bandwidth and rendering + // https://github.com/MinecraftForge/MinecraftForge/pull/1627 + world.markBlockForUpdate(x, y, z); } + @Override public void updateTick(World world, int x, int y, int z, Random random) { From 4c72917c05d8f6b44efbfe4e2d6527fe73c0de3a Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 7 Jan 2015 20:30:38 -0800 Subject: [PATCH 157/175] Fix #444 Upper half slabs render incorrectly --- src/main/java/forestry/arboriculture/gadgets/BlockSlab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java index 8126b60d4..0c3ad2497 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSlab.java @@ -113,7 +113,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp @Override public WoodType getWoodType(int meta) { - int woodOrdinal = meta + cat.ordinal() * slabsPerCat; + int woodOrdinal = (meta % slabsPerCat) + cat.ordinal() * slabsPerCat; if(woodOrdinal < WoodType.VALUES.length) return WoodType.VALUES[woodOrdinal]; else From 0a68dc03072cc6cd6f19eb66d508ac77eff6a22f Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Fri, 9 Jan 2015 13:15:31 -0800 Subject: [PATCH 158/175] Issue #431 Work around no longer required, fix merged into Forge 1.7.10-10.13.2.1283 and 1.8-11.14.0.1282 --- .../forestry/arboriculture/gadgets/ForestryBlockLeaves.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java index 1d18bd47a..29d675ab6 100644 --- a/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java +++ b/src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java @@ -181,11 +181,6 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv if (tile == null || tile.isDecorative()) return; super.beginLeavesDecay(world, x, y, z); - - // TODO: Remove the following line when/if the following Forge PR is accepted - // This work around is very costly in terms of both bandwidth and rendering - // https://github.com/MinecraftForge/MinecraftForge/pull/1627 - world.markBlockForUpdate(x, y, z); } From 98372c3e0833941eaef013fe31fd1a6f7cbfaeef Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 9 Jan 2015 20:29:34 -0800 Subject: [PATCH 159/175] Fix #445 Beehouse and Apiary do not detect hellish biome --- src/main/java/forestry/apiculture/gadgets/TileBeehouse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java index 2586566dc..7165d75ee 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java +++ b/src/main/java/forestry/apiculture/gadgets/TileBeehouse.java @@ -136,7 +136,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised { @Override public EnumTemperature getTemperature() { - return EnumTemperature.getFromValue(getExactTemperature()); + return EnumTemperature.getFromBiome(biome); } @Override From fae3b3d24e770f734c400be08f805f79b93c0d88 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 10 Jan 2015 10:37:25 -0800 Subject: [PATCH 160/175] Update development Forge version --- application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.properties b/application.properties index 75c3a02a7..920caf67a 100644 --- a/application.properties +++ b/application.properties @@ -1,5 +1,5 @@ mcversion=1.7.10 -forgeversion=10.13.2.1277 +forgeversion=10.13.2.1284 version_major=3 version_minor=3 version_patch=0 From 04d6b979aba44bab4384cf07589b1c9f6413c27e Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 01:40:54 -0800 Subject: [PATCH 161/175] Clean and simplify the implementation of hives through the API --- api/forestry | 2 +- .../apiculture/gadgets/BlockBeehives.java | 20 ++-- .../gadgets/TileAlvearySwarmer.java | 6 +- .../forestry/apiculture/worldgen/Hive.java | 83 ++++++++++++++ .../apiculture/worldgen/HiveDecorator.java | 32 +++--- .../apiculture/worldgen/HiveDescription.java | 103 ++++++++++++++++++ ...armer.java => HiveDescriptionSwarmer.java} | 48 +++++++- .../apiculture/worldgen/HiveForest.java | 33 ------ .../{HiveJungle.java => HiveGen.java} | 62 +++++------ .../apiculture/worldgen/HiveGenGround.java | 46 ++++++++ .../{HiveEnd.java => HiveGenHelper.java} | 59 +++++----- .../apiculture/worldgen/HiveGenTree.java | 40 +++++++ .../apiculture/worldgen/HiveMeadows.java | 34 ------ .../apiculture/worldgen/HiveParched.java | 41 ------- .../apiculture/worldgen/HiveRegistry.java | 55 ++++++++++ .../apiculture/worldgen/HiveSnow.java | 35 ------ .../apiculture/worldgen/HiveSwamp.java | 34 ------ .../forestry/plugins/PluginApiculture.java | 64 ++++------- 18 files changed, 487 insertions(+), 310 deletions(-) create mode 100644 src/main/java/forestry/apiculture/worldgen/Hive.java create mode 100644 src/main/java/forestry/apiculture/worldgen/HiveDescription.java rename src/main/java/forestry/apiculture/worldgen/{HiveSwarmer.java => HiveDescriptionSwarmer.java} (54%) delete mode 100644 src/main/java/forestry/apiculture/worldgen/HiveForest.java rename src/main/java/forestry/apiculture/worldgen/{HiveJungle.java => HiveGen.java} (54%) create mode 100644 src/main/java/forestry/apiculture/worldgen/HiveGenGround.java rename src/main/java/forestry/apiculture/worldgen/{HiveEnd.java => HiveGenHelper.java} (59%) create mode 100644 src/main/java/forestry/apiculture/worldgen/HiveGenTree.java delete mode 100644 src/main/java/forestry/apiculture/worldgen/HiveMeadows.java delete mode 100644 src/main/java/forestry/apiculture/worldgen/HiveParched.java create mode 100644 src/main/java/forestry/apiculture/worldgen/HiveRegistry.java delete mode 100644 src/main/java/forestry/apiculture/worldgen/HiveSnow.java delete mode 100644 src/main/java/forestry/apiculture/worldgen/HiveSwamp.java diff --git a/api/forestry b/api/forestry index 2ad2ee6d7..b41c05d38 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 2ad2ee6d7c4997cb463ca0a73b1463f1e6b47a2f +Subproject commit b41c05d38a2e000f1743a34aeba81a94b1c65856 diff --git a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java index c40cd2514..f0f33c111 100755 --- a/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java +++ b/src/main/java/forestry/apiculture/gadgets/BlockBeehives.java @@ -13,13 +13,15 @@ package forestry.apiculture.gadgets; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import forestry.api.apiculture.IHiveDrop; -import forestry.api.apiculture.hives.HiveManager; +import forestry.apiculture.worldgen.HiveRegistry; import forestry.api.core.Tabs; import forestry.apiculture.MaterialBeehive; import forestry.core.config.Config; import forestry.core.inventory.InvTools; import forestry.core.render.TextureManager; import forestry.core.utils.StackUtils; +import forestry.plugins.PluginApiculture; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -126,18 +128,18 @@ public class BlockBeehives extends BlockContainer { String hiveName = getHiveNameForMeta(meta); if (hiveName == null) return Collections.emptyList(); - return HiveManager.get(hiveName).getDrops(); + return PluginApiculture.hiveRegistry.getDrops(hiveName); } private String getHiveNameForMeta(int meta) { switch (meta) { - case 1: return HiveManager.forest; - case 2: return HiveManager.meadows; - case 3: return HiveManager.desert; - case 4: return HiveManager.jungle; - case 5: return HiveManager.end; - case 6: return HiveManager.snow; - case 7: return HiveManager.swamp; + case 1: return HiveRegistry.forest; + case 2: return HiveRegistry.meadows; + case 3: return HiveRegistry.desert; + case 4: return HiveRegistry.jungle; + case 5: return HiveRegistry.end; + case 6: return HiveRegistry.snow; + case 7: return HiveRegistry.swamp; } return null; } diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java index e73518279..74d6e05ac 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java @@ -25,8 +25,9 @@ import forestry.api.apiculture.IAlvearyComponent; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IBeeHousing; import forestry.api.core.ForestryAPI; +import forestry.apiculture.worldgen.Hive; import forestry.apiculture.worldgen.HiveDecorator; -import forestry.apiculture.worldgen.HiveSwarmer; +import forestry.apiculture.worldgen.HiveDescriptionSwarmer; import forestry.core.inventory.TileInventoryAdapter; import forestry.core.inventory.wrappers.IInvSlot; import forestry.core.inventory.wrappers.InventoryIterator; @@ -127,7 +128,8 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory { private void trySpawnSwarm() { ItemStack toSpawn = pendingSpawns.peek(); - HiveSwarmer hive = new HiveSwarmer(128, toSpawn); + HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn); + Hive hive = new Hive(hiveDescription); int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16; diff --git a/src/main/java/forestry/apiculture/worldgen/Hive.java b/src/main/java/forestry/apiculture/worldgen/Hive.java new file mode 100644 index 000000000..ee26e6eb4 --- /dev/null +++ b/src/main/java/forestry/apiculture/worldgen/Hive.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.apiculture.worldgen; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import forestry.api.apiculture.IHiveDrop; +import forestry.api.apiculture.hives.IHiveDescription; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public final class Hive { + + private final IHiveDescription hiveDescription; + private final List drops = new ArrayList(); + + public Hive(IHiveDescription hiveDescription) { + if (hiveDescription == null) + throw new IllegalArgumentException("Tried to create hive with null hive description"); + this.hiveDescription = hiveDescription; + } + + public Block getHiveBlock() { + return hiveDescription.getBlock(); + } + + public int getHiveMeta() { + return hiveDescription.getMeta(); + } + + public void addDrops(List drops) { + this.drops.addAll(drops); + } + + public List getDrops() { + return drops; + } + + public float genChance() { + return hiveDescription.getGenChance(); + } + + public void postGen(World world, int x, int y, int z) { + hiveDescription.postGen(world, x, y, z); + } + + public boolean isGoodBiome(BiomeGenBase biome) { + return hiveDescription.isGoodBiome(biome); + } + + public boolean isGoodHumidity(EnumHumidity humidity) { + return hiveDescription.isGoodHumidity(humidity); + } + + public boolean isGoodTemperature(EnumTemperature temperature) { + return hiveDescription.isGoodTemperature(temperature); + } + + public boolean isValidLocation(World world, int x, int y, int z) { + return hiveDescription.getHiveGen().isValidLocation(world, x, y, z); + } + + public boolean canReplace(World world, int x, int y, int z) { + return hiveDescription.getHiveGen().canReplace(world, x, y, z); + } + + public int getYForHive(World world, int x, int z) { + return hiveDescription.getHiveGen().getYForHive(world, x, z); + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 5869040af..ce6253592 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -10,22 +10,25 @@ ******************************************************************************/ package forestry.apiculture.worldgen; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import forestry.api.apiculture.hives.HiveManager; -import forestry.api.apiculture.hives.IHive; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.Config; -import forestry.core.config.Defaults; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; + import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType; import net.minecraftforge.event.terraingen.TerrainGen; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.core.config.Config; +import forestry.core.config.Defaults; +import forestry.plugins.PluginApiculture; + /** * * @author CovertJaguar @@ -55,14 +58,15 @@ public class HiveDecorator { } private void decorateHives(World world, Random rand, int chunkX, int chunkZ) { - for (IHive hive : HiveManager.getHives()) + for (Hive hive : PluginApiculture.hiveRegistry.getHives()) { if (Config.generateBeehivesDebug) genHiveDebug(world, chunkX, chunkZ, hive); else genHive(world, rand, chunkX, chunkZ, hive); + } } - public boolean genHive(World world, Random rand, int chunkX, int chunkZ, IHive hive) { + public boolean genHive(World world, Random rand, int chunkX, int chunkZ, Hive hive) { if (hive.genChance() < rand.nextFloat() * 128.0f) return false; @@ -86,7 +90,9 @@ public class HiveDecorator { return false; } - private void genHiveDebug(World world, int worldX, int worldZ, IHive hive) { + private void genHiveDebug(World world, int chunkX, int chunkZ, Hive hive) { + int worldX = chunkX * 16; + int worldZ = chunkZ * 16; BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); @@ -98,7 +104,7 @@ public class HiveDecorator { tryGenHive(world, worldX + x, worldZ + z, hive); } - private boolean tryGenHive(World world, int x, int z, IHive hive) { + private boolean tryGenHive(World world, int x, int z, Hive hive) { int y = hive.getYForHive(world, x, z); @@ -113,13 +119,13 @@ public class HiveDecorator { if (!hive.isGoodTemperature(temperature)) return false; - if (!hive.isGoodLocation(world, x, y, z)) + if (!hive.isValidLocation(world, x, y, z)) return false; return setHive(world, x, y, z, hive); } - protected boolean setHive(World world, int x, int y, int z, IHive hive) { + protected boolean setHive(World world, int x, int y, int z, Hive hive) { Block hiveBlock = hive.getHiveBlock(); boolean placed = world.setBlock(x, y, z, hiveBlock, hive.getHiveMeta(), Defaults.FLAG_BLOCK_SYNCH); if (!placed) diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java new file mode 100644 index 000000000..d11418b54 --- /dev/null +++ b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * 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.apiculture.worldgen; + +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import forestry.api.apiculture.hives.HiveManager; +import forestry.api.apiculture.hives.IHiveDescription; +import forestry.api.apiculture.hives.IHiveGen; +import forestry.api.core.BiomeHelper; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.core.config.ForestryBlock; + +public enum HiveDescription implements IHiveDescription { + + FOREST(1, 3.0f, EnumSet.of(EnumHumidity.NORMAL), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.tree()), + MEADOWS(2, 1.0f, EnumSet.of(EnumHumidity.NORMAL), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)), + DESERT(3, 1.0f, EnumSet.of(EnumHumidity.ARID), EnumSet.of(EnumTemperature.HOT), HiveManager.genHelper.ground(Blocks.sand, Blocks.sandstone)), + JUNGLE(4, 4.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.WARM), HiveManager.genHelper.tree()), + END(5, 4.0f, EnumSet.allOf(EnumHumidity.class), EnumSet.allOf(EnumTemperature.class), HiveManager.genHelper.ground(Blocks.end_stone)) { + @Override + public boolean isGoodBiome(BiomeGenBase biome) { + return biome.biomeID == BiomeGenBase.sky.biomeID; + } + }, + SNOW(6, 2.0f, EnumSet.allOf(EnumHumidity.class), EnumSet.of(EnumTemperature.COLD, EnumTemperature.ICY), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) { + @Override + public void postGen(World world, int x, int y, int z) { + if (world.isAirBlock(x, y + 1, z)) + world.setBlock(x, y + 1, z, Blocks.snow_layer, 0, 0); + } + }, + SWAMP(7, 2.0f, EnumSet.of(EnumHumidity.DAMP), EnumSet.of(EnumTemperature.NORMAL), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)), + ; + + private final int meta; + private final float genChance; + private final EnumSet humidities; + private final EnumSet temperatures; + private final IHiveGen hiveGen; + + private HiveDescription(int meta, float genChance, EnumSet humidities, EnumSet temperatures, IHiveGen hiveGen) { + this.meta = meta; + this.genChance = genChance; + this.humidities = humidities; + this.temperatures = temperatures; + this.hiveGen = hiveGen; + } + + @Override + public IHiveGen getHiveGen() { + return hiveGen; + } + + @Override + public Block getBlock() { + return ForestryBlock.beehives.block(); + } + + @Override + public int getMeta() { + return meta; + } + + @Override + public boolean isGoodBiome(BiomeGenBase biome) { + return !BiomeHelper.isBiomeHellish(biome); + } + + @Override + public boolean isGoodHumidity(EnumHumidity humidity) { + return humidities.contains(humidity); + } + + @Override + public boolean isGoodTemperature(EnumTemperature temperature) { + return temperatures.contains(temperature); + } + + @Override + public float getGenChance() { + return genChance; + } + + @Override + public void postGen(World world, int x, int y, int z) { + + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java b/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java similarity index 54% rename from src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java rename to src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java index e06dca4bb..b796d70e4 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDescriptionSwarmer.java @@ -10,23 +10,63 @@ ******************************************************************************/ package forestry.apiculture.worldgen; -import forestry.api.apiculture.hives.HiveGround; +import forestry.api.apiculture.hives.IHiveDescription; +import forestry.api.apiculture.hives.IHiveGen; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; import forestry.apiculture.gadgets.TileSwarm; import forestry.core.config.ForestryBlock; + +import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; -public class HiveSwarmer extends HiveGround { +public class HiveDescriptionSwarmer implements IHiveDescription { private final ItemStack[] bees; - public HiveSwarmer(float genChance, ItemStack... bees) { - super(ForestryBlock.beehives.block(), 8, genChance, Blocks.dirt, Blocks.grass); + public HiveDescriptionSwarmer(ItemStack... bees) { this.bees = bees; } + @Override + public IHiveGen getHiveGen() { + return new HiveGenGround(Blocks.dirt, Blocks.grass); + } + + @Override + public Block getBlock() { + return ForestryBlock.beehives.block(); + } + + @Override + public int getMeta() { + return 8; + } + + @Override + public boolean isGoodBiome(BiomeGenBase biome) { + return true; + } + + @Override + public boolean isGoodHumidity(EnumHumidity humidity) { + return true; + } + + @Override + public boolean isGoodTemperature(EnumTemperature temperature) { + return true; + } + + @Override + public float getGenChance() { + return 128.0f; + } + @Override public void postGen(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); diff --git a/src/main/java/forestry/apiculture/worldgen/HiveForest.java b/src/main/java/forestry/apiculture/worldgen/HiveForest.java deleted file mode 100644 index fdc25a5d7..000000000 --- a/src/main/java/forestry/apiculture/worldgen/HiveForest.java +++ /dev/null @@ -1,33 +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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveTree; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; - -public class HiveForest extends HiveTree { - - public HiveForest(float genChance) { - super(ForestryBlock.beehives.block(), 1, genChance); - } - - @Override - public boolean isGoodHumidity(EnumHumidity humidity) { - return humidity == EnumHumidity.NORMAL; - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.NORMAL; - } -} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveJungle.java b/src/main/java/forestry/apiculture/worldgen/HiveGen.java similarity index 54% rename from src/main/java/forestry/apiculture/worldgen/HiveJungle.java rename to src/main/java/forestry/apiculture/worldgen/HiveGen.java index 59e1b341d..4eadb38c9 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveJungle.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveGen.java @@ -1,33 +1,29 @@ -/******************************************************************************* - * 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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveTree; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; - -public class HiveJungle extends HiveTree { - - public HiveJungle(float genChance) { - super(ForestryBlock.beehives.block(), 4, genChance); - } - - @Override - public boolean isGoodHumidity(EnumHumidity humidity) { - return humidity == EnumHumidity.DAMP; - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.WARM; - } -} +/******************************************************************************* + * 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.apiculture.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; + +import forestry.api.apiculture.hives.IHiveGen; + +public abstract class HiveGen implements IHiveGen { + + @Override + public boolean canReplace(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + Material material = block.getMaterial(); + return (material.isReplaceable() && !material.isLiquid()) || + material == Material.air || + material == Material.plants; + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java b/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java new file mode 100644 index 000000000..8d7c8da33 --- /dev/null +++ b/src/main/java/forestry/apiculture/worldgen/HiveGenGround.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.apiculture.worldgen; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; + +public class HiveGenGround extends HiveGen { + + private final Set groundMaterials = new HashSet(); + + public HiveGenGround(Block... groundBlocks) { + for (Block block : groundBlocks) + groundMaterials.add(block.getMaterial()); + } + + @Override + public boolean isValidLocation(World world, int x, int y, int z) { + Block ground = world.getBlock(x, y - 1, z); + return groundMaterials.contains(ground.getMaterial()); + } + + @Override + public int getYForHive(World world, int x, int z) { + int y = world.getHeightValue(x, z); + + // get to the ground + while (y >= 0 && (world.getBlock(x, y - 1, z).isLeaves(world, x, y - 1, z) || canReplace(world, x, y - 1, z))) { + y--; + } + + return y; + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveEnd.java b/src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java similarity index 59% rename from src/main/java/forestry/apiculture/worldgen/HiveEnd.java rename to src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java index 1a675700a..27f0fe03d 100644 --- a/src/main/java/forestry/apiculture/worldgen/HiveEnd.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java @@ -1,28 +1,31 @@ -/******************************************************************************* - * 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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveGround; -import forestry.core.config.ForestryBlock; -import net.minecraft.init.Blocks; -import net.minecraft.world.biome.BiomeGenBase; - -public class HiveEnd extends HiveGround { - - public HiveEnd(float genChance) { - super(ForestryBlock.beehives.block(), 5, genChance, Blocks.end_stone); - } - - @Override - public boolean isGoodBiome(BiomeGenBase biome) { - return biome.biomeID == BiomeGenBase.sky.biomeID; - } -} +/******************************************************************************* + * 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.apiculture.worldgen; + +import net.minecraft.block.Block; + +import forestry.api.apiculture.hives.IHiveGen; +import forestry.api.apiculture.hives.IHiveGenHelper; + +public class HiveGenHelper implements IHiveGenHelper { + + private static IHiveGen treeGen = new HiveGenTree(); + + @Override + public IHiveGen ground(Block... validGroundBlocks) { + return new HiveGenGround(validGroundBlocks); + } + + @Override + public IHiveGen tree() { + return treeGen; + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java b/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java new file mode 100644 index 000000000..32e0079c7 --- /dev/null +++ b/src/main/java/forestry/apiculture/worldgen/HiveGenTree.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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.apiculture.worldgen; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class HiveGenTree extends HiveGen { + + @Override + public boolean isValidLocation(World world, int x, int y, int z) { + Block blockAbove = world.getBlock(x, y + 1, z); + if (!blockAbove.isLeaves(world, x, y + 1, z)) + return false; + + // not a good location if right on top of something + return canReplace(world, x, y - 1, z); + } + + @Override + public int getYForHive(World world, int x, int z) { + // get top leaf block + int y = world.getHeightValue(x, z) - 1; + if (!world.getBlock(x, y, z).isLeaves(world, x, y, z)) + return -1; + + // get to the bottom of the leaves + do { y--; } while (world.getBlock(x, y, z).isLeaves(world, x, y, z)); + + return y; + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java b/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java deleted file mode 100644 index 4917582cc..000000000 --- a/src/main/java/forestry/apiculture/worldgen/HiveMeadows.java +++ /dev/null @@ -1,34 +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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; -import net.minecraft.init.Blocks; - -public class HiveMeadows extends HiveGround { - - public HiveMeadows(float genChance) { - super(ForestryBlock.beehives.block(), 2, genChance, Blocks.dirt, Blocks.grass); - } - - @Override - public boolean isGoodHumidity(EnumHumidity humidity) { - return humidity == EnumHumidity.NORMAL; - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.NORMAL; - } -} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveParched.java b/src/main/java/forestry/apiculture/worldgen/HiveParched.java deleted file mode 100644 index 45e478258..000000000 --- a/src/main/java/forestry/apiculture/worldgen/HiveParched.java +++ /dev/null @@ -1,41 +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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.BiomeHelper; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; -import net.minecraft.init.Blocks; -import net.minecraft.world.biome.BiomeGenBase; - -public class HiveParched extends HiveGround { - - public HiveParched(float genChance) { - super(ForestryBlock.beehives.block(), 3, genChance, Blocks.sand, Blocks.sandstone); - } - - @Override - public boolean isGoodBiome(BiomeGenBase biome) { - return !BiomeHelper.canRainOrSnow(biome); - } - - @Override - public boolean isGoodHumidity(EnumHumidity humidity) { - return humidity == EnumHumidity.ARID; - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.HOT; - } -} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java b/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java new file mode 100644 index 000000000..d15b3bc86 --- /dev/null +++ b/src/main/java/forestry/apiculture/worldgen/HiveRegistry.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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.apiculture.worldgen; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import forestry.api.apiculture.IHiveDrop; +import forestry.api.apiculture.hives.IHiveDescription; +import forestry.api.apiculture.hives.IHiveRegistry; + +public class HiveRegistry implements IHiveRegistry { + + private final Map hives = new HashMap(); + + @Override + public void registerHive(String hiveName, IHiveDescription hiveDescription) { + if (hives.containsKey(hiveName)) + throw new IllegalArgumentException("Hive already exists with name: " + hiveName); + + Hive hive = new Hive(hiveDescription); + hives.put(hiveName, hive); + } + + @Override + public void addDrops(String hiveName, List drops) { + Hive hive = hives.get(hiveName); + if (hive == null) + throw new IllegalArgumentException("No hive registered with name: " + hiveName); + + hive.addDrops(drops); + } + + public List getHives() { + return new ArrayList(hives.values()); + } + + public List getDrops(String hiveName) { + Hive hive = hives.get(hiveName); + if (hive == null) + throw new IllegalArgumentException("No hive registered with name: " + hiveName); + + return hive.getDrops(); + } +} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveSnow.java b/src/main/java/forestry/apiculture/worldgen/HiveSnow.java deleted file mode 100644 index deafc8802..000000000 --- a/src/main/java/forestry/apiculture/worldgen/HiveSnow.java +++ /dev/null @@ -1,35 +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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; - -public class HiveSnow extends HiveGround { - - public HiveSnow(float genChance) { - super(ForestryBlock.beehives.block(), 6, genChance, Blocks.dirt, Blocks.grass, Blocks.snow); - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.COLD || temperature == EnumTemperature.ICY; - } - - @Override - public void postGen(World world, int x, int y, int z) { - if (world.isAirBlock(x, y + 1, z)) - world.setBlock(x, y + 1, z, Blocks.snow_layer, 0, 0); - } -} diff --git a/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java b/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java deleted file mode 100644 index efa47f548..000000000 --- a/src/main/java/forestry/apiculture/worldgen/HiveSwamp.java +++ /dev/null @@ -1,34 +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.apiculture.worldgen; - -import forestry.api.apiculture.hives.HiveGround; -import forestry.api.core.EnumHumidity; -import forestry.api.core.EnumTemperature; -import forestry.core.config.ForestryBlock; -import net.minecraft.init.Blocks; - -public class HiveSwamp extends HiveGround { - - public HiveSwamp(float genChance) { - super(ForestryBlock.beehives.block(), 7, genChance, Blocks.dirt, Blocks.grass); - } - - @Override - public boolean isGoodHumidity(EnumHumidity humidity) { - return humidity == EnumHumidity.DAMP; - } - - @Override - public boolean isGoodTemperature(EnumTemperature temperature) { - return temperature == EnumTemperature.NORMAL; - } -} diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index b8afe45e0..994ac171b 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -51,7 +51,6 @@ import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeRoot; import forestry.api.apiculture.IHiveDrop; import forestry.api.apiculture.hives.HiveManager; -import forestry.api.apiculture.hives.IHive; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.Tabs; @@ -132,13 +131,9 @@ import forestry.apiculture.items.ItemWaxCast; import forestry.apiculture.proxy.ProxyApiculture; import forestry.apiculture.trigger.ApicultureTriggers; import forestry.apiculture.worldgen.HiveDecorator; -import forestry.apiculture.worldgen.HiveEnd; -import forestry.apiculture.worldgen.HiveForest; -import forestry.apiculture.worldgen.HiveJungle; -import forestry.apiculture.worldgen.HiveMeadows; -import forestry.apiculture.worldgen.HiveParched; -import forestry.apiculture.worldgen.HiveSnow; -import forestry.apiculture.worldgen.HiveSwamp; +import forestry.apiculture.worldgen.HiveDescription; +import forestry.apiculture.worldgen.HiveGenHelper; +import forestry.apiculture.worldgen.HiveRegistry; import forestry.core.GameMode; import forestry.core.config.Config; import forestry.core.config.Configuration; @@ -186,6 +181,8 @@ public class PluginApiculture extends ForestryPlugin { * See {@link IBeeRoot} for details */ public static IBeeRoot beeInterface; + public static HiveRegistry hiveRegistry; + public static MachineDefinition definitionApiary; public static MachineDefinition definitionChest; public static MachineDefinition definitionBeehouse; @@ -198,6 +195,8 @@ public class PluginApiculture extends ForestryPlugin { MinecraftForge.EVENT_BUS.register(this); + HiveManager.hiveRegistry = hiveRegistry = new HiveRegistry(); + HiveManager.genHelper = new HiveGenHelper(); createHiveDropArrays(); ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture"); @@ -790,44 +789,23 @@ public class PluginApiculture extends ForestryPlugin { } private void createHives() { - HiveManager.put(HiveManager.forest, new HiveForest(3)); - HiveManager.put(HiveManager.meadows, new HiveMeadows(1)); - HiveManager.put(HiveManager.desert, new HiveParched(1)); - HiveManager.put(HiveManager.jungle, new HiveJungle(4)); - HiveManager.put(HiveManager.end, new HiveEnd(4)); - HiveManager.put(HiveManager.snow, new HiveSnow(2)); - HiveManager.put(HiveManager.swamp, new HiveSwamp(2)); + hiveRegistry.registerHive(HiveRegistry.forest, HiveDescription.FOREST); + hiveRegistry.registerHive(HiveRegistry.meadows, HiveDescription.MEADOWS); + hiveRegistry.registerHive(HiveRegistry.desert, HiveDescription.DESERT); + hiveRegistry.registerHive(HiveRegistry.jungle, HiveDescription.JUNGLE); + hiveRegistry.registerHive(HiveRegistry.end, HiveDescription.END); + hiveRegistry.registerHive(HiveRegistry.snow, HiveDescription.SNOW); + hiveRegistry.registerHive(HiveRegistry.swamp, HiveDescription.SWAMP); } - @Deprecated // deprecated since 3.1. remove when BeeManager.hiveDrops is removed private void updateHiveDrops() { - IHive hive = HiveManager.getForestHive(); - for (IHiveDrop drop : forestDrops) - hive.addDrop(drop); - - hive = HiveManager.getMeadowsHive(); - for (IHiveDrop drop : meadowsDrops) - hive.addDrop(drop); - - hive = HiveManager.getDesertHive(); - for (IHiveDrop drop : desertDrops) - hive.addDrop(drop); - - hive = HiveManager.getJungleHive(); - for (IHiveDrop drop : jungleDrops) - hive.addDrop(drop); - - hive = HiveManager.getEndHive(); - for (IHiveDrop drop : endDrops) - hive.addDrop(drop); - - hive = HiveManager.getSnowHive(); - for (IHiveDrop drop : snowDrops) - hive.addDrop(drop); - - hive = HiveManager.getSwampHive(); - for (IHiveDrop drop : swampDrops) - hive.addDrop(drop); + hiveRegistry.addDrops(HiveRegistry.forest, forestDrops); + hiveRegistry.addDrops(HiveRegistry.meadows, meadowsDrops); + hiveRegistry.addDrops(HiveRegistry.desert, desertDrops); + hiveRegistry.addDrops(HiveRegistry.jungle, jungleDrops); + hiveRegistry.addDrops(HiveRegistry.end, endDrops); + hiveRegistry.addDrops(HiveRegistry.snow, snowDrops); + hiveRegistry.addDrops(HiveRegistry.swamp, swampDrops); } private void createAlleles() { From b3fbadce84050595d8e4f8f4a7d5f750383a191a Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 13:57:47 -0800 Subject: [PATCH 162/175] Shuffle the order that hives try to generate --- .../java/forestry/apiculture/worldgen/HiveDecorator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index ce6253592..9036d05e4 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.apiculture.worldgen; +import java.util.Collections; +import java.util.List; import java.util.Random; import net.minecraft.block.Block; @@ -58,7 +60,10 @@ public class HiveDecorator { } private void decorateHives(World world, Random rand, int chunkX, int chunkZ) { - for (Hive hive : PluginApiculture.hiveRegistry.getHives()) { + List hives = PluginApiculture.hiveRegistry.getHives(); + Collections.shuffle(hives, rand); + + for (Hive hive : hives) { if (Config.generateBeehivesDebug) genHiveDebug(world, chunkX, chunkZ, hive); else From d94a688f287b260e9a2bddc6dbdc6e3ae1efb21f Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 19:33:37 -0800 Subject: [PATCH 163/175] Fix #135 Feature for adding Forestry resources to existing chunks --- .../apiculture/worldgen/HiveDecorator.java | 14 ++--- src/main/java/forestry/core/ForestryCore.java | 11 ++-- .../forestry/core/TickHandlerCoreServer.java | 61 ++++++++++++++++++- .../java/forestry/core/WorldGenerator.java | 27 +++++++- .../java/forestry/core/config/Config.java | 24 ++++++++ .../core/proxy/ClientProxyCommon.java | 5 +- .../java/forestry/core/proxy/ProxyCommon.java | 5 +- .../java/forestry/core/utils/ChunkCoords.java | 27 ++++++++ .../java/forestry/plugins/ForestryPlugin.java | 6 +- .../forestry/plugins/PluginApiculture.java | 19 ++++-- .../java/forestry/plugins/PluginManager.java | 13 +++- 11 files changed, 184 insertions(+), 28 deletions(-) create mode 100644 src/main/java/forestry/core/utils/ChunkCoords.java diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 9036d05e4..3127f2cda 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -17,14 +17,12 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType; import net.minecraftforge.event.terraingen.TerrainGen; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.core.config.Config; @@ -51,15 +49,15 @@ public class HiveDecorator { private HiveDecorator() { } - @SubscribeEvent - public void generate(PopulateChunkEvent.Post event) { - if (!TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) { + public void decorateHives(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { + if (!TerrainGen.populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) { return; } - decorateHives(event.world, event.rand, event.chunkX, event.chunkZ); + + decorateHives(world, rand, chunkX, chunkZ); } - private void decorateHives(World world, Random rand, int chunkX, int chunkZ) { + public void decorateHives(World world, Random rand, int chunkX, int chunkZ) { List hives = PluginApiculture.hiveRegistry.getHives(); Collections.shuffle(hives, rand); diff --git a/src/main/java/forestry/core/ForestryCore.java b/src/main/java/forestry/core/ForestryCore.java index d6bcac59c..9d20d965c 100755 --- a/src/main/java/forestry/core/ForestryCore.java +++ b/src/main/java/forestry/core/ForestryCore.java @@ -64,10 +64,6 @@ public class ForestryCore { } public void init(Object basemod) { - - // Register world generator - GameRegistry.registerWorldGenerator(new WorldGenerator(), 0); - // Set fuels and resources for the fermenter FuelManager.fermenterFuel.put(ForestryItem.fertilizerCompound.getItemStack(), new FermenterFuel(ForestryItem.fertilizerCompound.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.value.fertilizer"), GameMode.getGameMode().getIntegerSetting("fermenter.cycles.fertilizer"))); @@ -126,7 +122,12 @@ public class ForestryCore { public void postInit() { PluginManager.runPostInit(); - Proxies.common.registerTickHandlers(); + // Register world generator + WorldGenerator worldGenerator = new WorldGenerator(); + GameRegistry.registerWorldGenerator(worldGenerator, 0); + + // Register tick handlers + Proxies.common.registerTickHandlers(worldGenerator); // Handle IMC messages. processIMCMessages(FMLInterModComms.fetchRuntimeMessages(ForestryAPI.instance)); diff --git a/src/main/java/forestry/core/TickHandlerCoreServer.java b/src/main/java/forestry/core/TickHandlerCoreServer.java index dfa355c52..74a091310 100755 --- a/src/main/java/forestry/core/TickHandlerCoreServer.java +++ b/src/main/java/forestry/core/TickHandlerCoreServer.java @@ -10,7 +10,17 @@ ******************************************************************************/ package forestry.core; +import com.google.common.collect.LinkedListMultimap; + +import java.util.List; +import java.util.Random; + import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkDataEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -18,12 +28,20 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import forestry.core.config.Config; +import forestry.core.config.Defaults; import forestry.core.interfaces.IResupplyHandler; +import forestry.core.utils.ChunkCoords; import forestry.plugins.PluginManager; public class TickHandlerCoreServer { - public TickHandlerCoreServer() { + + private final WorldGenerator worldGenerator; + private final LinkedListMultimap chunkRegenList = LinkedListMultimap.create(); + + public TickHandlerCoreServer(WorldGenerator worldGenerator) { + this.worldGenerator = worldGenerator; FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent @@ -37,5 +55,46 @@ public class TickHandlerCoreServer { handler.resupply(player); } } + + if (Config.doRetrogen) { + World world = event.world; + int dimensionID = world.provider.dimensionId; + List chunkList = chunkRegenList.get(dimensionID); + + if (chunkList.size() > 0) { + ChunkCoords coords = chunkList.get(0); + chunkList.remove(0); + + // This bit is from FML's GameRegistry.generateWorld where the seed is constructed. + long worldSeed = world.getSeed(); + Random random = new Random(worldSeed); + long xSeed = random.nextLong() >> 2 + 1L; + long zSeed = random.nextLong() >> 2 + 1L; + random.setSeed((xSeed * coords.xCoord + zSeed * coords.zCoord) ^ worldSeed); + + worldGenerator.retroGen(random, coords.xCoord, coords.zCoord, world); + } + } + } + + @SubscribeEvent + public void chunkSaveEventHandler(ChunkDataEvent.Save event) { + NBTTagCompound tag = new NBTTagCompound(); + if (Config.doRetrogen) { + tag.setBoolean("retrogen", true); + } + + event.getData().setTag(Defaults.MOD, tag); + } + + @SubscribeEvent + public void chunkLoadEventHandler(ChunkDataEvent.Load event) { + if (Config.doRetrogen) { + NBTTagCompound tag = (NBTTagCompound)event.getData().getTag(Defaults.MOD); + if (tag == null || !tag.hasKey("retrogen") || Config.forceRetrogen) { + ChunkCoords coords = new ChunkCoords(event.getChunk()); + chunkRegenList.put(coords.dimension, coords); + } + } } } diff --git a/src/main/java/forestry/core/WorldGenerator.java b/src/main/java/forestry/core/WorldGenerator.java index 0b8d11d6b..66b6dcc2b 100755 --- a/src/main/java/forestry/core/WorldGenerator.java +++ b/src/main/java/forestry/core/WorldGenerator.java @@ -15,7 +15,11 @@ import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; + import cpw.mods.fml.common.IWorldGenerator; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import forestry.core.config.Config; import forestry.core.config.ForestryBlock; @@ -29,8 +33,28 @@ public class WorldGenerator implements IWorldGenerator { private WorldGenMinableMeta copperGenerator; private WorldGenMinableMeta tinGenerator; + public WorldGenerator() { + MinecraftForge.EVENT_BUS.register(this); + } + @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + generateWorld(random, chunkX, chunkZ, world); + } + + @SubscribeEvent + public void populateChunk(PopulateChunkEvent.Post event) { + // / PLUGIN WORLD GENERATION + PluginManager.populateChunk(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated); + } + + public void retroGen(Random random, int chunkX, int chunkZ, World world) { + generateWorld(random, chunkX, chunkZ, world); + PluginManager.populateChunkRetroGen(world, random, chunkX, chunkZ); + world.getChunkFromChunkCoords(chunkX, chunkZ).setChunkModified(); + } + + private void generateWorld(Random random, int chunkX, int chunkZ, World world) { if (apatiteGenerator == null) { apatiteGenerator = new WorldGenMinableMeta(ForestryBlock.resources, 0, 36); @@ -69,9 +93,6 @@ public class WorldGenerator implements IWorldGenerator { int randPosZ = chunkZ + random.nextInt(16); tinGenerator.generate(world, random, randPosX, randPosY, randPosZ); } - - // / PLUGIN WORLD GENERATION - PluginManager.generateSurface(world, random, chunkX, chunkZ); } } diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 1ea5d2a79..9419ec6f2 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -62,6 +62,10 @@ public class Config { public static boolean generateBeehives = true; public static boolean generateBeehivesDebug = false; + // Retrogen + public static boolean doRetrogen = false; + public static boolean forceRetrogen = false; + // Performance public static boolean enableBackpackResupply = true; @@ -122,6 +126,26 @@ public class Config { particleFX.comment = "set to false to disable particle fx on slower machines"; enableParticleFX = Boolean.parseBoolean(particleFX.value); + // RetroGen + + String retroGenMessage = "Forestry will attempt worldGen in chunks that were created before the mod was added."; + Property retroGen = config.get("world.retrogen.normal", CATEGORY_COMMON, false); + retroGen.comment = "Set to true, " + retroGenMessage; + doRetrogen = Boolean.parseBoolean(retroGen.value); + + String forcedRetroGenMessage = "Forestry will attempt worldGen in all chunks for this game instance. Config option will be set to false after this run."; + Property forceRetroGen = config.get("world.retrogen.forced", CATEGORY_COMMON, false); + forceRetroGen.comment = "Set to true, " + forcedRetroGenMessage; + forceRetrogen = Boolean.parseBoolean(forceRetroGen.value); + + if (forceRetrogen) { + Proxies.log.info(forcedRetroGenMessage); + config.set("world.generate.retrogen.forced", CATEGORY_COMMON, false); + doRetrogen = true; + } else if (doRetrogen) { + Proxies.log.info(retroGenMessage); + } + Property genApatiteOre = config.get("world.generate.apatite", CATEGORY_COMMON, true); genApatiteOre.comment = "set to false to force forestry to skip generating own apatite ore blocks in the world"; generateApatiteOre = Boolean.parseBoolean(genApatiteOre.value); diff --git a/src/main/java/forestry/core/proxy/ClientProxyCommon.java b/src/main/java/forestry/core/proxy/ClientProxyCommon.java index e87f55154..45aec45bb 100755 --- a/src/main/java/forestry/core/proxy/ClientProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ClientProxyCommon.java @@ -14,6 +14,7 @@ import com.mojang.authlib.GameProfile; import forestry.apiculture.render.TextureBiomefinder; import forestry.core.ForestryClient; import forestry.core.TickHandlerCoreClient; +import forestry.core.WorldGenerator; import forestry.core.config.Config; import forestry.core.render.SpriteSheet; import java.io.File; @@ -43,8 +44,8 @@ public class ClientProxyCommon extends ProxyCommon { } @Override - public void registerTickHandlers() { - super.registerTickHandlers(); + public void registerTickHandlers(WorldGenerator worldGenerator) { + super.registerTickHandlers(worldGenerator); new TickHandlerCoreClient(); } diff --git a/src/main/java/forestry/core/proxy/ProxyCommon.java b/src/main/java/forestry/core/proxy/ProxyCommon.java index e41783504..40eff4ed2 100755 --- a/src/main/java/forestry/core/proxy/ProxyCommon.java +++ b/src/main/java/forestry/core/proxy/ProxyCommon.java @@ -23,6 +23,7 @@ import cpw.mods.fml.common.versioning.VersionParser; import cpw.mods.fml.common.versioning.VersionRange; import forestry.Forestry; import forestry.core.TickHandlerCoreServer; +import forestry.core.WorldGenerator; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; @@ -61,8 +62,8 @@ public class ProxyCommon { return Loader.instance().getMinecraftModContainer().getVersion(); } - public void registerTickHandlers() { - new TickHandlerCoreServer(); + public void registerTickHandlers(WorldGenerator worldGenerator) { + new TickHandlerCoreServer(worldGenerator); } public void registerBlock(Block block, Class itemClass) { diff --git a/src/main/java/forestry/core/utils/ChunkCoords.java b/src/main/java/forestry/core/utils/ChunkCoords.java new file mode 100644 index 000000000..d214b0dd5 --- /dev/null +++ b/src/main/java/forestry/core/utils/ChunkCoords.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.utils; + +import net.minecraft.world.chunk.Chunk; + +public class ChunkCoords +{ + public int dimension; + public int xCoord; + public int zCoord; + + public ChunkCoords(Chunk chunk) + { + this.dimension = chunk.worldObj.provider.dimensionId; + this.xCoord = chunk.xPosition; + this.zCoord = chunk.zPosition; + } +} diff --git a/src/main/java/forestry/plugins/ForestryPlugin.java b/src/main/java/forestry/plugins/ForestryPlugin.java index e5b8577f0..302370f82 100755 --- a/src/main/java/forestry/plugins/ForestryPlugin.java +++ b/src/main/java/forestry/plugins/ForestryPlugin.java @@ -22,6 +22,7 @@ import java.util.EnumSet; import java.util.Random; import net.minecraft.command.ICommand; import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; public abstract class ForestryPlugin { @@ -65,7 +66,10 @@ public abstract class ForestryPlugin { return null; } - public void generateSurface(World world, Random rand, int chunkX, int chunkZ) { + public void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGeneratedZ) { + } + + public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) { } public IPacketHandler getPacketHandler() { diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index 994ac171b..70cd1073f 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -11,6 +11,7 @@ package forestry.plugins; import java.util.ArrayList; +import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; @@ -25,6 +26,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.util.IIcon; import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.BiomeDictionary; @@ -336,10 +339,6 @@ public class PluginApiculture extends ForestryPlugin { Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_BEEKEEPER, Defaults.TEXTURE_SKIN_BEEKPEEPER); VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_BEEKEEPER, villageHandler); - // Register world gen - if (Config.generateBeehives) - MinecraftForge.EVENT_BUS.register(HiveDecorator.instance()); - proxy.initializeRendering(); } @@ -1243,6 +1242,18 @@ public class PluginApiculture extends ForestryPlugin { return null; } + @Override + public void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { + if (Config.generateBeehives) + HiveDecorator.instance().decorateHives(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + } + + @Override + public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) { + if (Config.generateBeehives) + HiveDecorator.instance().decorateHives(world, rand, chunkX, chunkZ); + } + @Override public boolean processIMCMessage(IMCMessage message) { if (message.key.equals("add-candle-lighting-id")) { diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index 463eb95d5..e521a671c 100755 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -35,6 +35,8 @@ import net.minecraft.command.ICommand; import net.minecraft.server.MinecraftServer; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -288,10 +290,17 @@ public class PluginManager { } } - public static void generateSurface(World world, Random rand, int chunkX, int chunkZ) { + public static void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { for (Module m : loadedModules) { ForestryPlugin plugin = m.instance; - plugin.generateSurface(world, rand, chunkX, chunkZ); + plugin.populateChunk(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + } + } + + public static void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) { + for (Module m : loadedModules) { + ForestryPlugin plugin = m.instance; + plugin.populateChunkRetroGen(world, rand, chunkX, chunkZ); } } From a3ae2b797fec5889902968511bc177e09e4af3a5 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 20:42:08 -0800 Subject: [PATCH 164/175] Improve hiveGen debug setting --- .../apiculture/worldgen/HiveDecorator.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 3127f2cda..db9eb3b05 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -59,13 +59,17 @@ public class HiveDecorator { public void decorateHives(World world, Random rand, int chunkX, int chunkZ) { List hives = PluginApiculture.hiveRegistry.getHives(); - Collections.shuffle(hives, rand); + if (Config.generateBeehivesDebug) { + decorateHivesDebug(world, chunkX, chunkZ, hives); + return; + } + + Collections.shuffle(hives, rand); for (Hive hive : hives) { - if (Config.generateBeehivesDebug) - genHiveDebug(world, chunkX, chunkZ, hive); - else - genHive(world, rand, chunkX, chunkZ, hive); + if (genHive(world, rand, chunkX, chunkZ, hive)) { + return; + } } } @@ -93,18 +97,23 @@ public class HiveDecorator { return false; } - private void genHiveDebug(World world, int chunkX, int chunkZ, Hive hive) { + private void decorateHivesDebug(World world, int chunkX, int chunkZ, List hives) { int worldX = chunkX * 16; int worldZ = chunkZ * 16; BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ); EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall); - if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) - return; + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + Collections.shuffle(hives, world.rand); + for (Hive hive : hives) { + if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity)) + continue; - for (int x = 0; x < 16; x++) - for (int z = 0; z < 16; z++) - tryGenHive(world, worldX + x, worldZ + z, hive); + tryGenHive(world, worldX + x, worldZ + z, hive); + } + } + } } private boolean tryGenHive(World world, int x, int z, Hive hive) { From 61704192fe830185dd59c9916762fa6a37ea2eac Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 20:55:59 -0800 Subject: [PATCH 165/175] Skip hive postGen when in hiveGen debug mode --- src/main/java/forestry/apiculture/worldgen/HiveDecorator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index db9eb3b05..719180f9a 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -150,7 +150,9 @@ public class HiveDecorator { hiveBlock.onBlockAdded(world, x, y, z); world.markBlockForUpdate(x, y, z); - hive.postGen(world, x, y, z); + if (!Config.generateBeehivesDebug) { + hive.postGen(world, x, y, z); + } return true; } } From 9cd3b9af5b04823fc4068b3442ae09caf951d780 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 11 Jan 2015 22:36:47 -0800 Subject: [PATCH 166/175] Fix forced retrogen not disabling itself after being set --- src/main/java/forestry/core/config/Config.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 9419ec6f2..677aff035 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -134,13 +134,14 @@ public class Config { doRetrogen = Boolean.parseBoolean(retroGen.value); String forcedRetroGenMessage = "Forestry will attempt worldGen in all chunks for this game instance. Config option will be set to false after this run."; - Property forceRetroGen = config.get("world.retrogen.forced", CATEGORY_COMMON, false); + String forcedRetroGenKey = "world.retrogen.forced"; + Property forceRetroGen = config.get(forcedRetroGenKey, CATEGORY_COMMON, false); forceRetroGen.comment = "Set to true, " + forcedRetroGenMessage; forceRetrogen = Boolean.parseBoolean(forceRetroGen.value); if (forceRetrogen) { Proxies.log.info(forcedRetroGenMessage); - config.set("world.generate.retrogen.forced", CATEGORY_COMMON, false); + config.set(forcedRetroGenKey, CATEGORY_COMMON, false); doRetrogen = true; } else if (doRetrogen) { Proxies.log.info(retroGenMessage); From 122af6d72de93d58a1977a38f9c91618671e16f9 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 14 Jan 2015 22:38:37 -0800 Subject: [PATCH 167/175] Update developer forge --- application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.properties b/application.properties index 920caf67a..4d14e2e00 100644 --- a/application.properties +++ b/application.properties @@ -1,5 +1,5 @@ mcversion=1.7.10 -forgeversion=10.13.2.1284 +forgeversion=10.13.2.1286 version_major=3 version_minor=3 version_patch=0 From 2a35b05ec19656ed29c9f53a240a2ef52b2997b9 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 14 Jan 2015 23:25:08 -0800 Subject: [PATCH 168/175] Fix #452 Opening a multiblock inventory momentarily places a block --- .../forestry/apiculture/gadgets/TileAlveary.java | 9 ++++++++- .../java/forestry/core/gadgets/BlockStructure.java | 13 ++++++------- .../java/forestry/farming/gadgets/TileFarm.java | 12 +++++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java index a44705bc8..04e86449f 100755 --- a/src/main/java/forestry/apiculture/gadgets/TileAlveary.java +++ b/src/main/java/forestry/apiculture/gadgets/TileAlveary.java @@ -124,8 +124,12 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon @Override public PacketPayload getPacketPayload() { - PacketPayload payload = new PacketPayload(0, 1); + PacketPayload payload = new PacketPayload(0, 2); payload.shortPayload[0] = (short) (isMaster() ? 1 : 0); + + // so the client can know if it is part of an integrated structure + payload.shortPayload[1] = (short) this.masterY; + return payload; } @@ -133,6 +137,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon public void fromPacketPayload(PacketPayload payload) { if (payload.shortPayload[0] > 0) makeMaster(); + + // so the client can know if it is part of an integrated structure + this.masterY = payload.shortPayload[1]; } /* ITILESTRUCTURE */ diff --git a/src/main/java/forestry/core/gadgets/BlockStructure.java b/src/main/java/forestry/core/gadgets/BlockStructure.java index e4ccaa9cd..e87e8e969 100755 --- a/src/main/java/forestry/core/gadgets/BlockStructure.java +++ b/src/main/java/forestry/core/gadgets/BlockStructure.java @@ -64,18 +64,17 @@ public abstract class BlockStructure extends BlockForestry { if (!Utils.isUseableByPlayer(player, tile)) return false; - if (!Proxies.common.isSimulating(world)) - return player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IStructureBlockItem); - // GUIs can only be opened on integrated structure blocks. if (tile instanceof ITileStructure) if (!((ITileStructure) tile).isIntegratedIntoStructure()) return false; - if (tile.allowsViewing(player)) { - tile.openGui(player); - } else { - player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", PlayerUtil.getOwnerName(tile))); + if (Proxies.common.isSimulating(world)) { + if (tile.allowsViewing(player)) { + tile.openGui(player); + } else { + player.addChatMessage(new ChatComponentTranslation("for.chat.accesslocked", PlayerUtil.getOwnerName(tile))); + } } return true; } diff --git a/src/main/java/forestry/farming/gadgets/TileFarm.java b/src/main/java/forestry/farming/gadgets/TileFarm.java index 07ade1966..763dc388d 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarm.java +++ b/src/main/java/forestry/farming/gadgets/TileFarm.java @@ -12,7 +12,6 @@ package forestry.farming.gadgets; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -28,7 +27,6 @@ import forestry.api.farming.IFarmComponent; import forestry.api.farming.IFarmListener; import forestry.core.gadgets.TileForestry; import forestry.core.inventory.IInventoryAdapter; -import forestry.core.inventory.TileInventoryAdapter; import forestry.core.network.GuiId; import forestry.core.network.PacketPayload; import forestry.core.proxy.Proxies; @@ -151,9 +149,14 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { /* TILEFORESTRY */ @Override public PacketPayload getPacketPayload() { - PacketPayload payload = new PacketPayload(0, 2); + PacketPayload payload = new PacketPayload(0, 3); payload.shortPayload[0] = (short) farmBlock.ordinal(); + payload.shortPayload[1] = (short) (isMaster() ? 1 : 0); + + // so the client can know if it is part of an integrated structure + payload.shortPayload[2] = (short) masterY; + return payload; } @@ -163,6 +166,9 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent { if (payload.shortPayload[1] > 0) makeMaster(); + // so the client can know if it is part of an integrated structure + this.masterY = payload.shortPayload[2]; + if (this.farmBlock != farmType) { this.farmBlock = farmType; worldObj.func_147479_m(xCoord, yCoord, zCoord); From 8977d04de00bcf65f8e54305d60c9673a27af754 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 14 Jan 2015 23:37:37 -0800 Subject: [PATCH 169/175] Fix #446 Special products don't align in beealyzer --- src/main/java/forestry/apiculture/gui/GuiBeealyzer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 35efd1f78..183be6b2b 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -255,6 +255,7 @@ public class GuiBeealyzer extends GuiAlyzer { newLine(); drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0); + newLine(); x = COLUMN_0; for (ItemStack stack : bee.getSpecialtyList()) { From baa70ece6d218093d6b1d4f797a48f1dc456e460 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Mon, 12 Jan 2015 23:58:42 -0600 Subject: [PATCH 170/175] Add Fermenter support for Barley, Natura Saplings --- src/main/java/forestry/plugins/PluginNatura.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 859572794..70d47da8d 100755 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -18,6 +18,7 @@ import forestry.core.GameMode; import forestry.core.config.Defaults; import forestry.core.fluids.Fluids; import forestry.core.proxy.Proxies; +import forestry.core.utils.RecipeUtil; import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -64,6 +65,10 @@ public class PluginNatura extends ForestryPlugin { for (String key : saplingItemKeys) { Item saplingItem = GameRegistry.findItem(NATURA, key); + + ItemStack saplingWild = new ItemStack(saplingItem, 1, Defaults.WILDCARD); + RecipeUtil.injectLeveledRecipe(saplingWild, GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); + String saplingName = GameData.getItemRegistry().getNameForObject(saplingItem); FMLInterModComms.sendMessage(Defaults.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName)); } @@ -115,6 +120,10 @@ public class PluginNatura extends ForestryPlugin { amount = (amount > 1) ? amount : 1; // Produce at least 1 mb of juice. for (ItemStack berry : berries) RecipeManagers.squeezerManager.addRecipe(3, new ItemStack[]{berry}, Fluids.JUICE.getFluid(amount)); + + ItemStack itemBarley = GameRegistry.findItemStack(NATURA, "barleyFood", 1); + if (itemBarley != null) + RecipeUtil.injectLeveledRecipe(itemBarley, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); } } From f46bcf228c969472665ed9209e02422c724e0a19 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 15 Jan 2015 20:36:46 -0800 Subject: [PATCH 171/175] Fix #454 Forestry fences don't connect to fence gates --- .../java/forestry/arboriculture/gadgets/BlockArbFence.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java index 7a1ec78f9..2d949a96f 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbFence.java @@ -19,9 +19,11 @@ import forestry.plugins.PluginArboriculture; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockFence; +import net.minecraft.block.BlockFenceGate; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -70,7 +72,10 @@ public class BlockArbFence extends BlockFence implements IWoodTyped { public boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z) { if (!isFence(world, x, y, z)) { Block block = world.getBlock(x, y, z); - return block != null && block.getMaterial().isOpaque() && block.renderAsNormalBlock() && block.getMaterial() != Material.gourd; + if (block == this || block instanceof BlockFenceGate) + return true; + + return block.getMaterial().isOpaque() && block.renderAsNormalBlock() && block.getMaterial() != Material.gourd; } else return true; } From e1758f63cd9ddfe0c68648e0867de0d9982939ad Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 15 Jan 2015 21:02:24 -0800 Subject: [PATCH 172/175] Fix #455 Item duplicating by letters --- .../forestry/core/gui/ContainerItemInventory.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index 6f4f6c8d2..cc2734931 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -39,19 +39,6 @@ public abstract class ContainerItemInventory extends ContainerForestry { addSlotToContainer(new Slot(other, slot, x, y)); } - public void purgeBag(EntityPlayer player) { - for (int i = 0; i < inventorySlots.size() - 9 * 4; i++) { - Slot slot = (Slot) inventorySlots.get(i); - ItemStack stack = slot.getStack(); - - if (stack == null || slot.isItemValid(stack)) - continue; - - Proxies.common.dropItemPlayer(player, stack); - inventory.setInventorySlotContents(i, null); - } - } - public void saveInventory(EntityPlayer entityplayer) { if (inventory.isItemInventory) inventory.onGuiSaved(entityplayer); @@ -63,7 +50,6 @@ public abstract class ContainerItemInventory extends ContainerForestry { if (!Proxies.common.isSimulating(player.worldObj)) return; - purgeBag(player); saveInventory(player); } } From 1601136304b6ecf52a5839350332244e7fbf58c4 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 15 Jan 2015 21:12:23 -0800 Subject: [PATCH 173/175] Fix #456 Pipes cannot extract from Farm Hatch --- src/main/java/forestry/farming/gadgets/TileFarmPlain.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java index 7665a1ac9..9c7514fd9 100755 --- a/src/main/java/forestry/farming/gadgets/TileFarmPlain.java +++ b/src/main/java/forestry/farming/gadgets/TileFarmPlain.java @@ -373,6 +373,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable } return false; } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, int side) { + return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT); + } }); FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER); tankManager = new TankManager(liquidTank); From 10678d64697bc82a08644595282d9c9939d9da61 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 15 Jan 2015 22:50:33 -0800 Subject: [PATCH 174/175] Fix deprecation warnings from Forge --- .../java/forestry/arboriculture/gadgets/BlockArbStairs.java | 4 ++-- .../java/forestry/arboriculture/gadgets/BlockSapling.java | 2 +- src/main/java/forestry/farming/gadgets/BlockFarm.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java index c75d86afe..79e379ba1 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockArbStairs.java @@ -107,8 +107,8 @@ public class BlockArbStairs extends BlockStairs { } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - ItemStack itemStack = super.getPickBlock(target, world, x, y, z); + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + ItemStack itemStack = super.getPickBlock(target, world, x, y, z, player); NBTTagCompound stairsNBT = getTagCompoundForStairs(world, x, y, z); itemStack.setTagCompound(stairsNBT); return itemStack; diff --git a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java index cf5cc876f..2b043f5ae 100755 --- a/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java +++ b/src/main/java/forestry/arboriculture/gadgets/BlockSapling.java @@ -145,7 +145,7 @@ public class BlockSapling extends BlockTreeContainer { } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { TileSapling sapling = getSaplingTile(world, x, y, z); if (sapling == null || sapling.getTree() == null) return null; diff --git a/src/main/java/forestry/farming/gadgets/BlockFarm.java b/src/main/java/forestry/farming/gadgets/BlockFarm.java index 2028e48a2..270f55bd1 100755 --- a/src/main/java/forestry/farming/gadgets/BlockFarm.java +++ b/src/main/java/forestry/farming/gadgets/BlockFarm.java @@ -61,10 +61,10 @@ public class BlockFarm extends BlockStructure { } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ArrayList drops = getDrops(world, x, y, z, 0, 0); if (drops.isEmpty()) - return super.getPickBlock(target, world, x, y, z); + return super.getPickBlock(target, world, x, y, z, player); return drops.get(0); } From 1e9952e908983ff8ef9f8e3791a0f0f83ced57d9 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 15 Jan 2015 22:51:29 -0800 Subject: [PATCH 175/175] Update for BuildCraft 6.3 --- build.gradle | 2 +- .../java/forestry/core/inventory/InvTools.java | 16 ++-------------- .../forestry/plugins/PluginBuildCraftFuels.java | 2 +- .../plugins/PluginBuildCraftRecipes.java | 2 +- .../plugins/PluginBuildCraftStatements.java | 2 +- .../plugins/PluginBuildCraftTransport.java | 2 +- 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index 27564b68b..d3175fa11 100755 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ configurations { dependencies { api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api' - api 'com.mod-buildcraft:buildcraft:6.2.1:dev' + api 'com.mod-buildcraft:buildcraft:6.3.1:dev' } processResources { diff --git a/src/main/java/forestry/core/inventory/InvTools.java b/src/main/java/forestry/core/inventory/InvTools.java index e4774954b..0b24e07df 100755 --- a/src/main/java/forestry/core/inventory/InvTools.java +++ b/src/main/java/forestry/core/inventory/InvTools.java @@ -13,7 +13,6 @@ package forestry.core.inventory; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; -import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -55,7 +54,6 @@ import forestry.core.utils.StackUtils; import forestry.plugins.PluginManager; import buildcraft.api.transport.IPipeTile; -import buildcraft.api.transport.PipeManager; public abstract class InvTools { @@ -155,11 +153,6 @@ public abstract class InvTools { if (tile == null || !(tile instanceof IInventory)) return null; - if (PluginManager.Module.BUILDCRAFT_TRANSPORT.isEnabled()) { - if(!internal_canExtractFromBuildCraftPipe(tile)) - return null; - } - if (tile instanceof TileEntityChest) { TileEntityChest chest = (TileEntityChest) tile; return new ChestWrapper(chest); @@ -167,11 +160,6 @@ public abstract class InvTools { return getInventory((IInventory) tile, side); } - @Optional.Method(modid = "BuildCraftAPI|transport") - private static boolean internal_canExtractFromBuildCraftPipe(TileEntity tile) { - return PipeManager.canExtractItems(null, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); - } - public static IInventory getInventory(IInventory inv, ForgeDirection side) { if (inv == null) return null; @@ -797,9 +785,9 @@ public abstract class InvTools { int choice = tileCache.getSource().getWorldObj().rand.nextInt(pipes.size()); Map.Entry pipe = pipes.get(choice); - if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite()) > 0) + if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) if (removeOneItem(source, stackToMove) != null) { - pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite()); + pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null); return true; } return false; diff --git a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java index 5b3e2150f..e8c159d0b 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftFuels.java @@ -26,7 +26,7 @@ public class PluginBuildCraftFuels extends ForestryPlugin { @Override public boolean isAvailable() { - return Proxies.common.isAPILoaded("buildcraft.api.fuels", "[2.0, 2.1)"); + return Proxies.common.isAPILoaded("buildcraft.api.fuels", "[2.0, 3.0)"); } @Override diff --git a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java index 78ae9dde2..52b94edbc 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftRecipes.java @@ -21,7 +21,7 @@ public class PluginBuildCraftRecipes extends ForestryPlugin { @Override public boolean isAvailable() { - return Proxies.common.isAPILoaded("buildcraft.api.recipes", "[2.0, 2.1)"); + return Proxies.common.isAPILoaded("buildcraft.api.recipes", "[2.0, 3.0)"); } @Override diff --git a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java index fc6705261..b93b073a3 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftStatements.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftStatements.java @@ -28,7 +28,7 @@ public class PluginBuildCraftStatements extends ForestryPlugin implements ITrigg @Override public boolean isAvailable() { - return Proxies.common.isAPILoaded("buildcraft.api.statements", "[1.0, 1.1)"); + return Proxies.common.isAPILoaded("buildcraft.api.statements", "[1.0, 2.0)"); } @Override diff --git a/src/main/java/forestry/plugins/PluginBuildCraftTransport.java b/src/main/java/forestry/plugins/PluginBuildCraftTransport.java index 6d9b6d3d9..e717bc066 100644 --- a/src/main/java/forestry/plugins/PluginBuildCraftTransport.java +++ b/src/main/java/forestry/plugins/PluginBuildCraftTransport.java @@ -22,7 +22,7 @@ public class PluginBuildCraftTransport extends ForestryPlugin { @Override public boolean isAvailable() { - return Proxies.common.isModLoaded("BuildCraft|Transport"); + return Proxies.common.isAPILoaded("buildcraft.api.transport", "[2.0, 4.0)"); } @Override