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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user