Getting close with bags!
This commit is contained in:
parent
c3dd664629
commit
31aff45a72
7 changed files with 129 additions and 78 deletions
|
@ -4,11 +4,13 @@ import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
|||
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
|
||||
import com.pahimar.ee3.inventory.InventoryAlchemicalBag;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.lib.Textures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
|
@ -21,16 +23,41 @@ import org.lwjgl.opengl.GL11;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemicalBag extends GuiContainer
|
||||
{
|
||||
private final ItemStack parentItemStack;
|
||||
private final InventoryAlchemicalBag inventoryAlchemicalBag;
|
||||
|
||||
public GuiAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag)
|
||||
{
|
||||
super(new ContainerAlchemicalBag(entityPlayer, inventoryAlchemicalBag));
|
||||
|
||||
this.parentItemStack = inventoryAlchemicalBag.parentItemStack;
|
||||
this.inventoryAlchemicalBag = inventoryAlchemicalBag;
|
||||
|
||||
if (this.parentItemStack.getItemDamage() == 0)
|
||||
{
|
||||
xSize = 230;
|
||||
ySize = 186;
|
||||
}
|
||||
else if (this.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
xSize = 230;
|
||||
ySize = 240;
|
||||
}
|
||||
else if (this.parentItemStack.getItemDamage() == 2)
|
||||
{
|
||||
xSize = 248;
|
||||
ySize = 256;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
|
||||
if (this.parentItemStack.getItemDamage() == 0 || this.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
fontRenderer.drawString(StatCollector.translateToLocal(inventoryAlchemicalBag.getInvName()), 8, 6, 4210752);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 35, ySize - 95 + 2, 4210752);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,6 +65,19 @@ public class GuiAlchemicalBag extends GuiContainer
|
|||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if (this.parentItemStack.getItemDamage() == 0)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_SMALL);
|
||||
}
|
||||
else if (this.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_MEDIUM);
|
||||
}
|
||||
else if (this.parentItemStack.getItemDamage() == 2)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_LARGE);
|
||||
}
|
||||
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.pahimar.ee3.client.handler;
|
|||
import com.pahimar.ee3.api.WrappedStack;
|
||||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.item.ItemAlchemicalBag;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.event.EventPriority;
|
||||
|
@ -51,10 +50,5 @@ public class ItemTooltipEventHandler
|
|||
event.toolTip.add("No EMC value");
|
||||
}
|
||||
}
|
||||
|
||||
if (event.itemStack.getItem() instanceof ItemAlchemicalBag && event.itemStack.getTagCompound() != null)
|
||||
{
|
||||
event.toolTip.add("NBT: " + event.itemStack.getTagCompound().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class GuiHandler implements IGuiHandler
|
|||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
||||
{
|
||||
// return new ContainerAlchemicalBag(player.inventory, player.getHeldItem());
|
||||
return new ContainerAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
||||
}
|
||||
else if (ID == GuiIds.ALUDEL)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public class GuiHandler implements IGuiHandler
|
|||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
||||
{
|
||||
// return new GuiAlchemicalBag(player.inventory, player.getHeldItem());
|
||||
return new GuiAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
||||
}
|
||||
else if (ID == GuiIds.ALUDEL)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.pahimar.ee3.lib.Strings;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
|
@ -43,78 +44,78 @@ public class ContainerAlchemicalBag extends Container
|
|||
this.entityPlayer = entityPlayer;
|
||||
this.inventoryAlchemicalBag = inventoryAlchemicalBag;
|
||||
|
||||
// if (alchemicalBag.getItemDamage() == 0)
|
||||
// {
|
||||
// bagInventoryRows = SMALL_BAG_INVENTORY_ROWS;
|
||||
// bagInventoryColumns = SMALL_BAG_INVENTORY_COLUMNS;
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 1)
|
||||
// {
|
||||
// bagInventoryRows = MEDIUM_BAG_INVENTORY_ROWS;
|
||||
// bagInventoryColumns = MEDIUM_BAG_INVENTORY_COLUMNS;
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 2)
|
||||
// {
|
||||
// bagInventoryRows = LARGE_BAG_INVENTORY_ROWS;
|
||||
// bagInventoryColumns = LARGE_BAG_INVENTORY_COLUMNS;
|
||||
// }
|
||||
//
|
||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
||||
{
|
||||
bagInventoryRows = SMALL_BAG_INVENTORY_ROWS;
|
||||
bagInventoryColumns = SMALL_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
bagInventoryRows = MEDIUM_BAG_INVENTORY_ROWS;
|
||||
bagInventoryColumns = MEDIUM_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
||||
{
|
||||
bagInventoryRows = LARGE_BAG_INVENTORY_ROWS;
|
||||
bagInventoryColumns = LARGE_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
|
||||
// // Add the Alchemical Chest slots to the container
|
||||
// for (int bagRowIndex = 0; bagRowIndex < bagInventoryRows; ++bagRowIndex)
|
||||
// {
|
||||
// for (int bagColumnIndex = 0; bagColumnIndex < bagInventoryColumns; ++bagColumnIndex)
|
||||
// {
|
||||
// if (alchemicalBag.getItemDamage() == 0)
|
||||
// if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
||||
// this.addSlotToContainer(new SlotAlchemicalBag(this, entityPlayer.inventory, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 1)
|
||||
// else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
||||
// this.addSlotToContainer(new SlotAlchemicalBag(this, entityPlayer.inventory, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 2)
|
||||
// else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 8 + bagRowIndex * 18));
|
||||
// this.addSlotToContainer(new SlotAlchemicalBag(this, entityPlayer.inventory, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 8 + bagRowIndex * 18));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Add the player's inventory slots to the container
|
||||
// for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
// {
|
||||
// for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
// {
|
||||
// if (alchemicalBag.getItemDamage() == 0)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 1)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 2)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Add the player's action bar slots to the container
|
||||
// for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
// {
|
||||
// if (alchemicalBag.getItemDamage() == 0)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 1)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
|
||||
// }
|
||||
// else if (alchemicalBag.getItemDamage() == 2)
|
||||
// {
|
||||
// this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Add the player's inventory slots to the container
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
|
||||
}
|
||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,9 +16,24 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable
|
|||
protected ItemStack[] inventory;
|
||||
protected String customName;
|
||||
|
||||
public InventoryAlchemicalBag(ItemStack itemStack, int size)
|
||||
public InventoryAlchemicalBag(ItemStack itemStack)
|
||||
{
|
||||
parentItemStack = itemStack;
|
||||
|
||||
int size;
|
||||
if (itemStack.getItemDamage() == 1)
|
||||
{
|
||||
size = ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
else if (itemStack.getItemDamage() == 2)
|
||||
{
|
||||
size = ContainerAlchemicalBag.LARGE_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.LARGE_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = ContainerAlchemicalBag.SMALL_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.SMALL_BAG_INVENTORY_COLUMNS;
|
||||
}
|
||||
|
||||
inventory = new ItemStack[size];
|
||||
|
||||
readFromNBT(itemStack.getTagCompound());
|
||||
|
@ -137,7 +152,7 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable
|
|||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return this.hasCustomName() ? this.getCustomName() : Strings.ALCHEMICAL_BAG_NAME;
|
||||
return this.hasCustomName() ? this.getCustomName() : Strings.CONTAINER_ALCHEMICAL_BAG_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ public class SlotAlchemicalBag extends Slot
|
|||
private final EntityPlayer entityPlayer;
|
||||
private ContainerAlchemicalBag containerAlchemicalBag;
|
||||
|
||||
public SlotAlchemicalBag(EntityPlayer entityPlayer, ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, int x, int y, int z)
|
||||
public SlotAlchemicalBag(ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, EntityPlayer entityPlayer, int x, int y, int z)
|
||||
{
|
||||
super(inventory, x, y, z);
|
||||
this.entityPlayer = entityPlayer;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.helper.ItemHelper;
|
||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Colours;
|
||||
import com.pahimar.ee3.lib.GuiIds;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -11,7 +13,6 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -69,14 +70,14 @@ public class ItemAlchemicalBag extends ItemEE implements IDyeable
|
|||
{
|
||||
// Set a UUID on the Alchemical Bag, if one doesn't exist already
|
||||
ItemStackNBTHelper.setUUID(itemStack);
|
||||
// ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN, true);
|
||||
// entityPlayer.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_BAG, entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ);
|
||||
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN, true);
|
||||
entityPlayer.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_BAG, entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ);
|
||||
}
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Pahimar: Sorry not ready yet!"));
|
||||
}
|
||||
// if (world.isRemote)
|
||||
// {
|
||||
// entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText("Pahimar: Sorry not ready yet!"));
|
||||
// }
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue