Fixed Bug: #0260 - Hotbar Keys + Inscriber

This commit is contained in:
AlgorithmX2
2014-03-29 18:36:37 -05:00
parent 740e9e27bf
commit 794177b8d2
6 changed files with 175 additions and 12 deletions
+63
View File
@@ -756,4 +756,67 @@ public abstract class AEBaseContainer extends Container
}
}
public void swapSlotContents(int slotA, int slotB)
{
Slot a = getSlot( slotA );
Slot b = getSlot( slotB );
// NPE protection...
if ( a == null || b == null )
return;
ItemStack isA = a.getStack();
ItemStack isB = b.getStack();
// something to do?
if ( isA == null && isB == null )
return;
// can take?
if ( isA != null && !a.canTakeStack( invPlayer.player ) )
return;
if ( isB != null && !b.canTakeStack( invPlayer.player ) )
return;
// swap valid?
if ( isB != null && !a.isItemValid( isB ) )
return;
if ( isA != null && !b.isItemValid( isA ) )
return;
ItemStack testA = isB == null ? null : isB.copy();
ItemStack testB = isA == null ? null : isA.copy();
// can put some back?
if ( testA != null && testA.stackSize > a.getSlotStackLimit() )
{
if ( testB != null )
return;
int totalA = testA.stackSize;
testA.stackSize = a.getSlotStackLimit();
testB = testA.copy();
testB.stackSize = totalA - testA.stackSize;
}
if ( testB != null && testB.stackSize > b.getSlotStackLimit() )
{
if ( testA != null )
return;
int totalB = testB.stackSize;
testB.stackSize = b.getSlotStackLimit();
testA = testB.copy();
testA.stackSize = totalB - testA.stackSize;
}
a.putStack( testA );
b.putStack( testB );
}
}