2013-12-27 23:59:59 +01:00
|
|
|
package appeng.util.item;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.init.Items;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.Item;
|
2013-12-28 21:55:31 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTBase;
|
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
public class AEItemDef
|
|
|
|
{
|
|
|
|
|
|
|
|
public int myHash;
|
|
|
|
|
|
|
|
public int def;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
private int itemID;
|
2013-12-27 23:59:59 +01:00
|
|
|
public Item item;
|
|
|
|
public int damageValue;
|
|
|
|
|
|
|
|
public int dspDamage;
|
|
|
|
public int maxDamage;
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
public AESharedNBT tagCompound;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public String displayName;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public List tooltip;
|
|
|
|
|
2014-02-13 06:24:07 +01:00
|
|
|
public OreRefrence isOre;
|
2014-02-05 08:25:44 +01:00
|
|
|
|
2014-03-22 04:58:03 +01:00
|
|
|
static AESharedNBT lowTag = new AESharedNBT( Integer.MIN_VALUE );
|
|
|
|
static AESharedNBT highTag = new AESharedNBT( Integer.MAX_VALUE );
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public AEItemDef copy()
|
|
|
|
{
|
|
|
|
AEItemDef t = new AEItemDef();
|
|
|
|
t.def = def;
|
|
|
|
t.item = item;
|
|
|
|
t.damageValue = damageValue;
|
|
|
|
t.dspDamage = dspDamage;
|
|
|
|
t.maxDamage = maxDamage;
|
2014-01-06 07:55:16 +01:00
|
|
|
t.tagCompound = tagCompound;
|
2014-02-05 08:25:44 +01:00
|
|
|
t.isOre = isOre;
|
2014-02-09 02:34:52 +01:00
|
|
|
t.itemID = itemID;
|
2013-12-27 23:59:59 +01:00
|
|
|
return t;
|
|
|
|
}
|
2013-12-28 21:55:31 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj)
|
|
|
|
{
|
|
|
|
AEItemDef def = (AEItemDef) obj;
|
|
|
|
return def.damageValue == damageValue && def.item == item && tagCompound == def.tagCompound;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDamageValueHack(ItemStack is)
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
return Items.blaze_rod.getDamage( is );
|
2013-12-28 21:55:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isItem(ItemStack otherStack)
|
|
|
|
{
|
|
|
|
// hackery!
|
|
|
|
int dmg = getDamageValueHack( otherStack );
|
|
|
|
|
|
|
|
if ( item == otherStack.getItem() && dmg == damageValue )
|
|
|
|
{
|
|
|
|
if ( (tagCompound != null) == otherStack.hasTagCompound() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( tagCompound != null && otherStack.hasTagCompound() )
|
|
|
|
return Platform.NBTEqualityTest( (NBTBase) tagCompound, otherStack.getTagCompound() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-06 07:55:16 +01:00
|
|
|
|
|
|
|
public void reHash()
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
def = itemID << Platform.DEF_OFFSET | damageValue;
|
2014-01-06 07:55:16 +01:00
|
|
|
myHash = def ^ (tagCompound == null ? 0 : System.identityHashCode( tagCompound ));
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|