Re-implemented Alchemical Bag functionality, and added back the fuel handler

This commit is contained in:
pahimar 2014-04-30 19:33:29 -04:00
parent cf1dcfa1a0
commit 26d3a5dd11
8 changed files with 678 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package com.pahimar.ee3;
import com.pahimar.ee3.handler.CraftingHandler;
import com.pahimar.ee3.handler.FuelHandler;
import com.pahimar.ee3.handler.GuiHandler;
import com.pahimar.ee3.init.ModBlocks;
import com.pahimar.ee3.init.ModItems;
@ -18,6 +19,7 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Items;
import net.minecraftforge.common.MinecraftForge;
@ -71,6 +73,9 @@ public class EquivalentExchange3
MinecraftForge.EVENT_BUS.register(EventHandlers.itemEventHandler);
CraftingHandler.init();
// Register our fuels
GameRegistry.registerFuelHandler(new FuelHandler());
}
@EventHandler

View file

@ -0,0 +1,98 @@
package com.pahimar.ee3.client.gui.inventory;
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
import com.pahimar.ee3.inventory.InventoryAlchemicalBag;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.reference.Textures;
import com.pahimar.ee3.util.NBTHelper;
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;
@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)
{
fontRendererObj.drawString(StatCollector.translateToLocal(inventoryAlchemicalBag.getInventoryName()), 8, 6, 4210752);
fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), 35, ySize - 95 + 2, 4210752);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
{
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);
}
@Override
public void onGuiClosed()
{
super.onGuiClosed();
if (mc.thePlayer != null)
{
for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory)
{
if (itemStack != null)
{
if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN))
{
NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN);
}
}
}
}
}
}

View file

@ -0,0 +1,58 @@
package com.pahimar.ee3.handler;
import com.pahimar.ee3.init.ModBlocks;
import com.pahimar.ee3.init.ModItems;
import com.pahimar.ee3.item.ItemAlchemicalFuel;
import com.pahimar.ee3.item.ItemBlockAlchemicalFuel;
import cpw.mods.fml.common.IFuelHandler;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
public class FuelHandler implements IFuelHandler
{
private static final ItemStack ALCHEMICAL_COAL = new ItemStack(ModItems.alchemicalFuel, 1, 0);
private static final ItemStack MOBIUS_FUEL = new ItemStack(ModItems.alchemicalFuel, 1, 1);
private static final ItemStack AETERNALIS_FUEL = new ItemStack(ModItems.alchemicalFuel, 1, 2);
private static final ItemStack ALCHEMICAL_COAL_BLOCK = new ItemStack(ModBlocks.alchemicalFuel, 1, 0);
private static final ItemStack MOBIUS_FUEL_BLOCK = new ItemStack(ModBlocks.alchemicalFuel, 1, 1);
private static final ItemStack AETERNALIS_FUEL_BLOCK = new ItemStack(ModBlocks.alchemicalFuel, 1, 2);
@Override
public int getBurnTime(ItemStack fuel)
{
if (fuel.getItem() instanceof ItemAlchemicalFuel)
{
if (fuel.getItemDamage() == ALCHEMICAL_COAL.getItemDamage())
{
return 8 * TileEntityFurnace.getItemBurnTime(new ItemStack(Items.coal));
}
else if (fuel.getItemDamage() == MOBIUS_FUEL.getItemDamage())
{
return 8 * getBurnTime(ALCHEMICAL_COAL);
}
else if (fuel.getItemDamage() == AETERNALIS_FUEL.getItemDamage())
{
return 8 * getBurnTime(MOBIUS_FUEL);
}
}
else if (fuel.getItem() instanceof ItemBlockAlchemicalFuel)
{
if (fuel.getItemDamage() == ALCHEMICAL_COAL_BLOCK.getItemDamage())
{
return 9 * getBurnTime(ALCHEMICAL_COAL);
}
else if (fuel.getItemDamage() == MOBIUS_FUEL_BLOCK.getItemDamage())
{
return 9 * getBurnTime(MOBIUS_FUEL);
}
else if (fuel.getItemDamage() == AETERNALIS_FUEL_BLOCK.getItemDamage())
{
return 9 * getBurnTime(AETERNALIS_FUEL);
}
}
return 0;
}
}

View file

@ -1,9 +1,12 @@
package com.pahimar.ee3.handler;
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalBag;
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalChest;
import com.pahimar.ee3.client.gui.inventory.GuiGlassBell;
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
import com.pahimar.ee3.inventory.ContainerGlassBell;
import com.pahimar.ee3.inventory.InventoryAlchemicalBag;
import com.pahimar.ee3.reference.GuiIds;
import com.pahimar.ee3.tileentity.TileEntityAlchemicalChest;
import com.pahimar.ee3.tileentity.TileEntityGlassBell;
@ -26,6 +29,10 @@ public class GuiHandler implements IGuiHandler
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
return new ContainerGlassBell(player.inventory, tileEntityGlassBell);
}
else if (id == GuiIds.ALCHEMICAL_BAG)
{
return new ContainerAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
}
return null;
}
@ -43,6 +50,10 @@ public class GuiHandler implements IGuiHandler
TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z);
return new GuiGlassBell(player.inventory, tileEntityGlassBell);
}
else if (id == GuiIds.ALCHEMICAL_BAG)
{
return new GuiAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
}
return null;
}

View file

@ -0,0 +1,200 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.item.ItemAlchemicalBag;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.util.NBTHelper;
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;
public class ContainerAlchemicalBag extends Container
{
// Small Bag
public static final int SMALL_BAG_INVENTORY_ROWS = 4;
public static final int SMALL_BAG_INVENTORY_COLUMNS = 12;
// Medium Bag
public static final int MEDIUM_BAG_INVENTORY_ROWS = 7;
public static final int MEDIUM_BAG_INVENTORY_COLUMNS = 12;
// Large Bag
public static final int LARGE_BAG_INVENTORY_ROWS = 9;
public static final int LARGE_BAG_INVENTORY_COLUMNS = 13;
private final EntityPlayer entityPlayer;
private final InventoryAlchemicalBag inventoryAlchemicalBag;
// Player Inventory
private final int PLAYER_INVENTORY_ROWS = 3;
private final int PLAYER_INVENTORY_COLUMNS = 9;
private int bagInventoryRows;
private int bagInventoryColumns;
public ContainerAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag)
{
this.entityPlayer = entityPlayer;
this.inventoryAlchemicalBag = inventoryAlchemicalBag;
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 (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
{
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
}
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
{
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
}
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
{
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, 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 (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
public boolean canInteractWith(EntityPlayer var1)
{
return true;
}
@Override
public void onContainerClosed(EntityPlayer entityPlayer)
{
super.onContainerClosed(entityPlayer);
if (!entityPlayer.worldObj.isRemote)
{
// We can probably do this better now considering the InventoryAlchemicalBag has a findParent method
InventoryPlayer invPlayer = entityPlayer.inventory;
for (ItemStack itemStack : invPlayer.mainInventory)
{
if (itemStack != null)
{
if (NBTHelper.hasTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN))
{
NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN);
}
}
}
saveInventory(entityPlayer);
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
{
ItemStack newItemStack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack())
{
ItemStack itemStack = slot.getStack();
newItemStack = itemStack.copy();
// Attempt to shift click something from the bag inventory into the player inventory
if (slotIndex < bagInventoryRows * bagInventoryColumns)
{
if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, inventorySlots.size(), false))
{
return null;
}
}
// Special case if we are dealing with an Alchemical Bag being shift clicked
else if (itemStack.getItem() instanceof ItemAlchemicalBag)
{
// Attempt to shift click a bag from the player inventory into the hot bar inventory
if (slotIndex < (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS))
{
if (!this.mergeItemStack(itemStack, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false))
{
return null;
}
}
// Attempt to shift click a bag from the hot bar inventory into the player inventory
else if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false))
{
return null;
}
}
// Attempt to shift click a non-Alchemical Bag into the bag inventory
else if (!this.mergeItemStack(itemStack, 0, bagInventoryRows * bagInventoryColumns, false))
{
return null;
}
if (itemStack.stackSize == 0)
{
slot.putStack(null);
}
else
{
slot.onSlotChanged();
}
}
return newItemStack;
}
public void saveInventory(EntityPlayer entityPlayer)
{
inventoryAlchemicalBag.onGuiSaved(entityPlayer);
}
}

View file

@ -0,0 +1,260 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.util.INBTTaggable;
import com.pahimar.ee3.util.NBTHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import java.util.UUID;
public class InventoryAlchemicalBag implements IInventory, INBTTaggable
{
public ItemStack parentItemStack;
protected ItemStack[] inventory;
protected String customName;
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());
}
public void onGuiSaved(EntityPlayer entityPlayer)
{
parentItemStack = findParentItemStack(entityPlayer);
if (parentItemStack != null)
{
save();
}
}
public ItemStack findParentItemStack(EntityPlayer entityPlayer)
{
if (NBTHelper.hasUUID(parentItemStack))
{
UUID parentItemStackUUID = new UUID(parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG));
for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++)
{
ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i);
if (NBTHelper.hasUUID(itemStack))
{
if (itemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) == parentItemStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) == parentItemStackUUID.getLeastSignificantBits())
{
return itemStack;
}
}
}
}
return null;
}
public boolean matchesUUID(UUID uuid)
{
return NBTHelper.hasUUID(parentItemStack) && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) == uuid.getLeastSignificantBits() && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) == uuid.getMostSignificantBits();
}
public void save()
{
NBTTagCompound nbtTagCompound = parentItemStack.getTagCompound();
if (nbtTagCompound == null)
{
nbtTagCompound = new NBTTagCompound();
UUID uuid = UUID.randomUUID();
nbtTagCompound.setLong(Names.NBT.UUID_MOST_SIG, uuid.getMostSignificantBits());
nbtTagCompound.setLong(Names.NBT.UUID_LEAST_SIG, uuid.getLeastSignificantBits());
}
writeToNBT(nbtTagCompound);
parentItemStack.setTagCompound(nbtTagCompound);
}
@Override
public int getSizeInventory()
{
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slotIndex)
{
return inventory[slotIndex];
}
@Override
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
{
ItemStack itemStack = getStackInSlot(slotIndex);
if (itemStack != null)
{
if (itemStack.stackSize <= decrementAmount)
{
setInventorySlotContents(slotIndex, null);
}
else
{
itemStack = itemStack.splitStack(decrementAmount);
if (itemStack.stackSize == 0)
{
setInventorySlotContents(slotIndex, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex)
{
if (inventory[slotIndex] != null)
{
ItemStack itemStack = inventory[slotIndex];
inventory[slotIndex] = null;
return itemStack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
{
inventory[slotIndex] = itemStack;
}
@Override
public String getInventoryName()
{
return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALCHEMICAL_BAG;
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public void markDirty()
{
// NOOP
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
{
return true;
}
@Override
public void openInventory()
{
// NOOP
}
@Override
public void closeInventory()
{
// NOOP
}
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
if (nbtTagCompound != null && nbtTagCompound.hasKey("Items"))
{
// Read in the ItemStacks in the inventory from NBT
if (nbtTagCompound.hasKey("Items"))
{
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
inventory = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
byte slotIndex = tagCompound.getByte("Slot");
if (slotIndex >= 0 && slotIndex < inventory.length)
{
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
// Read in any custom name for the inventory
if (nbtTagCompound.hasKey("display") && nbtTagCompound.getTag("display").getClass().equals(NBTTagCompound.class))
{
if (nbtTagCompound.getCompoundTag("display").hasKey("Name"))
{
customName = nbtTagCompound.getCompoundTag("display").getString("Name");
}
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
// Write the ItemStacks in the inventory to NBT
NBTTagList tagList = new NBTTagList();
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
{
if (inventory[currentIndex] != null)
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte) currentIndex);
inventory[currentIndex].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
nbtTagCompound.setTag("Items", tagList);
}
public boolean hasCustomName()
{
return customName != null && customName.length() > 0;
}
public String getCustomName()
{
return customName;
}
}

View file

@ -0,0 +1,36 @@
package com.pahimar.ee3.inventory;
import com.pahimar.ee3.item.ItemAlchemicalBag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotAlchemicalBag extends Slot
{
private final EntityPlayer entityPlayer;
private ContainerAlchemicalBag containerAlchemicalBag;
public SlotAlchemicalBag(ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, EntityPlayer entityPlayer, int x, int y, int z)
{
super(inventory, x, y, z);
this.entityPlayer = entityPlayer;
this.containerAlchemicalBag = containerAlchemicalBag;
}
@Override
public void onSlotChange(ItemStack itemStack1, ItemStack itemStack2)
{
super.onSlotChange(itemStack1, itemStack2);
containerAlchemicalBag.saveInventory(entityPlayer);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
@Override
public boolean isItemValid(ItemStack itemStack)
{
return itemStack.getItem() instanceof ItemAlchemicalBag ? false : true;
}
}

View file

@ -0,0 +1,10 @@
package com.pahimar.ee3.util;
import net.minecraft.nbt.NBTTagCompound;
public interface INBTTaggable
{
void readFromNBT(NBTTagCompound nbtTagCompound);
void writeToNBT(NBTTagCompound nbtTagCompound);
}