equivalent-exchange-3/ee3_common/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java
2013-03-08 13:40:59 -05:00

60 lines
2 KiB
Java

package com.pahimar.ee3.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.pahimar.ee3.core.helper.NBTHelper;
import com.pahimar.ee3.lib.Strings;
/**
* Equivalent-Exchange-3
*
* ContainerAlchemicalBag
*
* @author pahimar
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class ContainerAlchemicalBag extends Container {
public ContainerAlchemicalBag(InventoryPlayer inventoryPlayer) {
// Add the player's inventory slots to the container
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
}
}
// Add the player's action bar slots to the container
for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 162));
}
}
@Override
public boolean canInteractWith(EntityPlayer var1) {
return true;
}
@Override
public void onCraftGuiClosed(EntityPlayer player) {
super.onCraftGuiClosed(player);
if (!player.worldObj.isRemote) {
InventoryPlayer invPlayer = player.inventory;
for (ItemStack itemStack : invPlayer.mainInventory) {
if (itemStack != null) {
if (NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN)) {
NBTHelper.removeTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
}
}
}
}
}
}