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:
yueh
2016-11-04 09:27:52 +01:00
committed by GitHub
parent f85ab7ddc2
commit 1e20086799
53 changed files with 555 additions and 471 deletions
@@ -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;
}