2013-08-23 16:59:50 +02:00
|
|
|
package com.pahimar.ee3.item;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.EquivalentExchange3;
|
2013-12-17 21:48:21 +01:00
|
|
|
import com.pahimar.ee3.helper.ItemHelper;
|
|
|
|
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
2013-08-23 16:59:50 +02:00
|
|
|
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;
|
2013-12-16 02:26:42 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.util.Icon;
|
|
|
|
import net.minecraft.world.World;
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Equivalent-Exchange-3
|
2013-12-16 02:26:42 +01:00
|
|
|
* <p/>
|
2013-08-23 16:59:50 +02:00
|
|
|
* ItemAlchemicalBag
|
2013-12-16 02:26:42 +01:00
|
|
|
*
|
2013-08-23 16:59:50 +02:00
|
|
|
* @author pahimar
|
|
|
|
*/
|
2014-01-02 09:55:01 +01:00
|
|
|
public class ItemAlchemicalBag extends ItemEE implements IDyeable
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-12-20 12:58:15 +01:00
|
|
|
private static final String[] ALCHEMICAL_BAG_ICONS = {"Open", "OpenDrawString", "Closed", "ClosedDrawString"};
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private Icon[] icons;
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
public ItemAlchemicalBag(int id)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
super(id);
|
2014-01-02 09:55:01 +01:00
|
|
|
this.setUnlocalizedName(Strings.ALCHEMICAL_BAG_NAME);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-16 02:26:42 +01:00
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
2013-12-20 12:58:15 +01:00
|
|
|
icons = new Icon[ALCHEMICAL_BAG_ICONS.length];
|
2013-08-23 16:59:50 +02:00
|
|
|
|
2013-12-20 12:58:15 +01:00
|
|
|
for (int i = 0; i < ALCHEMICAL_BAG_ICONS.length; ++i)
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-12-20 12:58:15 +01:00
|
|
|
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME + ALCHEMICAL_BAG_ICONS[i]);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
|
|
|
|
{
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2013-11-20 01:42:29 +01:00
|
|
|
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN, true);
|
2013-08-23 16:59:50 +02:00
|
|
|
entityPlayer.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_BAG, entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public boolean getShareTag()
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-16 02:26:42 +01:00
|
|
|
public boolean requiresMultipleRenderPasses()
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public Icon getIcon(ItemStack itemStack, int renderPass)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
// If the bag is open
|
2013-12-16 02:26:42 +01:00
|
|
|
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
if (renderPass != 1)
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return icons[0];
|
2013-12-16 02:26:42 +01:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
else
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return icons[1];
|
2013-12-16 02:26:42 +01:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
// Else, the bag is closed
|
2013-12-16 02:26:42 +01:00
|
|
|
else
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
if (renderPass != 1)
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return icons[2];
|
2013-12-16 02:26:42 +01:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
else
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return icons[3];
|
2013-12-16 02:26:42 +01:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-16 02:26:42 +01:00
|
|
|
public int getColorFromItemStack(ItemStack itemStack, int renderPass)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
if (renderPass == 1)
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
2013-12-16 02:26:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
int bagColor = this.getColor(itemStack);
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (bagColor < 0)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
bagColor = Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bagColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-02 09:55:01 +01:00
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public boolean hasColor(ItemStack itemStack)
|
|
|
|
{
|
2013-10-18 02:53:08 +02:00
|
|
|
return ItemHelper.hasColor(itemStack);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 09:55:01 +01:00
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public int getColor(ItemStack itemStack)
|
|
|
|
{
|
2013-10-18 02:53:08 +02:00
|
|
|
return ItemHelper.getColor(itemStack);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 09:55:01 +01:00
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public void setColor(ItemStack itemStack, int color)
|
|
|
|
{
|
|
|
|
if (itemStack != null)
|
|
|
|
{
|
2013-12-20 12:58:15 +01:00
|
|
|
if (itemStack.getItem() instanceof ItemAlchemicalBag)
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-10-18 02:53:08 +02:00
|
|
|
ItemHelper.setColor(itemStack, color);
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-02 09:55:01 +01:00
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public void removeColor(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
if (itemStack != null)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (nbtTagCompound != null)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR))
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
displayTagCompound.removeTag(Strings.NBT_ITEM_COLOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|