nus-yam/ex-repair huggingface dataset:
Program: 165770
Project: 165770
Buggy source:
private void testSyringe(){
  if (!checkSyringe) {
    return;
  }
  checkSyringe=false;
  mobId=null;
  ItemStack itemStack=inventoryHelper.getStackInSlot(0);
  if (itemStack == null || itemStack.stackSize == 0) {
    clearMatter();
    return;
  }
  NBTTagCompound tagCompound=itemStack.getTagCompound();
  if (tagCompound == null) {
    clearMatter();
    return;
  }
  mobId=tagCompound.getString("String_Node_Str");
  if (mobId == null) {
    clearMatter();
    return;
  }
  int level=tagCompound.getInteger("String_Node_Str");
  if (level < GeneralConfiguration.maxMobInjections) {
    clearMatter();
    return;
  }
}

Fixed version (ground truth):
private void testSyringe(){
  if (!checkSyringe) {
    return;
  }
  checkSyringe=false;
  mobId=null;
  ItemStack itemStack=inventoryHelper.getStackInSlot(0);
  if (itemStack == null || itemStack.stackSize == 0) {
    clearMatter();
    return;
  }
  NBTTagCompound tagCompound=itemStack.getTagCompound();
  if (tagCompound == null) {
    clearMatter();
    return;
  }
  mobId=tagCompound.getString("String_Node_Str");
  if (mobId == null) {
    clearMatter();
    return;
  }
  int level=tagCompound.getInteger("String_Node_Str");
  if (level < GeneralConfiguration.maxMobInjections) {
    clearMatter();
    return;
  }
  if (prevMobId != null && !prevMobId.equals(mobId)) {
    clearMatter();
  }
}
Program: 165771
Project: 165771
Buggy source:
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  writeBufferToNBT(tagCompound,inventoryHelper);
  tagCompound.setFloat("String_Node_Str",matter[0]);
  tagCompound.setFloat("String_Node_Str",matter[1]);
  tagCompound.setFloat("String_Node_Str",matter[2]);
  tagCompound.setBoolean("String_Node_Str",checkSyringe);
  if (mobId != null && !mobId.isEmpty()) {
    tagCompound.setString("String_Node_Str",mobId);
  }
}

Fixed version (ground truth):
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  writeBufferToNBT(tagCompound,inventoryHelper);
  tagCompound.setFloat("String_Node_Str",matter[0]);
  tagCompound.setFloat("String_Node_Str",matter[1]);
  tagCompound.setFloat("String_Node_Str",matter[2]);
  if (mobId != null && !mobId.isEmpty()) {
    tagCompound.setString("String_Node_Str",mobId);
  }
}
Program: 165772
Project: 165772
Buggy source:
@Override public void setupFromNBT(NBTTagCompound tagCompound,int dim,BlockPos pos){
  if (tagCompound != null) {
    coordinate=BlockPosTools.INVALID;
    if (tagCompound.hasKey("String_Node_Str")) {
      if (tagCompound.hasKey("String_Node_Str")) {
        this.dim=tagCompound.getInteger("String_Node_Str");
      }
 else {
        this.dim=tagCompound.getInteger("String_Node_Str");
      }
      if (dim == this.dim) {
        BlockPos c=new BlockPos(tagCompound.getInteger("String_Node_Str"),tagCompound.getInteger("String_Node_Str"),tagCompound.getInteger("String_Node_Str"));
        int dx=Math.abs(c.getX() - pos.getX());
        int dy=Math.abs(c.getY() - pos.getY());
        int dz=Math.abs(c.getZ() - pos.getZ());
        if (dx <= 64 && dy <= 64 && dz <= 64) {
          coordinate=c;
        }
      }
      vertical=tagCompound.getBoolean("String_Node_Str");
      large=tagCompound.getBoolean("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void setupFromNBT(NBTTagCompound tagCompound,int dim,BlockPos pos){
  if (tagCompound != null) {
    coordinate=BlockPosTools.INVALID;
    if (tagCompound.hasKey("String_Node_Str")) {
      if (tagCompound.hasKey("String_Node_Str")) {
        this.dim=tagCompound.getInteger("String_Node_Str");
      }
 else {
        this.dim=tagCompound.getInteger("String_Node_Str");
      }
      if (dim == this.dim) {
        BlockPos c=new BlockPos(tagCompound.getInteger("String_Node_Str"),tagCompound.getInteger("String_Node_Str"),tagCompound.getInteger("String_Node_Str"));
        int dx=Math.abs(c.getX() - pos.getX());
        int dz=Math.abs(c.getZ() - pos.getZ());
        if (dx <= 64 && dz <= 64) {
          coordinate=c;
        }
      }
      vertical=tagCompound.getBoolean("String_Node_Str");
      large=tagCompound.getBoolean("String_Node_Str");
    }
  }
}
Program: 165776
Project: 165776
Buggy source:
@Override public boolean isItemValid(ItemStack stack){
  if (isServer()) {
    RemoteStorageTileEntity storage=getRemoteStorage();
    int si=-1;
    if (storage != null) {
      si=storage.findRemoteIndex(getStorageID());
    }
    if (si != -1) {
      entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().setInteger("String_Node_Str",storage.getMaxStacks(si));
      return storage.isItemValidForSlot(getSlotIndex(),stack);
    }
 else {
      entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().setInteger("String_Node_Str",0);
      return false;
    }
  }
 else {
    int maxSize=entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().getInteger("String_Node_Str");
    if (getSlotIndex() >= maxSize) {
      return false;
    }
    return super.isItemValid(stack);
  }
}

Fixed version (ground truth):
@Override public boolean isItemValid(ItemStack stack){
  if (isServer()) {
    RemoteStorageTileEntity storage=getRemoteStorage();
    int si=-1;
    if (storage != null) {
      si=storage.findRemoteIndex(getStorageID());
    }
    if (si != -1) {
      entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().setInteger("String_Node_Str",storage.getMaxStacks(si));
      return true;
    }
 else {
      entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().setInteger("String_Node_Str",0);
      return false;
    }
  }
 else {
    int maxSize=entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound().getInteger("String_Node_Str");
    if (getSlotIndex() >= maxSize) {
      return false;
    }
    return super.isItemValid(stack);
  }
}
Program: 165777
Project: 165777
Buggy source:
@Override public ItemStack removeStackFromSlot(int index){
  version++;
  return inventoryHelper.removeStackFromSlot(index);
}

Fixed version (ground truth):
@Override public ItemStack removeStackFromSlot(int index){
  version++;
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return null;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return null;
    }
    return storageTileEntity.removeStackFromSlotRemote(si,index);
  }
 else {
    return inventoryHelper.removeStackFromSlot(index);
  }
}
Program: 165778
Project: 165778
Buggy source:
public void update(){
  if (worldObj.isRemote) {
    return;
  }
  if (channel == -1) {
    return;
  }
  if ((powerLevel > 0) != prevValue) {
    prevValue=powerLevel > 0;
    RedstoneChannels channels=RedstoneChannels.getChannels(worldObj);
    RedstoneChannels.RedstoneChannel ch=channels.getOrCreateChannel(channel);
    ch.setValue(powerLevel > 0 ? 15 : 0);
    channels.save(worldObj);
  }
}

Fixed version (ground truth):
public void update(){
  if (worldObj.isRemote) {
    return;
  }
  if (channel == -1) {
    return;
  }
  boolean powered=powerLevel > 0;
  if (powered != prevIn) {
    prevIn=powered;
    markDirty();
    RedstoneChannels channels=RedstoneChannels.getChannels(worldObj);
    RedstoneChannels.RedstoneChannel ch=channels.getOrCreateChannel(channel);
    ch.setValue(powered ? 15 : 0);
    channels.save(worldObj);
  }
}
Program: 165779
Project: 165779
Buggy source:
@Override public boolean isItemValidForSlot(int index,ItemStack stack){
  if (index >= CrafterContainer.SLOT_BUFFER && index < CrafterContainer.SLOT_BUFFEROUT) {
    ItemStack ghostSlot=ghostSlots[index - CrafterContainer.SLOT_BUFFER];
    if (ghostSlot != null) {
      if (!ghostSlot.isItemEqual(stack)) {
        return false;
      }
    }
    if (inventoryHelper.containsItem(CrafterContainer.SLOT_FILTER_MODULE)) {
      getFilterCache();
      if (filterCache != null) {
        return filterCache.match(stack);
      }
    }
  }
 else   if (index >= CrafterContainer.SLOT_BUFFEROUT && index < CrafterContainer.SLOT_FILTER_MODULE) {
    ItemStack ghostSlot=ghostSlots[index - CrafterContainer.SLOT_BUFFEROUT + CrafterContainer.BUFFER_SIZE];
    if (ghostSlot != null) {
      if (!ghostSlot.isItemEqual(stack)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean isItemValidForSlot(int index,ItemStack stack){
  if (index >= CrafterContainer.SLOT_CRAFTINPUT && index <= CrafterContainer.SLOT_CRAFTOUTPUT) {
    return false;
  }
  if (index >= CrafterContainer.SLOT_BUFFER && index < CrafterContainer.SLOT_BUFFEROUT) {
    ItemStack ghostSlot=ghostSlots[index - CrafterContainer.SLOT_BUFFER];
    if (ghostSlot != null) {
      if (!ghostSlot.isItemEqual(stack)) {
        return false;
      }
    }
    if (inventoryHelper.containsItem(CrafterContainer.SLOT_FILTER_MODULE)) {
      getFilterCache();
      if (filterCache != null) {
        return filterCache.match(stack);
      }
    }
  }
 else   if (index >= CrafterContainer.SLOT_BUFFEROUT && index < CrafterContainer.SLOT_FILTER_MODULE) {
    ItemStack ghostSlot=ghostSlots[index - CrafterContainer.SLOT_BUFFEROUT + CrafterContainer.BUFFER_SIZE];
    if (ghostSlot != null) {
      if (!ghostSlot.isItemEqual(stack)) {
        return false;
      }
    }
  }
  return true;
}
Program: 165780
Project: 165780
Buggy source:
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  tagCompound.setInteger("String_Node_Str",radius);
  tagCompound.setBoolean("String_Node_Str",exportToCurrent);
  tagCompound.setTag("String_Node_Str",craftingGrid.writeToNBT());
}

Fixed version (ground truth):
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  writeBufferToNBT(tagCompound,inventoryHelper);
  tagCompound.setInteger("String_Node_Str",radius);
  tagCompound.setBoolean("String_Node_Str",exportToCurrent);
  tagCompound.setTag("String_Node_Str",craftingGrid.writeToNBT());
}
Program: 165781
Project: 165781
Buggy source:
@Override public int[] getSlotsForFace(EnumFacing side){
  return StorageScannerContainer.factory.getAccessibleSlots();
}

Fixed version (ground truth):
@Override public int[] getSlotsForFace(EnumFacing side){
  return SLOTS;
}
Program: 165782
Project: 165782
Buggy source:
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  radius=tagCompound.getInteger("String_Node_Str");
  exportToCurrent=tagCompound.getBoolean("String_Node_Str");
  craftingGrid.readFromNBT(tagCompound.getCompoundTag("String_Node_Str"));
}

Fixed version (ground truth):
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  readBufferFromNBT(tagCompound,inventoryHelper);
  radius=tagCompound.getInteger("String_Node_Str");
  exportToCurrent=tagCompound.getBoolean("String_Node_Str");
  craftingGrid.readFromNBT(tagCompound.getCompoundTag("String_Node_Str"));
}
Program: 165783
Project: 165783
Buggy source:
@Override public boolean canInsertItem(int index,ItemStack itemStackIn,EnumFacing direction){
  return StorageScannerContainer.factory.isInputSlot(index);
}

Fixed version (ground truth):
@Override public boolean canInsertItem(int index,ItemStack itemStackIn,EnumFacing direction){
  return isItemValidForSlot(index,itemStackIn);
}
Program: 165784
Project: 165784
Buggy source:
void decrStackSize(IItemKey key,int amount);

Fixed version (ground truth):
ItemStack decrStackSize(IItemKey key,int amount);
Program: 165785
Project: 165785
Buggy source:
@Override public void decrStackSize(IItemKey key,int amount){
  ItemKey realKey=(ItemKey)key;
  ItemStack stack=realKey.getInventory().getStackInSlot(realKey.getSlot());
  stack.splitStack(amount);
  if (stack.stackSize == 0) {
    realKey.getInventory().setInventorySlotContents(realKey.getSlot(),null);
  }
}

Fixed version (ground truth):
@Override public ItemStack decrStackSize(IItemKey key,int amount){
  ItemKey realKey=(ItemKey)key;
  ItemStack stack=realKey.getInventory().getStackInSlot(realKey.getSlot());
  ItemStack result=stack.splitStack(amount);
  if (stack.stackSize == 0) {
    realKey.getInventory().setInventorySlotContents(realKey.getSlot(),null);
  }
  return result;
}
Program: 165786
Project: 165786
Buggy source:
private static void undo(EntityPlayerMP player,IItemSource itemSource,Map<IItemKey,ItemStack> undo){
  for (  Map.Entry<IItemKey,ItemStack> entry : undo.entrySet()) {
    itemSource.putStack(entry.getKey(),entry.getValue());
  }
  player.openContainer.detectAndSendChanges();
}

Fixed version (ground truth):
private static void undo(EntityPlayerMP player,IItemSource itemSource,List<Pair<IItemKey,ItemStack>> undo){
  for (  Pair<IItemKey,ItemStack> pair : undo) {
    itemSource.insertStack(pair.getKey(),pair.getValue());
  }
  player.openContainer.detectAndSendChanges();
}
Program: 165787
Project: 165787
Buggy source:
private static int findMatchingItems(InventoryCrafting workInventory,Map<IItemKey,ItemStack> undo,int i,ItemStack stack,int count,IItemSource itemSource,boolean strictDamage){
  for (  Pair<IItemKey,ItemStack> pair : itemSource.getItems()) {
    ItemStack input=pair.getValue();
    if (input != null) {
      if (match(stack,input,strictDamage)) {
        workInventory.setInventorySlotContents(i,input.copy());
        int ss=count;
        if (input.stackSize - ss < 0) {
          ss=input.stackSize;
        }
        count-=ss;
        IItemKey key=pair.getKey();
        if (!undo.containsKey(key)) {
          undo.put(key,input.copy());
        }
        itemSource.decrStackSize(key,ss);
      }
    }
    if (count == 0) {
      break;
    }
  }
  return count;
}

Fixed version (ground truth):
private static int findMatchingItems(InventoryCrafting workInventory,List<Pair<IItemKey,ItemStack>> undo,int i,ItemStack stack,int count,IItemSource itemSource,boolean strictDamage){
  for (  Pair<IItemKey,ItemStack> pair : itemSource.getItems()) {
    ItemStack input=pair.getValue();
    if (input != null) {
      if (match(stack,input,strictDamage)) {
        workInventory.setInventorySlotContents(i,input.copy());
        int ss=count;
        if (input.stackSize - ss < 0) {
          ss=input.stackSize;
        }
        count-=ss;
        IItemKey key=pair.getKey();
        ItemStack actuallyExtracted=itemSource.decrStackSize(key,ss);
        undo.add(Pair.of(key,actuallyExtracted));
      }
    }
    if (count == 0) {
      break;
    }
  }
  return count;
}
Program: 165788
Project: 165788
Buggy source:
static int[] tryRecipe(EntityPlayerMP player,CraftingRecipe craftingRecipe,int n,IItemSource itemSource,boolean strictDamage){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<IItemKey,ItemStack> undo=new HashMap<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  int[] missingCount=new int[10];
  for (int i=0; i < 10; i++) {
    missingCount[i]=0;
  }
  for (int counter=0; counter < n; counter++) {
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null) {
        int count=stack.stackSize;
        count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,strictDamage);
        missingCount[i]+=count;
      }
 else {
        workInventory.setInventorySlotContents(i,null);
      }
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (!recipe.matches(workInventory,player.worldObj)) {
    missingCount[9]=1;
  }
 else {
    missingCount[9]=0;
  }
  undo(player,itemSource,undo);
  return missingCount;
}

Fixed version (ground truth):
static int[] tryRecipe(EntityPlayerMP player,CraftingRecipe craftingRecipe,int n,IItemSource itemSource,boolean strictDamage){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  List<Pair<IItemKey,ItemStack>> undo=new ArrayList<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  int[] missingCount=new int[10];
  for (int i=0; i < 10; i++) {
    missingCount[i]=0;
  }
  for (int counter=0; counter < n; counter++) {
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null) {
        int count=stack.stackSize;
        count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,strictDamage);
        missingCount[i]+=count;
      }
 else {
        workInventory.setInventorySlotContents(i,null);
      }
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (!recipe.matches(workInventory,player.worldObj)) {
    missingCount[9]=1;
  }
 else {
    missingCount[9]=0;
  }
  undo(player,itemSource,undo);
  return missingCount;
}
Program: 165789
Project: 165789
Buggy source:
private static List<ItemStack> testAndConsumeCraftingItems(EntityPlayerMP player,CraftingRecipe craftingRecipe,IItemSource itemSource,boolean strictDamage){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<IItemKey,ItemStack> undo=new HashMap<>();
  List<ItemStack> result=new ArrayList<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,strictDamage);
      if (count > 0) {
        undo(player,itemSource,undo);
        return Collections.emptyList();
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (!recipe.matches(workInventory,player.worldObj)) {
    result.clear();
    undo(player,itemSource,undo);
    return result;
  }
  ItemStack stack=recipe.getCraftingResult(workInventory);
  if (stack != null) {
    result.add(stack);
    ItemStack[] remaining=recipe.getRemainingItems(workInventory);
    if (remaining != null) {
      for (      ItemStack s : remaining) {
        if (s != null) {
          result.add(s);
        }
      }
    }
  }
 else {
    result.clear();
    undo(player,itemSource,undo);
  }
  return result;
}

Fixed version (ground truth):
private static List<ItemStack> testAndConsumeCraftingItems(EntityPlayerMP player,CraftingRecipe craftingRecipe,IItemSource itemSource,boolean strictDamage){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  List<Pair<IItemKey,ItemStack>> undo=new ArrayList<>();
  List<ItemStack> result=new ArrayList<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,strictDamage);
      if (count > 0) {
        undo(player,itemSource,undo);
        return Collections.emptyList();
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (!recipe.matches(workInventory,player.worldObj)) {
    result.clear();
    undo(player,itemSource,undo);
    return result;
  }
  ItemStack stack=recipe.getCraftingResult(workInventory);
  if (stack != null) {
    result.add(stack);
    ItemStack[] remaining=recipe.getRemainingItems(workInventory);
    if (remaining != null) {
      for (      ItemStack s : remaining) {
        if (s != null) {
          result.add(s);
        }
      }
    }
  }
 else {
    result.clear();
    undo(player,itemSource,undo);
  }
  return result;
}
Program: 165790
Project: 165790
Buggy source:
@Override public void decrStackSize(IItemKey key,int amount){
  ItemKey realKey=(ItemKey)key;
  Object te=realKey.getInventory();
  if (te instanceof IItemHandler) {
    IItemHandler handler=(IItemHandler)te;
    handler.extractItem(realKey.getSlot(),amount,false);
  }
 else   if (te instanceof IInventory) {
    IInventory inventory=(IInventory)te;
    ItemStack stack=inventory.getStackInSlot(realKey.getSlot());
    stack.splitStack(amount);
    if (stack.stackSize == 0) {
      inventory.setInventorySlotContents(realKey.getSlot(),null);
    }
  }
}

Fixed version (ground truth):
@Override public ItemStack decrStackSize(IItemKey key,int amount){
  ItemKey realKey=(ItemKey)key;
  Object te=realKey.getInventory();
  if (te instanceof IItemHandler) {
    IItemHandler handler=(IItemHandler)te;
    return handler.extractItem(realKey.getSlot(),amount,false);
  }
 else   if (te instanceof IInventory) {
    IInventory inventory=(IInventory)te;
    ItemStack stack=inventory.getStackInSlot(realKey.getSlot());
    ItemStack result=stack.splitStack(amount);
    if (stack.stackSize == 0) {
      inventory.setInventorySlotContents(realKey.getSlot(),null);
    }
    return result;
  }
  return null;
}
Program: 165791
Project: 165791
Buggy source:
private boolean testAndConsumeCraftingItems(CraftingRecipe craftingRecipe,Map<Integer,ItemStack> undo,boolean strictDamage){
  int keep=craftingRecipe.isKeepOne() ? 1 : 0;
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      for (int j=0; j < CrafterContainer.BUFFER_SIZE; j++) {
        int slotIdx=CrafterContainer.SLOT_BUFFER + j;
        ItemStack input=inventoryHelper.getStackInSlot(slotIdx);
        if (input != null && input.stackSize > keep) {
          if (match(stack,input,strictDamage)) {
            workInventory.setInventorySlotContents(i,input.copy());
            int ss=count;
            if (input.stackSize - ss < keep) {
              ss=input.stackSize - keep;
            }
            count-=ss;
            if (!undo.containsKey(slotIdx)) {
              undo.put(slotIdx,input.copy());
            }
            input.splitStack(ss);
            if (input.stackSize == 0) {
              inventoryHelper.setStackInSlot(slotIdx,null);
            }
          }
        }
        if (count == 0) {
          break;
        }
      }
      if (count > 0) {
        return false;
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean testAndConsumeCraftingItems(CraftingRecipe craftingRecipe,Map<Integer,ItemStack> undo,boolean strictDamage){
  int keep=craftingRecipe.isKeepOne() ? 1 : 0;
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      for (int j=0; j < CrafterContainer.BUFFER_SIZE; j++) {
        int slotIdx=CrafterContainer.SLOT_BUFFER + j;
        ItemStack input=inventoryHelper.getStackInSlot(slotIdx);
        if (input != null && input.stackSize > keep) {
          if (match(stack,input,strictDamage)) {
            workInventory.setInventorySlotContents(i,input.copy());
            int ss=count;
            if (input.stackSize - ss < keep) {
              ss=input.stackSize - keep;
            }
            count-=ss;
            if (!undo.containsKey(slotIdx)) {
              undo.put(slotIdx,input.copy());
            }
            input.splitStack(ss);
            if (input.stackSize == 0) {
              inventoryHelper.setStackInSlot(slotIdx,null);
            }
          }
        }
        if (count == 0) {
          break;
        }
      }
      if (count > 0) {
        return false;
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(worldObj);
  return recipe.matches(workInventory,worldObj);
}
Program: 165792
Project: 165792
Buggy source:
private void initKeepMode(){
  keepItem=new ChoiceLabel(mc,this).addChoices("String_Node_Str","String_Node_Str").setTooltips("String_Node_Str","String_Node_Str","String_Node_Str").setEnabled(false).setLayoutHint(new PositionalLayout.PositionalHint(148,7,41,14));
}

Fixed version (ground truth):
private void initKeepMode(){
  keepItem=new ChoiceLabel(mc,this).addChoices("String_Node_Str","String_Node_Str").setEnabled(false).setLayoutHint(new PositionalLayout.PositionalHint(148,7,41,14));
  keepItem.setChoiceTooltip("String_Node_Str","String_Node_Str",TextFormatting.GREEN + "String_Node_Str");
  keepItem.setChoiceTooltip("String_Node_Str","String_Node_Str",TextFormatting.GREEN + "String_Node_Str");
}
Program: 165793
Project: 165793
Buggy source:
private void initInternalRecipe(){
  internalRecipe=new ChoiceLabel(mc,this).addChoices("String_Node_Str","String_Node_Str","String_Node_Str").setTooltips("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").setEnabled(false).setLayoutHint(new PositionalLayout.PositionalHint(148,24,41,14));
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str");
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str");
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
private void initInternalRecipe(){
  internalRecipe=new ChoiceLabel(mc,this).addChoices("String_Node_Str","String_Node_Str","String_Node_Str").setTooltips("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").setEnabled(false).setLayoutHint(new PositionalLayout.PositionalHint(148,24,41,14));
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str",TextFormatting.GREEN + "String_Node_Str");
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str",TextFormatting.GREEN + "String_Node_Str");
  internalRecipe.setChoiceTooltip("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",TextFormatting.GREEN + "String_Node_Str");
}
Program: 165794
Project: 165794
Buggy source:
void insertStack(IItemKey key,ItemStack stack);

Fixed version (ground truth):
boolean insertStack(IItemKey key,ItemStack stack);
Program: 165795
Project: 165795
Buggy source:
@Override public void insertStack(IItemKey key,ItemStack stack){
  ItemKey realKey=(ItemKey)key;
  IInventory inventory=realKey.getInventory();
  ItemStack origStack=inventory.removeStackFromSlot(realKey.getSlot());
  if (origStack != null) {
    stack.stackSize+=origStack.stackSize;
  }
  inventory.setInventorySlotContents(realKey.getSlot(),stack);
}

Fixed version (ground truth):
@Override public boolean insertStack(IItemKey key,ItemStack stack){
  ItemKey realKey=(ItemKey)key;
  IInventory inventory=realKey.getInventory();
  ItemStack origStack=inventory.removeStackFromSlot(realKey.getSlot());
  if (origStack != null) {
    if (ItemHandlerHelper.canItemStacksStack(origStack,stack)) {
      if ((stack.stackSize + origStack.stackSize) > stack.getMaxStackSize()) {
        return false;
      }
      stack.stackSize+=origStack.stackSize;
    }
 else {
      return false;
    }
  }
  inventory.setInventorySlotContents(realKey.getSlot(),stack);
  return true;
}
Program: 165796
Project: 165796
Buggy source:
private static void undo(EntityPlayerMP player,IItemSource itemSource,List<Pair<IItemKey,ItemStack>> undo){
  for (  Pair<IItemKey,ItemStack> pair : undo) {
    itemSource.insertStack(pair.getKey(),pair.getValue());
  }
  player.openContainer.detectAndSendChanges();
}

Fixed version (ground truth):
private static void undo(EntityPlayerMP player,IItemSource itemSource,List<Pair<IItemKey,ItemStack>> undo){
  for (  Pair<IItemKey,ItemStack> pair : undo) {
    ItemStack stack=pair.getValue();
    if (!itemSource.insertStack(pair.getKey(),stack)) {
      int amountLeft=itemSource.insertStackAnySlot(pair.getKey(),stack);
      if (amountLeft > 0) {
        ItemStack copy=stack.copy();
        copy.stackSize=amountLeft;
        ItemHandlerHelper.giveItemToPlayer(player,copy);
      }
    }
  }
  player.openContainer.detectAndSendChanges();
}
Program: 165797
Project: 165797
Buggy source:
private static void insertStackInSlot(Object inv,int slot,ItemStack stack){
  if (inv instanceof IItemHandler) {
    IItemHandler handler=(IItemHandler)inv;
    handler.insertItem(slot,stack,false);
  }
 else   if (inv instanceof IInventory) {
    IInventory inventory=(IInventory)inv;
    ItemStack oldStack=inventory.getStackInSlot(slot);
    if (oldStack != null) {
      stack.stackSize+=oldStack.stackSize;
    }
    inventory.setInventorySlotContents(slot,stack);
  }
}

Fixed version (ground truth):
private static boolean insertStackInSlot(Object inv,int slot,ItemStack stack){
  if (inv instanceof IItemHandler) {
    IItemHandler handler=(IItemHandler)inv;
    if (handler.insertItem(slot,stack,true) != null) {
      return false;
    }
    return handler.insertItem(slot,stack,false) == null;
  }
 else   if (inv instanceof IInventory) {
    IInventory inventory=(IInventory)inv;
    ItemStack oldStack=inventory.getStackInSlot(slot);
    if (oldStack != null) {
      if ((stack.stackSize + oldStack.stackSize) > stack.getMaxStackSize()) {
        return false;
      }
      stack.stackSize+=oldStack.stackSize;
    }
    inventory.setInventorySlotContents(slot,stack);
    return true;
  }
  return false;
}
Program: 165798
Project: 165798
Buggy source:
@Override public void insertStack(IItemKey key,ItemStack stack){
  ItemKey realKey=(ItemKey)key;
  insertStackInSlot(realKey.getInventory(),realKey.getSlot(),stack);
}

Fixed version (ground truth):
@Override public boolean insertStack(IItemKey key,ItemStack stack){
  ItemKey realKey=(ItemKey)key;
  return insertStackInSlot(realKey.getInventory(),realKey.getSlot(),stack);
}
Program: 165799
Project: 165799
Buggy source:
public void draw(){
  int selected=recipeList.getSelected();
  storeButton.setEnabled(selected != -1);
  populateList();
  testRecipe();
  int x=Mouse.getEventX() * gui.width / gui.mc.displayWidth;
  int y=gui.height - Mouse.getEventY() * gui.height / gui.mc.displayHeight - 1;
  Widget widget=craftWindow.getToplevel().getWidgetAtPosition(x,y);
  if (widget == craft1Button) {
    testCraft(1);
  }
 else   if (widget == craft4Button) {
    testCraft(4);
  }
 else   if (widget == craft8Button) {
    testCraft(8);
  }
 else   if (widget == craftSButton) {
    testCraft(-1);
  }
 else {
    testResultFromServer=null;
    lastTestAmount=-2;
    lastTestTimer=0;
  }
  craftWindow.draw();
  if (testResultFromServer != null) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)gui.guiLeft,(float)gui.guiTop,0.0F);
    for (int i=0; i < 9; i++) {
      if (testResultFromServer[i] > 0) {
        Slot slot=gui.inventorySlots.getSlotFromInventory(provider.getCraftingGrid().getCraftingGridInventory(),CraftingGridInventory.SLOT_GHOSTINPUT + i);
        if (slot != null) {
          GlStateManager.colorMask(true,true,true,false);
          gui.drawRect(slot.xDisplayPosition,slot.yDisplayPosition,slot.xDisplayPosition + 16,slot.yDisplayPosition + 16,0xffff0000);
        }
      }
    }
    GlStateManager.popMatrix();
  }
}

Fixed version (ground truth):
public void draw(){
  int selected=recipeList.getSelected();
  storeButton.setEnabled(selected != -1);
  populateList();
  testRecipe();
  int x=Mouse.getEventX() * gui.width / gui.mc.displayWidth;
  int y=gui.height - Mouse.getEventY() * gui.height / gui.mc.displayHeight - 1;
  Widget widget=craftWindow.getToplevel().getWidgetAtPosition(x,y);
  if (widget == craft1Button) {
    testCraft(1);
  }
 else   if (widget == craft4Button) {
    testCraft(4);
  }
 else   if (widget == craft8Button) {
    testCraft(8);
  }
 else   if (widget == craftSButton) {
    testCraft(-1);
  }
 else {
    testResultFromServer=null;
    lastTestAmount=-2;
    lastTestTimer=0;
  }
  craftWindow.draw();
  if (testResultFromServer != null) {
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)gui.guiLeft,(float)gui.guiTop,0.0F);
    if (testResultFromServer[9] > 0) {
      Slot slot=gui.inventorySlots.getSlotFromInventory(provider.getCraftingGrid().getCraftingGridInventory(),CraftingGridInventory.SLOT_GHOSTOUTPUT);
      if (slot != null) {
        GlStateManager.colorMask(true,true,true,false);
        gui.drawRect(slot.xDisplayPosition,slot.yDisplayPosition,slot.xDisplayPosition + 16,slot.yDisplayPosition + 16,0xffff0000);
      }
    }
    for (int i=0; i < 9; i++) {
      if (testResultFromServer[i] > 0) {
        Slot slot=gui.inventorySlots.getSlotFromInventory(provider.getCraftingGrid().getCraftingGridInventory(),CraftingGridInventory.SLOT_GHOSTINPUT + i);
        if (slot != null) {
          GlStateManager.colorMask(true,true,true,false);
          gui.drawRect(slot.xDisplayPosition,slot.yDisplayPosition,slot.xDisplayPosition + 16,slot.yDisplayPosition + 16,0xffff0000);
        }
      }
    }
    GlStateManager.popMatrix();
  }
}
Program: 165800
Project: 165800
Buggy source:
@Override public void toBytes(ByteBuf buf){
  for (int i=0; i < 9; i++) {
    buf.writeInt(testResult[i]);
  }
}

Fixed version (ground truth):
@Override public void toBytes(ByteBuf buf){
  for (int i=0; i < 10; i++) {
    buf.writeInt(testResult[i]);
  }
}
Program: 165801
Project: 165801
Buggy source:
@Override public void fromBytes(ByteBuf buf){
  testResult=new int[9];
  for (int i=0; i < 9; i++) {
    testResult[i]=buf.readInt();
  }
}

Fixed version (ground truth):
@Override public void fromBytes(ByteBuf buf){
  testResult=new int[10];
  for (int i=0; i < 10; i++) {
    testResult[i]=buf.readInt();
  }
}
Program: 165802
Project: 165802
Buggy source:
public static int[] testCraftItems(EntityPlayerMP player,int n,CraftingRecipe craftingRecipe,IItemSource itemSource){
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (recipe == null) {
    return null;
  }
  if (craftingRecipe.getResult() != null && craftingRecipe.getResult().stackSize > 0) {
    if (n == -1) {
      n=craftingRecipe.getResult().getMaxStackSize();
    }
    int remainder=n % craftingRecipe.getResult().stackSize;
    n/=craftingRecipe.getResult().stackSize;
    if (remainder != 0) {
      n++;
    }
    if (n * craftingRecipe.getResult().stackSize > craftingRecipe.getResult().getMaxStackSize()) {
      n--;
    }
    return tryRecipe(player,craftingRecipe,n,itemSource);
  }
  return null;
}

Fixed version (ground truth):
public static int[] testCraftItems(EntityPlayerMP player,int n,CraftingRecipe craftingRecipe,IItemSource itemSource){
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (recipe == null) {
    return null;
  }
  if (craftingRecipe.getResult() != null && craftingRecipe.getResult().stackSize > 0) {
    if (n == -1) {
      n=craftingRecipe.getResult().getMaxStackSize();
    }
    int remainder=n % craftingRecipe.getResult().stackSize;
    n/=craftingRecipe.getResult().stackSize;
    if (remainder != 0) {
      n++;
    }
    if (n * craftingRecipe.getResult().stackSize > craftingRecipe.getResult().getMaxStackSize()) {
      n--;
    }
    int[] result=tryRecipe(player,craftingRecipe,n,itemSource,true);
    for (int i=0; i < 10; i++) {
      if (result[i] > 0) {
        int[] result2=tryRecipe(player,craftingRecipe,n,itemSource,false);
        if (result2[9] == 0) {
          return result2;
        }
 else {
          return result;
        }
      }
    }
    return result;
  }
  return null;
}
Program: 165803
Project: 165803
Buggy source:
static int[] tryRecipe(EntityPlayerMP player,CraftingRecipe craftingRecipe,int n,IItemSource itemSource){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<IItemKey,ItemStack> undo=new HashMap<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  int[] missingCount=new int[9];
  for (int i=0; i < 9; i++) {
    missingCount[i]=0;
  }
  for (int counter=0; counter < n; counter++) {
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null) {
        int count=stack.stackSize;
        count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,false);
        missingCount[i]+=count;
      }
 else {
        workInventory.setInventorySlotContents(i,null);
      }
    }
  }
  undo(player,itemSource,undo);
  return missingCount;
}

Fixed version (ground truth):
static int[] tryRecipe(EntityPlayerMP player,CraftingRecipe craftingRecipe,int n,IItemSource itemSource,boolean strictDamage){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<IItemKey,ItemStack> undo=new HashMap<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  int[] missingCount=new int[10];
  for (int i=0; i < 10; i++) {
    missingCount[i]=0;
  }
  for (int counter=0; counter < n; counter++) {
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null) {
        int count=stack.stackSize;
        count=findMatchingItems(workInventory,undo,i,stack,count,itemSource,strictDamage);
        missingCount[i]+=count;
      }
 else {
        workInventory.setInventorySlotContents(i,null);
      }
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  if (!recipe.matches(workInventory,player.worldObj)) {
    missingCount[9]=1;
  }
 else {
    missingCount[9]=0;
  }
  undo(player,itemSource,undo);
  return missingCount;
}
Program: 165804
Project: 165804
Buggy source:
@Override protected boolean needsCustomInvWrapper(){
  return true;
}

Fixed version (ground truth):
@Override protected boolean needsCustomInvWrapper(){
  return false;
}
Program: 165805
Project: 165805
Buggy source:
@Override public void addProbeInfo(ProbeMode mode,IProbeInfo probeInfo,EntityPlayer player,World world,IBlockState blockState,IProbeHitData data){
  super.addProbeInfo(mode,probeInfo,player,world,blockState,data);
  TileEntity te=world.getTileEntity(data.getPos());
  if (te instanceof MatterTransmitterTileEntity) {
    MatterTransmitterTileEntity matterTransmitterTileEntity=(MatterTransmitterTileEntity)te;
    probeInfo.text(TextFormatting.GREEN + "String_Node_Str" + matterTransmitterTileEntity.getName());
    if (matterTransmitterTileEntity.isDialed()) {
      Integer teleportId=matterTransmitterTileEntity.getTeleportId();
      if (teleportId == null) {
        ReturnDestinationInfoHelper.id=null;
      }
 else {
        if (System.currentTimeMillis() - lastTime > 500) {
          lastTime=System.currentTimeMillis();
          RFToolsMessages.INSTANCE.sendToServer(new PacketGetDestinationInfo(teleportId));
        }
      }
      String name="String_Node_Str";
      if (ReturnDestinationInfoHelper.id != null && ReturnDestinationInfoHelper.id.equals(teleportId)) {
        name=ReturnDestinationInfoHelper.name;
      }
      probeInfo.text(TextFormatting.YELLOW + "String_Node_Str" + name+ "String_Node_Str");
    }
    if (matterTransmitterTileEntity.isOnce()) {
      probeInfo.text(TextFormatting.YELLOW + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void addProbeInfo(ProbeMode mode,IProbeInfo probeInfo,EntityPlayer player,World world,IBlockState blockState,IProbeHitData data){
  super.addProbeInfo(mode,probeInfo,player,world,blockState,data);
  TileEntity te=world.getTileEntity(data.getPos());
  if (te instanceof MatterTransmitterTileEntity) {
    MatterTransmitterTileEntity matterTransmitterTileEntity=(MatterTransmitterTileEntity)te;
    probeInfo.text(TextFormatting.GREEN + "String_Node_Str" + matterTransmitterTileEntity.getName());
    if (matterTransmitterTileEntity.isDialed()) {
      Integer teleportId=matterTransmitterTileEntity.getTeleportId();
      TeleportDestinations destinations=TeleportDestinations.getDestinations(world);
      String name="String_Node_Str";
      if (teleportId != null) {
        name=TeleportDestinations.getDestinationName(destinations,teleportId);
      }
      probeInfo.text(TextFormatting.YELLOW + "String_Node_Str" + name+ "String_Node_Str");
    }
    if (matterTransmitterTileEntity.isOnce()) {
      probeInfo.text(TextFormatting.YELLOW + "String_Node_Str");
    }
  }
}
Program: 165806
Project: 165806
Buggy source:
private void handle(PacketGetDestinationInfo message,MessageContext ctx){
  World world=ctx.getServerHandler().playerEntity.worldObj;
  TeleportDestinations destinations=TeleportDestinations.getDestinations(world);
  GlobalCoordinate coordinate=destinations.getCoordinateForId(message.receiverId);
  String name;
  if (coordinate == null) {
    name="String_Node_Str";
  }
 else {
    TeleportDestination destination=destinations.getDestination(coordinate);
    if (destination == null) {
      name="String_Node_Str";
    }
 else {
      name=destination.getName();
      if (name == null || name.isEmpty()) {
        name=destination.getCoordinate() + "String_Node_Str" + destination.getDimension()+ "String_Node_Str";
      }
    }
  }
  RFToolsMessages.INSTANCE.sendTo(new PacketReturnDestinationInfo(message.receiverId,name),ctx.getServerHandler().playerEntity);
}

Fixed version (ground truth):
private void handle(PacketGetDestinationInfo message,MessageContext ctx){
  World world=ctx.getServerHandler().playerEntity.worldObj;
  TeleportDestinations destinations=TeleportDestinations.getDestinations(world);
  int receiverId=message.receiverId;
  String name=TeleportDestinations.getDestinationName(destinations,receiverId);
  RFToolsMessages.INSTANCE.sendTo(new PacketReturnDestinationInfo(receiverId,name),ctx.getServerHandler().playerEntity);
}
Program: 165807
Project: 165807
Buggy source:
private void undo(Map<Integer,ItemStack> undo){
  for (  Map.Entry<Integer,ItemStack> entry : undo.entrySet()) {
    inventoryHelper.setStackInSlot(entry.getKey(),entry.getValue());
  }
}

Fixed version (ground truth):
private void undo(Map<Integer,ItemStack> undo){
  for (  Map.Entry<Integer,ItemStack> entry : undo.entrySet()) {
    inventoryHelper.setStackInSlot(entry.getKey(),entry.getValue());
  }
  undo.clear();
}
Program: 165808
Project: 165808
Buggy source:
private void handle(PacketGridToServer message,MessageContext ctx){
  EntityPlayerMP player=ctx.getServerHandler().playerEntity;
  World world=player.worldObj;
  CraftingGridProvider provider=message.handleMessage(world,player);
  if (provider != null) {
    CraftingGridInventory inventory=provider.getCraftingGrid().getCraftingGridInventory();
    for (int i=0; i < 10; i++) {
      inventory.setInventorySlotContents(i,message.stacks[i]);
    }
    provider.markDirty();
  }
}

Fixed version (ground truth):
private void handle(PacketGridToServer message,MessageContext ctx){
  EntityPlayerMP player=ctx.getServerHandler().playerEntity;
  World world=player.worldObj;
  CraftingGridProvider provider=message.handleMessage(world,player);
  if (provider != null) {
    CraftingGridInventory inventory=provider.getCraftingGrid().getCraftingGridInventory();
    for (int i=0; i < 10; i++) {
      inventory.setInventorySlotContents(i,message.stacks[i]);
    }
    provider.markInventoryDirty();
  }
}
Program: 165809
Project: 165809
Buggy source:
public GuiModularStorage(ModularStorageTileEntity modularStorageTileEntity,Container container){
  super(RFTools.instance,RFToolsMessages.INSTANCE,modularStorageTileEntity,container,RFTools.GUI_MANUAL_MAIN,"String_Node_Str");
  craftingGrid=new GuiCraftingGrid();
  xSize=STORAGE_WIDTH;
  ScaledResolution scaledresolution=new ScaledResolution(Minecraft.getMinecraft());
  int height=scaledresolution.getScaledHeight();
  if (height > 510) {
    ySize=STORAGE_HEIGHT2;
  }
 else   if (height > 340) {
    ySize=STORAGE_HEIGHT1;
  }
 else {
    ySize=STORAGE_HEIGHT0;
  }
  for (  Object o : container.inventorySlots) {
    Slot slot=(Slot)o;
    slot.yDisplayPosition+=ySize - STORAGE_HEIGHT0;
  }
}

Fixed version (ground truth):
public GuiModularStorage(ModularStorageTileEntity modularStorageTileEntity,Container container){
  super(RFTools.instance,RFToolsMessages.INSTANCE,modularStorageTileEntity,container,RFTools.GUI_MANUAL_MAIN,"String_Node_Str");
  craftingGrid=new GuiCraftingGrid();
  xSize=STORAGE_WIDTH;
  ScaledResolution scaledresolution=new ScaledResolution(Minecraft.getMinecraft());
  int height=scaledresolution.getScaledHeight();
  if (height > 510) {
    ySize=STORAGE_HEIGHT2;
  }
 else   if (height > 340) {
    ySize=STORAGE_HEIGHT1;
  }
 else {
    ySize=STORAGE_HEIGHT0;
  }
  IInventory gridInventory=((GenericContainer)container).getInventory(CONTAINER_GRID);
  for (  Object o : container.inventorySlots) {
    Slot slot=(Slot)o;
    if (slot.inventory != gridInventory) {
      slot.yDisplayPosition+=ySize - STORAGE_HEIGHT0;
    }
  }
}
Program: 165810
Project: 165810
Buggy source:
static List<ItemStack> testAndConsumeCraftingItems(EntityPlayerMP player,CraftingRecipe craftingRecipe,IInventory thisInventory,int thisInventoryOffset){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<Pair<IInventory,Integer>,ItemStack> undo=new HashMap<>();
  List<ItemStack> result=new ArrayList<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      count=findMatchingItems(workInventory,undo,result,i,stack,count,player.inventory,0);
      if (count > 0) {
        count=findMatchingItems(workInventory,undo,result,i,stack,count,thisInventory,thisInventoryOffset);
      }
      if (count > 0) {
        undo(player,undo);
        return Collections.emptyList();
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  ItemStack stack=recipe.getCraftingResult(workInventory);
  if (stack != null) {
    result.add(stack);
  }
 else {
    result.clear();
    undo(player,undo);
  }
  return result;
}

Fixed version (ground truth):
static List<ItemStack> testAndConsumeCraftingItems(EntityPlayerMP player,CraftingRecipe craftingRecipe,IInventory thisInventory,int thisInventoryOffset){
  InventoryCrafting workInventory=new InventoryCrafting(new Container(){
    @Override public boolean canInteractWith(    EntityPlayer var1){
      return false;
    }
  }
,3,3);
  Map<Pair<IInventory,Integer>,ItemStack> undo=new HashMap<>();
  List<ItemStack> result=new ArrayList<>();
  InventoryCrafting inventory=craftingRecipe.getInventory();
  for (int i=0; i < inventory.getSizeInventory(); i++) {
    ItemStack stack=inventory.getStackInSlot(i);
    if (stack != null) {
      int count=stack.stackSize;
      count=findMatchingItems(workInventory,undo,result,i,stack,count,player.inventory,0);
      if (count > 0) {
        count=findMatchingItems(workInventory,undo,result,i,stack,count,thisInventory,thisInventoryOffset);
      }
      if (count > 0) {
        undo(player,undo);
        return Collections.emptyList();
      }
    }
 else {
      workInventory.setInventorySlotContents(i,null);
    }
  }
  IRecipe recipe=craftingRecipe.getCachedRecipe(player.worldObj);
  ItemStack stack=recipe.getCraftingResult(workInventory);
  if (stack != null) {
    result.add(stack);
    ItemStack[] remaining=recipe.getRemainingItems(workInventory);
    if (remaining != null) {
      for (      ItemStack s : remaining) {
        if (s != null) {
          result.add(s);
        }
      }
    }
  }
 else {
    result.clear();
    undo(player,undo);
  }
  return result;
}