Program: 30531
Project: 30531
Buggy source:
public void doAction(EntityPlayerMP player,InventoryAction action,int slot,long id){
  if (slot >= 0 && slot < inventorySlots.size()) {
    Slot s=getSlot(slot);
    if (s instanceof SlotCraftingTerm) {
switch (action) {
case CRAFT_SHIFT:
case CRAFT_ITEM:
case CRAFT_STACK:
        ((SlotCraftingTerm)s).doClick(action,player);
      updateHeld(player);
default :
  }
}
if (s instanceof SlotFake) {
  ItemStack hand=player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SETDOWN:
    if (hand == null)     s.putStack(null);
 else     s.putStack(hand.copy());
  break;
case SPLIT_OR_PLACESINGLE:
ItemStack is=s.getStack();
if (is != null) {
if (hand == null) is.stackSize--;
 else if (hand.isItemEqual(is)) is.stackSize=Math.min(is.getMaxStackSize(),is.stackSize + 1);
 else {
  is=hand.copy();
  is.stackSize=1;
}
s.putStack(is);
}
 else if (hand != null) {
is=hand.copy();
is.stackSize=1;
s.putStack(is);
}
break;
case CREATIVE_DUPLICATE:
case MOVE_REGION:
case SHIFT_CLICK:
default :
break;
}
}
if (action == InventoryAction.MOVE_REGION) {
List<Slot> from=new LinkedList();
for (Object j : inventorySlots) {
if (j instanceof Slot && j.getClass() == s.getClass()) from.add((Slot)j);
}
for (Slot fr : from) transferStackInSlot(player,fr.slotNumber);
}
return;
}
IAEItemStack slotItem=getTargetStack();
switch (action) {
case SHIFT_CLICK:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
ItemStack myItem=ais.getItemStack();
ais.setStackSize(myItem.getMaxStackSize());
InventoryAdaptor adp=InventoryAdaptor.getAdaptor(player,ForgeDirection.UNKNOWN);
myItem.stackSize=(int)ais.getStackSize();
myItem=adp.simulateAdd(myItem);
if (myItem != null) ais.setStackSize(ais.getStackSize() - myItem.stackSize);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) adp.addItems(ais.getItemStack());
}
break;
case ROLLDOWN:
if (powerSrc == null || cellInv == null) return;
int releaseQty=1;
ItemStack isg=player.inventory.getItemStack();
if (isg != null && releaseQty > 0) {
IAEItemStack ais=AEApi.instance().storage().createItemStack(isg);
ais.setStackSize(1);
IAEItemStack extracted=ais.copy();
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais == null) {
InventoryAdaptor ia=new AdaptorPlayerHand(player);
ItemStack fail=ia.removeItems(1,extracted.getItemStack(),null);
if (fail == null) cellInv.extractItems(extracted,Actionable.MODULATE,mySrc);
updateHeld(player);
}
}
break;
case ROLLUP:
case PICKUP_SINGLE:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
int liftQty=1;
ItemStack isgg=player.inventory.getItemStack();
if (isgg != null) {
if (isgg.stackSize >= isgg.getMaxStackSize()) liftQty=0;
if (!Platform.isSameItemPrecise(slotItem.getItemStack(),isgg)) liftQty=0;
}
if (liftQty > 0) {
IAEItemStack ais=slotItem.copy();
ais.setStackSize(1);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) {
InventoryAdaptor ia=new AdaptorPlayerHand(player);
ItemStack fail=ia.addItems(ais.getItemStack());
if (fail != null) cellInv.injectItems(ais,Actionable.MODULATE,mySrc);
updateHeld(player);
}
}
}
break;
case PICKUP_OR_SETDOWN:
if (powerSrc == null || cellInv == null) return;
if (player.inventory.getItemStack() == null) {
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
ais.setStackSize(ais.getItemStack().getMaxStackSize());
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
}
 else {
IAEItemStack ais=AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
break;
case SPLIT_OR_PLACESINGLE:
if (powerSrc == null || cellInv == null) return;
if (player.inventory.getItemStack() == null) {
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
long maxSize=ais.getItemStack().getMaxStackSize();
ais.setStackSize(maxSize);
ais=cellInv.extractItems(ais,Actionable.SIMULATE,mySrc);
if (ais != null) {
long stackSize=Math.min(maxSize,ais.getStackSize());
ais.setStackSize((stackSize + 1) >> 1);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
}
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
}
 else {
IAEItemStack ais=AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
ais.setStackSize(1);
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais == null) {
ItemStack is=player.inventory.getItemStack();
is.stackSize--;
if (is.stackSize <= 0) player.inventory.setItemStack(null);
updateHeld(player);
}
}
break;
case CREATIVE_DUPLICATE:
if (player.capabilities.isCreativeMode && slotItem != null) {
ItemStack is=slotItem.getItemStack();
is.stackSize=is.getMaxStackSize();
player.inventory.setItemStack(is);
updateHeld(player);
}
break;
case MOVE_REGION:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
int playerInv=9 * 4;
for (int slotNum=0; slotNum < playerInv; slotNum++) {
IAEItemStack ais=slotItem.copy();
ItemStack myItem=ais.getItemStack();
ais.setStackSize(myItem.getMaxStackSize());
InventoryAdaptor adp=InventoryAdaptor.getAdaptor(player,ForgeDirection.UNKNOWN);
myItem.stackSize=(int)ais.getStackSize();
myItem=adp.simulateAdd(myItem);
if (myItem != null) ais.setStackSize(ais.getStackSize() - myItem.stackSize);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) adp.addItems(ais.getItemStack());
 else return;
}
}
break;
default :
break;
}
}

Fixed version (ground truth):
public void doAction(EntityPlayerMP player,InventoryAction action,int slot,long id){
  if (slot >= 0 && slot < inventorySlots.size()) {
    Slot s=getSlot(slot);
    if (s instanceof SlotCraftingTerm) {
switch (action) {
case CRAFT_SHIFT:
case CRAFT_ITEM:
case CRAFT_STACK:
        ((SlotCraftingTerm)s).doClick(action,player);
      updateHeld(player);
default :
  }
}
if (s instanceof SlotFake) {
  ItemStack hand=player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SETDOWN:
    if (hand == null)     s.putStack(null);
 else     s.putStack(hand.copy());
  break;
case PLACE_SINGLE:
if (hand != null) {
  ItemStack is=hand.copy();
  is.stackSize=1;
  s.putStack(is);
}
break;
case SPLIT_OR_PLACESINGLE:
ItemStack is=s.getStack();
if (is != null) {
if (hand == null) is.stackSize--;
 else if (hand.isItemEqual(is)) is.stackSize=Math.min(is.getMaxStackSize(),is.stackSize + 1);
 else {
is=hand.copy();
is.stackSize=1;
}
s.putStack(is);
}
 else if (hand != null) {
is=hand.copy();
is.stackSize=1;
s.putStack(is);
}
break;
case CREATIVE_DUPLICATE:
case MOVE_REGION:
case SHIFT_CLICK:
default :
break;
}
}
if (action == InventoryAction.MOVE_REGION) {
List<Slot> from=new LinkedList();
for (Object j : inventorySlots) {
if (j instanceof Slot && j.getClass() == s.getClass()) from.add((Slot)j);
}
for (Slot fr : from) transferStackInSlot(player,fr.slotNumber);
}
return;
}
IAEItemStack slotItem=getTargetStack();
switch (action) {
case SHIFT_CLICK:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
ItemStack myItem=ais.getItemStack();
ais.setStackSize(myItem.getMaxStackSize());
InventoryAdaptor adp=InventoryAdaptor.getAdaptor(player,ForgeDirection.UNKNOWN);
myItem.stackSize=(int)ais.getStackSize();
myItem=adp.simulateAdd(myItem);
if (myItem != null) ais.setStackSize(ais.getStackSize() - myItem.stackSize);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) adp.addItems(ais.getItemStack());
}
break;
case ROLLDOWN:
if (powerSrc == null || cellInv == null) return;
int releaseQty=1;
ItemStack isg=player.inventory.getItemStack();
if (isg != null && releaseQty > 0) {
IAEItemStack ais=AEApi.instance().storage().createItemStack(isg);
ais.setStackSize(1);
IAEItemStack extracted=ais.copy();
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais == null) {
InventoryAdaptor ia=new AdaptorPlayerHand(player);
ItemStack fail=ia.removeItems(1,extracted.getItemStack(),null);
if (fail == null) cellInv.extractItems(extracted,Actionable.MODULATE,mySrc);
updateHeld(player);
}
}
break;
case ROLLUP:
case PICKUP_SINGLE:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
int liftQty=1;
ItemStack isgg=player.inventory.getItemStack();
if (isgg != null) {
if (isgg.stackSize >= isgg.getMaxStackSize()) liftQty=0;
if (!Platform.isSameItemPrecise(slotItem.getItemStack(),isgg)) liftQty=0;
}
if (liftQty > 0) {
IAEItemStack ais=slotItem.copy();
ais.setStackSize(1);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) {
InventoryAdaptor ia=new AdaptorPlayerHand(player);
ItemStack fail=ia.addItems(ais.getItemStack());
if (fail != null) cellInv.injectItems(ais,Actionable.MODULATE,mySrc);
updateHeld(player);
}
}
}
break;
case PICKUP_OR_SETDOWN:
if (powerSrc == null || cellInv == null) return;
if (player.inventory.getItemStack() == null) {
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
ais.setStackSize(ais.getItemStack().getMaxStackSize());
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
}
 else {
IAEItemStack ais=AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
break;
case SPLIT_OR_PLACESINGLE:
if (powerSrc == null || cellInv == null) return;
if (player.inventory.getItemStack() == null) {
if (slotItem != null) {
IAEItemStack ais=slotItem.copy();
long maxSize=ais.getItemStack().getMaxStackSize();
ais.setStackSize(maxSize);
ais=cellInv.extractItems(ais,Actionable.SIMULATE,mySrc);
if (ais != null) {
long stackSize=Math.min(maxSize,ais.getStackSize());
ais.setStackSize((stackSize + 1) >> 1);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
}
if (ais != null) player.inventory.setItemStack(ais.getItemStack());
 else player.inventory.setItemStack(null);
updateHeld(player);
}
}
 else {
IAEItemStack ais=AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
ais.setStackSize(1);
ais=Platform.poweredInsert(powerSrc,cellInv,ais,mySrc);
if (ais == null) {
ItemStack is=player.inventory.getItemStack();
is.stackSize--;
if (is.stackSize <= 0) player.inventory.setItemStack(null);
updateHeld(player);
}
}
break;
case CREATIVE_DUPLICATE:
if (player.capabilities.isCreativeMode && slotItem != null) {
ItemStack is=slotItem.getItemStack();
is.stackSize=is.getMaxStackSize();
player.inventory.setItemStack(is);
updateHeld(player);
}
break;
case MOVE_REGION:
if (powerSrc == null || cellInv == null) return;
if (slotItem != null) {
int playerInv=9 * 4;
for (int slotNum=0; slotNum < playerInv; slotNum++) {
IAEItemStack ais=slotItem.copy();
ItemStack myItem=ais.getItemStack();
ais.setStackSize(myItem.getMaxStackSize());
InventoryAdaptor adp=InventoryAdaptor.getAdaptor(player,ForgeDirection.UNKNOWN);
myItem.stackSize=(int)ais.getStackSize();
myItem=adp.simulateAdd(myItem);
if (myItem != null) ais.setStackSize(ais.getStackSize() - myItem.stackSize);
ais=Platform.poweredExtraction(powerSrc,cellInv,ais,mySrc);
if (ais != null) adp.addItems(ais.getItemStack());
 else return;
}
}
break;
default :
break;
}
}