Merge branch 'master' into plugins-rcstyle

Conflicts:
	api
	lang
This commit is contained in:
CovertJaguar committed 2014-09-20 18:26:01 -07:00
commit 8278f4688a
212 files changed
+4247 -2662

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 ChickenBones
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,38 @@
package codechicken.nei;
public class VisiblityData
{
public boolean showUtilityButtons = true;
public boolean showStateButtons = true;
/**
* Item panel and associated buttons
*/
public boolean showItemPanel = true;
/**
* Item and search section
*/
public boolean showItemSection = true;
/**
* Dropdown and Item search field
*/
public boolean showSearchSection = true;
/**
* All widgets except options button
*/
public boolean showWidgets = true;
/**
* The entire NEI interface, aka hidden
*/
public boolean showNEI = true;
public boolean enableDeleteMode = true;
public void translateDependancies()
{
if(!showNEI)
showWidgets = false;
if(!showWidgets)
showItemSection = showUtilityButtons = showStateButtons = false;
if(!showItemSection)
showSearchSection = showItemPanel = false;
}
}
@@ -0,0 +1,49 @@
package codechicken.nei.api;
import codechicken.nei.VisiblityData;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import java.util.List;
/**
* If this is implemented on a gui, it will be automatically registered
*/
public interface INEIGuiHandler
{
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
/**
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
* return null for no range
*/
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
/**
* @return A list of TaggedInventoryAreas that will be used with the savestates.
*/
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
/**
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
* Changes made to the stackSize of the dragged stack will be kept
* @param gui The current gui instance
* @param mousex The x position of the mouse
* @param mousey The y position of the mouse
* @param draggedStack The stack being dragged from the item panel
* @param button The button presed
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
*/
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
/**
* Used to prevent the item panel from drawing on top of other gui elements.
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
* @param x The x coordinate of the rectangle bounding the slot
* @param y The y coordinate of the rectangle bounding the slot
* @param w The w coordinate of the rectangle bounding the slot
* @param h The h coordinate of the rectangle bounding the slot
* @return true if the item panel slot within the specified rectangle should not be rendered.
*/
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h);
}
@@ -0,0 +1,48 @@
package codechicken.nei.api;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import java.util.HashSet;
public class TaggedInventoryArea
{
public HashSet<Integer> slots = new HashSet<Integer>();
public String tagName;
/**
* Only for player inventories.
*/
private IInventory inventory;
/**
* Other inventories
*/
private Container container;
public TaggedInventoryArea(InventoryPlayer invPlayer)
{
this("InventoryPlayer", 0, 39, null);
inventory = invPlayer;
}
public TaggedInventoryArea(String name, int first, int last, Container container)
{
this.container = container;
tagName = name;
for(int i = first; i <= last; i++)
slots.add(i);
}
public ItemStack getStackInSlot(int i)
{
if(inventory != null)
return inventory.getStackInSlot(i);
return container.getSlot(i).getStack();
}
public boolean isContainer()
{
return inventory == null;
}
}
+49 -6
View File
@@ -15,22 +15,31 @@ import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.EngineCopperFuel;
import forestry.api.fuels.FermenterFuel;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.GeneratorFuel;
import forestry.api.fuels.MoistenerFuel;
import forestry.api.fuels.RainSubstrate;
import forestry.core.ForestryCore;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.config.Version;
import forestry.core.network.PacketHandler;
import forestry.core.proxy.Proxies;
import forestry.core.utils.FluidMap;
import forestry.core.utils.ItemStackMap;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
/**
* Forestry Minecraft Mod
@@ -41,11 +50,11 @@ import forestry.core.utils.ItemStackMap;
modid = Defaults.MOD,
name = "Forestry",
version = Version.VERSION,
dependencies = "required-after:Forge@[10.13.0.1180,);"
+ "after:Buildcraft|Core;"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2")
dependencies = "required-after:Forge@[10.13.0.1207,);"
+ "after:Buildcraft|Core;"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -58,6 +67,7 @@ public class Forestry {
FuelManager.rainSubstrate = new ItemStackMap<RainSubstrate>();
FuelManager.bronzeEngineFuel = new FluidMap<EngineBronzeFuel>();
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
}
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
public static ForestryCore core = new ForestryCore();
@@ -96,4 +106,37 @@ public class Forestry {
public void processIMCMessages(IMCEvent event) {
core.processIMCMessages(event.getMessages());
}
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (MissingMapping mapping : event.get())
if (mapping.type == Type.BLOCK) {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
mapping.remap(block);
Proxies.log.warning("Remapping block " + mapping.name + " to " + StringUtil.cleanBlockName(block));
}
} else {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
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());
}
}
}
}
@@ -204,7 +204,10 @@ public class CommandBeekeepingMode extends CommandMC {
private void listModes(ICommandSender sender, String[] arguments) {
World world = getWorld(sender, arguments);
sendChatMessage(sender, StringUtil.localize("chat.bees.command.mode.current").replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName()).replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion())));
String message = StringUtil.localize("chat.bees.command.mode.current");
message = message.replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
message = message.replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion()));
sendChatMessage(sender, message);
String help = "";
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
@@ -147,6 +147,8 @@ public class BlockAlveary extends BlockStructure {
return icons[BOTTOM];
switch (metadata) {
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
@@ -162,7 +164,7 @@ public class BlockAlveary extends BlockStructure {
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return icons[PLAIN];
return null;
}
}
@@ -155,6 +155,9 @@ public class BlockBeehives extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j >= 8)
return null;
if (i == 0 || i == 1) {
if (j * 2 < icons.length && icons[j * 2] != null)
return icons[j * 2];
@@ -136,10 +136,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
nbttagcompound.setInteger("Heating", transferTime);
}
@Override
public String getInventoryName() {
return "tile.alveary.climatiser";
}
/* NETWORK */
@Override
@@ -18,17 +18,20 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Defaults;
import forestry.core.fluids.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.ForestryTank;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
@@ -57,7 +60,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
/* MEMBERS */
InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
private ForestryTank liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY);
private final TankManager tankManager;
private FilteredTank liquidTank;
private HygroregulatorRecipe currentRecipe;
private int transferTime;
@@ -65,9 +69,16 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
public TileAlvearyHygroregulator() {
super(BLOCK_META);
recipes = new HygroregulatorRecipe[] { new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_WATER), 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_LAVA), 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(LiquidHelper.getFluid(Defaults.LIQUID_ICE), 1), 10, 0.02f, -0.01f) };
Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER);
Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA);
Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE);
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
tankManager = new TankManager(liquidTank);
recipes = new HygroregulatorRecipe[] { new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
}
@Override
@@ -77,7 +88,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public String getInventoryName() {
return "tile.alveary.5";
return getUnlocalizedName();
}
/* UPDATING */
@@ -146,9 +157,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
canInventory.readFromNBT(nbttagcompound);
liquidTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY);
if (nbttagcompound.hasKey("LiquidTank"))
liquidTank.readFromNBT(nbttagcompound.getCompoundTag("LiquidTank"));
tankManager.readTanksFromNBT(nbttagcompound);
transferTime = nbttagcompound.getInteger("TransferTime");
@@ -164,9 +173,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
canInventory.writeToNBT(nbttagcompound);
NBTTagCompound NBTresourceSlot = new NBTTagCompound();
liquidTank.writeToNBT(NBTresourceSlot);
nbttagcompound.setTag("LiquidTank", NBTresourceSlot);
tankManager.writeTanksToNBT(nbttagcompound);
nbttagcompound.setInteger("TransferTime", transferTime);
if (currentRecipe != null) {
@@ -268,30 +275,54 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
if (slotIndex == 0) {
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
if (fluid == null || fluid.amount <= 0)
return false;
return liquidTank.accepts(fluid.getFluid());
}
return super.isItemValidForSlot(slotIndex, itemstack);
}
/* ILIQUIDTANKCONTAINER */
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return liquidTank.fill(resource, doFill);
return tankManager.fill(from, resource, doFill);
}
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return liquidTank.drain(maxDrain, doDrain);
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public ForestryTank[] getTanks() {
return new ForestryTank[] { liquidTank };
public boolean canFill(ForgeDirection from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
/* SMP GUI */
public void getGUINetworkData(int i, int j) {
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return tankManager.getTankInfo(from);
}
@Override
public void getGUINetworkData(int messageId, int data) {}
@Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {}
}
@@ -54,6 +54,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
public static final int SLOT_DRONE = 1;
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCTION_COUNT = 7;
public static final int BLOCK_META = 0;
// / MEMBERS
protected IBeekeepingLogic beekeepingLogic;
protected int biomeId;
@@ -582,7 +584,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public String getInventoryName() {
return "alveary.0";
return getUnlocalizedName();
}
@Override
@@ -45,10 +45,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
player.openGui(ForestryAPI.instance, GuiId.AlvearySieveGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
}
@Override
public String getInventoryName() {
return "tile.alveary.7";
}
@Override
public boolean hasFunction() {
@@ -46,10 +46,6 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
}
@Override
public String getInventoryName() {
return "tile.alveary.6";
}
@Override
public boolean hasFunction() {
@@ -267,7 +267,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
@Override
public String getInventoryName() {
return "tile.alveary.2";
return getUnlocalizedName();
}
@Override
@@ -30,7 +30,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public String getInventoryName() {
return "apiculture.0";
return getUnlocalizedName();
}
@Override
@@ -68,11 +68,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
}
@Override
public String getInventoryName() {
return "apiculture.2";
}
@Override
public void openGui(EntityPlayer player, TileBase tile) {
player.openGui(ForestryAPI.instance, GuiId.BeehouseGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
@@ -37,17 +37,4 @@ public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
}
@Override
public void updateProgressBar(int i, int j) {
tile.getGUINetworkData(i, j);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++)
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
}
}
@@ -10,74 +10,17 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
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.ContainerItemInventory;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.proxy.Proxies;
public class ContainerBeealyzer extends ContainerItemInventory {
import net.minecraft.entity.player.InventoryPlayer;
BeealyzerInventory inventory;
public class ContainerBeealyzer extends ContainerAlyzer {
public ContainerBeealyzer(InventoryPlayer inventoryplayer, BeealyzerInventory inventory) {
super(inventory, inventoryplayer.player);
this.inventory = inventory;
// Energy
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
// Bee to analyze
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_SPECIMEN, 172, 26, new Object[] { ItemBeeGE.class }));
// Analyzed bee
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemBeeGE.class }));
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemBeeGE.class }));
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemBeeGE.class }));
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemBeeGE.class }));
this.addSlot(new SlotCustom(inventory, BeealyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemBeeGE.class }));
// Player inventory
for (int i1 = 0; i1 < 3; i1++)
for (int l1 = 0; l1 < 9; l1++)
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 18 + l1 * 18, 156 + i1 * 18);
// Player hotbar
for (int j1 = 0; j1 < 9; j1++)
addSecuredSlot(inventoryplayer, j1, 18 + j1 * 18, 214);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer) {
if (!Proxies.common.isSimulating(entityplayer.worldObj))
return;
// Last slot is the energy slot, so we don't save that one.
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (i == BeealyzerInventory.SLOT_ENERGY)
continue;
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
continue;
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
}
inventory.onGuiSaved(entityplayer);
}
@Override
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
return true;
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemBeeGE.class });
}
}
@@ -14,12 +14,11 @@ import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
public class GuiAlveary extends GuiForestry<TileAlvearyPlain> {
public class GuiAlveary extends GuiForestryTitled<TileAlvearyPlain> {
public GuiAlveary(InventoryPlayer inventory, TileAlvearyPlain tile) {
super(Defaults.TEXTURE_PATH_GUI + "/alveary.png", new ContainerAlveary(inventory, tile), tile);
@@ -27,13 +26,6 @@ public class GuiAlveary extends GuiForestry<TileAlvearyPlain> {
ySize = 190;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String title = StringUtil.localize("tile." + tile.getInventoryName());
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
@@ -14,23 +14,15 @@ import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import forestry.core.utils.StringUtil;
public class GuiAlvearyHygroregulator extends GuiForestry<TileAlvearyHygroregulator> {
public class GuiAlvearyHygroregulator extends GuiForestryTitled<TileAlvearyHygroregulator> {
public GuiAlvearyHygroregulator(InventoryPlayer inventory, TileAlvearyHygroregulator tile) {
super(Defaults.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile));
super(Defaults.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile), tile);
widgetManager.add(new TankWidget(this.widgetManager, 104, 17, 0));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String name = StringUtil.localize("tile.alveary.5");
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
}
}
@@ -15,12 +15,11 @@ 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.GuiForestry;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
public class GuiApiary extends GuiForestry<TileBeehouse> {
public class GuiApiary extends GuiForestryTitled<TileBeehouse> {
public GuiApiary(InventoryPlayer inventory, TileApiary tile) {
super(Defaults.TEXTURE_PATH_GUI + "/apiary.png", new ContainerApiary(inventory, tile, true), tile);
@@ -34,13 +33,6 @@ public class GuiApiary extends GuiForestry<TileBeehouse> {
ySize = 190;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String name = StringUtil.localize("tile.for." + tile.getInventoryName());
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
@@ -41,8 +41,7 @@ public class GuiBeealyzer extends GuiAlyzer {
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"), player,
new ContainerBeealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
xSize = 196;
ySize = 238;
guiName = "gui.beealyzer";
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
@@ -96,45 +95,6 @@ public class GuiBeealyzer extends GuiAlyzer {
}
private void drawAnalyticsOverview() {
startPage();
newLine();
String title = StringUtil.localize("gui.beealyzer").toUpperCase();
drawCenteredLine(title, 8, 158);
newLine();
fontRendererObj.drawSplitString(StringUtil.localize("gui.beealyzer.help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
(int) ((guiTop + 42) * (1 / factor)), (int) (158 * (1 / factor)), fontColor.get("gui.screen"));
newLine();
newLine();
newLine();
newLine();
drawLine(StringUtil.localize("gui.beealyzer.overview") + ":", COLUMN_0 + 4);
newLine();
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
newLine();
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
newLine();
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
newLine();
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
newLine();
String mode = breedingTracker.getModeName();
if (mode != null && !mode.isEmpty()) {
newLine();
String rules = StringUtil.localize("gui.beealyzer.behaviour") + ": " + StringUtil.capitalize(mode);
drawLine(rules, 8 + getCenteredOffset(title, 158), fontColor.get("gui.beealyzer.binomial"));
}
endPage();
}
private void drawAnalyticsPage1(IBee bee, EnumBeeType type) {
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
@@ -268,16 +228,14 @@ public class GuiBeealyzer extends GuiAlyzer {
if (!bee.isNatural())
displayText = "bees.stock.ignoble";
displayText = StringUtil.localize(displayText);
// int offset = (int)(((158 - fontRendererObj.getStringWidth(origin)) / 2)*(1/factor));
drawCenteredLine(displayText, 8, 158, fontColor.get("gui.beealyzer.binomial"));;
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
}
if (bee.getGeneration() >= 0) {
newLine();
displayText = StringUtil.localizeAndFormat("gui.beealyzer.generations", bee.getGeneration());
// offset = (int)(((158 - fontRendererObj.getStringWidth(origin)) / 2)*(1/factor));
drawCenteredLine(displayText, 8, 158, fontColor.get("gui.beealyzer.binomial"));
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
}
endPage();
@@ -285,6 +243,9 @@ public class GuiBeealyzer extends GuiAlyzer {
private void drawAnalyticsPage3(IBee bee, EnumBeeType type) {
float factor = this.factor;
this.setFactor(1.0f);
tempProductList = bee.getProduceList();
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
@@ -295,8 +256,8 @@ public class GuiBeealyzer extends GuiAlyzer {
int x = COLUMN_0;
for (ItemStack stack : tempProductList) {
itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, (int) ((guiLeft + x) * (1 / factor)),
(int) ((guiTop + getLineY()) * (1 / factor)));
widgetManager.add(new ItemStackWidget(adjustToFactor(x), adjustToFactor(getLineY()), stack));
x += 18;
if (x > adjustToFactor(148)) {
x = COLUMN_0;
@@ -304,16 +265,16 @@ public class GuiBeealyzer extends GuiAlyzer {
}
}
newLine();
newLine();
newLine();
drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0);
newLine();
x = COLUMN_0;
for (ItemStack stack : bee.getSpecialtyList()) {
itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, (int) ((guiLeft + x) * (1 / factor)),
(int) ((guiTop + getLineY()) * (1 / factor)));
widgetManager.add(new ItemStackWidget(adjustToFactor(x), adjustToFactor(getLineY()), stack));
x += 18;
if (x > adjustToFactor(148)) {
x = COLUMN_0;
@@ -322,6 +283,8 @@ public class GuiBeealyzer extends GuiAlyzer {
}
endPage();
this.setFactor(factor);
}
}
@@ -77,7 +77,10 @@ public class ItemBeeGE extends ItemGE {
if(StatCollector.canTranslate("for." + customBeeKey)){
return StringUtil.localize(customBeeKey);
}
return StringUtil.localize("bees.grammar." + type.getName()).replaceAll("%SPECIES", individual.getDisplayName()).replaceAll("%TYPE", StringUtil.localize("bees.grammar." + type.getName() + ".type"));
String beeGrammar = StringUtil.localize("bees.grammar." + type.getName());
String beeSpecies = individual.getDisplayName();
String beeType = StringUtil.localize("bees.grammar." + type.getName() + ".type");
return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.apiculture.items;
import forestry.core.utils.AlyzerInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import forestry.api.apiculture.IBee;
@@ -27,22 +27,11 @@ 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.plugins.PluginApiculture;
public class ItemBeealyzer extends ItemInventoried {
public static class BeealyzerInventory extends ItemInventory implements IErrorSource, IHintSource {
public static final int SLOT_SPECIMEN = 0;
public static final int SLOT_ANALYZE_1 = 1;
public static final int SLOT_ANALYZE_2 = 2;
public static final int SLOT_ANALYZE_3 = 3;
public static final int SLOT_ANALYZE_4 = 4;
public static final int SLOT_ANALYZE_5 = 6;
public static final int SLOT_ENERGY = 5;
EntityPlayer player;
public static class BeealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
public BeealyzerInventory(EntityPlayer player) {
super(ItemBeealyzer.class, 7);
@@ -54,21 +43,6 @@ public class ItemBeealyzer extends ItemInventoried {
this.player = player;
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
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);
}
nbttagcompound.setTag("Items", nbttaglist);
}
private boolean isEnergy(ItemStack itemstack) {
if (itemstack == null || itemstack.stackSize <= 0)
return false;
@@ -18,8 +18,10 @@ import net.minecraft.block.material.Material;
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.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -35,6 +37,8 @@ import forestry.api.arboriculture.ITree;
import forestry.api.core.IToolScoop;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.api.lepidopterology.IButterfly;
import forestry.arboriculture.items.ItemLeavesBlock;
import forestry.core.config.ForestryBlock;
import forestry.core.config.Defaults;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
@@ -147,6 +151,20 @@ public class BlockLeaves extends BlockTreeContainer {
return prod;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
TileLeaves leaves = getLeafTile(world, x, y, z);
NBTTagCompound nbttagcompound = new NBTTagCompound();
leaves.getTree().writeToNBT(nbttagcompound);
ItemLeavesBlock leavesItem = (ItemLeavesBlock)ForestryBlock.leaves.item();
ItemStack leavesStack = new ItemStack(leavesItem);
leavesStack.setTagCompound(nbttagcompound);
return leavesStack;
}
/* RENDERING */
@Override
public boolean isOpaqueCube() {
@@ -103,6 +103,7 @@ public class BlockLog extends Block implements IWoodTyped {
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
if(cat == LogCat.CAT6) {
itemList.add(new ItemStack(this, 1, 0));
return;
}
@@ -123,7 +124,10 @@ public class BlockLog extends Block implements IWoodTyped {
int oriented = meta & 12;
WoodType type = getWoodType(getTypeFromMeta(meta));
WoodType type = getWoodType(meta);
if (type == null)
return null;
switch (oriented) {
case 4:
if (side > 3)
@@ -157,7 +161,7 @@ public class BlockLog extends Block implements IWoodTyped {
/* PROPERTIES */
@Override
public float getBlockHardness(World world, int x, int y, int z) {
return getWoodType(getTypeFromMeta(world.getBlockMetadata(x, y, z))).getHardness();
return getWoodType(world.getBlockMetadata(x, y, z)).getHardness();
}
@Override
@@ -192,10 +196,11 @@ 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];
else
return WoodType.LARCH;
return null;
}
@Override
@@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -145,6 +146,12 @@ public class BlockSapling extends BlockTreeContainer {
return new ArrayList<ItemStack>();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
TileSapling sapling = getSaplingTile(world, x, y, z);
return PluginArboriculture.treeInterface.getMemberStack(sapling.getTree(), EnumGermlingType.SAPLING.ordinal());
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (Proxies.common.isSimulating(world) && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
@@ -277,16 +277,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
/* NETWORK */
@Override
public Packet getDescriptionPacket() {
return new PacketLeafUpdate(xCoord, yCoord, zCoord, this).getPacket();
return new PacketLeafUpdate(this).getPacket();
}
@Override
public void sendNetworkUpdate() {
Proxies.net.sendNetworkPacket(new PacketLeafUpdate(xCoord, yCoord, zCoord, this), xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this), xCoord, yCoord, zCoord);
}
private void sendNetworkUpdateRipening() {
Proxies.net.sendNetworkPacket(new PacketLeafUpdate(xCoord, yCoord, zCoord, determineFruitColour()), xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(new PacketLeafUpdate(this, determineFruitColour()), xCoord, yCoord, zCoord);
}
@Override
@@ -296,6 +296,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
if(packet.isRipeningUpdate()) {
colourFruits = packet.colourFruits;
} else {
readFromNBT(packet.getTagCompound());
isFruitLeaf = packet.isFruitLeaf();
isPollinatedState = packet.isPollinated();
textureIndexFancy = packet.textureIndexFancy;
@@ -39,7 +39,7 @@ public class GrowthProvider implements IGrowthProvider {
@Override
public String getDescription() {
return StringUtil.localize("gui.growth.normal");
return StringUtil.localize("growth.normal");
}
@Override
@@ -12,19 +12,20 @@ package forestry.arboriculture.genetics;
import java.util.EnumSet;
import forestry.core.utils.StringUtil;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumGrowthConditions;
import forestry.api.arboriculture.ITreeGenome;
import forestry.core.utils.StringUtil;
public class GrowthProviderTropical extends GrowthProvider {
@Override
public EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, int xPos, int yPos, int zPos) {
EnumGrowthConditions light = getConditionFromLight(world, xPos, yPos, zPos);
EnumGrowthConditions moisture = getConditionsFromRainfall(world, xPos, yPos, zPos, 0.9f, 2.0f);
EnumGrowthConditions temperature = getConditionsFromTemperature(world, xPos, yPos, zPos, 1.2f, 1.9f);
EnumGrowthConditions moisture = getConditionsFromRainfall(world, xPos, yPos, zPos, BiomeGenBase.jungle.rainfall, 2.0f);
EnumGrowthConditions temperature = getConditionsFromTemperature(world, xPos, yPos, zPos, BiomeGenBase.jungle.temperature, BiomeGenBase.desert.temperature - 0.1f);
EnumSet<EnumGrowthConditions> conditions = EnumSet.of(light, moisture, temperature);
@@ -42,7 +43,7 @@ public class GrowthProviderTropical extends GrowthProvider {
@Override
public String getDescription() {
return StringUtil.localize("gui.growth.tropical");
return StringUtil.localize("growth.tropical");
}
}
@@ -10,77 +10,23 @@
******************************************************************************/
package forestry.arboriculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.ArrayUtils;
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.ContainerItemInventory;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.proxy.Proxies;
public class ContainerTreealyzer extends ContainerItemInventory {
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);
public ContainerTreealyzer(InventoryPlayer inventoryplayer, TreealyzerInventory inventory) {
super(inventory, inventoryplayer.player);
this.inventory = inventory;
// Energy
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
// Tree to analyze
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_SPECIMEN, 172, 26, ArrayUtils.addAll(AlleleManager.ersatzSaplings.keySet().toArray(new Object[0]), ItemGermlingGE.class)));
// Analyzed tree
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemGermlingGE.class }));
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemGermlingGE.class }));
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemGermlingGE.class }));
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemGermlingGE.class }));
this.addSlot(new SlotCustom(inventory, TreealyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemGermlingGE.class }));
// Player inventory
for (int i1 = 0; i1 < 3; i1++)
for (int l1 = 0; l1 < 9; l1++)
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 18 + l1 * 18, 156 + i1 * 18);
// Player hotbar
for (int j1 = 0; j1 < 9; j1++)
addSecuredSlot(inventoryplayer, j1, 18 + j1 * 18, 214);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer) {
if (!Proxies.common.isSimulating(entityplayer.worldObj))
return;
// Last slot is the energy slot, so we don't save that one.
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (i == TreealyzerInventory.SLOT_ENERGY)
continue;
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
continue;
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
}
inventory.onGuiSaved(entityplayer);
}
@Override
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
return true;
super(inventoryplayer, inventory, acceptedEnergy, acceptedSpecimens);
}
}
@@ -46,8 +46,7 @@ public class GuiTreealyzer extends GuiAlyzer {
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"), player,
new ContainerTreealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
xSize = 196;
ySize = 238;
guiName = "gui.treealyzer";
ArrayList<ItemStack> treeList = new ArrayList<ItemStack>();
((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false);
@@ -99,35 +98,6 @@ public class GuiTreealyzer extends GuiAlyzer {
}
private void drawAnalyticsOverview() {
startPage();
newLine();
String title = StringUtil.localize("gui.treealyzer").toUpperCase();
drawCenteredLine(title, 8, 158);
newLine();
fontRendererObj.drawSplitString(StringUtil.localize("gui.treealyzer.help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
(int) ((guiTop + 42) * (1 / factor)), (int) (158 * (1 / factor)), fontColor.get("gui.screen"));
newLine();
newLine();
newLine();
newLine();
drawLine(StringUtil.localize("gui.treealyzer.overview") + ":", COLUMN_0 + 4);
newLine();
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
newLine();
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
newLine();
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
newLine();
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
endPage();
}
private void drawAnalyticsPage1(ITree tree, EnumGermlingType type) {
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
@@ -0,0 +1,43 @@
package forestry.arboriculture.items;
import forestry.api.arboriculture.ITree;
import forestry.arboriculture.genetics.Tree;
import forestry.core.items.ItemForestryBlock;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class ItemLeavesBlock extends ItemForestryBlock {
public ItemLeavesBlock(Block block) {
super(block);
}
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
String type = StringUtil.localize("trees.grammar.leaves.type");
if (!itemstack.hasTagCompound())
return type;
ITree tree = getTree(itemstack);
String customTreeKey = "trees.custom.leaves." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.","");
if(StatCollector.canTranslate("for." + customTreeKey)){
return StringUtil.localize(customTreeKey);
}
String grammar = StringUtil.localize("trees.grammar.leaves");
return grammar.replaceAll("%SPECIES", tree.getDisplayName()).replaceAll("%TYPE", type);
}
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
ITree tree = getTree(itemstack);
return tree.getGenome().getPrimary().getLeafColour(tree);
}
private ITree getTree(ItemStack itemStack) {
return new Tree(itemStack.getTagCompound());
}
}
@@ -13,9 +13,9 @@ package forestry.arboriculture.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import forestry.core.utils.AlyzerInventory;
import forestry.api.arboriculture.ITree;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
@@ -27,22 +27,12 @@ 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.utils.Utils;
import forestry.plugins.PluginArboriculture;
public class ItemTreealyzer extends ItemInventoried {
public static class TreealyzerInventory extends ItemInventory implements IErrorSource, IHintSource {
public final static int SLOT_SPECIMEN = 0;
public final static int SLOT_ANALYZE_1 = 1;
public final static int SLOT_ANALYZE_2 = 2;
public final static int SLOT_ANALYZE_3 = 3;
public final static int SLOT_ANALYZE_4 = 4;
public final static int SLOT_ANALYZE_5 = 6;
public final static int SLOT_ENERGY = 5;
EntityPlayer player;
public static class TreealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
public TreealyzerInventory(EntityPlayer player) {
super(ItemTreealyzer.class, 7);
@@ -54,22 +44,6 @@ public class ItemTreealyzer extends ItemInventoried {
this.player = player;
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
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);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
private boolean isEnergy(ItemStack itemstack) {
if (itemstack == null || itemstack.stackSize <= 0)
return false;
@@ -34,6 +34,8 @@ public class ItemWoodBlock extends ItemForestryBlock {
IWoodTyped block = (IWoodTyped) getBlock();
int meta = itemstack.getItemDamage();
WoodType woodType = block.getWoodType(meta);
if (woodType == null)
return null;
return "tile.for." + block.getBlockKind() + "." + woodType.ordinal();
}
return super.getUnlocalizedName(itemstack);
@@ -15,10 +15,10 @@ import java.io.DataOutputStream;
import java.io.IOException;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketTileNBT;
public class PacketLeafUpdate extends PacketCoordinates {
public class PacketLeafUpdate extends PacketTileNBT {
public byte isRipeningUpdate = 0;
@@ -33,8 +33,8 @@ public class PacketLeafUpdate extends PacketCoordinates {
public PacketLeafUpdate() {
}
public PacketLeafUpdate(int posX, int posY, int posZ, TileLeaves leaves) {
super(PacketIds.LEAF_UPDATE, posX, posY, posZ);
public PacketLeafUpdate(TileLeaves leaves) {
super(PacketIds.LEAF_UPDATE, leaves);
leafState = 0;
if(leaves.hasFruit())
@@ -48,8 +48,8 @@ public class PacketLeafUpdate extends PacketCoordinates {
colourFruits = leaves.determineFruitColour();
}
public PacketLeafUpdate(int posX, int posY, int posZ, int fruitColour) {
super(PacketIds.LEAF_UPDATE, posX, posY, posZ);
public PacketLeafUpdate(TileLeaves leaves, int fruitColour) {
super(PacketIds.LEAF_UPDATE, leaves);
isRipeningUpdate = 1;
colourFruits = fruitColour;
@@ -24,6 +24,7 @@ public class BlockTypeLeaf extends BlockType {
public BlockTypeLeaf(GameProfile owner) {
super(ForestryBlock.leaves, 0);
this.owner = owner;
}
@Override
@@ -58,10 +58,10 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
private GameProfile getOwner() {
TileEntity tile = world.getTileEntity(startX, startY, startZ);
if (!(tile instanceof TileSapling))
return Utils.getForestryPlayerProfile();
return ((TileSapling) tile).getOwnerProfile();
if (tile instanceof TileSapling)
return ((TileSapling) tile).getOwnerProfile();
else
return null;
}
public abstract void preGenerate();
+17 -3
View File
@@ -66,7 +66,7 @@ public enum EnumErrorCode {
NOHONEY("noHoney", 22),
NOTPOSTPAID("notPostpaid", 23),
NOTPOSTPAID("notPostpaid", "noStamps", 23),
NORECIPIENT("noRecipient", 24),
@@ -86,14 +86,28 @@ public enum EnumErrorCode {
CIRCUITMISMATCH("circuitMismatch", 26),
NOLIQUID("noLiquid", 29);
NOLIQUID("noLiquid", 29),
NOPAPER("noPaper", 30),
NOSTAMPSNOPAPER("noStampsNoPaper", "noStamps", 31),
NOSUPPLIES("noSupplies", "noResource", 32),
NOTRADE("noTrade", "noResource", 33);
private String name;
private String iconName;
@SideOnly(Side.CLIENT)
private IIcon icon;
private EnumErrorCode(String name, int iconIndex) {
this(name, name, iconIndex);
}
private EnumErrorCode(String name, String iconName, int iconIndex) {
this.name = name;
this.iconName = iconName;
}
public String getDescription() {
@@ -106,7 +120,7 @@ public enum EnumErrorCode {
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
icon = TextureManager.getInstance().registerTex(register, "errors/" + name);
icon = TextureManager.getInstance().registerTex(register, "errors/" + iconName);
}
@SideOnly(Side.CLIENT)
@@ -0,0 +1,5 @@
package forestry.core;
public interface IItemTyped {
public Enum getTypeFromMeta(int meta);
}
@@ -21,14 +21,10 @@ public abstract class Circuit implements ICircuit {
String uid;
int limit = 1;
boolean requiresDiscovery;
String name;
String[] descriptions;
public Circuit(String uid, boolean requiresDiscovery, String name, String[] descriptions) {
public Circuit(String uid, boolean requiresDiscovery) {
this.uid = uid;
this.requiresDiscovery = requiresDiscovery;
this.name = name;
this.descriptions = descriptions;
ChipsetManager.circuitRegistry.registerCircuit(this);
}
@@ -54,14 +50,23 @@ public abstract class Circuit implements ICircuit {
@Override
public String getName() {
return "circuit." + this.name;
return "circuit." + this.uid;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addTooltip(List list) {
for (String description : descriptions)
list.add(" - " + StringUtil.localize(description));
list.add(StringUtil.localize(getName()));
int i = 1;
while (true) {
String unlocalizedDescription = getName() + ".description." + i;
String description = StringUtil.localize(unlocalizedDescription);
if (description.endsWith(unlocalizedDescription))
break;
list.add(" - " + description);
i++;
}
}
public static ICircuit energyElectricChoke1;
@@ -104,9 +104,6 @@ public class Config {
// Mail
public static boolean mailAlertEnabled = true;
public static String fakeUserLogin = "[Forestry]";
public static boolean fakeUserAutoop = true;
// Hints
public static boolean disableHints = false;
public static HashMap<String, String[]> hints = new HashMap<String, String[]>();
@@ -254,14 +251,6 @@ public class Config {
for (String str : disabledStructures)
Proxies.log.finer("Disabled structure '%s'.", str);
property = config.get("permissions.login", CATEGORY_COMMON, "[Forestry]");
property.Comment = "set the default login used by Forestry.";
Config.fakeUserLogin = property.Value;
property = config.get("permissions.autoop", CATEGORY_COMMON, true);
property.Comment = "set to false to prevent Forestry's user from autooping.";
Config.fakeUserAutoop = Boolean.parseBoolean(property.Value);
registerClimates();
ForestryTrigger.initialize();
@@ -0,0 +1,286 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.inventory.InvTools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.world.World;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public final class FluidHelper {
public static final int BUCKET_FILL_TIME = 8;
public static final int NETWORK_UPDATE_INTERVAL = 128;
public static final int BUCKET_VOLUME = 1000;
private FluidHelper() {
}
public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) {
if (player == null)
return false;
ItemStack current = player.inventory.getCurrentItem();
if (current != null) {
FluidStack liquid = getFluidStackInContainer(current);
if (fill && liquid != null) {
int used = tank.fill(side, liquid, true);
if (used > 0) {
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
}
return true;
}
} else if (drain) {
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = fillContainer(available, current);
liquid = getFluidStackInContainer(filled);
if (liquid != null) {
if (current.stackSize > 1) {
if (!player.inventory.addItemStackToInventory(filled))
return false;
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
player.inventory.markDirty();
}
tank.drain(side, liquid.amount, true);
return true;
}
}
}
}
return false;
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot) {
processContainers(tank, inv, inputSlot, outputSlot, tank.getFluidType(), true, true);
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
TankManager tankManger = new TankManager();
tankManger.add(tank);
processContainers(tankManger, inv, inputSlot, outputSlot, fluidToFill, processFilled, processEmpty);
}
public static void processContainers(TankManager tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
processContainers(tank, inv, inputSlot, outputSlot, fluidToFill, true, true);
}
public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
ItemStack input = inv.getStackInSlot(inputSlot);
if (input == null)
return;
if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot))
return;
if (processEmpty && fluidToFill != null)
fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill);
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
ItemStack filled = getFilledContainer(fluidToFill, input);
if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(filled, output)))) {
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (drain != null && drain.amount == fluidInContainer.amount) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
return false;
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
if (input != null) {
FluidStack fluidInContainer = getFluidStackInContainer(input);
ItemStack emptyItem = input.getItem().getContainerItem(input);
if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) {
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used >= fluidInContainer.amount) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null)
if (output == null)
inv.setInventorySlotContents(outputSlot, emptyItem);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
}
return false;
}
public static boolean isBucket(ItemStack stack) {
return FluidContainerRegistry.isBucket(stack);
}
public static boolean isContainer(ItemStack stack) {
if (stack != null && stack.getItem() instanceof IFluidContainerItem)
return true;
return FluidContainerRegistry.isContainer(stack);
}
public static boolean isFilledContainer(ItemStack stack) {
return FluidContainerRegistry.isFilledContainer(stack);
}
public static boolean isEmptyContainer(ItemStack stack) {
return FluidContainerRegistry.isEmptyContainer(stack);
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null || empty == null) return null;
return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty);
}
public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) {
if (fluid == null || empty == null) return null;
fluid = fluid.copy();
fluid.amount = Integer.MAX_VALUE;
return FluidContainerRegistry.fillFluidContainer(fluid, empty);
}
public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) {
if (liquid == null || empty == null) return null;
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static Fluid getFluidInContianer(ItemStack stack) {
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
return fluidStack != null ? fluidStack.getFluid() : null;
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1));
}
public static boolean isFluidEqual(FluidStack L1, FluidStack L2) {
if (L1 == null || L2 == null)
return false;
return L1.isFluidEqual(L2);
}
public static Collection<ItemStack> getContainersFilledWith(FluidStack fluidStack) {
List<ItemStack> containers = new ArrayList<ItemStack>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
FluidStack inContainer = getFluidStackInContainer(data.filledContainer);
if (inContainer != null && inContainer.containsFluid(fluidStack))
containers.add(data.filledContainer.copy());
}
return containers;
}
public static void nerfWaterBottle() {
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) {
data.fluid.amount = 333;
return;
}
}
}
public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) {
return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain);
}
public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) {
if (block instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock)block;
if (fluidBlock.canDrain(world, x, y, z))
return fluidBlock.drain(world, x, y, z, doDrain);
} else if (block == Blocks.water || block == Blocks.flowing_water) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
} else if (block == Blocks.lava || block == Blocks.flowing_lava) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME);
}
return null;
}
public static boolean isFullFluidBlock(World world, int x, int y, int z) {
return isFullFluidBlock(world.getBlock(x, y, z), world, x, y, z);
}
public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) {
if (block instanceof BlockLiquid || block instanceof IFluidBlock)
return world.getBlockMetadata(x, y, z) == 0;
return false;
}
public static Fluid getFluid(Block block) {
if (block instanceof IFluidBlock)
return ((IFluidBlock) block).getFluid();
else if (block == Blocks.water || block == Blocks.flowing_water)
return FluidRegistry.WATER;
else if (block == Blocks.lava || block == Blocks.flowing_lava)
return FluidRegistry.LAVA;
return null;
}
}
@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids;
import java.util.Locale;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public enum Fluids {
WATER, LAVA, FUEL, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, COAL, PYROTHEUM;
private final String tag;
private Fluids() {
tag = name().toLowerCase(Locale.ENGLISH);
}
public String getTag() {
return tag;
}
public Fluid get() {
return FluidRegistry.getFluid(tag);
}
/**
* Gets a FluidStack filled with qty milliBuckets worth of Fluid.
*
* @param qty
* @return
*/
public FluidStack get(int qty) {
return FluidRegistry.getFluidStack(tag, qty);
}
/**
* Gets a FluidStack filled with n buckets worth of Fluid.
*
* @param n
* @return
*/
public FluidStack getB(int n) {
return FluidRegistry.getFluidStack(tag, n * FluidContainerRegistry.BUCKET_VOLUME);
}
public boolean is(Fluid fluid) {
return get() == fluid;
}
public boolean is(FluidStack fluidStack) {
return fluidStack != null && get() == fluidStack.getFluid();
}
public boolean isContained(ItemStack containerStack) {
return containerStack != null && FluidHelper.containsFluid(containerStack, get());
}
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
if (fluidStack != null && fluid == fluidStack.getFluid())
return true;
return fluid == null && fluidStack == null;
}
}
@@ -0,0 +1,371 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids;
import com.google.common.collect.ForwardingList;
import forestry.core.fluids.tanks.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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class TankManager extends ForwardingList<StandardTank> implements IFluidHandler, List<StandardTank> {
public static final ITileFilter TANK_FILTER = new ITileFilter() {
@Override
public boolean matches(TileEntity tile) {
return tile instanceof IFluidHandler;
}
};
private static final byte NETWORK_DATA = 3;
private final List<StandardTank> tanks = new ArrayList<StandardTank>();
private final List<FluidStack> prevFluidStacks = new ArrayList<FluidStack>();
private final List<Integer> prevColor = new ArrayList<Integer>();
public TankManager() {
}
public TankManager(StandardTank... tanks) {
addAll(Arrays.asList(tanks));
}
@Override
protected List<StandardTank> delegate() {
return tanks;
}
@Override
public boolean addAll(Collection<? extends StandardTank> collection) {
boolean changed = false;
for (StandardTank tank : collection)
changed |= add(tank);
return changed;
}
@Override
public boolean add(StandardTank tank) {
boolean added = tanks.add(tank);
int index = tanks.indexOf(tank);
tank.setTankIndex(index);
prevFluidStacks.add(tank.getFluid() == null ? null : tank.getFluid().copy());
prevColor.add(tank.getColor());
return added;
}
public int maxMessageId() {
return NETWORK_DATA * tanks.size();
}
public void writeTanksToNBT(NBTTagCompound data) {
NBTTagList tagList = new NBTTagList();
for (byte slot = 0; slot < tanks.size(); slot++) {
StandardTank tank = tanks.get(slot);
if (tank.getFluid() != null) {
NBTTagCompound tag = new NBTTagCompound();
tag.setByte("tank", slot);
tank.writeToNBT(tag);
tagList.appendTag(tag);
}
}
data.setTag("tanks", tagList);
}
public void readTanksFromNBT(NBTTagCompound data) {
NBTList<NBTTagCompound> tagList = NBTUtil.getNBTList(data, "tanks", NBTUtil.EnumNBTType.COMPOUND);
for (NBTTagCompound tag : tagList) {
int slot = tag.getByte("tank");
if (slot >= 0 && slot < tanks.size())
tanks.get(slot).readFromNBT(tag);
}
}
public void writePacketData(DataOutputStream data) throws IOException {
for (int i = 0; i < tanks.size(); i++)
writePacketData(data, i);
}
public void writePacketData(DataOutputStream data, int tankIndex) throws IOException {
if (tankIndex >= tanks.size())
return;
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null) {
data.writeShort(fluidStack.fluidID);
data.writeInt(fluidStack.amount);
data.writeInt(fluidStack.getFluid().getColor(fluidStack));
} else
data.writeShort(-1);
}
public void readPacketData(DataInputStream data) throws IOException {
for (int i = 0; i < tanks.size(); i++)
readPacketData(data, i);
}
public void readPacketData(DataInputStream data, int tankIndex) throws IOException {
if (tankIndex >= tanks.size())
return;
StandardTank tank = tanks.get(tankIndex);
int fluidId = data.readShort();
if (fluidId != -1) {
tank.setFluid(new FluidStack(fluidId, data.readInt()));
tank.colorCache = data.readInt();
} else
tank.setFluid(null);
}
public void initGuiData(Container container, ICrafting player) {
for (StandardTank tank : tanks)
initGuiData(container, player, tank.getTankIndex());
}
public void initGuiData(Container container, ICrafting player, int tankIndex) {
if (tankIndex >= tanks.size())
return;
FluidStack fluidStack = tanks.get(tankIndex).getFluid();
int fluidId = -1;
int fluidAmount = 0;
if (fluidStack != null && fluidStack.amount > 0) {
fluidId = fluidStack.getFluid().getID();
fluidAmount = fluidStack.amount;
}
player.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
Proxies.net.sendToPlayer(packet, (EntityPlayerMP)player);
}
public void updateGuiData(Container container, List crafters) {
for (StandardTank tank : tanks)
updateGuiData(container, crafters, tank.getTankIndex());
}
public void updateGuiData(Container container, List crafters, int tankIndex) {
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
FluidStack prev = prevFluidStacks.get(tankIndex);
int color = tank.getColor();
int pColor = prevColor.get(tankIndex);
for (Object crafter1 : crafters) {
ICrafting crafter = (ICrafting) crafter1;
EntityPlayerMP player = (EntityPlayerMP) crafter1;
if (fluidStack == null ^ prev == null) {
int fluidId = -1;
int fluidAmount = 0;
if (fluidStack != null) {
fluidId = fluidStack.fluidID;
fluidAmount = fluidStack.amount;
}
crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidId);
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidAmount);
Proxies.net.sendToPlayer(packet, player);
} else if (fluidStack != null && prev != null) {
if (fluidStack.getFluid() != prev.getFluid())
crafter.sendProgressBarUpdate(container, tankIndex * NETWORK_DATA + 0, fluidStack.fluidID);
if (fluidStack.amount != prev.amount) {
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 1, fluidStack.amount);
Proxies.net.sendToPlayer(packet, player);
}
if (color != pColor) {
PacketGuiInteger packet = new PacketGuiInteger(container.windowId, tankIndex * NETWORK_DATA + 2, color);
Proxies.net.sendToPlayer(packet, player);
}
}
}
prevFluidStacks.set(tankIndex, tank.getFluid() == null ? null : tank.getFluid().copy());
prevColor.set(tankIndex, color);
}
public void processGuiUpdate(int messageId, int data) {
int tankIndex = messageId / NETWORK_DATA;
if (tankIndex >= tanks.size())
return;
StandardTank tank = tanks.get(tankIndex);
FluidStack fluidStack = tank.getFluid();
if (fluidStack == null) {
fluidStack = new FluidStack(-1, 0);
tank.setFluid(fluidStack);
}
int fluidId = fluidStack.fluidID;
int amount = fluidStack.amount;
int color = tank.colorCache;
boolean newLiquid = false;
switch (messageId % NETWORK_DATA) {
case 0:
fluidId = data;
newLiquid = true;
break;
case 1:
amount = data;
break;
case 2:
color = data;
break;
}
if (newLiquid) {
fluidStack = new FluidStack(fluidId, 0);
tank.setFluid(fluidStack);
}
fluidStack.amount = amount;
tank.colorCache = color;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
for (StandardTank tank : tanks)
if (tankAcceptsFluid(tank, resource))
return fill(tank.getTankIndex(), resource, doFill);
return FakeTank.INSTANCE.fill(resource, doFill);
}
public int fill(int tankIndex, FluidStack resource, boolean doFill) {
if (tankIndex < 0 || tankIndex >= tanks.size() || resource == null)
return 0;
StandardTank tank = tanks.get(tankIndex);
if (!tank.canBeFilledExternally())
return 0;
return tank.fill(resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
for (StandardTank tank : tanks)
if (tankCanDrain(tank))
return drain(tank.getTankIndex(), maxDrain, doDrain);
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
}
public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
if (tankIndex < 0 || tankIndex >= tanks.size())
return null;
StandardTank tank = tanks.get(tankIndex);
if (!tank.canBeDrainedExternally())
return null;
return tank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
for (StandardTank tank : tanks)
if (tankCanDrainFluid(tank, resource))
return tank.drain(resource.amount, doDrain);
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection direction) {
FluidTankInfo[] info = new FluidTankInfo[size()];
for (int i = 0; i < size(); i++)
info[i] = get(i).getInfo();
return info;
}
public FluidTankInfo[] getTankInfo() {
return getTankInfo(ForgeDirection.UNKNOWN);
}
public FluidTankInfo getTankInfo(int tankIndex) {
return get(tankIndex).getInfo();
}
public FluidStack getFluid(int tankIndex) {
return get(tankIndex).getFluid();
}
@Override
public StandardTank get(int tankIndex) {
return tanks.get(tankIndex);
}
public void setCapacity(int tankIndex, int capacity) {
StandardTank tank = get(tankIndex);
tank.setCapacity(capacity);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null && fluidStack.amount > capacity)
fluidStack.amount = capacity;
}
public static IFluidHandler getTankFromTile(TileEntity tile) {
IFluidHandler tank = null;
if (tile instanceof IFluidHandler)
tank = (IFluidHandler) tile;
return tank;
}
private boolean tankAcceptsFluid(StandardTank tank, FluidStack fluidStack) {
if (fluidStack == null)
return false;
if (!tank.canBeFilledExternally())
return false;
if (tank.fill(fluidStack, false) > 0)
return true;
return false;
}
private boolean tankCanDrain(StandardTank tank) {
if (!tank.canBeDrainedExternally())
return false;
FluidStack drained = tank.drain(1, false);
if (drained != null && drained.amount > 0)
return true;
return false;
}
private boolean tankCanDrainFluid(StandardTank tank, FluidStack fluidStack) {
return fluidStack != null && tankCanDrain(tank);
}
}
@@ -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.core.fluids.tanks;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public final class FakeTank extends StandardTank {
public static final FakeTank INSTANCE = new FakeTank();
public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE};
public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()};
private FakeTank() {
super(1);
}
@Override
public int fill(FluidStack resource, boolean doFill) {
return 0;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
return null;
}
}
@@ -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.core.fluids.tanks;
import forestry.core.gui.tooltips.ToolTipLine;
import net.minecraft.item.EnumRarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class FilteredTank extends StandardTank {
private HashSet<Fluid> filters;
public FilteredTank(int capacity, Fluid... filters) {
this(capacity, Arrays.asList(filters), null);
}
public FilteredTank(int capacity, Collection<Fluid> filters) {
this(capacity, filters, null);
}
public FilteredTank(int capacity, Collection<Fluid> filters, TileEntity tile) {
super(capacity, tile);
this.filters = new HashSet<Fluid>(filters);
}
public void addFilter(Fluid filter) {
if (!accepts(filter))
filters.add(filter);
}
@Override
public int fill(FluidStack resource, boolean doFill) {
if (liquidMatchesFilter(resource))
return super.fill(resource, doFill);
return 0;
}
@Override
public boolean accepts(Fluid fluid) {
return filters.contains(fluid);
}
public boolean liquidMatchesFilter(FluidStack resource) {
if (resource == null || filters == null)
return false;
return filters.contains(resource.getFluid());
}
@Override
protected void refreshTooltip() {
if (hasFluid()) {
super.refreshTooltip();
return;
}
toolTip.clear();
int amount = 0;
for (Fluid filter : filters) {
EnumRarity rarity = filter.getRarity();
if (rarity == null)
rarity = EnumRarity.common;
FluidStack filterFluidStack = FluidRegistry.getFluidStack(filter.getName(), 0);
ToolTipLine name = new ToolTipLine(filter.getLocalizedName(filterFluidStack), rarity.rarityColor);
name.setSpacing(2);
toolTip.add(name);
if (getFluid() != null)
amount = getFluid().amount;
}
toolTip.add(new ToolTipLine(String.format("%,d", amount) + " / " + String.format("%,d", getCapacity())));
}
}
@@ -0,0 +1,172 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.fluids.tanks;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.tooltips.ToolTipLine;
import java.util.Locale;
import net.minecraft.item.EnumRarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class StandardTank extends FluidTank {
// defines how the tank responds to IFluidHandler requests
public enum TankMode {
DEFAULT, OUTPUT, INPUT, INTERNAL
}
public TankMode tankMode = TankMode.DEFAULT;
public static final int DEFAULT_COLOR = 0xFFFFFF;
public int colorCache = DEFAULT_COLOR;
private int tankIndex;
public StandardTank(int capacity) {
super(capacity);
}
public StandardTank(FluidStack fluid, int capacity) {
this(capacity);
setFluid(fluid);
}
public StandardTank(int capacity, TileEntity tile) {
this(capacity);
this.tile = tile;
}
public StandardTank(FluidStack fluid, int capacity, TileEntity tile) {
this(capacity);
this.tile = tile;
setFluid(fluid);
}
public void setTankIndex(int index) {
this.tankIndex = index;
}
public int getTankIndex() {
return tankIndex;
}
@Override
public void setFluid(FluidStack fluid) {
super.setFluid(fluid);
colorCache = StandardTank.DEFAULT_COLOR;
}
public int getColor() {
Fluid f = getFluidType();
if (f == null)
return DEFAULT_COLOR;
return f.getColor(getFluid());
}
public boolean isEmpty() {
return getFluid() == null || getFluid().amount <= 0;
}
public boolean isFull() {
return getFluid() != null && getFluid().amount == getCapacity();
}
public int getRemainingSpace() {
return capacity - getFluidAmount();
}
public Fluid getFluidType() {
return getFluid() != null ? getFluid().getFluid() : null;
}
@Override
public int fill(final FluidStack resource, final boolean doFill) {
if (resource == null)
return 0;
if (resource.amount <= 0)
return 0;
if (!accepts(resource.getFluid()))
return 0;
return super.fill(resource, doFill);
}
public boolean accepts(Fluid fluid) {
return true;
}
public boolean canBeFilledExternally() {
switch (tankMode) {
case DEFAULT:
case INPUT:
return true;
}
return false;
}
public boolean canBeDrainedExternally() {
switch (tankMode) {
case DEFAULT:
case OUTPUT:
return true;
}
return false;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
if (maxDrain <= 0)
return null;
return super.drain(maxDrain, doDrain);
}
@Override
public String toString() {
return String.format("Tank: %s, %d/%d", fluid != null && fluid.getFluid() != null ? fluid.getFluid().getName() : "Empty", getFluidAmount(), getCapacity());
}
public ToolTip getToolTip() {
return toolTip;
}
protected boolean hasFluid() {
FluidStack fluid = getFluid();
return fluid != null && fluid.amount > 0 && fluid.getFluid() != null;
}
protected void refreshTooltip() {
toolTip.clear();
int amount = 0;
if (hasFluid()) {
Fluid fluidType = getFluidType();
EnumRarity rarity = fluidType.getRarity();
if (rarity == null)
rarity = EnumRarity.common;
ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(getFluid()), rarity.rarityColor);
fluidName.setSpacing(2);
toolTip.add(fluidName);
amount = getFluid().amount;
}
toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity())));
}
protected final ToolTip toolTip = new ToolTip() {
@Override
public void refresh() {
refreshTooltip();
}
};
}
@@ -242,7 +242,7 @@ public class BlockBase extends BlockForestry {
@Override
public IIcon getIcon(int side, int metadata) {
if (metadata >= definitions.size() || definitions.get(metadata) == null)
metadata = 0;
return null;
return definitions.get(metadata).getBlockTextureFromSideAndMetadata(side, metadata);
}
@@ -101,8 +101,10 @@ public class BlockResource extends Block {
return iconApatite;
else if (j == 1)
return iconCopper;
else
else if (j == 2)
return iconTin;
else
return null;
}
}
@@ -14,6 +14,7 @@ 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;
@@ -45,9 +46,13 @@ import forestry.core.render.TextureManager;
* @author
*
*/
public class BlockSoil extends Block {
public class BlockSoil extends Block implements IItemTyped {
private final int degradeDelimiter = 3;
public enum SoilType {
HUMUS, BOG_EARTH, PEAT;
}
private static final int degradeDelimiter = 3;
public BlockSoil() {
super(Material.sand);
@@ -66,16 +71,15 @@ public class BlockSoil extends Block {
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int type = (metadata & 0x03);
int maturity = metadata >> 2;
SoilType type = getTypeFromMeta(metadata);
if (maturity >= this.degradeDelimiter && type == 1) {
if (type == SoilType.PEAT) {
ret.add(ForestryItem.peat.getItemStack());
ret.add(new ItemStack(Blocks.dirt));
} else if (type == 0)
} else if (type == SoilType.HUMUS)
ret.add(new ItemStack(Blocks.dirt));
else
ret.add(new ItemStack(this, 1, type));
ret.add(new ItemStack(this, 1, SoilType.BOG_EARTH.ordinal()));
return ret;
}
@@ -91,14 +95,13 @@ public class BlockSoil extends Block {
return;
int meta = world.getBlockMetadata(i, j, k);
int type = (meta & 0x03);
if (type == 0)
SoilType type = getTypeFromMeta(meta);
if (type == SoilType.HUMUS)
updateTickHumus(world, i, j, k, random);
else if (type == 1)
else if (type == SoilType.BOG_EARTH)
updateTickBogEarth(world, i, j, k, random);
else
Proxies.log.warning(this.getClass() + " with unknown type " + type + " encountered.");
}
private void updateTickHumus(World world, int i, int j, int k, Random random) {
@@ -155,17 +158,17 @@ public class BlockSoil extends Block {
int type = meta & 0x03;
int grade = meta >> 2;
// Increment (de)gradation
grade++;
// Increment (de)gradation
grade++;
// Repackage in format TTGG
meta = (grade << 2 | type);
// Repackage in format TTGG
meta = (grade << 2 | type);
if (grade >= this.degradeDelimiter)
world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
world.markBlockForUpdate(i, j, k);
if (grade >= this.degradeDelimiter)
world.setBlock(i, j, k, Blocks.sand, 0, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
world.markBlockForUpdate(i, j, k);
}
public static boolean isMoistened(World world, int x, int y, int z) {
@@ -192,15 +195,15 @@ public class BlockSoil extends Block {
int type = meta & 0x03;
int maturity = meta >> 2;
if (maturity >= this.degradeDelimiter)
return;
if (maturity >= this.degradeDelimiter)
return;
// Increment (de)gradation
maturity++;
// Increment (de)gradation
maturity++;
meta = (maturity << 2 | type);
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
world.markBlockForUpdate(i, j, k);
meta = (maturity << 2 | type);
world.setBlockMetadataWithNotify(i, j, k, meta, Defaults.FLAG_BLOCK_SYNCH);
world.markBlockForUpdate(i, j, k);
}
@Override
@@ -210,8 +213,9 @@ public class BlockSoil extends Block {
return false;
int meta = world.getBlockMetadata(x, y, z);
SoilType type = getTypeFromMeta(meta);
return (meta & 0x03) == 0;
return type == SoilType.HUMUS;
}
@Override
@@ -219,6 +223,19 @@ public class BlockSoil extends Block {
return false;
}
public SoilType getTypeFromMeta(int meta) {
int type = meta & 0x03;
int maturity = meta >> 2;
if (type == 1)
if (maturity < degradeDelimiter)
return SoilType.BOG_EARTH;
else
return SoilType.PEAT;
else
return SoilType.HUMUS;
}
// / CREATIVE INVENTORY
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@@ -245,19 +262,16 @@ public class BlockSoil extends Block {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
public IIcon getIcon(int side, int meta) {
int meta = j;
int type = meta & 0x03;
int maturity = meta >> 2;
SoilType type = getTypeFromMeta(meta);
if (type == 1)
if (maturity < this.degradeDelimiter)
return iconBogEarth;
else
return iconPeat;
else
return iconHumus;
switch (type) {
case HUMUS: return iconHumus;
case BOG_EARTH: return iconBogEarth;
case PEAT: return iconPeat;
}
return null;
}
}
@@ -19,7 +19,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import buildcraft.api.core.Position;
import buildcraft.api.power.IPowerEmitter;
@@ -35,7 +34,6 @@ import forestry.core.interfaces.IPowerHandler;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ForestryTank;
import forestry.plugins.PluginBuildCraft;
public abstract class Engine extends TileBase implements IPowerHandler, IPipeConnection, IPowerEmitter {
@@ -52,7 +50,6 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
payload.intPayload[2] = heat;
payload.floatPayload[0] = pistonSpeedServer;
return payload;
}
@@ -96,20 +93,7 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
powerProvider.configure(10, 200, 10, 100000);
}
protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, ForestryTank tank) {
if (container == null)
return inventoryStack;
if (tank.fill(container.fluid, false) >= container.fluid.amount) {
tank.fill(container.fluid, true);
if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer))
inventoryStack = container.emptyContainer.copy();
else
inventoryStack.stackSize--;
}
return inventoryStack;
}
@Override
public void rotateAfterPlacement(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
@@ -22,15 +22,18 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.Packet;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.core.EnumErrorCode;
import forestry.core.fluids.TankManager;
import forestry.core.config.Defaults;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
@@ -38,11 +41,10 @@ import forestry.core.network.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.proxy.Proxies;
import forestry.core.utils.ForestryTank;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
@@ -65,18 +67,22 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
private final short inputSlot1 = 2;
private final short outputSlot1 = 8;
public FluidStack resource = FluidRegistry.getFluidStack(Defaults.LIQUID_HONEY, HONEY_REQUIRED);
@EntityNetData
public ForestryTank resourceTank = new ForestryTank(Defaults.PROCESSOR_TANK_CAPACITY);
public FilteredTank resourceTank;
private final TankManager tankManager;
private final Stack<ItemStack> pendingProducts = new Stack<ItemStack>();
/* CONSTRUCTOR */
public TileAnalyzer() {
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.getFluid(Defaults.LIQUID_HONEY));
tankManager = new TankManager(resourceTank);
}
@Override
public String getInventoryName() {
return StringUtil.localize("core.0");
return getUnlocalizedName();
}
/* GUI */
@@ -92,8 +98,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
nbttagcompound.setInteger("AnalyzeTime", analyzeTime);
// / Resource tank
resourceTank.writeToNBT(nbttagcompound);
tankManager.writeTanksToNBT(nbttagcompound);
// / Pending Products
NBTTagList nbttaglist = new NBTTagList();
@@ -117,8 +122,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
analyzeTime = nbttagcompound.getInteger("AnalyzeTime");
// / Resource tank
resourceTank.readFromNBT(nbttagcompound);
tankManager.readTanksFromNBT(nbttagcompound);
// / Pending Products
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10);
@@ -146,7 +150,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
// Check if we have suitable items waiting in the can slot
if (getStackInSlot(canSlot) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(getStackInSlot(canSlot));
if (container != null && resource.isFluidEqual(container.fluid)) {
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
setInventorySlotContents(canSlot, StackUtils.replenishByContainer(this, getStackInSlot(canSlot), container, resourceTank));
if (getStackInSlot(canSlot).stackSize <= 0)
@@ -187,7 +191,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
return;
// We need our liquid honey
if (resourceTank.getFluidAmount() < resource.amount) {
if (resourceTank.getFluidAmount() < HONEY_REQUIRED) {
setErrorState(EnumErrorCode.NORESOURCE);
return;
}
@@ -208,7 +212,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
setInventorySlotContents(analyzeSlot, getStackInSlot(i));
setInventorySlotContents(i, null);
resourceTank.drain(resource.amount, true);
resourceTank.drain(HONEY_REQUIRED, true);
analyzeTime = TIME_TO_ANALYZE;
sendNetworkUpdate();
return;
@@ -251,6 +255,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
/* SMP */
public void getGUINetworkData(int i, int j) {
i -= tankManager.maxMessageId() + 1;
switch (i) {
case 0:
analyzeTime = j;
@@ -259,7 +264,8 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
}
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
iCrafting.sendProgressBarUpdate(container, 0, analyzeTime);
int i = tankManager.maxMessageId() + 1;
iCrafting.sendProgressBarUpdate(container, i, analyzeTime);
}
@@ -388,7 +394,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
if (!AlleleManager.alleleRegistry.isIndividual(stack)) {
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
if (container == null || !container.fluid.isFluidEqual(resource))
if (container == null || !resourceTank.accepts(container.fluid.getFluid()))
return 0;
if (getStackInSlot(canSlot) == null) {
@@ -423,33 +429,39 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
}
/* ILIQUIDCONTAINER */
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
// We only accept what is already in the tank or valid ingredients
if (resourceTank.getFluidAmount() > 0 && !resourceTank.getFluid().isFluidEqual(resource))
return 0;
else if (!LiquidHelper.isLiquid(Defaults.LIQUID_HONEY, resource))
return 0;
int used = resourceTank.fill(resource, doFill);
if (doFill && used > 0)
sendNetworkUpdate();
return used;
return tankManager.fill(from, resource, doFill);
}
@Override
public ForestryTank[] getTanks() {
return new ForestryTank[] { resourceTank };
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
/*
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) {
return resourceTank;
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return tankManager.getTankInfo(from);
}
*/
}
@@ -21,11 +21,6 @@ import forestry.core.utils.Utils;
public abstract class TileBase extends TileForestry implements IHintSource {
@Override
public String getInventoryName() {
return null;
}
@Override
public boolean isOwnable() {
return true;
@@ -47,7 +47,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
private final InventoryAdapter inventory;
@Override
public String getInventoryName() {
return StringUtil.localize("core.1");
return getUnlocalizedName();
}
public TileEscritoire() {
@@ -33,6 +33,7 @@ import com.mojang.authlib.GameProfile;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.tanks.FakeTank;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.interfaces.IOwnable;
@@ -43,7 +44,7 @@ import forestry.core.network.PacketPayload;
import forestry.core.network.PacketTileUpdate;
import forestry.core.proxy.Proxies;
import forestry.core.utils.EnumAccess;
import forestry.core.utils.ForestryTank;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.Vect;
@@ -263,13 +264,6 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
return owner;
}
public EntityPlayer getOwnerEntity() {
if (owner != null)
return worldObj.func_152378_a(owner.getId());
else
return null;
}
@Override
public void setOwner(EntityPlayer player) {
this.owner = player.getGameProfile();
@@ -297,7 +291,14 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
}
/* NAME */
public abstract String getInventoryName();
/**
* Gets the tile's unlocalized name, based on the block at the location of this entity (client-only).
*/
public String getUnlocalizedName() {
String blockUnlocalizedName = getBlockType().getUnlocalizedName().replace("tile.for.","");
return blockUnlocalizedName + "." + getBlockMetadata() + ".name";
}
public boolean hasCustomInventoryName() {
return true;
@@ -344,37 +345,4 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
return getInternalInventory().getSizeInventorySide(side);
}
/* IFLUIDHANDLER BASICS */
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
if (this instanceof ILiquidTankContainer) {
ForestryTank[] tanks = ((ILiquidTankContainer) this).getTanks();
FluidTankInfo[] info = new FluidTankInfo[tanks.length];
for (int i = 0; i < info.length; i++) {
info[i] = tanks[i].getInfo();
}
return info;
}
return ForestryTank.DUMMY_TANKINFO_ARRAY;
}
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return 0;
}
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
}
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return resource != null ? drain(from, resource.amount, doDrain) : null;
}
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
}
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
}
@@ -42,7 +42,7 @@ import forestry.plugins.PluginEnergy;
import forestry.plugins.PluginFactory;
import forestry.plugins.PluginMail;
public class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource {
public abstract class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource {
public TileMachine() {
}
@@ -301,7 +301,7 @@ public class TileMachine extends TileForestry implements ISpecialInventory, ICli
@Override
public String getInventoryName() {
return "[Unknown]";
return getUnlocalizedName();
}
@Override
@@ -37,7 +37,7 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory
@Override
public String getInventoryName() {
return StringUtil.localize("tile.mill.3");
return getUnlocalizedName();
}
@Override
@@ -29,7 +29,7 @@ import forestry.core.network.IndexInPayload;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.ForestryTank;
import forestry.core.fluids.tanks.StandardTank;
public abstract class TilePowered extends TileBase implements IPowerHandler, IRenderableMachine {
@@ -179,7 +179,7 @@ public abstract class TilePowered extends TileBase implements IPowerHandler, IRe
} */
/* LIQUID CONTAINER HANDLING */
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, ForestryTank tank) {
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) {
if (tank.getFluidAmount() < container.fluid.amount)
return outputStack;
if (canStack.stackSize <= 0)
@@ -0,0 +1,83 @@
package forestry.core.gui;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.proxy.Proxies;
import forestry.core.utils.AlyzerInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class ContainerAlyzer extends ContainerItemInventory {
private AlyzerInventory inventory;
protected ContainerAlyzer(InventoryPlayer inventoryplayer, AlyzerInventory inventory, Object[] acceptedEnergy, Object[] acceptedSpecimens) {
super(inventory, inventoryplayer.player);
this.inventory = inventory;
final int xPosLeftSlots = 223;
// Energy
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ENERGY, xPosLeftSlots, 8, acceptedEnergy));
// Bee to analyze
this.addSlot(new SlotCustom(inventory, inventory.SLOT_SPECIMEN, xPosLeftSlots, 26, acceptedSpecimens));
// Analyzed bee
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_1, xPosLeftSlots, 57, acceptedSpecimens));
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_2, xPosLeftSlots, 75, acceptedSpecimens));
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_3, xPosLeftSlots, 93, acceptedSpecimens));
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_4, xPosLeftSlots, 111, acceptedSpecimens));
this.addSlot(new SlotCustom(inventory, inventory.SLOT_ANALYZE_5, xPosLeftSlots, 129, acceptedSpecimens));
final int xPosPlayerInv = 43;
final int xSpacePlayerInv = 18;
final int yPosPlayerInv= 156;
final int ySpacePlayerInv = 18;
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
int slot = l1 + i1 * 9 + 9;
int x = xPosPlayerInv + (l1 * xSpacePlayerInv);
int y = yPosPlayerInv + (i1 * ySpacePlayerInv);
addSecuredSlot(inventoryplayer, slot, x, y);
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
int x = xPosPlayerInv + (j1 * xSpacePlayerInv);
addSecuredSlot(inventoryplayer, j1, x, 214);
}
}
@Override
public void onContainerClosed(EntityPlayer entityplayer) {
if (!Proxies.common.isSimulating(entityplayer.worldObj))
return;
// Last slot is the energy slot, so we don't save that one.
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (i == inventory.SLOT_ENERGY)
continue;
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
continue;
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
}
inventory.onGuiSaved(entityplayer);
}
@Override
protected boolean isAcceptedItem(EntityPlayer player, ItemStack stack) {
return true;
}
}
@@ -54,17 +54,4 @@ public class ContainerAnalyzer extends ContainerLiquidTanks {
}
@Override
public void updateProgressBar(int i, int j) {
tile.getGUINetworkData(i, j);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++)
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
}
}
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.core.gui;
import forestry.core.fluids.tanks.FakeTank;
import forestry.core.fluids.tanks.StandardTank;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -19,8 +21,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.core.gui.slots.SlotForestry;
import forestry.core.utils.ForestryTank;
import forestry.core.utils.StackUtils;
import net.minecraftforge.fluids.IFluidTank;
public class ContainerForestry extends Container {
@@ -204,11 +206,4 @@ public class ContainerForestry extends Container {
public boolean canInteractWith(EntityPlayer entityplayer) {
return inventory.isUseableByPlayer(entityplayer);
}
public void onTankUpdate(NBTTagCompound nbt) {
}
public ForestryTank getTank(int slot) {
return ForestryTank.FAKETANK;
}
}
@@ -10,35 +10,29 @@
******************************************************************************/
package forestry.core.gui;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import forestry.api.core.IToolPipette;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketPayload;
import forestry.core.network.PacketTankUpdate;
import forestry.core.network.PacketUpdate;
import forestry.core.proxy.Proxies;
import forestry.core.utils.ForestryTank;
public class ContainerLiquidTanks extends ContainerForestry {
private ILiquidTankContainer tanks;
private ILiquidTankContainer tile;
public ContainerLiquidTanks(IInventory inventory, ILiquidTankContainer tanks) {
public ContainerLiquidTanks(IInventory inventory, ILiquidTankContainer tile) {
super(inventory);
this.tanks = tanks;
this.tile = tile;
}
public void handlePipetteClick(int slot, EntityPlayer player) {
@@ -52,74 +46,52 @@ public class ContainerLiquidTanks extends ContainerForestry {
return;
if (!Proxies.common.isSimulating(player.worldObj)) {
PacketPayload payload = new PacketPayload(1, 0, 0);
payload.intPayload[0] = slot;
Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload));
return;
}
IToolPipette pipette = (IToolPipette) held;
int liquidAmount = tanks.getTanks()[slot].getFluid().amount;
StandardTank tank = tile.getTankManager().get(slot);
int liquidAmount = tank.getFluid().amount;
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
if (liquidAmount > 0) {
int filled = pipette.fill(itemstack, tanks.getTanks()[slot].drain(1000, false),
true);
tanks.getTanks()[slot].drain(filled, true);
FluidStack fillAmount = tank.drain(1000, false);
int filled = pipette.fill(itemstack, fillAmount, true);
tank.drain(filled, true);
}
} else {
IFluidTank tank = tanks.getTanks()[slot];
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
if (potential != null)
pipette.drain(itemstack, tank.fill(potential, true), true);
}
}
private Map<Integer, ForestryTank> syncedFluids = new HashMap<Integer, ForestryTank>();
@Override
public void updateProgressBar(int messageId, int data) {
super.updateProgressBar(messageId, data);
tile.getTankManager().processGuiUpdate(messageId, data);
tile.getGUINetworkData(messageId, data);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < tanks.getTanks().length; i++) {
ForestryTank tank = tanks.getTanks()[i];
// If null has been synced
if (tank.getFluid() == null && getTank(i).getFluidAmount() <= 0)
continue;
// If fluid has been synced
if (tank.getFluid() != null && tank.getFluid().isFluidStackIdentical(getTank(i).getFluid()))
continue;
for (int j = 0; j < this.crafters.size(); ++j) {
if (this.crafters.get(j) instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) this.crafters.get(j);
Proxies.net.sendToPlayer(new PacketTankUpdate(i, tank), player);
}
}
syncedFluids.put(i, new ForestryTank(tank.getFluid() == null ? null : tank.getFluid().copy(), tank.getCapacity()));
}
tile.getTankManager().updateGuiData(this, crafters);
for (int i = 0; i < crafters.size(); i++)
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
}
@Override
public void onTankUpdate(NBTTagCompound nbt) {
int tankID = nbt.getByte("tank");
int capacity = nbt.getShort("capacity");
tanks.getTanks()[tankID].readFromNBT(nbt);
ForestryTank tank = new ForestryTank(capacity);
tank.readFromNBT(nbt);
syncedFluids.put(tankID, tank);
public void addCraftingToCrafters(ICrafting icrafting) {
super.addCraftingToCrafters(icrafting);
tile.getTankManager().initGuiData(this, icrafting);
}
@Override
public ForestryTank getTank(int slot) {
return syncedFluids.get(slot) == null ? ForestryTank.FAKETANK : syncedFluids.get(slot);
public StandardTank getTank(int slot) {
return tile.getTankManager().get(slot);
}
}
+114 -98
View File
@@ -21,6 +21,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.opengl.GL11;
import forestry.api.apiculture.EnumBeeChromosome;
@@ -43,17 +44,22 @@ import forestry.core.utils.StringUtil;
public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
protected static final int COLUMN_0 = 12;
protected static final int COLUMN_1 = 52;
protected static final int COLUMN_2 = 108;
protected static final int COLUMN_1 = 85;
protected static final int COLUMN_2 = 150;
protected IInventory inventory;
protected ISpeciesRoot speciesRoot;
protected IBreedingTracker breedingTracker;
protected String guiName;
protected HashMap<String, ItemStack> iconStacks = new HashMap<String, ItemStack>();
public GuiAlyzer(ISpeciesRoot speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, int pageMax, int pageSize) {
super(Defaults.TEXTURE_PATH_GUI + "/beealyzer.png", container);
super(Defaults.TEXTURE_PATH_GUI + "/beealyzer2.png", container);
xSize = 246;
ySize = 238;
this.inventory = inventory;
this.speciesRoot = speciesRoot;
@@ -94,8 +100,8 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
int columnwidth = column2 - column1 - 16;
RenderHelper.enableStandardItemLighting();
drawItemStack(iconStacks.get(primary.getUID()), adjustToFactor(guiLeft + column1 + columnwidth + 2), adjustToFactor(guiTop + getLineY()));
drawItemStack(iconStacks.get(secondary.getUID()), adjustToFactor(guiLeft + column2 + columnwidth + 4), adjustToFactor(guiTop + getLineY()));
drawItemStack(iconStacks.get(primary.getUID()), adjustToFactor(guiLeft + column1 + columnwidth - 4), adjustToFactor(guiTop + getLineY()));
drawItemStack(iconStacks.get(secondary.getUID()), adjustToFactor(guiLeft + column2 + columnwidth - 2), adjustToFactor(guiTop + getLineY()));
RenderHelper.disableStandardItemLighting();
String primaryName;
@@ -124,6 +130,50 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
widgetManager.clear();
}
protected void drawAnalyticsOverview() {
startPage();
newLine();
String title = StringUtil.localize(guiName).toUpperCase();
drawCenteredLine(title, 8, 208);
newLine();
fontRendererObj.drawSplitString(StringUtil.localize(guiName + ".help"), (int) ((guiLeft + COLUMN_0 + 4) * (1 / factor)),
(int) ((guiTop + 42) * (1 / factor)), (int) (195 * (1 / factor)), fontColor.get("gui.screen"));
newLine();
newLine();
newLine();
newLine();
drawLine(StringUtil.localize("gui.alyzer.overview") + ":", COLUMN_0 + 4);
newLine();
drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4);
newLine();
drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4);
newLine();
drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4);
newLine();
drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4);
newLine();
String mode = breedingTracker.getModeName();
if (mode != null && !mode.isEmpty()) {
newLine();
String rules = StringUtil.localize(guiName + ".behaviour") + ": " + StringUtil.capitalize(mode);
drawCenteredLine(rules, 8, 208, fontColor.get(guiName + ".binomial"));
}
endPage();
}
protected final void drawAnalyticsPageClassification(IIndividual individual) {
startPage();
@@ -151,9 +201,9 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
continue;
drawLine(group.getScientific(), x, group.getLevel().getColour());
drawLine(group.getLevel().name(), 130, group.getLevel().getColour());
drawLine(group.getLevel().name(), 155, group.getLevel().getColour());
newLine();
x += 8;
x += 10;
}
// Add the species name
@@ -162,26 +212,26 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH);
drawLine(binomial, x, 0xebae85);
drawLine("SPECIES", 130, 0xebae85);
drawLine("SPECIES", 155, 0xebae85);
newLine();
newLine();
drawLine(StringUtil.localize("gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12);
if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) {
String extinct = ">> " + StringUtil.localize("gui.alyzer.extinct").toUpperCase() + " <<";
fontRendererObj.drawStringWithShadow(extinct, adjustToFactor(guiLeft + 160) - fontRendererObj.getStringWidth(extinct),
fontRendererObj.drawStringWithShadow(extinct, adjustToFactor(guiLeft + 208) - fontRendererObj.getStringWidth(extinct),
adjustToFactor(guiTop + getLineY()), fontColor.get("gui.beealyzer.dominant"));
}
newLine();
String description = individual.getGenome().getPrimary().getDescription();
if (description == null || description.isEmpty())
drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 156, 0x666666);
if (StringUtils.isBlank(description) || description.startsWith("for.description."))
drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 208, 0x666666);
else {
String tokens[] = description.split("\\|");
drawSplitLine(tokens[0], 12, 152, 0x666666);
drawSplitLine(tokens[0], 12, 208, 0x666666);
if (tokens.length > 1)
fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 160) - fontRendererObj.getStringWidth("- " + tokens[1]),
fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 208) - fontRendererObj.getStringWidth("- " + tokens[1]),
adjustToFactor(guiTop + 145 - 14), 0x99cc32);
}
@@ -191,10 +241,12 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
protected void drawAnalyticsPage4(IIndividual individual) {
float factor = this.factor;
this.setFactor(1.0f);
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
drawLine(StringUtil.localize("gui.beealyzer.mutations") + ":", COLUMN_0);
newLine();
newLine();
RenderHelper.enableGUIStandardItemLighting();
@@ -222,7 +274,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
}
x += columnWidth;
if (x > 150) {
if (x >= columnWidth * 4) {
x = 0;
newLine();
newLine();
@@ -230,100 +282,64 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
}
endPage();
this.setFactor(factor);
}
protected void drawMutationInfo(IMutation combination, IAllele species, int x) {
drawItemStack(iconStacks.get(combination.getPartner(species).getUID()),
adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY());
/*
itemRenderer.renderItemIntoGUI(fontRendererObj, mc.renderEngine, iconStacks.get(combination.getPartner(species).getUID()), adjustToFactor(guiLeft) + x,
adjustToFactor(guiTop) + getLineY());
itemRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, iconStacks.get(combination.getPartner(species).getUID()), adjustToFactor(guiLeft)
+ x, adjustToFactor(guiTop) + getLineY());
*/
ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID());
widgetManager.add(new ItemStackWidget(x, getLineY(), partnerBee));
drawProbabilityArrow(combination.getBaseChance(), adjustToFactor(guiLeft) + x + 18, adjustToFactor(guiTop) + getLineY() + 4);
IAllele result = combination.getTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
drawItemStack(iconStacks.get(result.getUID()),
adjustToFactor(guiLeft) + x + 33, adjustToFactor(guiTop) + getLineY());
/*
itemRenderer.renderItemIntoGUI(fontRendererObj, mc.renderEngine, iconStacks.get(result.getUID()), adjustToFactor(guiLeft) + x + 33, adjustToFactor(guiTop)
+ getLineY());
itemRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, iconStacks.get(result.getUID()), adjustToFactor(guiLeft) + x + 33,
adjustToFactor(guiTop) + getLineY());
*/
int line = 0;
int column = 196;
switch (EnumMutateChance.rateChance(combination.getBaseChance())) {
case HIGHEST:
column = 226;
line = 9;
break;
case HIGHER:
column = 211;
line = 9;
break;
case HIGH:
line = 9;
break;
case NORMAL:
column = 226;
break;
case LOW:
column = 211;
break;
case LOWEST:
default:
break;
}
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 18, adjustToFactor(guiTop) + getLineY() + 4, column, line, 15, 9);
ItemStack resultBee = iconStacks.get(result.getUID());
widgetManager.add(new ItemStackWidget(x + 33, getLineY(), resultBee));
}
protected void drawUnknownMutation(IMutation combination, IAllele species, int x) {
// Question marks
drawQuestionMark(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY());
drawProbabilityArrow(combination.getBaseChance(), adjustToFactor(guiLeft) + x + 18, adjustToFactor(guiTop) + getLineY() + 4);
drawQuestionMark(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY());
}
protected void drawQuestionMark(int x, int y) {
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
drawTexturedModalRect(x, y, 78, 240, 16, 16);
}
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
int line = 0;
int column = 196;
switch (EnumMutateChance.rateChance(combination.getBaseChance())) {
case HIGHEST:
column = 226;
line = 9;
break;
case HIGHER:
column = 211;
line = 9;
break;
case HIGH:
line = 9;
break;
case NORMAL:
column = 226;
break;
case LOW:
column = 211;
break;
case LOWEST:
default:
break;
protected void drawProbabilityArrow(float chance, int x, int y) {
int line = 247;
int column = 100;
switch (EnumMutateChance.rateChance(chance)) {
case HIGHEST:
column = 100;
break;
case HIGHER:
column = 100 + 15;
break;
case HIGH:
column = 100 + 15 * 2;
break;
case NORMAL:
column = 100 + 15 * 3;
break;
case LOW:
column = 100 + 15 * 4;
break;
case LOWEST:
column = 100 + 15 * 5;
default:
break;
}
// Probability arrow
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 18, adjustToFactor(guiTop) + getLineY() + 4, column, line, 15, 9);
drawTexturedModalRect(x, y, column, line, 15, 9);
}
protected void drawToleranceInfo(EnumTolerance tolerance, int x, int textColor) {
@@ -367,22 +383,22 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
private void drawDownSymbol(int x, int y) {
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 196, 34, 15, 9);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 0, 247, 15, 9);
}
private void drawUpSymbol(int x, int y) {
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 211, 34, 15, 9);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 15, 247, 15, 9);
}
private void drawBothSymbol(int x, int y) {
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 226, 34, 15, 9);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 30, 247, 15, 9);
}
private void drawNoneSymbol(int x, int y) {
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 241, 34, 15, 9);
drawTexturedModalRect((int) ((guiLeft + x) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 45, 247, 15, 9);
}
protected void drawFertilityInfo(int fertility, int x, int textColor, int texOffset) {
@@ -390,7 +406,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect((int) ((guiLeft + x + 19) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 196, 43 + texOffset, 12, 9);
drawTexturedModalRect((int) ((guiLeft + x + 14) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 60, 240 + texOffset, 12, 8);
drawLine(Integer.toString(fertility) + " x", x, textColor);
}
@@ -16,10 +16,9 @@ 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.StringUtil;
import forestry.core.utils.Utils;
public class GuiAnalyzer extends GuiForestry<TileAnalyzer> {
public class GuiAnalyzer extends GuiForestryTitled<TileAnalyzer> {
public GuiAnalyzer(InventoryPlayer inventory, TileAnalyzer tile) {
super(Defaults.TEXTURE_PATH_GUI + "/alyzer.png", new ContainerAnalyzer(inventory, tile), tile);
@@ -27,13 +26,6 @@ public class GuiAnalyzer extends GuiForestry<TileAnalyzer> {
widgetManager.add(new TankWidget(this.widgetManager, 95, 24, 0));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String title = StringUtil.localize("tile.for." + tile.getInventoryName());
this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title"));
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
@@ -10,9 +10,14 @@
******************************************************************************/
package forestry.core.gui;
import java.awt.Color;
import java.util.Collection;
import java.util.List;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -35,6 +40,7 @@ import forestry.core.gui.slots.SlotForestry;
import forestry.core.gui.tooltips.IToolTipProvider;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.tooltips.ToolTipLine;
import forestry.core.gui.widgets.Widget;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
@@ -43,7 +49,7 @@ import forestry.core.interfaces.IPowerHandler;
import forestry.core.proxy.Proxies;
import forestry.core.utils.FontColour;
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer implements INEIGuiHandler {
/* WIDGETS */
protected WidgetManager widgetManager;
@@ -53,10 +59,6 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
public ResourceLocation textureFile;
protected FontColour fontColor;
public GuiForestry(ContainerForestry container) {
this("", container);
}
public GuiForestry(String texture, ContainerForestry container) {
this(new ResourceLocation("forestry", texture), container, null);
}
@@ -323,38 +325,40 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
int left = this.guiLeft;
int top = this.guiTop;
int lenght = 0;
int length = 0;
int height = 0;
int x;
int y;
for (ToolTipLine tip : toolTips) {
y = this.fontRendererObj.getStringWidth(tip.text);
if (y > lenght)
lenght = y;
height += 10 + tip.getSpacing();
if (y > length)
length = y;
}
x = mouseX - left + 12;
y = mouseY - top - 12;
int var14 = 8;
if (toolTips.size() > 1)
var14 += 2 + (toolTips.size() - 1) * 10;
this.zLevel = 300.0F;
itemRender.zLevel = 300.0F;
int var15 = -267386864;
this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15);
this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x - 4, y - 3, x - 3, y + var14 + 3, var15, var15);
this.drawGradientRect(x + lenght + 3, y - 3, x + lenght + 4, y + var14 + 3, var15, var15);
int var16 = 1347420415;
int var17 = (var16 & 16711422) >> 1 | var16 & -16777216;
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x + lenght + 2, y - 3 + 1, x + lenght + 3, y + var14 + 3 - 1, var16, var17);
this.drawGradientRect(x - 3, y - 3, x + lenght + 3, y - 3 + 1, var16, var16);
this.drawGradientRect(x - 3, y + var14 + 2, x + lenght + 3, y + var14 + 3, var17, var17);
Color backgroundColor = new Color(16, 0, 16, 240);
int backgroundColorInt = backgroundColor.getRGB();
this.drawGradientRect(x - 3, y - 4, x + length + 2, y - 3, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 3, y + height + 1, x + length + 2, y + height + 2, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 3, y - 3, x + length + 2, y + height + 1, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x - 4, y - 3, x - 3, y + height + 1, backgroundColorInt, backgroundColorInt);
this.drawGradientRect(x + length + 2, y - 3, x + length + 3, y + height + 1, backgroundColorInt, backgroundColorInt);
Color borderColorTop = new Color(80, 0, 255, 80);
int borderColorTopInt = borderColorTop.getRGB();
Color borderColorBottom = new Color((borderColorTopInt & 0xfefefe) >> 1 | borderColorTopInt & -0x1000000, true);
int borderColorBottomInt = borderColorBottom.getRGB();
this.drawGradientRect(x - 3, y - 3 + 1, x - 3 + 1, y + height, borderColorTopInt, borderColorBottomInt);
this.drawGradientRect(x + length + 1, y - 3 + 1, x + length + 2, y + height, borderColorTopInt, borderColorBottomInt);
this.drawGradientRect(x - 3, y - 3, x + length + 2, y - 3 + 1, borderColorTopInt, borderColorTopInt);
this.drawGradientRect(x - 3, y + height, x + length + 2, y + height + 1, borderColorBottomInt, borderColorBottomInt);
for (ToolTipLine tip : toolTips) {
String line = tip.text;
@@ -545,4 +549,49 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
protected class ItemStackWidget extends Widget {
ItemStack itemStack;
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);
}
@Override
public ToolTip getToolTip() {
ToolTip tip = new ToolTip();
tip.add(itemStack.getDisplayName());
return tip;
}
}
/* NEI */
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { return null; }
@Override
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) { return null; }
@Override
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) { return null; }
@Override
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { return false; }
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (gui instanceof GuiForestry)
return ((GuiForestry)gui).ledgerManager.ledgerOverlaps(x, y, w, h);
else
return false;
}
}
@@ -0,0 +1,34 @@
/*******************************************************************************
* 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;
import net.minecraft.util.ResourceLocation;
import forestry.core.gadgets.TileForestry;
import forestry.core.utils.StringUtil;
public abstract class GuiForestryTitled<T extends TileForestry> extends GuiForestry<T> {
public GuiForestryTitled(String texture, ContainerForestry container, Object inventory) {
super(texture, container, inventory);
}
public GuiForestryTitled(ResourceLocation texture, ContainerForestry container, Object inventory) {
super(texture, container, inventory);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String name = StringUtil.localizeTile(tile.getUnlocalizedName());
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
}
@@ -117,4 +117,8 @@ public class LedgerManager {
}
public boolean ledgerOverlaps(int x, int y, int width, int height) {
return getAtPosition(x + width, y + height) != null || getAtPosition(x + width, y) != null || getAtPosition(x, y + height) != null || getAtPosition(x, y) != null;
}
}
@@ -42,8 +42,8 @@ public class SlotCustom extends SlotForestry {
private ICrafter crafter;
private String blockedTexture = "slots/blocked";
public SlotCustom(IInventory iinventory, int i, int j, int k, boolean exclusion) {
super(iinventory, i, j, k);
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, boolean exclusion) {
super(iinventory, slotIndex, xPos, yPos);
items = new Object[0];
this.exclusion = exclusion;
}
@@ -52,17 +52,17 @@ public class SlotCustom extends SlotForestry {
this(iinventory, i, j, k, items.toArray());
}*/
public SlotCustom(IInventory iinventory, Collection<?> items, int i, int j, int k) {
this(iinventory, i, j, k, items.toArray());
public SlotCustom(IInventory iinventory, Collection<?> items, int slotIndex, int xPos, int yPos) {
this(iinventory, slotIndex, xPos, yPos, items.toArray());
}
public SlotCustom(IInventory iinventory, int i, int j, int k, boolean exclusion, Object... items) {
this(iinventory, i, j, k, items);
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, boolean exclusion, Object... items) {
this(iinventory, slotIndex, xPos, yPos, items);
this.exclusion = exclusion;
}
public SlotCustom(IInventory iinventory, int i, int j, int k, Object... items) {
super(iinventory, i, j, k);
public SlotCustom(IInventory iinventory, int slotIndex, int xPos, int yPos, Object... items) {
super(iinventory, slotIndex, xPos, yPos);
this.items = items;
}
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.core.gui.widgets;
import forestry.farming.gui.ContainerFarm;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@@ -19,13 +21,13 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import forestry.api.core.IToolPipette;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.WidgetManager;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.ForestryTank;
/**
* Slot for liquid tanks
@@ -48,8 +50,13 @@ public class TankWidget extends Widget {
return this;
}
public ForestryTank getTank() {
return ((ContainerForestry) manager.gui.inventorySlots).getTank(slot);
public StandardTank getTank() {
Container container = manager.gui.inventorySlots;
if (container instanceof ContainerLiquidTanks)
return ((ContainerLiquidTanks) container).getTank(slot);
else if (container instanceof ContainerFarm)
return ((ContainerFarm) container).getTank(slot);
return null;
}
@Override
@@ -96,7 +103,7 @@ public class TankWidget extends Widget {
@Override
public ToolTip getToolTip() {
ForestryTank tank = getTank();
StandardTank tank = getTank();
if (tank == null)
return null;
return tank.getToolTip();
@@ -10,12 +10,16 @@
******************************************************************************/
package forestry.core.interfaces;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.StandardTank;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraftforge.fluids.IFluidHandler;
import forestry.core.utils.ForestryTank;
public interface ILiquidTankContainer extends IFluidHandler {
ForestryTank[] getTanks();
TankManager getTankManager();
void getGUINetworkData(int messageId, int data);
void sendGUINetworkData(Container container, ICrafting iCrafting);
}
@@ -81,13 +81,13 @@ public class ItemCrated extends Item implements IGenericCrate {
return itemstack;
}
// @Override
// public String getItemStackDisplayName(ItemStack itemstack) {
// if (contained != null)
// return StringUtil.localize("item.crated.adj") + " " + Proxies.common.getDisplayName(contained);
// else
// return StringUtil.localize("item.crated.unknown");
// }
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (contained != null)
return StringUtil.localize("item.crated.adj") + " " + Proxies.common.getDisplayName(contained);
else
return StringUtil.localize("item.crated.unknown");
}
@SideOnly(Side.CLIENT)
@Override
@@ -10,9 +10,12 @@
******************************************************************************/
package forestry.core.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
public class ItemForestryBlock extends ItemBlock {
@@ -31,6 +34,12 @@ public class ItemForestryBlock extends ItemBlock {
return field_150939_a;
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIconFromDamage(int meta) {
return this.getBlock().getIcon(1, meta);
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
return getBlock().getUnlocalizedName() + "." + itemstack.getItemDamage();
@@ -10,55 +10,31 @@
******************************************************************************/
package forestry.core.items;
import net.minecraft.entity.player.EntityPlayer;
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.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import forestry.core.CreativeTabForestry;
public class ItemForestryFood extends ItemForestry {
public class ItemForestryFood extends ItemFood {
private boolean isAlwaysEdible = false;
private boolean isDrink = false;
private int healAmount = 0;
private final float saturationModifier;
private int potionId;
private int potionDuration;
private int potionAmplifier;
private float potionEffectProbability;
public ItemForestryFood(int heal) {
this(heal, 0.6f);
}
public ItemForestryFood(int heal, float saturation) {
super();
healAmount = heal;
saturationModifier = saturation;
super(heal, saturation, false);
setCreativeTab(CreativeTabForestry.tabForestry);
}
@Override
public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) {
itemstack.stackSize--;
entityplayer.getFoodStats().addStats(healAmount, saturationModifier);
world.playSoundAtEntity(entityplayer, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
if (!world.isRemote && potionId > 0 && world.rand.nextFloat() < potionEffectProbability)
entityplayer.addPotionEffect(new PotionEffect(potionId, potionDuration * 20, potionAmplifier));
return itemstack;
}
@Override
public int getMaxItemUseDuration(ItemStack itemstack) {
return 32;
}
@Override
public EnumAction getItemUseAction(ItemStack itemstack) {
if (isDrink)
@@ -67,29 +43,15 @@ public class ItemForestryFood extends ItemForestry {
return EnumAction.eat;
}
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
if (entityplayer.canEat(isAlwaysEdible))
entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack));
return itemstack;
}
public ItemForestryFood setIsDrink() {
isDrink = true;
return this;
}
public ItemForestryFood setPotionEffect(int i, int j, int k, float f) {
potionId = i;
potionDuration = j;
potionAmplifier = k;
potionEffectProbability = f;
return this;
}
public ItemForestryFood setAlwaysEdible() {
isAlwaysEdible = true;
return this;
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
itemIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanItemName(this));
}
}
@@ -0,0 +1,30 @@
package forestry.core.items;
import forestry.core.IItemTyped;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
/**
* For blocks whose type depends on metadata.
* This allows control over which localized name maps to which meta value.
*/
public class ItemTypedBlock extends ItemForestryBlock {
public ItemTypedBlock(Block block) {
super(block);
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
Block block = getBlock();
if (block instanceof IItemTyped) {
IItemTyped blockTyped = (IItemTyped)block;
Enum type = blockTyped.getTypeFromMeta(itemstack.getItemDamage());
if (type != null)
return getBlock().getUnlocalizedName() + "." + type.ordinal();
else
return null;
}
return super.getUnlocalizedName(itemstack);
}
}
@@ -76,10 +76,13 @@ public class ClassMap {
}
for (Field member : gameProfileMember) {
GameProfile profile = (GameProfile) member.get(obj);
intPayload[index.intIndex] = (int) (profile.getId().getMostSignificantBits() >>> 32);
intPayload[index.intIndex + 1] = (int) profile.getId().getMostSignificantBits();
intPayload[index.intIndex + 2] = (int) (profile.getId().getLeastSignificantBits() >>> 32);
intPayload[index.intIndex + 3] = (int) profile.getId().getLeastSignificantBits();
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++;
@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.network;
import cpw.mods.fml.client.FMLClientHandler;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.client.entity.EntityClientPlayerMP;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public class PacketGuiInteger extends ForestryPacket {
private int windowId, dataId, value;
public PacketGuiInteger() {
super();
}
public PacketGuiInteger(int windowId, int dataId, int value) {
this.windowId = windowId;
this.dataId = dataId;
this.value = value;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeByte(windowId);
data.writeByte(dataId);
data.writeInt(value);
}
@Override
public void readData(DataInputStream data) throws IOException {
windowId = data.readByte();
dataId = data.readByte();
value = data.readInt();
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
if (player.openContainer != null && player.openContainer.windowId == windowId)
player.openContainer.updateProgressBar(dataId, value);
}
@Override
public int getID() {
return PacketIds.GUI_INTEGER;
}
}
@@ -141,10 +141,9 @@ public class PacketHandler {
packetTR.readData(data);
onGenomeTrackerUpdate(packetTR);
break;
case PacketIds.TANK_UPDATE:
PacketTankUpdate packetAB = new PacketTankUpdate();
packetAB.readData(data);
onTankUpdate(packetAB);
case PacketIds.GUI_INTEGER:
PacketGuiInteger packet = new PacketGuiInteger();
packet.readData(data);
break;
default:
for (forestry.core.interfaces.IPacketHandler handler : PluginManager.packetHandlers)
@@ -168,17 +167,6 @@ public class PacketHandler {
channel.sendTo(packet, player);
}
private void onTankUpdate(PacketTankUpdate packetAB) {
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
EntityPlayer player = Proxies.common.getPlayer();
if (player.openContainer instanceof ContainerForestry) {
((ContainerForestry)player.openContainer).onTankUpdate(packetAB.nbttagcompound);
}
}
private void onGenomeTrackerUpdate(PacketNBT packet) {
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
@@ -42,13 +42,13 @@ public class PacketIds {
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 TRADING_INFO = 83;
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 TANK_UPDATE = 91;
public static final int GUI_INTEGER = 92;
// Propolis pipe
public static final int PROP_SEND_FILTER_SET = 100;
@@ -1,31 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.network;
import net.minecraft.nbt.NBTTagCompound;
import forestry.core.utils.ForestryTank;
public class PacketTankUpdate extends PacketNBT {
public PacketTankUpdate(int tankSlot, ForestryTank tank) {
super(PacketIds.TANK_UPDATE);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("tank", (byte) tankSlot);
nbt.setShort("capacity", (short) tank.getCapacity());
tank.writeToNBT(nbt);
this.nbttagcompound = nbt;
}
public PacketTankUpdate() {
}
}
@@ -12,6 +12,8 @@ package forestry.core.proxy;
import java.io.File;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
@@ -23,6 +25,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import org.lwjgl.input.Keyboard;
@@ -90,6 +95,17 @@ public class ClientProxyCommon extends ProxyCommon {
return true;
}
@Override
public EntityPlayer getPlayer(World world, GameProfile profile) {
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
if (player != null)
return player;
else if (world instanceof WorldServer)
return FakePlayerFactory.get((WorldServer) world, profile);
else
return null;
}
@Override
public double getBlockReachDistance(EntityPlayer entityplayer) {
if (entityplayer instanceof EntityPlayerSP)
@@ -12,6 +12,8 @@ package forestry.core.proxy;
import java.io.File;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IResourceManager;
@@ -31,7 +33,14 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.common.versioning.VersionRange;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@@ -148,6 +157,19 @@ public class ProxyCommon {
return server.getConfigurationManager().func_152596_g(player.getGameProfile());
}
/**
* Get a player for a given World and GameProfile.
* If they are not in the World, returns a FakePlayer.
* Do not store references to the return value, to prevent worlds staying in memory.
*/
public EntityPlayer getPlayer(World world, GameProfile profile) {
EntityPlayer player = world.getPlayerEntityByName(profile.getName());
if (player != null)
return player;
else
return FakePlayerFactory.get((WorldServer)world, profile);
}
public double getBlockReachDistance(EntityPlayer entityplayer) {
return 4f;
}
@@ -237,9 +259,31 @@ public class ProxyCommon {
return Loader.isModLoaded(modname);
}
public Object instantiateIfModLoaded(String modname, String className) {
public boolean isModLoaded(String modname, String versionRangeString) {
if (!isModLoaded(modname))
return false;
if (isModLoaded(modname))
if (versionRangeString != null) {
ModContainer mod = Loader.instance().getIndexedModList().get(modname);
ArtifactVersion modVersion = mod.getProcessedVersion();
VersionRange versionRange = VersionParser.parseRange(versionRangeString);
DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange);
if (!requiredVersion.containsVersion(modVersion))
return false;
}
return true;
}
public Object instantiateIfModLoaded(String modname, String className) {
return instantiateIfModLoaded(modname, null, className);
}
public Object instantiateIfModLoaded(String modname, String versionRangeString, String className) {
if (isModLoaded(modname, versionRangeString))
try {
Class<?> clas = Class.forName(className, true, Loader.instance().getModClassLoader());
return clas.newInstance();
@@ -15,6 +15,7 @@ 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;
@@ -38,7 +39,7 @@ public class ProxyNetwork {
}
public void sendToPlayer(ForestryPacket packet, EntityPlayer entityplayer) {
if (!(entityplayer instanceof EntityPlayerMP))
if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer))
return;
EntityPlayerMP player = (EntityPlayerMP) entityplayer;
@@ -0,0 +1,45 @@
package forestry.core.utils;
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 {
public static final int SLOT_SPECIMEN = 0;
public static final int SLOT_ANALYZE_1 = 1;
public static final int SLOT_ANALYZE_2 = 2;
public static final int SLOT_ANALYZE_3 = 3;
public static final int SLOT_ANALYZE_4 = 4;
public static final int SLOT_ANALYZE_5 = 6;
public static final int SLOT_ENERGY = 5;
protected EntityPlayer player;
public AlyzerInventory(Class<? extends Item> itemClass, int slots) {
super(itemClass, slots);
}
public AlyzerInventory(Class<? extends Item> itemClass, int size, ItemStack itemstack) {
super(itemClass, size, itemstack);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
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);
}
}
nbttagcompound.setTag("Items", nbttaglist);
}
}
@@ -1,86 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.utils;
import java.util.Locale;
import net.minecraft.item.EnumRarity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.core.config.Config;
import forestry.core.gui.tooltips.ToolTip;
import forestry.core.gui.tooltips.ToolTipLine;
public class ForestryTank extends FluidTank {
public static final ForestryTank FAKETANK = new ForestryTank(0);
public static final ForestryTank[] FAKETANK_ARRAY = new ForestryTank[] { FAKETANK };
public static final FluidTankInfo DUMMY_TANK_INFO = new FluidTankInfo(FAKETANK);
public static final FluidTankInfo[] DUMMY_TANKINFO_ARRAY = new FluidTankInfo[] { DUMMY_TANK_INFO };
public ForestryTank(FluidStack stack, int capacity) {
super(stack, capacity);
}
public ForestryTank(int capacity) {
super(capacity);
}
public ForestryTank(Fluid fluid, int amount, int capacity) {
super(fluid, amount, capacity);
}
public boolean isEmpty() {
return getFluid() == null || getFluid().amount <= 0;
}
public boolean isFull() {
return getFluid() != null && getFluid().amount == getCapacity();
}
public Fluid getFluidType() {
return getFluid() != null ? getFluid().getFluid() : null;
}
@Override
public String toString() {
return String.format("Tank: %s, %d/%d", fluid != null && fluid.getFluid() != null ? fluid.getFluid().getName() : "Empty", getFluidAmount(), getCapacity());
}
public ToolTip getToolTip() {
return toolTip;
}
protected final ToolTip toolTip = new ToolTip() {
@Override
public void refresh() {
toolTip.clear();
int amount = 0;
if (getFluid() != null && getFluid().amount > 0 && getFluid().getFluid() != null) {
Fluid fluidType = getFluidType();
EnumRarity rarity = fluidType.getRarity();
if (rarity == null)
rarity = EnumRarity.common;
ToolTipLine fluidName = new ToolTipLine(fluidType.getLocalizedName(getFluid()), rarity.rarityColor);
fluidName.setSpacing(2);
toolTip.add(fluidName);
amount = getFluid().amount;
} else {
toolTip.add(new ToolTipLine(StringUtil.localize("gui.empty")));
}
if (Config.tooltipLiquidAmount)
toolTip.add(new ToolTipLine(String.format(Locale.ENGLISH, "%,d / %,d", amount, getCapacity())));
}
};
}
@@ -76,17 +76,20 @@ public class InventoryAdapter implements IInventory, INBTTagable {
}
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) {
boolean addedAll = true;
for (ItemStack stack : stacks) {
if (stack == null)
continue;
if (!tryAddStack(stack.copy(), all))
addedAll = false;
if (!tryAddStack(stack.copy(), startSlot, slots, all))
return false;
}
return addedAll;
return true;
}
public boolean tryAddStacks(ItemStack[] stacks, boolean all) {
@@ -121,7 +124,11 @@ public class InventoryAdapter implements IInventory, INBTTagable {
}
public boolean tryAddStack(ItemStack stack, int startSlot, int slots, boolean all, boolean doAdd) {
return addStack(stack, startSlot, slots, all, doAdd) > 0;
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) {
@@ -184,68 +191,60 @@ public class InventoryAdapter implements IInventory, INBTTagable {
/* CONTAINS */
public boolean contains(ItemStack[] query, int startSlot, int slots) {
for (ItemStack queried : query) {
int itemCount = 0;
for (int i = startSlot; i < startSlot + slots; i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
continue;
if (StackUtils.equals(Blocks.air, queried)) {
itemCount += stack.stackSize;
continue;
}
if (queried.getItemDamage() < 0) {
if (stack.getItem() == queried.getItem())
itemCount += stack.stackSize;
continue;
}
if (stack.isItemEqual(queried) && ItemStack.areItemStackTagsEqual(stack, queried))
itemCount += stack.stackSize;
}
if (itemCount < queried.stackSize)
return false;
}
return true;
ItemStack[] stock = getStacks(startSlot, slots);
return StackUtils.containsSets(query, stock) > 0;
}
/* REMOVAL */
public void removeResources(ItemStack[] query, int startSlot, int slots) {
for (ItemStack queried : query) {
/**
* 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 remain = queried.copy();
ItemStack[] condensedSet = StackUtils.condenseStacks(set, -1, false);
for (int i = startSlot; i < startSlot + slots; i++) {
ItemStack stack = inventory.getStackInSlot(i);
ItemStack[] stock = getStacks(firstSlotIndex, slotCount);
if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count)
return false;
if (stack == null)
continue;
for (ItemStack stackToRemove : condensedSet) {
stackToRemove.stackSize *= count;
if (queried.getItemDamage() < 0) {
if (stack.getItem() == queried.getItem()) {
ItemStack removed = decrStackSize(i, remain.stackSize);
remain.stackSize -= removed.stackSize;
}
} else if (stack.isItemEqual(remain) && ItemStack.areItemStackTagsEqual(stack, remain)) {
ItemStack removed = decrStackSize(i, remain.stackSize);
remain.stackSize -= removed.stackSize;
}
if (remain.stackSize <= 0)
break;
}
// 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 */
@@ -42,7 +42,7 @@ public class ItemInventory implements IInventory, INBTTagable {
isItemInventory = true;
// Set an uid to identify the itemstack on SMP
setUID(true);
setUID(false);
readFromNBT(itemstack.getTagCompound());
}
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.utils;
import com.google.common.collect.ForwardingList;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.nbt.*;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class NBTUtil {
public enum EnumNBTType {
END(NBTTagEnd.class),
BYTE(NBTTagByte.class),
SHORT(NBTTagShort.class),
INT(NBTTagInt.class),
LONG(NBTTagLong.class),
FLOAT(NBTTagFloat.class),
DOUBLE(NBTTagDouble.class),
BYTE_ARRAY(NBTTagByteArray.class),
STRING(NBTTagString.class),
LIST(NBTTagList.class),
COMPOUND(NBTTagCompound.class),
INT_ARRAY(NBTTagIntArray.class);
public static final EnumNBTType[] VALUES = values();
public final Class<? extends NBTBase> classObject;
private EnumNBTType(Class<? extends NBTBase> c) {
this.classObject = c;
}
public static EnumNBTType fromClass(Class<? extends NBTBase> c) {
for (EnumNBTType type : VALUES) {
if (type.classObject == c)
return type;
}
return null;
}
}
public static <T extends NBTBase> NBTList<T> getNBTList(NBTTagCompound nbt, String tag, EnumNBTType type) {
NBTTagList nbtList = nbt.getTagList(tag, type.ordinal());
return new NBTList<T>(nbtList);
}
public static class NBTList<T extends NBTBase> extends ForwardingList<T> {
private final ArrayList<T> backingList;
private final NBTTagList nbtList;
public NBTList(NBTTagList nbtList) {
this.nbtList = nbtList;
backingList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtList, 0);
}
@Override
protected List<T> delegate() {
return backingList;
}
}
}
@@ -21,10 +21,10 @@ import java.util.Map;
* @param <T> The thing this map maps onto
* @param <P> The stack class (i.e. ItemStack, FluidStack) used for lookups
*/
public abstract class StackMap<P, T> extends HashMap<Object, T>{
public abstract class StackMap<P, T> extends HashMap<P, T>{
@Override
public final T put(Object key, T value) {
public final T put(P key, T value) {
if(isValidKey(key) && key != null && value != null)
return super.put(key, value);
return null;
@@ -36,7 +36,7 @@ public abstract class StackMap<P, T> extends HashMap<Object, T>{
public final boolean containsKey(Object key) {
P stack = getStack(key);
if(stack == null) return false;
for (Map.Entry<Object, T> entry : this.entrySet())
for (Map.Entry<P, T> entry : this.entrySet())
if (areEqual(stack, entry.getKey()))
return true;
return super.containsKey(key);
@@ -46,7 +46,7 @@ public abstract class StackMap<P, T> extends HashMap<Object, T>{
public final T get(Object key) {
P stack = getStack(key);
if(stack == null) return null;
for (Map.Entry<Object, T> entry : this.entrySet())
for (Map.Entry<P, T> entry : this.entrySet())
if (areEqual(stack, entry.getKey()))
return entry.getValue();
return super.get(key);
@@ -29,6 +29,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.oredict.OreDictionary;
import forestry.core.config.Defaults;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.gadgets.TileForestry;
public class StackUtils {
@@ -193,7 +194,7 @@ public class StackUtils {
* without decreasing the source stack.
*
* @param stack
* @param i
* @param amount
* @return
*/
public static ItemStack createSplitStack(ItemStack stack, int amount) {
@@ -254,7 +255,7 @@ public class StackUtils {
* @return
*/
public static int containsSets(ItemStack[] set, ItemStack[] stock) {
return containsSets(set, stock, null, false, false);
return containsSets(set, stock, false, false);
}
/**
@@ -264,10 +265,10 @@ public class StackUtils {
* @param stock
* @return
*/
public static int containsSets(ItemStack[] set, ItemStack[] stock, ItemStack exclude, boolean oreDictionary, boolean craftingTools) {
public static int containsSets(ItemStack[] set, ItemStack[] stock, boolean oreDictionary, boolean craftingTools) {
int count = 0;
ItemStack[] condensedRequired = StackUtils.condenseStacks(set);
ItemStack[] condensedRequired = StackUtils.condenseStacks(set, -1, oreDictionary);
ItemStack[] condensedOffered = StackUtils.condenseStacks(stock, -1, oreDictionary);
for (ItemStack req : condensedRequired) {
@@ -275,9 +276,6 @@ public class StackUtils {
boolean matched = false;
for (ItemStack offer : condensedOffered) {
if (exclude != null && isIdenticalItem(offer, exclude))
continue;
if (isCraftingEquivalent(req, offer, oreDictionary, craftingTools)) {
matched = true;
@@ -297,6 +295,27 @@ public class StackUtils {
return count;
}
/**
* Compare two item stacks for crafting equivalency without oreDictionary or craftingTools
*/
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison) {
if (base == null || comparison == null)
return false;
if (base.getItem() != comparison.getItem())
return false;
if (base.getItemDamage() != Defaults.WILDCARD)
if (base.getItemDamage() != comparison.getItemDamage())
return false;
// When the base stackTagCompound is null or empty, treat it as a wildcard for crafting
if (base.stackTagCompound == null || base.stackTagCompound.hasNoTags())
return true;
else
return ItemStack.areItemStackTagsEqual(base, comparison);
}
/**
* Compare two item stacks for crafting equivalency.
*
@@ -306,9 +325,12 @@ public class StackUtils {
* @return
*/
public static boolean isCraftingEquivalent(ItemStack base, ItemStack comparison, boolean oreDictionary, boolean craftingTools) {
if (isIdenticalItem(base, comparison))
if (isCraftingEquivalent(base, comparison))
return true;
if (base == null || comparison == null)
return false;
if (oreDictionary) {
int[] idsBase = OreDictionary.getOreIDs(base);
for (int idBase : idsBase) {
@@ -376,12 +398,12 @@ public class StackUtils {
}
public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, ForestryTank tank) {
public static void replenishByContainer(TileForestry tile, ItemStack inventoryStack, StandardTank tank) {
FluidContainerData container = LiquidHelper.getLiquidContainer(inventoryStack);
replenishByContainer(tile, inventoryStack, container, tank);
}
public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, ForestryTank tank) {
public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, FluidContainerData container, StandardTank tank) {
if (container == null)
return inventoryStack;
@@ -22,14 +22,12 @@ public class StringUtil {
return StatCollector.translateToLocal("for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
}
public static String localizeAndFormat(String key, Object... args) {
String text = StringUtil.localize(key);
public static String localizeTile(String key) {
return StatCollector.translateToLocal("tile.for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
}
try {
return String.format(text, args);
} catch (IllegalFormatException ex) {
return "Format error: " + text;
}
public static String localizeAndFormat(String key, Object... args) {
return localizeAndFormatRaw("for." + key, args);
}
/**
+1 -37
View File
@@ -60,42 +60,6 @@ import forestry.plugins.PluginArboriculture;
public class Utils {
private static EntityPlayer modPlayer;
public static GameProfile getForestryPlayerProfile() {
return new GameProfile(UUID.nameUUIDFromBytes(Config.fakeUserLogin.getBytes(Charsets.UTF_8)),
Config.fakeUserLogin);
}
public static EntityPlayer getForestryPlayer(World world, int x, int y, int z) {
if (modPlayer == null) {
modPlayer = new EntityPlayer(world, getForestryPlayerProfile()) {
@Override
public boolean canCommandSenderUseCommand(int var1, String var2) {
return false;
}
@Override
public ChunkCoordinates getPlayerCoordinates() {
return null;
}
@Override
public void addChatMessage(IChatComponent var1) {
}
};
modPlayer.posX = x;
modPlayer.posY = y;
modPlayer.posZ = z;
Proxies.log.info("Created player '%s' for Forestry.", modPlayer.getGameProfile().getId());
if (Config.fakeUserAutoop) {
MinecraftServer.getServer().getConfigurationManager().func_152605_a(modPlayer.getGameProfile());
Proxies.log.info("Opped player '%s'.", modPlayer.getGameProfile().getId());
}
}
return modPlayer;
}
private static Random rand;
public static int getUID() {
@@ -320,7 +284,7 @@ public class Utils {
public static int addRGBComponents(int colour, int r, int g, int b) {
r = ((colour & 0xff0000) >> 16) + r;
g = ((colour & 0xff00) >> 8) + b;
g = ((colour & 0xff00) >> 8) + g;
b = ((colour & 0xff)) + b;
r = r <= 255 ? r : 255;
+1 -1
View File
@@ -51,7 +51,7 @@ public class Vect {
@Override
public String toString() {
return String.format("%sx%sx%s;", x, y, z);
return String.format("%sx%sx%s", x, y, z);
}
@Override
@@ -12,8 +12,8 @@ package forestry.energy.circuits;
public class CircuitElectricBoost extends CircuitElectricChange {
public CircuitElectricBoost(String uid, int limit, int eu, int mj, String name, String[] description) {
super(uid, false, name, description);
public CircuitElectricBoost(String uid, int limit, int eu, int mj) {
super(uid, false);
this.setLimit(limit);
this.configureChange(eu, mj);
}
@@ -20,8 +20,8 @@ public abstract class CircuitElectricChange extends Circuit {
int euChange = 7;
int mjChange = 2;
public CircuitElectricChange(String uid, boolean requiresDiscovery, String name, String[] descriptions) {
super(uid, requiresDiscovery, name, descriptions);
public CircuitElectricChange(String uid, boolean requiresDiscovery) {
super(uid, requiresDiscovery);
}
protected void configureChange(int euChange, int mjChange) {
@@ -13,7 +13,7 @@ package forestry.energy.circuits;
public class CircuitElectricChoke extends CircuitElectricChange {
public CircuitElectricChoke(String uid) {
super(uid, false, "electric.choke.1", new String[] { "Reduces ouput by 1 MJ/t", "Reduces intake by 2 EU/t" });
super(uid, false);
this.configureChange(-2, -1);
this.setLimit(1);
}
@@ -13,7 +13,7 @@ package forestry.energy.circuits;
public class CircuitElectricEfficiency extends CircuitElectricChange {
public CircuitElectricEfficiency(String uid) {
super(uid, false, "electric.efficiency.1", new String[] { "Reduces intake by 1 EU/t" });
super(uid, false);
this.setLimit(1);
this.configureChange(-1, 0);
}
@@ -18,7 +18,7 @@ import forestry.energy.gadgets.EngineCopper;
public class CircuitFireDampener extends Circuit {
public CircuitFireDampener(String uid) {
super(uid, false, "dampener.1", new String[] { "Reduces maximum output to 1 MJ/t", "Preserves fuel output" });
super(uid, false);
}
@Override
@@ -21,6 +21,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
@@ -29,12 +30,14 @@ import forestry.api.fuels.FuelManager;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.gadgets.Engine;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.GuiId;
import forestry.core.network.PacketPayload;
import forestry.core.utils.ForestryTank;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.TileInventoryAdapter;
@@ -65,8 +68,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
else
shutdown = false;
}
public ForestryTank fuelTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY);
public ForestryTank heatingTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY);
public FilteredTank fuelTank;
public FilteredTank heatingTank;
private final TankManager tankManager;
private final TileInventoryAdapter inventory;
public int burnTime;
public int totalTime;
@@ -81,6 +85,16 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
setHints(Config.hints.get("engine.bronze"));
inventory = new TileInventoryAdapter(this, 1, "Items");
fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet());
fuelTank.tankMode = StandardTank.TankMode.INPUT;
heatingTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FluidRegistry.LAVA);
heatingTank.tankMode = StandardTank.TankMode.INPUT;
this.tankManager = new TankManager(fuelTank, heatingTank);
}
public TankManager getTankManager() {
return tankManager;
}
@Override
@@ -99,11 +113,11 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
if (container != null) {
ForestryTank tank = null;
StandardTank tank = null;
if (container.fluid.isFluidEqual(LiquidHelper.getLiquid(Defaults.LIQUID_LAVA, 1)))
if (heatingTank.accepts(container.fluid.getFluid()))
tank = heatingTank;
else if (FuelManager.bronzeEngineFuel.containsKey(container.fluid))
else if (fuelTank.accepts(container.fluid.getFluid()))
tank = fuelTank;
if (tank != null) {
@@ -219,7 +233,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
* Returns the fuel value (power per cycle) an item of the passed ItemStack
* provides
*
* @param item
* @param fluid
* @return
*/
private int determineFuelValue(Fluid fluid) {
@@ -231,16 +245,31 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
/**
*
* @param fuelid
* @param fluid
* @return Duration of burn cycle of one bucket
*/
private int determineBurnTime(Fluid item) {
if (FuelManager.bronzeEngineFuel.containsKey(item))
return FuelManager.bronzeEngineFuel.get(item).burnDuration;
private int determineBurnTime(Fluid fluid) {
if (FuelManager.bronzeEngineFuel.containsKey(fluid))
return FuelManager.bronzeEngineFuel.get(fluid).burnDuration;
else
return 0;
}
protected ItemStack replenishByContainer(ItemStack inventoryStack, FluidContainerData container, StandardTank tank) {
if (container == null)
return inventoryStack;
if (tank.fill(container.fluid, false) >= container.fluid.amount) {
tank.fill(container.fluid, true);
if (container.filledContainer != null && container.filledContainer.getItem().hasContainerItem(container.filledContainer))
inventoryStack = container.emptyContainer.copy();
else
inventoryStack.stackSize--;
}
return inventoryStack;
}
// / STATE INFORMATION
@Override
public boolean isBurning() {
@@ -284,13 +313,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
currentFluidId = fluid.getID();
}
fuelTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY);
heatingTank = new ForestryTank(Defaults.ENGINE_TANK_CAPACITY);
if (nbt.hasKey("FuelSlot")) {
fuelTank.readFromNBT(nbt.getCompoundTag("FuelSlot"));
heatingTank.readFromNBT(nbt.getCompoundTag("HeatingSlot"));
}
tankManager.readTanksFromNBT(nbt);
inventory.readFromNBT(nbt);
}
@@ -310,21 +333,14 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
if (fluid != null)
nbt.setString("currentFluid", fluid.getName());
NBTTagCompound nbtFuelSlot = new NBTTagCompound();
NBTTagCompound nbtHeatingSlot = new NBTTagCompound();
fuelTank.writeToNBT(nbtFuelSlot);
heatingTank.writeToNBT(nbtHeatingSlot);
nbt.setTag("FuelSlot", nbtFuelSlot);
nbt.setTag("HeatingSlot", nbtHeatingSlot);
tankManager.writeTanksToNBT(nbt);
inventory.writeToNBT(nbt);
}
/* GUI */
@Override
public void getGUINetworkData(int id, int data) {
id -= tankManager.maxMessageId() + 1;
switch (id) {
case 0:
@@ -350,12 +366,13 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
@Override
public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {
iCrafting.sendProgressBarUpdate(containerEngine, 0, burnTime);
iCrafting.sendProgressBarUpdate(containerEngine, 1, totalTime);
iCrafting.sendProgressBarUpdate(containerEngine, 2, currentOutput);
iCrafting.sendProgressBarUpdate(containerEngine, 3, (int) storedEnergy);
iCrafting.sendProgressBarUpdate(containerEngine, 4, heat);
iCrafting.sendProgressBarUpdate(containerEngine, 5, currentFluidId);
int i = tankManager.maxMessageId() + 1;
iCrafting.sendProgressBarUpdate(containerEngine, i, burnTime);
iCrafting.sendProgressBarUpdate(containerEngine, i + 1, totalTime);
iCrafting.sendProgressBarUpdate(containerEngine, i + 2, currentOutput);
iCrafting.sendProgressBarUpdate(containerEngine, i + 3, (int) storedEnergy);
iCrafting.sendProgressBarUpdate(containerEngine, i + 4, heat);
iCrafting.sendProgressBarUpdate(containerEngine, i + 5, currentFluidId);
}
/* IINVENTORY */
@@ -405,12 +422,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public String getInventoryName() {
return super.getInventoryName();
return getUnlocalizedName();
}
/**
@@ -426,6 +440,13 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
if (slotIndex == SLOT_CAN) {
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
if (fluid == null || fluid.amount <= 0)
return false;
return fuelTank.accepts(fluid.getFluid()) || heatingTank.accepts(fluid.getFluid());
}
return super.isItemValidForSlot(slotIndex, itemstack);
}
@@ -444,23 +465,36 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
return null;
}
// / ITANKCONTAINER
// IFluidHandler
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
// We only accept biomass and water as fuel
int used = 0;
if (FuelManager.bronzeEngineFuel.containsKey(resource))
used = fuelTank.fill(resource, doFill);
if (LiquidHelper.isLiquid(Defaults.LIQUID_LAVA, resource))
used = heatingTank.fill(resource, doFill);
return used;
return tankManager.fill(from, resource, doFill);
}
@Override
public ForestryTank[] getTanks() {
return new ForestryTank[] { fuelTank, heatingTank };
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return tankManager.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return tankManager.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return tankManager.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return tankManager.getTankInfo(from);
}
}
@@ -204,7 +204,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
/**
* Returns the fuel value (power per cycle) an item of the passed ItemStack provides
*
* @param item
* @param fuel
* @return
*/
private int determineFuelValue(ItemStack fuel) {
@@ -217,7 +217,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
/**
* Returns the fuel value (power per cycle) an item of the passed ItemStack provides
*
* @param item
* @param fuel
* @return
*/
private int determineBurnDuration(ItemStack fuel) {
@@ -397,12 +397,9 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public String getInventoryName() {
return super.getInventoryName();
return getUnlocalizedName();
}
/**
Loaded 100 of 212 files, more files were not shown because too many files have changed in this diff. Show more