Rework analyzer guis to be wider.

close #132
This commit is contained in:
James Mitchell committed 2014-09-02 23:12:01 -07:00
1 parent d05dbd7f94
commit 9e3569d0cd
14 files changed
+219 -348

No files matched your search

@@ -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 });
}
}
@@ -41,9 +41,6 @@ public class GuiBeealyzer extends GuiAlyzer {
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"), player,
new ContainerBeealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
xSize = 196;
ySize = 238;
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList)
@@ -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;
@@ -10,77 +10,19 @@
******************************************************************************/
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;
public class ContainerTreealyzer extends ContainerAlyzer {
TreealyzerInventory inventory;
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, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemGermlingGE.class });
}
}
@@ -46,9 +46,6 @@ public class GuiTreealyzer extends GuiAlyzer {
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"), player,
new ContainerTreealyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
xSize = 196;
ySize = 238;
ArrayList<ItemStack> treeList = new ArrayList<ItemStack>();
((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false);
for (ItemStack beeStack : treeList)
@@ -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;
@@ -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 = 222;
// 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;
}
}
+61 -60
View File
@@ -43,8 +43,8 @@ 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;
@@ -55,6 +55,9 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
public GuiAlyzer(ISpeciesRoot speciesRoot, EntityPlayer player, ContainerForestry container, IInventory inventory, int pageMax, int pageSize) {
super(Defaults.TEXTURE_PATH_GUI + "/beealyzer.png", container);
xSize = 246;
ySize = 238;
this.inventory = inventory;
this.speciesRoot = speciesRoot;
this.breedingTracker = speciesRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
@@ -94,8 +97,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;
@@ -151,9 +154,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,7 +165,7 @@ 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();
@@ -179,7 +182,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 156, 0x666666);
else {
String tokens[] = description.split("\\|");
drawSplitLine(tokens[0], 12, 152, 0x666666);
drawSplitLine(tokens[0], 12, 202, 0x666666);
if (tokens.length > 1)
fontRendererObj.drawStringWithShadow("- " + tokens[1], adjustToFactor(guiLeft + 160) - fontRendererObj.getStringWidth("- " + tokens[1]),
adjustToFactor(guiTop + 145 - 14), 0x99cc32);
@@ -222,7 +225,7 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
}
x += columnWidth;
if (x > 150) {
if (x > columnWidth * 4) {
x = 0;
newLine();
newLine();
@@ -254,30 +257,29 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
adjustToFactor(guiTop) + getLineY());
*/
int line = 0;
int column = 196;
int line = 247;
int column = 100;
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;
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;
}
Proxies.common.bindTexture(textureFile);
@@ -289,35 +291,34 @@ public abstract class GuiAlyzer extends GuiForestry<TileForestry> {
// Question marks
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
drawTexturedModalRect(adjustToFactor(guiLeft) + x, adjustToFactor(guiTop) + getLineY(), 78, 240, 16, 16);
Proxies.common.bindTexture(textureFile);
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY(), 196, 18, 16, 16);
drawTexturedModalRect(adjustToFactor(guiLeft) + x + 32, adjustToFactor(guiTop) + getLineY(), 78, 240, 16, 16);
int line = 0;
int column = 196;
int line = 247;
int column = 100;
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;
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
@@ -367,22 +368,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 +391,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 + 19) * (1 / factor)), (int) ((guiTop + getLineY()) * (1 / factor)), 60, 240 + texOffset, 12, 8);
drawLine(Integer.toString(fertility) + " x", x, textColor);
}
@@ -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;
}
@@ -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);
}
}
@@ -10,75 +10,19 @@
******************************************************************************/
package forestry.lepidopterology.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.config.ForestryItem;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.proxy.Proxies;
import forestry.lepidopterology.items.ItemButterflyGE;
import forestry.lepidopterology.items.ItemFlutterlyzer.FlutterlyzerInventory;
public class ContainerFlutterlyzer extends ContainerItemInventory {
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFlutterlyzer extends ContainerAlyzer {
FlutterlyzerInventory inventory;
public ContainerFlutterlyzer(InventoryPlayer inventoryplayer, FlutterlyzerInventory inventory) {
super(inventory, inventoryplayer.player);
this.inventory = inventory;
// Energy
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ENERGY, 172, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
// Bee to analyze
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_SPECIMEN, 172, 26, new Object[] { ItemButterflyGE.class, Blocks.sapling }));
// Analyzed bee
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_1, 172, 57, new Object[] { ItemButterflyGE.class }));
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_2, 172, 75, new Object[] { ItemButterflyGE.class }));
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_3, 172, 93, new Object[] { ItemButterflyGE.class }));
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_4, 172, 111, new Object[] { ItemButterflyGE.class }));
this.addSlot(new SlotCustom(inventory, FlutterlyzerInventory.SLOT_ANALYZE_5, 172, 129, new Object[] { ItemButterflyGE.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 == FlutterlyzerInventory.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[] { ItemButterflyGE.class });
}
}
@@ -45,9 +45,6 @@ public class GuiFlutterlyzer extends GuiAlyzer {
super(AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"), player,
new ContainerFlutterlyzer(player.inventory, inventory), inventory, 1, inventory.getSizeInventory());
xSize = 196;
ySize = 238;
ArrayList<ItemStack> butterflyList = new ArrayList<ItemStack>();
((ItemButterflyGE) ForestryItem.butterflyGE.item()).addCreativeItems(butterflyList, false);
for (ItemStack butterflyStack : butterflyList)
@@ -13,9 +13,9 @@ package forestry.lepidopterology.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.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.api.lepidopterology.IButterfly;
@@ -27,21 +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.PluginLepidopterology;
public class ItemFlutterlyzer extends ItemInventoried {
public static class FlutterlyzerInventory 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 FlutterlyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
public FlutterlyzerInventory(EntityPlayer player) {
super(ItemFlutterlyzer.class, 7);
@@ -53,22 +43,6 @@ public class ItemFlutterlyzer 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;