Port to 1.11
This commit is contained in:
@@ -53,9 +53,9 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
int boundAmounts = amount;
|
||||
if( boundAmounts > is.stackSize )
|
||||
if( boundAmounts > is.getCount() )
|
||||
{
|
||||
boundAmounts = is.stackSize;
|
||||
boundAmounts = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -68,16 +68,16 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
{
|
||||
rv = is.copy();
|
||||
filter = rv;
|
||||
rv.stackSize = boundAmounts;
|
||||
rv.setCount( boundAmounts );
|
||||
amount -= boundAmounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv.stackSize += boundAmounts;
|
||||
rv.grow( boundAmounts );
|
||||
amount -= boundAmounts;
|
||||
}
|
||||
|
||||
if( is.stackSize == boundAmounts )
|
||||
if( is.getCount() == boundAmounts )
|
||||
{
|
||||
this.i.setInventorySlotContents( x, null );
|
||||
this.i.markDirty();
|
||||
@@ -85,7 +85,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
else
|
||||
{
|
||||
final ItemStack po = is.copy();
|
||||
po.stackSize -= boundAmounts;
|
||||
po.grow( -boundAmounts );
|
||||
this.i.setInventorySlotContents( x, po );
|
||||
this.i.markDirty();
|
||||
}
|
||||
@@ -111,9 +111,9 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
int boundAmount = amount;
|
||||
if( boundAmount > is.stackSize )
|
||||
if( boundAmount > is.getCount() )
|
||||
{
|
||||
boundAmount = is.stackSize;
|
||||
boundAmount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -125,12 +125,12 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
if( rv == null )
|
||||
{
|
||||
rv = is.copy();
|
||||
rv.stackSize = boundAmount;
|
||||
rv.setCount( boundAmount );
|
||||
amount -= boundAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv.stackSize += boundAmount;
|
||||
rv.grow( boundAmount );
|
||||
amount -= boundAmount;
|
||||
}
|
||||
}
|
||||
@@ -147,12 +147,13 @@ 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.itemComparisons().isFuzzyEqualItem( 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 )
|
||||
if( newAmount > is.getCount() )
|
||||
{
|
||||
newAmount = is.stackSize;
|
||||
newAmount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -163,9 +164,9 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
if( newAmount > 0 )
|
||||
{
|
||||
rv = is.copy();
|
||||
rv.stackSize = newAmount;
|
||||
rv.setCount( newAmount );
|
||||
|
||||
if( is.stackSize == rv.stackSize )
|
||||
if( is.getCount() == rv.getCount() )
|
||||
{
|
||||
this.i.setInventorySlotContents( x, null );
|
||||
this.i.markDirty();
|
||||
@@ -173,7 +174,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
else
|
||||
{
|
||||
final ItemStack po = is.copy();
|
||||
po.stackSize -= rv.stackSize;
|
||||
po.grow( -rv.getCount() );
|
||||
this.i.setInventorySlotContents( x, po );
|
||||
this.i.markDirty();
|
||||
}
|
||||
@@ -197,12 +198,13 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
{
|
||||
final ItemStack is = this.i.getStackInSlot( x );
|
||||
|
||||
if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( 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 )
|
||||
if( boundAmount > is.getCount() )
|
||||
{
|
||||
boundAmount = is.stackSize;
|
||||
boundAmount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -212,7 +214,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
if( boundAmount > 0 )
|
||||
{
|
||||
final ItemStack rv = is.copy();
|
||||
rv.stackSize = boundAmount;
|
||||
rv.setCount( boundAmount );
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -260,7 +262,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
*/
|
||||
private ItemStack addItems( final ItemStack itemsToAdd, final boolean modulate )
|
||||
{
|
||||
if( itemsToAdd == null || itemsToAdd.stackSize == 0 )
|
||||
if( itemsToAdd == null || itemsToAdd.getCount() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -273,14 +275,14 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
for( int slot = 0; slot < inventorySize; slot++ )
|
||||
{
|
||||
final ItemStack next = left.copy();
|
||||
next.stackSize = Math.min( perOperationLimit, next.stackSize );
|
||||
next.setCount( Math.min( perOperationLimit, next.getCount() ) );
|
||||
|
||||
if( this.i.isItemValidForSlot( slot, next ) )
|
||||
{
|
||||
final ItemStack is = this.i.getStackInSlot( slot );
|
||||
if( is == null )
|
||||
{
|
||||
left.stackSize -= next.stackSize;
|
||||
left.grow( -next.getCount() );
|
||||
|
||||
if( modulate )
|
||||
{
|
||||
@@ -288,25 +290,25 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
this.i.markDirty();
|
||||
}
|
||||
|
||||
if( left.stackSize <= 0 )
|
||||
if( left.getCount() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if( Platform.itemComparisons().isSameItem( is, left ) && is.stackSize < perOperationLimit )
|
||||
else if( Platform.itemComparisons().isSameItem( is, left ) && is.getCount() < perOperationLimit )
|
||||
{
|
||||
final int room = perOperationLimit - is.stackSize;
|
||||
final int used = Math.min( left.stackSize, room );
|
||||
final int room = perOperationLimit - is.getCount();
|
||||
final int used = Math.min( left.getCount(), room );
|
||||
|
||||
if( modulate )
|
||||
{
|
||||
is.stackSize += used;
|
||||
is.grow( used );
|
||||
this.i.setInventorySlotContents( slot, is );
|
||||
this.i.markDirty();
|
||||
}
|
||||
|
||||
left.stackSize -= used;
|
||||
if( left.stackSize <= 0 )
|
||||
left.grow( -used );
|
||||
if( left.getCount() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
// Use the first stack as a template for the result
|
||||
rv = extracted;
|
||||
filter = extracted;
|
||||
amount -= extracted.stackSize;
|
||||
amount -= extracted.getCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Subsequent stacks will just increase the extracted size
|
||||
rv.stackSize += extracted.stackSize;
|
||||
amount -= extracted.stackSize;
|
||||
rv.grow( extracted.getCount() );
|
||||
amount -= extracted.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
// Use the first stack as a template for the result
|
||||
rv = extracted.copy();
|
||||
filter = extracted;
|
||||
amount -= extracted.stackSize;
|
||||
amount -= extracted.getCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Subsequent stacks will just increase the extracted size
|
||||
rv.stackSize += extracted.stackSize;
|
||||
amount -= extracted.stackSize;
|
||||
rv.grow( extracted.getCount() );
|
||||
amount -= extracted.getCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,8 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
}
|
||||
|
||||
/**
|
||||
* For fuzzy extract, we will only ever extract one slot, since we're afraid of merging two item stacks with different damage values.
|
||||
* For fuzzy extract, we will only ever extract one slot, since we're afraid of merging two item stacks with
|
||||
* different damage values.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
|
||||
@@ -218,7 +219,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
|
||||
private ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate )
|
||||
{
|
||||
if( itemsToAdd == null || itemsToAdd.stackSize == 0 )
|
||||
if( itemsToAdd == null || itemsToAdd.getCount() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -233,7 +234,7 @@ public class AdaptorItemHandler extends InventoryAdaptor
|
||||
{
|
||||
left = itemHandler.insertItem( slot, left, simulate );
|
||||
|
||||
if( left == null || left.stackSize <= 0 )
|
||||
if( left == null || left.getCount() <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ public class AdaptorList extends InventoryAdaptor
|
||||
final ItemStack is = this.i.get( x );
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
if( amount > is.getCount() )
|
||||
{
|
||||
amount = is.stackSize;
|
||||
amount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -61,11 +61,11 @@ public class AdaptorList extends InventoryAdaptor
|
||||
if( amount > 0 )
|
||||
{
|
||||
final ItemStack rv = is.copy();
|
||||
rv.stackSize = amount;
|
||||
is.stackSize -= amount;
|
||||
rv.setCount( amount );
|
||||
is.grow( -amount );
|
||||
|
||||
// remove it..
|
||||
if( is.stackSize <= 0 )
|
||||
if( is.getCount() <= 0 )
|
||||
{
|
||||
this.i.remove( x );
|
||||
}
|
||||
@@ -84,9 +84,9 @@ public class AdaptorList extends InventoryAdaptor
|
||||
{
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
if( amount > is.getCount() )
|
||||
{
|
||||
amount = is.stackSize;
|
||||
amount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public class AdaptorList extends InventoryAdaptor
|
||||
if( amount > 0 )
|
||||
{
|
||||
final ItemStack rv = is.copy();
|
||||
rv.stackSize = amount;
|
||||
rv.setCount( amount );
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -113,9 +113,9 @@ public class AdaptorList extends InventoryAdaptor
|
||||
final ItemStack is = this.i.get( x );
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
if( amount > is.getCount() )
|
||||
{
|
||||
amount = is.stackSize;
|
||||
amount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -125,11 +125,11 @@ public class AdaptorList extends InventoryAdaptor
|
||||
if( amount > 0 )
|
||||
{
|
||||
final ItemStack rv = is.copy();
|
||||
rv.stackSize = amount;
|
||||
is.stackSize -= amount;
|
||||
rv.setCount( amount );
|
||||
is.grow( -amount );
|
||||
|
||||
// remove it..
|
||||
if( is.stackSize <= 0 )
|
||||
if( is.getCount() <= 0 )
|
||||
{
|
||||
this.i.remove( x );
|
||||
}
|
||||
@@ -148,9 +148,9 @@ public class AdaptorList extends InventoryAdaptor
|
||||
{
|
||||
if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) )
|
||||
{
|
||||
if( amount > is.stackSize )
|
||||
if( amount > is.getCount() )
|
||||
{
|
||||
amount = is.stackSize;
|
||||
amount = is.getCount();
|
||||
}
|
||||
if( destination != null && !destination.canInsert( is ) )
|
||||
{
|
||||
@@ -160,7 +160,7 @@ public class AdaptorList extends InventoryAdaptor
|
||||
if( amount > 0 )
|
||||
{
|
||||
final ItemStack rv = is.copy();
|
||||
rv.stackSize = amount;
|
||||
rv.setCount( amount );
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public class AdaptorList extends InventoryAdaptor
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if( toBeAdded.stackSize == 0 )
|
||||
if( toBeAdded.getCount() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class AdaptorList extends InventoryAdaptor
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( is, left ) )
|
||||
{
|
||||
is.stackSize += left.stackSize;
|
||||
is.grow( left.getCount() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
hand.stackSize -= amount;
|
||||
if( hand.stackSize <= 0 )
|
||||
result.setCount( hand.getCount() > amount ? amount : hand.getCount() );
|
||||
hand.grow( -amount );
|
||||
if( hand.getCount() <= 0 )
|
||||
{
|
||||
this.player.inventory.setItemStack( null );
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
result.setCount( hand.getCount() > amount ? amount : hand.getCount() );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
hand.stackSize -= amount;
|
||||
if( hand.stackSize <= 0 )
|
||||
result.setCount( hand.getCount() > amount ? amount : hand.getCount() );
|
||||
hand.grow( -amount );
|
||||
if( hand.getCount() <= 0 )
|
||||
{
|
||||
this.player.inventory.setItemStack( null );
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) )
|
||||
{
|
||||
final ItemStack result = hand.copy();
|
||||
result.stackSize = hand.stackSize > amount ? amount : hand.stackSize;
|
||||
result.setCount( hand.getCount() > amount ? amount : hand.getCount() );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if( toBeAdded.stackSize == 0 )
|
||||
if( toBeAdded.getCount() == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -168,15 +168,15 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
else
|
||||
{
|
||||
newHand = hand;
|
||||
original = hand.stackSize;
|
||||
newHand.stackSize += toBeAdded.stackSize;
|
||||
original = hand.getCount();
|
||||
newHand.grow( toBeAdded.getCount() );
|
||||
}
|
||||
|
||||
if( newHand.stackSize > newHand.getMaxStackSize() )
|
||||
if( newHand.getCount() > newHand.getMaxStackSize() )
|
||||
{
|
||||
newHand.stackSize = newHand.getMaxStackSize();
|
||||
newHand.setCount( newHand.getMaxStackSize() );
|
||||
final ItemStack B = toBeAdded.copy();
|
||||
B.stackSize -= newHand.stackSize - original;
|
||||
B.grow( -( newHand.getCount() - original ) );
|
||||
this.player.inventory.setItemStack( newHand );
|
||||
return B;
|
||||
}
|
||||
@@ -208,15 +208,15 @@ public class AdaptorPlayerHand extends InventoryAdaptor
|
||||
else
|
||||
{
|
||||
newHand = hand.copy();
|
||||
original = hand.stackSize;
|
||||
newHand.stackSize += toBeSimulated.stackSize;
|
||||
original = hand.getCount();
|
||||
newHand.grow( toBeSimulated.getCount() );
|
||||
}
|
||||
|
||||
if( newHand.stackSize > newHand.getMaxStackSize() )
|
||||
if( newHand.getCount() > newHand.getMaxStackSize() )
|
||||
{
|
||||
newHand.stackSize = newHand.getMaxStackSize();
|
||||
newHand.setCount( newHand.getMaxStackSize() );
|
||||
final ItemStack B = toBeSimulated.copy();
|
||||
B.stackSize -= newHand.stackSize - original;
|
||||
B.grow( -( newHand.getCount() - original ) );
|
||||
return B;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,9 @@ public class AdaptorPlayerInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer var1 )
|
||||
public boolean isUsableByPlayer( final EntityPlayer var1 )
|
||||
{
|
||||
return this.src.isUseableByPlayer( var1 );
|
||||
return this.src.isUsableByPlayer( var1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,4 +153,10 @@ public class AdaptorPlayerInventory implements IInventory
|
||||
{
|
||||
this.src.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.src.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,6 @@ public class IMEInventoryDestination implements IInventoryDestination
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return failed.getStackSize() != stack.stackSize;
|
||||
return failed.getStackSize() != stack.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer var1 )
|
||||
public boolean isUsableByPlayer( final EntityPlayer var1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -265,4 +265,11 @@ public class WrapperChainedInventory implements IInventory
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ public class WrapperInvSlot
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer entityplayer )
|
||||
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
|
||||
{
|
||||
return this.inv.isUseableByPlayer( entityplayer );
|
||||
return this.inv.isUsableByPlayer( entityplayer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,5 +164,12 @@ public class WrapperInvSlot
|
||||
{
|
||||
this.inv.setField( id, value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ public class WrapperInventoryRange implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer( final EntityPlayer var1 )
|
||||
public boolean isUsableByPlayer( final EntityPlayer var1 )
|
||||
{
|
||||
return this.src.isUseableByPlayer( var1 );
|
||||
return this.src.isUsableByPlayer( var1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,4 +206,11 @@ public class WrapperInventoryRange implements IInventory
|
||||
{
|
||||
this.slots = slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user