IAEStack#fuzzyComparison now compares the same subtypes. (#3384)

To reduce the amount of instanceof checks, it will now compare the same
subtupe.
Comparing an ItemStack and IAEItemStack can simply wrap it before
calling it. Heavy use should already use an IAEStack internal.
Analogue for fluids or other types.
This commit is contained in:
yueh
2018-05-27 21:15:42 +02:00
committed by GitHub
parent bf4818cf97
commit 62435a65f1
3 changed files with 17 additions and 50 deletions
@@ -163,37 +163,17 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
}
@Override
public boolean fuzzyComparison( final Object st, final FuzzyMode mode )
public boolean fuzzyComparison( final IAEItemStack other, final FuzzyMode mode )
{
if( st instanceof IAEItemStack )
if( mode == FuzzyMode.IGNORE_ALL && OreHelper.INSTANCE.sameOre( this, other ) )
{
final IAEItemStack other = (IAEItemStack) st;
if( OreHelper.INSTANCE.sameOre( this, other ) )
{
return true;
}
final ItemStack itemStack = this.getDefinition();
final ItemStack otherStack = other.getDefinition();
return this.fuzzyItemStackComparison( itemStack, otherStack, mode );
return true;
}
if( st instanceof ItemStack )
{
final ItemStack otherStack = (ItemStack) st;
final ItemStack itemStack = this.getDefinition();
final ItemStack otherStack = other.getDefinition();
if( OreHelper.INSTANCE.sameOre( this, otherStack ) )
{
return true;
}
final ItemStack itemStack = this.getDefinition();
return this.fuzzyItemStackComparison( itemStack, otherStack, mode );
}
return false;
return this.fuzzyItemStackComparison( itemStack, otherStack, mode );
}
@Override