Program: 30766
Project: 30766
Buggy source:
@Override public ItemStack transferStackInSlot(EntityPlayer p,int idx){
  if (Platform.isClient())   return null;
  boolean hasMETiles=false;
  for (  Object is : this.inventorySlots) {
    if (is instanceof InternalSlotME) {
      hasMETiles=true;
      break;
    }
  }
  if (hasMETiles && Platform.isClient()) {
    return null;
  }
  ItemStack tis=null;
  AppEngSlot clickSlot=(AppEngSlot)this.inventorySlots.get(idx);
  if (clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessable)   return null;
  if (clickSlot != null && clickSlot.getHasStack()) {
    tis=clickSlot.getStack();
    if (tis == null)     return null;
    List<Slot> selectedSlots=new ArrayList<Slot>();
    if (clickSlot.isPlayerSide()) {
      tis=shiftStoreItem(tis);
      for (int x=0; x < this.inventorySlots.size(); x++) {
        AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
        if (!(cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) {
          if (cs.isItemValid(tis))           selectedSlots.add(cs);
        }
      }
    }
 else {
      for (int x=0; x < this.inventorySlots.size(); x++) {
        AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
        if ((cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) {
          if (cs.isItemValid(tis))           selectedSlots.add(cs);
        }
      }
    }
    if (selectedSlots.isEmpty() && clickSlot.isPlayerSide()) {
      if (tis != null) {
        for (int x=0; x < this.inventorySlots.size(); x++) {
          AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
          ItemStack dest=cs.getStack();
          if (!(cs.isPlayerSide()) && cs instanceof SlotFake) {
            if (Platform.isSameItem(dest,tis))             return null;
 else             if (dest == null) {
              cs.putStack(tis != null ? tis.copy() : null);
              cs.onSlotChanged();
              updateSlot(cs);
              return null;
            }
          }
        }
      }
    }
    if (tis != null) {
      for (      Slot d : selectedSlots) {
        if (d instanceof SlotDisabled || d instanceof SlotME)         continue;
        if (d.isItemValid(tis) && tis != null) {
          if (d.getHasStack()) {
            ItemStack t=d.getStack();
            if (tis != null && Platform.isSameItem(tis,t)) {
              int maxSize=t.getMaxStackSize();
              if (maxSize > d.getSlotStackLimit())               maxSize=d.getSlotStackLimit();
              int placeAble=maxSize - t.stackSize;
              if (tis.stackSize < placeAble) {
                placeAble=tis.stackSize;
              }
              t.stackSize+=placeAble;
              tis.stackSize-=placeAble;
              if (tis.stackSize <= 0) {
                clickSlot.putStack(null);
                d.onSlotChanged();
                updateSlot(clickSlot);
                updateSlot(d);
                return null;
              }
 else               updateSlot(d);
            }
          }
        }
      }
      for (      Slot d : selectedSlots) {
        if (d instanceof SlotDisabled || d instanceof SlotME)         continue;
        if (d.isItemValid(tis) && tis != null) {
          if (d.getHasStack()) {
            ItemStack t=d.getStack();
            if (tis != null && Platform.isSameItem(t,tis)) {
              int maxSize=t.getMaxStackSize();
              if (d.getSlotStackLimit() < maxSize)               maxSize=d.getSlotStackLimit();
              int placeAble=maxSize - t.stackSize;
              if (tis.stackSize < placeAble) {
                placeAble=tis.stackSize;
              }
              t.stackSize+=placeAble;
              tis.stackSize-=placeAble;
              if (tis.stackSize <= 0) {
                clickSlot.putStack(null);
                d.onSlotChanged();
                updateSlot(clickSlot);
                updateSlot(d);
                return null;
              }
 else               updateSlot(d);
            }
          }
 else {
            int maxSize=tis.getMaxStackSize();
            if (maxSize > d.getSlotStackLimit())             maxSize=d.getSlotStackLimit();
            ItemStack tmp=tis.copy();
            if (tmp.stackSize > maxSize)             tmp.stackSize=maxSize;
            tis.stackSize-=tmp.stackSize;
            d.putStack(tmp);
            if (tis.stackSize <= 0) {
              clickSlot.putStack(null);
              d.onSlotChanged();
              updateSlot(clickSlot);
              updateSlot(d);
              return null;
            }
 else             updateSlot(d);
          }
        }
      }
    }
    clickSlot.putStack(tis != null ? tis.copy() : null);
  }
  updateSlot(clickSlot);
  return null;
}

Fixed version (ground truth):
@Override public ItemStack transferStackInSlot(EntityPlayer p,int idx){
  if (Platform.isClient())   return null;
  boolean hasMETiles=false;
  for (  Object is : this.inventorySlots) {
    if (is instanceof InternalSlotME) {
      hasMETiles=true;
      break;
    }
  }
  if (hasMETiles && Platform.isClient()) {
    return null;
  }
  ItemStack tis=null;
  AppEngSlot clickSlot=(AppEngSlot)this.inventorySlots.get(idx);
  if (clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessable)   return null;
  if (clickSlot != null && clickSlot.getHasStack()) {
    tis=clickSlot.getStack();
    if (tis == null)     return null;
    List<Slot> selectedSlots=new ArrayList<Slot>();
    if (clickSlot.isPlayerSide()) {
      tis=shiftStoreItem(tis);
      for (int x=0; x < this.inventorySlots.size(); x++) {
        AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
        if (!(cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) {
          if (cs.isItemValid(tis))           selectedSlots.add(cs);
        }
      }
    }
 else {
      for (int x=0; x < this.inventorySlots.size(); x++) {
        AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
        if ((cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix)) {
          if (cs.isItemValid(tis))           selectedSlots.add(cs);
        }
      }
    }
    if (selectedSlots.isEmpty() && clickSlot.isPlayerSide()) {
      if (tis != null) {
        for (int x=0; x < this.inventorySlots.size(); x++) {
          AppEngSlot cs=(AppEngSlot)this.inventorySlots.get(x);
          ItemStack dest=cs.getStack();
          if (!(cs.isPlayerSide()) && cs instanceof SlotFake) {
            if (Platform.isSameItemPrecise(dest,tis))             return null;
 else             if (dest == null) {
              cs.putStack(tis != null ? tis.copy() : null);
              cs.onSlotChanged();
              updateSlot(cs);
              return null;
            }
          }
        }
      }
    }
    if (tis != null) {
      for (      Slot d : selectedSlots) {
        if (d instanceof SlotDisabled || d instanceof SlotME)         continue;
        if (d.isItemValid(tis) && tis != null) {
          if (d.getHasStack()) {
            ItemStack t=d.getStack();
            if (tis != null && Platform.isSameItemPrecise(tis,t)) {
              int maxSize=t.getMaxStackSize();
              if (maxSize > d.getSlotStackLimit())               maxSize=d.getSlotStackLimit();
              int placeAble=maxSize - t.stackSize;
              if (tis.stackSize < placeAble) {
                placeAble=tis.stackSize;
              }
              t.stackSize+=placeAble;
              tis.stackSize-=placeAble;
              if (tis.stackSize <= 0) {
                clickSlot.putStack(null);
                d.onSlotChanged();
                updateSlot(clickSlot);
                updateSlot(d);
                return null;
              }
 else               updateSlot(d);
            }
          }
        }
      }
      for (      Slot d : selectedSlots) {
        if (d instanceof SlotDisabled || d instanceof SlotME)         continue;
        if (d.isItemValid(tis) && tis != null) {
          if (d.getHasStack()) {
            ItemStack t=d.getStack();
            if (tis != null && Platform.isSameItemPrecise(t,tis)) {
              int maxSize=t.getMaxStackSize();
              if (d.getSlotStackLimit() < maxSize)               maxSize=d.getSlotStackLimit();
              int placeAble=maxSize - t.stackSize;
              if (tis.stackSize < placeAble) {
                placeAble=tis.stackSize;
              }
              t.stackSize+=placeAble;
              tis.stackSize-=placeAble;
              if (tis.stackSize <= 0) {
                clickSlot.putStack(null);
                d.onSlotChanged();
                updateSlot(clickSlot);
                updateSlot(d);
                return null;
              }
 else               updateSlot(d);
            }
          }
 else {
            int maxSize=tis.getMaxStackSize();
            if (maxSize > d.getSlotStackLimit())             maxSize=d.getSlotStackLimit();
            ItemStack tmp=tis.copy();
            if (tmp.stackSize > maxSize)             tmp.stackSize=maxSize;
            tis.stackSize-=tmp.stackSize;
            d.putStack(tmp);
            if (tis.stackSize <= 0) {
              clickSlot.putStack(null);
              d.onSlotChanged();
              updateSlot(clickSlot);
              updateSlot(d);
              return null;
            }
 else             updateSlot(d);
          }
        }
      }
    }
    clickSlot.putStack(tis != null ? tis.copy() : null);
  }
  updateSlot(clickSlot);
  return null;
}