Added checks for null and equal class to .equals()
Also switched a check for null in OreHelper#sameOre to prevent null == null => true
This commit is contained in:
@@ -60,8 +60,12 @@ public class AEItemDef
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
AEItemDef def = (AEItemDef) obj;
|
||||
return def.damageValue == damageValue && def.item == item && tagCompound == def.tagCompound;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
AEItemDef other = (AEItemDef) obj;
|
||||
return other.damageValue == damageValue && other.item == item && tagCompound == other.tagCompound;
|
||||
}
|
||||
|
||||
public int getDamageValueHack(ItemStack is)
|
||||
|
||||
@@ -16,7 +16,8 @@ public class OreHelper
|
||||
class ItemRef
|
||||
{
|
||||
|
||||
ItemRef(ItemStack stack) {
|
||||
ItemRef(ItemStack stack)
|
||||
{
|
||||
ref = stack.getItem();
|
||||
|
||||
if ( stack.getItem().isDamageable() )
|
||||
@@ -32,10 +33,14 @@ public class OreHelper
|
||||
int hash;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
ItemRef obj = (ItemRef) o;
|
||||
return damage == obj.damage && ref == obj.ref;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
ItemRef other = (ItemRef) obj;
|
||||
return damage == other.damage && ref == other.ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,12 +108,12 @@ public class OreHelper
|
||||
OreReference a = aeItemStack.def.isOre;
|
||||
OreReference b = aeItemStack.def.isOre;
|
||||
|
||||
if ( a == b )
|
||||
return true;
|
||||
|
||||
if ( a == null || b == null )
|
||||
return false;
|
||||
|
||||
if ( a == b )
|
||||
return true;
|
||||
|
||||
Collection<Integer> bOres = b.getOres();
|
||||
for (Integer ore : a.getOres())
|
||||
{
|
||||
|
||||
@@ -23,10 +23,12 @@ public class SharedSearchObject
|
||||
{
|
||||
if ( obj == null )
|
||||
return false;
|
||||
SharedSearchObject b = (SharedSearchObject) obj;
|
||||
if ( def == b.def && hash == b.hash )
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
SharedSearchObject other = (SharedSearchObject) obj;
|
||||
if ( def == other.def && hash == other.hash )
|
||||
{
|
||||
return Platform.NBTEqualityTest( compound, b.compound );
|
||||
return Platform.NBTEqualityTest( compound, other.compound );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user