Extracts item comparison from Platform into their own helper. (#2555)
* Extracts item comparison from Platform into their own helper. Renamed methods to be more more fitting for the actual comparison. Added documentation about each methods behaviour.
This commit is contained in:
parent
f85ab7ddc2
commit
1e20086799
|
@ -300,7 +300,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
|||
|
||||
for( final ItemStack ol : itemDropCandidates )
|
||||
{
|
||||
if( Platform.isSameItemType( ol, op ) )
|
||||
if( Platform.itemComparisons().isEqualItemType( ol, op ) )
|
||||
{
|
||||
final NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
|
||||
if( tag != null )
|
||||
|
|
|
@ -227,7 +227,7 @@ public abstract class AEBaseContainer extends Container
|
|||
final ItemStack a = stack == null ? null : stack.getItemStack();
|
||||
final ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack();
|
||||
|
||||
if( Platform.isSameItemPrecise( a, b ) )
|
||||
if( Platform.itemComparisons().isSameItem( a, b ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ public abstract class AEBaseContainer extends Container
|
|||
|
||||
if( !( cs.isPlayerSide() ) && cs instanceof SlotFake )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( destination, tis ) )
|
||||
if( Platform.itemComparisons().isSameItem( destination, tis ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
final ItemStack t = d.getStack();
|
||||
|
||||
if( Platform.isSameItemPrecise( tis, t ) ) // t.isItemEqual(tis))
|
||||
if( Platform.itemComparisons().isSameItem( tis, t ) ) // t.isItemEqual(tis))
|
||||
{
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if( maxSize > d.getSlotStackLimit() )
|
||||
|
@ -629,7 +629,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
final ItemStack t = d.getStack();
|
||||
|
||||
if( Platform.isSameItemPrecise( t, tis ) )
|
||||
if( Platform.itemComparisons().isSameItem( t, tis ) )
|
||||
{
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if( d.getSlotStackLimit() < maxSize )
|
||||
|
@ -929,7 +929,7 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
liftQty = 0;
|
||||
}
|
||||
if( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) )
|
||||
if( !Platform.itemComparisons().isSameItem( slotItem.getItemStack(), item ) )
|
||||
{
|
||||
liftQty = 0;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
|||
{
|
||||
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( optional, is ) )
|
||||
if( Platform.itemComparisons().isSameItem( optional, is ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -126,18 +126,18 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
|||
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( bot, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( top, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
matches = true;
|
||||
for( final ItemStack option : recipe.getInputs() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( is, option ) )
|
||||
if( Platform.itemComparisons().isSameItem( is, option ) )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
|
@ -174,13 +174,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
|||
boolean isValid = false;
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( recipe.getTopOptional().orElse( null ), otherSlot ) )
|
||||
if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( null ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getBottomOptional().orElse( null ) );
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( null ) );
|
||||
}
|
||||
else if( Platform.isSameItemPrecise( recipe.getBottomOptional().orElse( null ), otherSlot ) )
|
||||
else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( null ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getTopOptional().orElse( null ) );
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( null ) );
|
||||
}
|
||||
|
||||
if( isValid )
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
|||
{
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( Platform.isSameItem( this.civ.getItemStack(), currentItem ) )
|
||||
if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ContainerNetworkTool extends AEBaseContainer
|
|||
{
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
|
||||
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
|||
|
||||
final IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
|
||||
|
||||
if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
|
||||
if( rr == r && Platform.itemComparisons().isSameItem( rr.getCraftingResult( real ), is ) )
|
||||
{
|
||||
final SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 );
|
||||
sc.onPickupFromSlot( p, is );
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
|
|||
{
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
|
||||
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
{
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) )
|
||||
if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
if( is != null && Platform.isSameItem( request, is ) )
|
||||
if( is != null && Platform.itemComparisons().isEqualItem( request, is ) )
|
||||
{
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public class SlotRestrictedInput extends AppEngSlot
|
|||
|
||||
for( final ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( optional, i ) )
|
||||
if( Platform.itemComparisons().isSameItem( optional, i ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ public class SlotRestrictedInput extends AppEngSlot
|
|||
|
||||
public static boolean isMetalIngot( final ItemStack i )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( i, new ItemStack( Items.IRON_INGOT ) ) )
|
||||
if( Platform.itemComparisons().isSameItem( i, new ItemStack( Items.IRON_INGOT ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ public class SlotRestrictedInput extends AppEngSlot
|
|||
{
|
||||
for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( i, ingot ) )
|
||||
if( Platform.itemComparisons().isSameItem( i, ingot ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ItemDefinition implements IItemDefinition
|
|||
@Override
|
||||
public final boolean isSameAs( final ItemStack comparableStack )
|
||||
{
|
||||
return isEnabled() && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() );
|
||||
return isEnabled() && Platform.itemComparisons().isEqualItemType( comparableStack, this.maybeStack( 1 ).get() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
|||
{
|
||||
for( final IGrinderEntry gr : this.recipes )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
if( Platform.itemComparisons().isSameItem( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
|||
{
|
||||
for( final IGrinderEntry r : this.recipes )
|
||||
{
|
||||
if( Platform.isSameItem( input, r.getInput() ) )
|
||||
if( Platform.itemComparisons().isEqualItem( input, r.getInput() ) )
|
||||
{
|
||||
this.log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
|
||||
return r;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo
|
|||
{
|
||||
for( final ItemStack o : this.DamageModifiers.keySet() )
|
||||
{
|
||||
if( Platform.isSameItem( o, is ) )
|
||||
if( Platform.itemComparisons().isEqualItem( o, is ) )
|
||||
{
|
||||
return this.DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
|||
return this.tunnels.get( is );
|
||||
}
|
||||
|
||||
if( Platform.isSameItem( is, trigger ) )
|
||||
if( Platform.itemComparisons().isEqualItem( is, trigger ) )
|
||||
{
|
||||
return this.tunnels.get( is );
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AchievementCraftingHandler
|
|||
switch( achievement.getType() )
|
||||
{
|
||||
case Craft:
|
||||
if( Platform.isSameItemPrecise( achievement.getStack(), event.crafting ) )
|
||||
if( Platform.itemComparisons().isSameItem( achievement.getStack(), event.crafting ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AchievementPickupHandler
|
|||
|
||||
for( final Achievements achievement : Achievements.values() )
|
||||
{
|
||||
if( achievement.getType() == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.getStack(), is ) )
|
||||
if( achievement.getType() == AchievementType.Pickup && Platform.itemComparisons().isSameItem( achievement.getStack(), is ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
|
|
@ -167,7 +167,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
|||
final ItemStack newItemStack = r.matches( testInv, pmp.worldObj ) ? r.getCraftingResult( testInv ) : null;
|
||||
testInv.setInventorySlotContents( x, patternItem );
|
||||
|
||||
if( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
|
||||
if( newItemStack == null || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.create( currentItem );
|
||||
if( in != null )
|
||||
|
|
|
@ -119,12 +119,12 @@ public final class EntityChargedQuartz extends AEBaseEntityItem
|
|||
final ItemStack other = ( (EntityItem) e ).getEntityItem();
|
||||
if( other != null && other.stackSize > 0 )
|
||||
{
|
||||
if( Platform.isSameItem( other, new ItemStack( Items.REDSTONE ) ) )
|
||||
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.REDSTONE ) ) )
|
||||
{
|
||||
redstone = (EntityItem) e;
|
||||
}
|
||||
|
||||
if( Platform.isSameItem( other, new ItemStack( Items.QUARTZ ) ) )
|
||||
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.QUARTZ ) ) )
|
||||
{
|
||||
netherQuartz = (EntityItem) e;
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||
{
|
||||
final ItemStack testOutput = this.standardRecipe.getCraftingResult( this.testFrame );
|
||||
|
||||
if( Platform.isSameItemPrecise( this.correctOutput, testOutput ) )
|
||||
if( Platform.itemComparisons().isSameItem( this.correctOutput, testOutput ) )
|
||||
{
|
||||
this.testFrame.setInventorySlotContents( slotIndex, this.crafting.getStackInSlot( slotIndex ) );
|
||||
this.markItemAs( slotIndex, i, TestStatus.ACCEPT );
|
||||
|
@ -256,7 +256,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||
{
|
||||
final ItemStack testOutput = CraftingManager.getInstance().findMatchingRecipe( this.testFrame, w );
|
||||
|
||||
if( Platform.isSameItemPrecise( this.correctOutput, testOutput ) )
|
||||
if( Platform.itemComparisons().isSameItem( this.correctOutput, testOutput ) )
|
||||
{
|
||||
this.testFrame.setInventorySlotContents( slotIndex, this.crafting.getStackInSlot( slotIndex ) );
|
||||
this.markItemAs( slotIndex, i, TestStatus.ACCEPT );
|
||||
|
|
|
@ -237,7 +237,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||
return true;
|
||||
}
|
||||
|
||||
return !Platform.isSameItemPrecise( a, b );
|
||||
return !Platform.itemComparisons().isSameItem( a, b );
|
||||
}
|
||||
|
||||
private void postDifference( final Iterable<IAEItemStack> a )
|
||||
|
|
|
@ -1066,7 +1066,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
|||
|
||||
final ItemStack current = p == null ? null : p.getItemStack( PartItemStack.WORLD );
|
||||
|
||||
if( Platform.isSameItemType( iss, current ) )
|
||||
if( Platform.itemComparisons().isEqualItemType( iss, current ) )
|
||||
{
|
||||
p.readFromNBT( extra );
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class StackUpgradeInventory extends UpgradeInventory
|
|||
|
||||
for( final ItemStack is : upgrades.getSupported().keySet() )
|
||||
{
|
||||
if( Platform.isSameItem( this.stack, is ) )
|
||||
if( Platform.itemComparisons().isEqualItem( this.stack, is ) )
|
||||
{
|
||||
max = upgrades.getSupported().get( is );
|
||||
break;
|
||||
|
|
|
@ -111,7 +111,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||
{
|
||||
ItemStack sub = itemHandler.getStackInSlot( i );
|
||||
|
||||
if( !Platform.isSameItemPrecise( sub, req ) )
|
||||
if( !Platform.itemComparisons().isSameItem( sub, req ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||
return false;
|
||||
}
|
||||
|
||||
return a == null || b == null || !Platform.isSameItemPrecise( a, b );
|
||||
return a == null || b == null || !Platform.itemComparisons().isSameItem( a, b );
|
||||
}
|
||||
|
||||
private void postDifference( Iterable<IAEItemStack> a )
|
||||
|
|
|
@ -270,7 +270,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
break;
|
||||
}
|
||||
|
||||
if( newType != null && !Platform.isSameItem( newType, this.getItemStack() ) )
|
||||
if( newType != null && !Platform.itemComparisons().isEqualItem( newType, this.getItemStack() ) )
|
||||
{
|
||||
final boolean oldOutput = this.isOutput();
|
||||
final long myFreq = this.getFrequency();
|
||||
|
|
|
@ -87,6 +87,6 @@ public class Crusher implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,6 @@ public class Grind implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@ public class GrindFZ implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,6 @@ public class HCCrusher implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public abstract class InscriberProcess implements ICraftHandler, IWebsiteSeriali
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack reqOutput ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return this.output != null && Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
|
||||
return this.output != null && Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -87,6 +87,6 @@ public class Macerator implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,6 @@ public class MekCrusher implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,6 @@ public class MekEnrichment implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ public class Pulverizer implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack output ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.pro_output[0].getItemStack(), output );
|
||||
return Platform.itemComparisons().isSameItem( this.pro_output[0].getItemStack(), output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
|||
{
|
||||
for( final ItemStack r : i.getItemStackSet() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( r, reqOutput ) )
|
||||
if( Platform.itemComparisons().isSameItem( r, reqOutput ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -171,6 +171,6 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer
|
|||
}
|
||||
}
|
||||
|
||||
return Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
|
||||
return Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
|||
{
|
||||
for( final ItemStack r : i.getItemStackSet() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( r, reqOutput ) )
|
||||
if( Platform.itemComparisons().isSameItem( r, reqOutput ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -136,6 +136,6 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer
|
|||
}
|
||||
}
|
||||
|
||||
return Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput );
|
||||
return Platform.itemComparisons().isSameItem( this.output.getItemStack(), reqOutput );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,6 @@ public class Smelt implements ICraftHandler, IWebsiteSerializer
|
|||
@Override
|
||||
public boolean canCraft( final ItemStack reqOutput ) throws RegistrationError, MissingIngredientError
|
||||
{
|
||||
return Platform.isSameItemPrecise( this.out.getItemStack(), reqOutput );
|
||||
return Platform.itemComparisons().isSameItem( this.out.getItemStack(), reqOutput );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
|||
|
||||
if( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
if( !Platform.isSameItem( is, this.myPattern ) )
|
||||
if( !Platform.itemComparisons().isEqualItem( is, this.myPattern ) )
|
||||
{
|
||||
final World w = this.getWorld();
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
|
|
|
@ -194,7 +194,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
|
|||
ItemStack removed = oldStack;
|
||||
ItemStack added = newItemStack;
|
||||
|
||||
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
|
||||
{
|
||||
if( oldStack.stackSize > newItemStack.stackSize )
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
|
|||
ItemStack removed = oldStack;
|
||||
ItemStack added = newItemStack;
|
||||
|
||||
if( oldStack != null && newItemStack != null && Platform.isSameItem( oldStack, newItemStack ) )
|
||||
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
|
||||
{
|
||||
if( oldStack.stackSize > newItemStack.stackSize )
|
||||
{
|
||||
|
|
|
@ -135,7 +135,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
|||
private boolean canAddOutput( final ItemStack output )
|
||||
{
|
||||
final ItemStack outputStack = this.getStackInSlot( 1 );
|
||||
return outputStack == null || ( Platform.isSameItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
|
||||
return outputStack == null || ( Platform.itemComparisons().isEqualItem( outputStack, output ) && outputStack.stackSize < outputStack.getMaxStackSize() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -256,7 +256,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
|||
|
||||
for( final ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( optionals, itemstack ) )
|
||||
if( Platform.itemComparisons().isSameItem( optionals, itemstack ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -410,17 +410,17 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
|||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
|
||||
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
for( final ItemStack option : recipe.getInputs() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) )
|
||||
if( Platform.itemComparisons().isSameItem( option, this.getStackInSlot( 2 ) ) )
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
|
||||
this.lastStateChange = this.worldObj.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.isSameItemPrecise( oldType, this.storageType );
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons().isSameItem( oldType, this.storageType );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.util;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -30,8 +29,8 @@ import java.util.EnumSet;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -55,11 +54,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import net.minecraft.server.management.PlayerChunkMap;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
|
@ -90,7 +85,6 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
|
@ -137,10 +131,9 @@ import appeng.integration.IntegrationType;
|
|||
import appeng.me.GridAccessException;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.util.helpers.ItemComparisonHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.AESharedNBT;
|
||||
import appeng.util.item.OreHelper;
|
||||
import appeng.util.item.OreReference;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
|
||||
|
||||
|
@ -162,9 +155,15 @@ public class Platform
|
|||
*/
|
||||
private static final Random RANDOM_GENERATOR = new Random();
|
||||
private static final WeakHashMap<World, EntityPlayer> FAKE_PLAYERS = new WeakHashMap<World, EntityPlayer>();
|
||||
private static Field tagList;
|
||||
private static Method getEntry;
|
||||
|
||||
private static final ItemComparisonHelper ITEM_COMPARISON_HELPER = new ItemComparisonHelper();
|
||||
|
||||
public static ItemComparisonHelper itemComparisons()
|
||||
{
|
||||
return ITEM_COMPARISON_HELPER;
|
||||
}
|
||||
|
||||
public static Random getRandom()
|
||||
{
|
||||
return RANDOM_GENERATOR;
|
||||
|
@ -423,251 +422,6 @@ public class Platform
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Lots of silliness to try and account for weird tag related junk, basically requires that two tags have at least
|
||||
* something in their tags before it wasts its time comparing them.
|
||||
*/
|
||||
private static boolean sameStackStags( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
if( a == null && b == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( a == null || b == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( a == b )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final NBTTagCompound ta = a.getTagCompound();
|
||||
final NBTTagCompound tb = b.getTagCompound();
|
||||
if( ta == tb )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if both tags are shared this is easy...
|
||||
if( AESharedNBT.isShared( ta ) && AESharedNBT.isShared( tb ) )
|
||||
{
|
||||
return ta == tb;
|
||||
}
|
||||
|
||||
return NBTEqualityTest( ta, tb );
|
||||
}
|
||||
|
||||
/*
|
||||
* recursive test for NBT Equality, this was faster then trying to compare / generate hashes, its also more reliable
|
||||
* then the vanilla version which likes to fail when NBT Compound data changes order, it is pretty expensive
|
||||
* performance wise, so try an use shared tag compounds as long as the system remains in AE.
|
||||
*/
|
||||
public static boolean NBTEqualityTest( final NBTBase left, final NBTBase right )
|
||||
{
|
||||
// same type?
|
||||
final byte id = left.getId();
|
||||
if( id == right.getId() )
|
||||
{
|
||||
switch( id )
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
final NBTTagCompound ctA = (NBTTagCompound) left;
|
||||
final NBTTagCompound ctB = (NBTTagCompound) right;
|
||||
|
||||
final Set<String> cA = ctA.getKeySet();
|
||||
final Set<String> cB = ctB.getKeySet();
|
||||
|
||||
if( cA.size() != cB.size() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( final String name : cA )
|
||||
{
|
||||
final NBTBase tag = ctA.getTag( name );
|
||||
final NBTBase aTag = ctB.getTag( name );
|
||||
if( aTag == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !NBTEqualityTest( tag, aTag ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 9: // ) // A instanceof NBTTagList )
|
||||
{
|
||||
final NBTTagList lA = (NBTTagList) left;
|
||||
final NBTTagList lB = (NBTTagList) right;
|
||||
if( lA.tagCount() != lB.tagCount() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<NBTBase> tag = tagList( lA );
|
||||
final List<NBTBase> aTag = tagList( lB );
|
||||
if( tag.size() != aTag.size() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int x = 0; x < tag.size(); x++ )
|
||||
{
|
||||
if( aTag.get( x ) == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !NBTEqualityTest( tag.get( x ), aTag.get( x ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 1: // ( A instanceof NBTTagByte )
|
||||
return ( (NBTPrimitive) left ).getByte() == ( (NBTPrimitive) right ).getByte();
|
||||
|
||||
case 4: // else if ( A instanceof NBTTagLong )
|
||||
return ( (NBTPrimitive) left ).getLong() == ( (NBTPrimitive) right ).getLong();
|
||||
|
||||
case 8: // else if ( A instanceof NBTTagString )
|
||||
return ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() ) || ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() );
|
||||
|
||||
case 6: // else if ( A instanceof NBTTagDouble )
|
||||
return ( (NBTPrimitive) left ).getDouble() == ( (NBTPrimitive) right ).getDouble();
|
||||
|
||||
case 5: // else if ( A instanceof NBTTagFloat )
|
||||
return ( (NBTPrimitive) left ).getFloat() == ( (NBTPrimitive) right ).getFloat();
|
||||
|
||||
case 3: // else if ( A instanceof NBTTagInt )
|
||||
return ( (NBTPrimitive) left ).getInt() == ( (NBTPrimitive) right ).getInt();
|
||||
|
||||
default:
|
||||
return left.equals( right );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<NBTBase> tagList( final NBTTagList lB )
|
||||
{
|
||||
if( tagList == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
tagList = lB.getClass().getDeclaredField( "tagList" );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
try
|
||||
{
|
||||
tagList = lB.getClass().getDeclaredField( "field_74747_a" );
|
||||
}
|
||||
catch( final Throwable z )
|
||||
{
|
||||
AELog.debug( t );
|
||||
AELog.debug( z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
tagList.setAccessible( true );
|
||||
return (List<NBTBase>) tagList.get( lB );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return new ArrayList<NBTBase>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Orderless hash on NBT Data, used to work thought huge piles fast, but ignores the order just in case MC decided
|
||||
* to change it... WHICH IS BAD...
|
||||
*/
|
||||
public static int NBTOrderlessHash( final NBTBase nbt )
|
||||
{
|
||||
// same type?
|
||||
int hash = 0;
|
||||
final byte id = nbt.getId();
|
||||
hash += id;
|
||||
switch( id )
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
final NBTTagCompound ctA = (NBTTagCompound) nbt;
|
||||
|
||||
final Set<String> cA = ctA.getKeySet();
|
||||
|
||||
for( final String name : cA )
|
||||
{
|
||||
hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
case 9: // ) // A instanceof NBTTagList )
|
||||
{
|
||||
final NBTTagList lA = (NBTTagList) nbt;
|
||||
hash += 9 * lA.tagCount();
|
||||
|
||||
final List<NBTBase> l = tagList( lA );
|
||||
for( int x = 0; x < l.size(); x++ )
|
||||
{
|
||||
hash += ( (Integer) x ).hashCode() ^ NBTOrderlessHash( l.get( x ) );
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
case 1: // ( A instanceof NBTTagByte )
|
||||
return hash + ( (NBTPrimitive) nbt ).getByte();
|
||||
|
||||
case 4: // else if ( A instanceof NBTTagLong )
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getLong();
|
||||
|
||||
case 8: // else if ( A instanceof NBTTagString )
|
||||
return hash + ( (NBTTagString) nbt ).getString().hashCode();
|
||||
|
||||
case 6: // else if ( A instanceof NBTTagDouble )
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getDouble();
|
||||
|
||||
case 5: // else if ( A instanceof NBTTagFloat )
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getFloat();
|
||||
|
||||
case 3: // else if ( A instanceof NBTTagInt )
|
||||
return hash + ( (NBTPrimitive) nbt ).getInt();
|
||||
|
||||
default:
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The usual version of this returns an ItemStack, this version returns the recipe.
|
||||
*/
|
||||
|
@ -1127,7 +881,7 @@ public class Platform
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public static int findEmpty( final Object[] l )
|
||||
{
|
||||
for( int x = 0; x < l.length; x++ )
|
||||
|
@ -1142,6 +896,7 @@ public class Platform
|
|||
|
||||
/**
|
||||
* Returns a random element from the given collection.
|
||||
*
|
||||
* @return null if the collection is empty
|
||||
*/
|
||||
@Nullable
|
||||
|
@ -1371,102 +1126,6 @@ public class Platform
|
|||
return I18n.translateToLocal( string );
|
||||
}
|
||||
|
||||
public static boolean isSameItemPrecise( @Nullable final ItemStack is, @Nullable final ItemStack filter )
|
||||
{
|
||||
return isSameItem( is, filter ) && sameStackStags( is, filter );
|
||||
}
|
||||
|
||||
public static boolean isSameItemFuzzy( final ItemStack a, final ItemStack b, final FuzzyMode mode )
|
||||
{
|
||||
if( a == null && b == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( a == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( b == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( a.itemID != 0 && b.itemID != 0 && a.isItemStackDamageable() && ! a.getHasSubtypes() && a.itemID ==
|
||||
* b.itemID ) { return (a.getItemDamage() > 0) == (b.getItemDamage() > 0); }
|
||||
*/
|
||||
|
||||
// test damageable items..
|
||||
if( a.getItem() != null && b.getItem() != null && a.getItem().isDamageable() && a.getItem() == b.getItem() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( mode == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
final Item ai = a.getItem();
|
||||
final Item bi = b.getItem();
|
||||
|
||||
return ( ai.getDurabilityForDisplay( a ) > 1 ) == ( bi.getDurabilityForDisplay( b ) > 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final Item ai = a.getItem();
|
||||
final Item bi = b.getItem();
|
||||
|
||||
final float percentDamagedOfA = 1.0f - (float) ai.getDurabilityForDisplay( a );
|
||||
final float percentDamagedOfB = 1.0f - (float) bi.getDurabilityForDisplay( b );
|
||||
|
||||
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
if( mode == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final float percentDamagedOfA = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
||||
final float percentDamagedOfB = (float) b.getItemDamage() / (float) b.getMaxDamage();
|
||||
|
||||
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final OreReference aOR = OreHelper.INSTANCE.isOre( a );
|
||||
final OreReference bOR = OreHelper.INSTANCE.isOre( b );
|
||||
|
||||
if( OreHelper.INSTANCE.sameOre( aOR, bOR ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* // test ore dictionary.. int OreID = getOreID( a ); if ( OreID != -1 ) return OreID == getOreID( b );
|
||||
* if ( Mode != FuzzyMode.IGNORE_ALL ) { if ( a.hasTagCompound() && !isShared( a.getTagCompound() ) ) { a =
|
||||
* Platform.getSharedItemStack( AEItemStack.create( a ) ); }
|
||||
* if ( b.hasTagCompound() && !isShared( b.getTagCompound() ) ) { b = Platform.getSharedItemStack(
|
||||
* AEItemStack.create( b ) ); }
|
||||
* // test regular items with damage values and what not... if ( isShared( a.getTagCompound() ) && isShared(
|
||||
* b.getTagCompound() ) && a.itemID == b.itemID ) { return ((AppEngSharedNBTTagCompound)
|
||||
* a.getTagCompound()).compareFuzzyWithRegistry( (AppEngSharedNBTTagCompound) b.getTagCompound() ); } }
|
||||
*/
|
||||
|
||||
return a.isItemEqual( b );
|
||||
}
|
||||
|
||||
public static LookDirection getPlayerRay( final EntityPlayer playerIn, final float eyeOffset )
|
||||
{
|
||||
double reachDistance = 5.0d;
|
||||
|
@ -1982,12 +1641,12 @@ public class Platform
|
|||
for( final IAEItemStack x : items )
|
||||
{
|
||||
final ItemStack sh = x.getItemStack();
|
||||
if( ( Platform.isSameItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !Platform.isSameItem( sh, output ) )
|
||||
if( ( Platform.itemComparisons().isEqualItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !Platform.itemComparisons().isEqualItem( sh, output ) )
|
||||
{ // Platform.isSameItemType( sh, providedTemplate )
|
||||
final ItemStack cp = Platform.cloneItemStack( sh );
|
||||
cp.stackSize = 1;
|
||||
ci.setInventorySlotContents( slot, cp );
|
||||
if( r.matches( ci, w ) && Platform.isSameItem( r.getCraftingResult( ci ), output ) )
|
||||
if( r.matches( ci, w ) && Platform.itemComparisons().isEqualItem( r.getCraftingResult( ci ), output ) )
|
||||
{
|
||||
final IAEItemStack ax = x.copy();
|
||||
ax.setStackSize( 1 );
|
||||
|
@ -2009,24 +1668,6 @@ public class Platform
|
|||
return null;
|
||||
}
|
||||
|
||||
public static boolean isSameItemType( final ItemStack that, final ItemStack other )
|
||||
{
|
||||
if( that != null && other != null && that.getItem() == other.getItem() )
|
||||
{
|
||||
if( that.isItemStackDamageable() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return that.getItemDamage() == other.getItemDamage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSameItem( @Nullable final ItemStack left, @Nullable final ItemStack right )
|
||||
{
|
||||
return left != null && right != null && left.isItemEqual( right );
|
||||
}
|
||||
|
||||
public static ItemStack cloneItemStack( final ItemStack a )
|
||||
{
|
||||
return a.copy();
|
||||
|
@ -2097,22 +1738,22 @@ public class Platform
|
|||
{
|
||||
if( parts.cableGlass().sameAs( AEColor.TRANSPARENT, stack ) )
|
||||
{
|
||||
return Collections.singletonList(stack);
|
||||
return Collections.singletonList( stack );
|
||||
}
|
||||
|
||||
if( parts.cableCovered().sameAs( AEColor.TRANSPARENT, stack ) )
|
||||
{
|
||||
return Collections.singletonList(stack);
|
||||
return Collections.singletonList( stack );
|
||||
}
|
||||
|
||||
if( parts.cableSmart().sameAs( AEColor.TRANSPARENT, stack ) )
|
||||
{
|
||||
return Collections.singletonList(stack);
|
||||
return Collections.singletonList( stack );
|
||||
}
|
||||
|
||||
if( parts.cableDense().sameAs( AEColor.TRANSPARENT, stack ) )
|
||||
{
|
||||
return Collections.singletonList(stack);
|
||||
return Collections.singletonList( stack );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,443 @@
|
|||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.util.helpers;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.item.AESharedNBT;
|
||||
import appeng.util.item.OreHelper;
|
||||
import appeng.util.item.OreReference;
|
||||
|
||||
|
||||
/**
|
||||
* A helper class for comparing {@link Item}, {@link ItemStack} or NBT
|
||||
*
|
||||
*/
|
||||
public class ItemComparisonHelper
|
||||
{
|
||||
|
||||
private static Field tagList;
|
||||
|
||||
/**
|
||||
* Compare the two {@link ItemStack}s based on the same {@link Item} and damage value.
|
||||
*
|
||||
* In case of the item being damageable, only the {@link Item} will be considered.
|
||||
* If not it will also compare both damage values.
|
||||
*
|
||||
* Ignores NBT.
|
||||
*
|
||||
* @return true, if both are equal.
|
||||
*/
|
||||
public boolean isEqualItemType( final ItemStack that, final ItemStack other )
|
||||
{
|
||||
if( that != null && other != null && that.getItem() == other.getItem() )
|
||||
{
|
||||
if( that.isItemStackDamageable() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return that.getItemDamage() == other.getItemDamage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around {@link ItemStack#isItemEqual(ItemStack)}.
|
||||
*
|
||||
* The benefit is to compare two null item stacks, without any additional null checks.
|
||||
*
|
||||
* Ignores NBT.
|
||||
*
|
||||
* @return true, if both are equal.
|
||||
*/
|
||||
public boolean isEqualItem( @Nullable final ItemStack left, @Nullable final ItemStack right )
|
||||
{
|
||||
return left != null && right != null && left.isItemEqual( right );
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two {@link ItemStack} and their NBT tag for equality.
|
||||
*
|
||||
* Use this when a precise check is required and the same item is required.
|
||||
* Not just something with different NBT tags.
|
||||
*
|
||||
* @return true, if both are identical.
|
||||
*/
|
||||
public boolean isSameItem( @Nullable final ItemStack is, @Nullable final ItemStack filter )
|
||||
{
|
||||
return isEqualItem( is, filter ) && hasSameNbtTag( is, filter );
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link ItemComparisonHelper#isEqualItem(ItemStack, ItemStack)},
|
||||
* but it can further check, if both match the same {@link FuzzyMode}
|
||||
* or are considered equal by the {@link OreDictionary}
|
||||
*
|
||||
* @param mode how to compare the two {@link ItemStack}s
|
||||
* @return true, if both are matching the mode or considered equal by the {@link OreDictionary}
|
||||
*/
|
||||
public boolean isFuzzyEqualItem( final ItemStack a, final ItemStack b, final FuzzyMode mode )
|
||||
{
|
||||
if( a == null && b == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( a == null || b == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( a.itemID != 0 && b.itemID != 0 && a.isItemStackDamageable() && ! a.getHasSubtypes() && a.itemID ==
|
||||
* b.itemID ) { return (a.getItemDamage() > 0) == (b.getItemDamage() > 0); }
|
||||
*/
|
||||
|
||||
// test damageable items..
|
||||
if( a.getItem() != null && b.getItem() != null && a.getItem().isDamageable() && a.getItem() == b.getItem() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( mode == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
final Item ai = a.getItem();
|
||||
final Item bi = b.getItem();
|
||||
|
||||
return ( ai.getDurabilityForDisplay( a ) > 1 ) == ( bi.getDurabilityForDisplay( b ) > 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final Item ai = a.getItem();
|
||||
final Item bi = b.getItem();
|
||||
|
||||
final float percentDamagedOfA = 1.0f - (float) ai.getDurabilityForDisplay( a );
|
||||
final float percentDamagedOfB = 1.0f - (float) bi.getDurabilityForDisplay( b );
|
||||
|
||||
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
if( mode == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final float percentDamagedOfA = (float) a.getItemDamage() / (float) a.getMaxDamage();
|
||||
final float percentDamagedOfB = (float) b.getItemDamage() / (float) b.getMaxDamage();
|
||||
|
||||
return ( percentDamagedOfA > mode.breakPoint ) == ( percentDamagedOfB > mode.breakPoint );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final OreReference aOR = OreHelper.INSTANCE.isOre( a );
|
||||
final OreReference bOR = OreHelper.INSTANCE.isOre( b );
|
||||
|
||||
if( OreHelper.INSTANCE.sameOre( aOR, bOR ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* // test ore dictionary.. int OreID = getOreID( a ); if ( OreID != -1 ) return OreID == getOreID( b );
|
||||
* if ( Mode != FuzzyMode.IGNORE_ALL ) { if ( a.hasTagCompound() && !isShared( a.getTagCompound() ) ) { a =
|
||||
* Platform.getSharedItemStack( AEItemStack.create( a ) ); }
|
||||
* if ( b.hasTagCompound() && !isShared( b.getTagCompound() ) ) { b = Platform.getSharedItemStack(
|
||||
* AEItemStack.create( b ) ); }
|
||||
* // test regular items with damage values and what not... if ( isShared( a.getTagCompound() ) && isShared(
|
||||
* b.getTagCompound() ) && a.itemID == b.itemID ) { return ((AppEngSharedNBTTagCompound)
|
||||
* a.getTagCompound()).compareFuzzyWithRegistry( (AppEngSharedNBTTagCompound) b.getTagCompound() ); } }
|
||||
*/
|
||||
|
||||
return a.isItemEqual( b );
|
||||
}
|
||||
|
||||
/**
|
||||
* recursive test for NBT Equality, this was faster then trying to compare / generate hashes, its also more reliable
|
||||
* then the vanilla version which likes to fail when NBT Compound data changes order, it is pretty expensive
|
||||
* performance wise, so try an use shared tag compounds as long as the system remains in AE.
|
||||
*/
|
||||
public boolean isNbtTagEqual( final NBTBase left, final NBTBase right )
|
||||
{
|
||||
// same type?
|
||||
final byte id = left.getId();
|
||||
if( id == right.getId() )
|
||||
{
|
||||
switch( id )
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
final NBTTagCompound ctA = (NBTTagCompound) left;
|
||||
final NBTTagCompound ctB = (NBTTagCompound) right;
|
||||
|
||||
final Set<String> cA = ctA.getKeySet();
|
||||
final Set<String> cB = ctB.getKeySet();
|
||||
|
||||
if( cA.size() != cB.size() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( final String name : cA )
|
||||
{
|
||||
final NBTBase tag = ctA.getTag( name );
|
||||
final NBTBase aTag = ctB.getTag( name );
|
||||
if( aTag == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !isNbtTagEqual( tag, aTag ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 9: // ) // A instanceof NBTTagList )
|
||||
{
|
||||
final NBTTagList lA = (NBTTagList) left;
|
||||
final NBTTagList lB = (NBTTagList) right;
|
||||
if( lA.tagCount() != lB.tagCount() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<NBTBase> tag = tagList( lA );
|
||||
final List<NBTBase> aTag = tagList( lB );
|
||||
if( tag.size() != aTag.size() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int x = 0; x < tag.size(); x++ )
|
||||
{
|
||||
if( aTag.get( x ) == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !isNbtTagEqual( tag.get( x ), aTag.get( x ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
case 1: // NBTTagByte
|
||||
return ( (NBTPrimitive) left ).getByte() == ( (NBTPrimitive) right ).getByte();
|
||||
|
||||
case 4: // NBTTagLong
|
||||
return ( (NBTPrimitive) left ).getLong() == ( (NBTPrimitive) right ).getLong();
|
||||
|
||||
case 8: // NBTTagString
|
||||
return ( (NBTTagString) left ).getString().equals( ( (NBTTagString) right ).getString() );
|
||||
|
||||
case 6: // NBTTagDouble
|
||||
return ( (NBTPrimitive) left ).getDouble() == ( (NBTPrimitive) right ).getDouble();
|
||||
|
||||
case 5: // NBTTagFloat
|
||||
return ( (NBTPrimitive) left ).getFloat() == ( (NBTPrimitive) right ).getFloat();
|
||||
|
||||
case 3: // NBTTagInt
|
||||
return ( (NBTPrimitive) left ).getInt() == ( (NBTPrimitive) right ).getInt();
|
||||
|
||||
default:
|
||||
return left.equals( right );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unordered hash of NBT Data, used to work thought huge piles fast, but ignores the order just in case MC
|
||||
* decided to change it... WHICH IS BAD...
|
||||
*/
|
||||
public int createUnorderedNbtHash( final NBTBase nbt )
|
||||
{
|
||||
// same type?
|
||||
int hash = 0;
|
||||
final byte id = nbt.getId();
|
||||
hash += id;
|
||||
switch( id )
|
||||
{
|
||||
case 10:
|
||||
{
|
||||
final NBTTagCompound ctA = (NBTTagCompound) nbt;
|
||||
|
||||
final Set<String> cA = ctA.getKeySet();
|
||||
|
||||
for( final String name : cA )
|
||||
{
|
||||
hash += name.hashCode() ^ createUnorderedNbtHash( ctA.getTag( name ) );
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
case 9: // ) // A instanceof NBTTagList )
|
||||
{
|
||||
final NBTTagList lA = (NBTTagList) nbt;
|
||||
hash += 9 * lA.tagCount();
|
||||
|
||||
final List<NBTBase> l = tagList( lA );
|
||||
for( int x = 0; x < l.size(); x++ )
|
||||
{
|
||||
hash += ( (Integer) x ).hashCode() ^ createUnorderedNbtHash( l.get( x ) );
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
case 1: // NBTTagByte
|
||||
return hash + ( (NBTPrimitive) nbt ).getByte();
|
||||
|
||||
case 4: // NBTTagLong
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getLong();
|
||||
|
||||
case 8: // NBTTagString
|
||||
return hash + ( (NBTTagString) nbt ).getString().hashCode();
|
||||
|
||||
case 6: // NBTTagDouble
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getDouble();
|
||||
|
||||
case 5: // NBTTagFloat
|
||||
return hash + (int) ( (NBTPrimitive) nbt ).getFloat();
|
||||
|
||||
case 3: // NBTTagInt
|
||||
return hash + ( (NBTPrimitive) nbt ).getInt();
|
||||
|
||||
default:
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lots of silliness to try and account for weird tag related junk, basically requires that two tags have at least
|
||||
* something in their tags before it wastes its time comparing them.
|
||||
*/
|
||||
private boolean hasSameNbtTag( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
if( a == null && b == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( a == null || b == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( a == b )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final NBTTagCompound ta = a.getTagCompound();
|
||||
final NBTTagCompound tb = b.getTagCompound();
|
||||
if( ta == tb )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if both tags are shared this is easy...
|
||||
if( AESharedNBT.isShared( ta ) && AESharedNBT.isShared( tb ) )
|
||||
{
|
||||
return ta == tb;
|
||||
}
|
||||
|
||||
return isNbtTagEqual( ta, tb );
|
||||
}
|
||||
|
||||
private List<NBTBase> tagList( final NBTTagList lB )
|
||||
{
|
||||
if( tagList == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
tagList = lB.getClass().getDeclaredField( "tagList" );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
try
|
||||
{
|
||||
tagList = lB.getClass().getDeclaredField( "field_74747_a" );
|
||||
}
|
||||
catch( final Throwable z )
|
||||
{
|
||||
AELog.debug( t );
|
||||
AELog.debug( z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
tagList.setAccessible( true );
|
||||
return (List<NBTBase>) tagList.get( lB );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return new ArrayList<NBTBase>();
|
||||
}
|
||||
|
||||
}
|
|
@ -50,7 +50,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
|||
for( int x = 0; x < s && amount > 0; x++ )
|
||||
{
|
||||
final ItemStack is = this.i.getStackInSlot( x );
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
int boundAmounts = amount;
|
||||
if( boundAmounts > is.stackSize )
|
||||
|
@ -108,7 +108,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
|||
for( int x = 0; x < s && amount > 0; x++ )
|
||||
{
|
||||
final ItemStack is = this.i.getStackInSlot( x );
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
int boundAmount = amount;
|
||||
if( boundAmount > is.stackSize )
|
||||
|
@ -147,7 +147,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
|||
for( int x = 0; x < s; x++ )
|
||||
{
|
||||
final ItemStack is = this.i.getStackInSlot( x );
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
int newAmount = amount;
|
||||
if( newAmount > is.stackSize )
|
||||
|
@ -197,7 +197,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
|||
{
|
||||
final ItemStack is = this.i.getStackInSlot( x );
|
||||
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
int boundAmount = amount;
|
||||
if( boundAmount > is.stackSize )
|
||||
|
@ -293,7 +293,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if( Platform.isSameItemPrecise( is, left ) && is.stackSize < perOperationLimit )
|
||||
else if( Platform.itemComparisons().isSameItem( is, left ) && is.stackSize < perOperationLimit )
|
||||
{
|
||||
final int room = perOperationLimit - is.stackSize;
|
||||
final int used = Math.min( left.stackSize, room );
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
|||
for( int slot = 0; slot < slots && amount > 0; slot++ )
|
||||
{
|
||||
final ItemStack is = itemHandler.getStackInSlot( slot );
|
||||
if( is == null || ( filter != null && !Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is == null || ( filter != null && !Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
|||
for( int slot = 0; slot < slots && amount > 0; slot++ )
|
||||
{
|
||||
final ItemStack is = itemHandler.getStackInSlot( slot );
|
||||
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
ItemStack extracted = itemHandler.extractItem( slot, amount, true );
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
|||
for( int slot = 0; slot < slots && extracted == null; slot++ )
|
||||
{
|
||||
final ItemStack is = itemHandler.getStackInSlot( slot );
|
||||
if( is == null || ( filter != null && !Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
|||
for( int slot = 0; slot < slots && extracted == null; slot++ )
|
||||
{
|
||||
final ItemStack is = itemHandler.getStackInSlot( slot );
|
||||
if( is == null || ( filter != null && !Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
|||
{
|
||||
ItemStack is = itemHandler.getStackInSlot( slot );
|
||||
|
||||
if( is == null || Platform.isSameItemPrecise( is, left ) )
|
||||
if( is == null || Platform.itemComparisons().isSameItem( is, left ) )
|
||||
{
|
||||
left = itemHandler.insertItem( slot, left, simulate );
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AdaptorList extends InventoryAdaptor
|
|||
for( int x = 0; x < s; x++ )
|
||||
{
|
||||
final ItemStack is = this.i.get( x );
|
||||
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public class AdaptorList extends InventoryAdaptor
|
|||
{
|
||||
for( final ItemStack is : this.i )
|
||||
{
|
||||
if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) )
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ public class AdaptorList extends InventoryAdaptor
|
|||
for( int x = 0; x < s; x++ )
|
||||
{
|
||||
final ItemStack is = this.i.get( x );
|
||||
if( is != null && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ public class AdaptorList extends InventoryAdaptor
|
|||
{
|
||||
for( final ItemStack is : this.i )
|
||||
{
|
||||
if( is != null && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) )
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ public class AdaptorList extends InventoryAdaptor
|
|||
|
||||
for( final ItemStack is : this.i )
|
||||
{
|
||||
if( Platform.isSameItem( is, left ) )
|
||||
if( Platform.itemComparisons().isEqualItem( is, left ) )
|
||||
{
|
||||
is.stackSize += left.stackSize;
|
||||
return null;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
|
||||
if( filter == null || Platform.isSameItemPrecise( filter, hand ) )
|
||||
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
|
@ -77,7 +77,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
|
||||
if( filter == null || Platform.isSameItemPrecise( filter, hand ) )
|
||||
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
|
@ -96,7 +96,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
|
||||
if( filter == null || Platform.isSameItemFuzzy( filter, hand, fuzzyMode ) )
|
||||
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
|
@ -121,7 +121,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
|
||||
if( filter == null || Platform.isSameItemFuzzy( filter, hand, fuzzyMode ) )
|
||||
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
|
@ -154,7 +154,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
|
||||
final ItemStack hand = this.player.inventory.getItemStack();
|
||||
|
||||
if( hand != null && !Platform.isSameItemPrecise( toBeAdded, hand ) )
|
||||
if( hand != null && !Platform.itemComparisons().isSameItem( toBeAdded, hand ) )
|
||||
{
|
||||
return toBeAdded;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
|||
return null;
|
||||
}
|
||||
|
||||
if( hand != null && !Platform.isSameItem( toBeSimulated, hand ) )
|
||||
if( hand != null && !Platform.itemComparisons().isEqualItem( toBeSimulated, hand ) )
|
||||
{
|
||||
return toBeSimulated;
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
|||
return ta == tb;
|
||||
}
|
||||
|
||||
return Platform.NBTEqualityTest( ta, tb );
|
||||
return Platform.itemComparisons().isNbtTagEqual( ta, tb );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -100,7 +100,7 @@ public class AEItemDef
|
|||
|
||||
if( this.getTagCompound() != null && otherStack.hasTagCompound() )
|
||||
{
|
||||
return Platform.NBTEqualityTest( this.getTagCompound(), otherStack.getTagCompound() );
|
||||
return Platform.itemComparisons().isNbtTagEqual( this.getTagCompound(), otherStack.getTagCompound() );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -522,7 +522,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
|||
return ta == tb;
|
||||
}
|
||||
|
||||
return Platform.NBTEqualityTest( ta, tb );
|
||||
return Platform.itemComparisons().isNbtTagEqual( ta, tb );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -136,7 +136,7 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
|
|||
x.setTag( name, c.getTag( name ).copy() );
|
||||
}
|
||||
|
||||
x.hash = Platform.NBTOrderlessHash( c );
|
||||
x.hash = Platform.itemComparisons().createUnorderedNbtHash( c );
|
||||
|
||||
final ItemStack isc = new ItemStack( itemID, 1, damageValue );
|
||||
isc.setTagCompound( c );
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SharedSearchObject
|
|||
public SharedSearchObject( final Item itemID, final int damageValue, final NBTTagCompound tagCompound )
|
||||
{
|
||||
this.def = ( damageValue << Platform.DEF_OFFSET ) | Item.REGISTRY.getIDForObject( itemID );
|
||||
this.hash = Platform.NBTOrderlessHash( tagCompound );
|
||||
this.hash = Platform.itemComparisons().createUnorderedNbtHash( tagCompound );
|
||||
this.setCompound( tagCompound );
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SharedSearchObject
|
|||
final SharedSearchObject other = (SharedSearchObject) obj;
|
||||
if( this.def == other.def && this.hash == other.hash )
|
||||
{
|
||||
return Platform.NBTEqualityTest( this.getCompound(), other.getCompound() );
|
||||
return Platform.itemComparisons().isNbtTagEqual( this.getCompound(), other.getCompound() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue