diff --git a/src/api/java/appeng/api/storage/data/IAEStack.java b/src/api/java/appeng/api/storage/data/IAEStack.java index 043655292..6a3d86ed3 100644 --- a/src/api/java/appeng/api/storage/data/IAEStack.java +++ b/src/api/java/appeng/api/storage/data/IAEStack.java @@ -149,16 +149,14 @@ public interface IAEStack> boolean equals( Object obj ); /** - * compare stacks using fuzzy logic + * Compare the same subtype of {@link IAEStack} with another using a fuzzy comparison. * - * a IAEItemStack to another AEItemStack or a ItemStack. - * - * @param st stacks - * @param mode used fuzzy mode + * @param other The stack to compare. + * @param mode Which {@link FuzzyMode} should be used. * * @return true if two stacks are equal based on AE Fuzzy Comparison. */ - boolean fuzzyComparison( Object st, FuzzyMode mode ); + boolean fuzzyComparison( T other, FuzzyMode mode ); /** * Slower for disk saving, but smaller/more efficient for packets. @@ -200,7 +198,7 @@ public interface IAEStack> /** * Returns itemstack for display and similar purposes. Always has a count of 1. - * + * * @return itemstack */ ItemStack asItemStackRepresentation(); diff --git a/src/main/java/appeng/util/item/AEFluidStack.java b/src/main/java/appeng/util/item/AEFluidStack.java index de39a707f..282378010 100644 --- a/src/main/java/appeng/util/item/AEFluidStack.java +++ b/src/main/java/appeng/util/item/AEFluidStack.java @@ -31,7 +31,6 @@ import io.netty.buffer.ByteBuf; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -207,7 +206,7 @@ public final class AEFluidStack extends AEStack implements IAEFlu if( this.tagCompound != null ) { - i.setTag( "tag", (NBTBase) this.tagCompound ); + i.setTag( "tag", this.tagCompound ); } else { @@ -216,19 +215,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu } @Override - public boolean fuzzyComparison( final Object st, final FuzzyMode mode ) + public boolean fuzzyComparison( final IAEFluidStack other, final FuzzyMode mode ) { - if( st instanceof FluidStack ) - { - return ( (FluidStack) st ).getFluid() == this.fluid; - } - - if( st instanceof IAEFluidStack ) - { - return ( (IAEFluidStack) st ).getFluid() == this.fluid; - } - - return false; + return this.fluid == other.getFluid(); } @Override @@ -289,7 +278,7 @@ public final class AEFluidStack extends AEStack implements IAEFlu if( is.getFluid() == this.fluid ) { - final NBTTagCompound ta = (NBTTagCompound) this.tagCompound; + final NBTTagCompound ta = this.tagCompound; final NBTTagCompound tb = is.tag; if( ta == tb ) { @@ -347,7 +336,7 @@ public final class AEFluidStack extends AEStack implements IAEFlu public ItemStack asItemStackRepresentation() { // TODO: fluids, how do they even work? - return FluidUtil.getFilledBucket( getFluidStack() ); + return FluidUtil.getFilledBucket( this.getFluidStack() ); } @Override @@ -358,7 +347,7 @@ public final class AEFluidStack extends AEStack implements IAEFlu i.writeByte( mask ); - writeToStream( i ); + this.writeToStream( i ); this.putPacketValue( i, this.getStackSize() ); this.putPacketValue( i, this.getCountRequestable() ); diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index 5385b0e11..b2047f4bc 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -163,37 +163,17 @@ public final class AEItemStack extends AEStack 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