new comparison methods.
This commit is contained in:
parent
22fafa697a
commit
e733df5448
|
@ -3,7 +3,10 @@ package appeng.util.item;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import appeng.api.storage.data.IAETagCompound;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -38,4 +41,34 @@ public class AEItemDef
|
|||
t.maxDamage = maxDamage;
|
||||
return t;
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
return Item.blazeRod.getDamage( is );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||
/*
|
||||
* Kinda Hacky
|
||||
*/
|
||||
def.damageValue = Item.blazeRod.getDamage( is );
|
||||
def.damageValue = def.getDamageValueHack( is );
|
||||
def.def = is.itemID << Platform.DEF_OFFSET | def.damageValue;
|
||||
|
||||
def.dspDamage = is.getItemDamageForDisplay();
|
||||
|
@ -496,4 +496,22 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||
{
|
||||
return def.tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IAEItemStack otherStack)
|
||||
{
|
||||
if ( otherStack == null )
|
||||
return false;
|
||||
|
||||
return def.equals( ((AEItemStack) otherStack).def );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(ItemStack otherStack)
|
||||
{
|
||||
if ( otherStack == null )
|
||||
return false;
|
||||
|
||||
return def.isItem( otherStack );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue