Fixed crash when shift-clicking items
This commit is contained in:
parent
f5068bda2b
commit
ab262c9b54
1 changed files with 77 additions and 2 deletions
|
@ -6,6 +6,7 @@ import net.minecraft.inventory.Container;
|
|||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import resonantinduction.api.IBattery;
|
||||
import resonantinduction.battery.BatteryManager.SlotBattery;
|
||||
import resonantinduction.battery.BatteryManager.SlotOut;
|
||||
|
||||
|
@ -51,9 +52,9 @@ public class ContainerBattery extends Container
|
|||
ItemStack itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
inventoryItemStacks.set(slotID, itemstack1);
|
||||
|
||||
for (int j = 0; j < this.crafters.size(); ++j)
|
||||
for (int j = 0; j < crafters.size(); ++j)
|
||||
{
|
||||
((ICrafting)this.crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
((ICrafting)crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,4 +74,78 @@ public class ContainerBattery extends Container
|
|||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||
{
|
||||
ItemStack stack = null;
|
||||
Slot currentSlot = (Slot)inventorySlots.get(slotID);
|
||||
|
||||
if(currentSlot != null && currentSlot.getHasStack())
|
||||
{
|
||||
ItemStack slotStack = currentSlot.getStack();
|
||||
stack = slotStack.copy();
|
||||
|
||||
if(slotID == 0 || slotID == 1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID == 2 || slotID == 3)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotStack.getItem() instanceof IBattery)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(slotID >= 4 && slotID <= 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slotID > 30)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == 0)
|
||||
{
|
||||
currentSlot.putStack((ItemStack)null);
|
||||
}
|
||||
else {
|
||||
currentSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(slotStack.stackSize == stack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
currentSlot.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue