nus-yam/ex-repair huggingface dataset:
Program: 30585
Project: 30585
Buggy source:
@Override public void generate(Random r,int chunkX,int chunkZ,World w,IChunkProvider chunkGenerator,IChunkProvider chunkProvider){
  int sealevel=w.provider.getAverageGroundLevel() + 1;
  if (oreNormal == null || oreCharged == null)   return;
  double oreDepthMultiplier=AEConfig.instance.quartzOresClusterAmount * sealevel / 64;
  int scale=(int)Math.round(r.nextGaussian() * Math.sqrt(oreDepthMultiplier) + oreDepthMultiplier);
  for (int x=0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x) {
    boolean isCharged=r.nextFloat() > AEConfig.instance.spawnChargedChance;
    WorldGenMinable whichOre=isCharged ? oreCharged : oreNormal;
    if (WorldGenRegistry.instance.isWorldGenEnabled(isCharged ? WorldGenType.ChargedCertusQuartz : WorldGenType.CertusQuartz,w)) {
      int cx=chunkX * 16 + r.nextInt(22);
      int cy=r.nextInt(40 * sealevel / 64) + r.nextInt(22 * sealevel / 64) + 12 * sealevel / 64;
      int cz=chunkZ * 16 + r.nextInt(22);
      whichOre.generate(w,r,cx,cy,cz);
    }
  }
}

Fixed version (ground truth):
@Override public void generate(Random r,int chunkX,int chunkZ,World w,IChunkProvider chunkGenerator,IChunkProvider chunkProvider){
  int sealevel=w.provider.getAverageGroundLevel() + 1;
  if (sealevel < 20) {
    int x=(chunkX << 4) + 8;
    int z=(chunkZ << 4) + 8;
    sealevel=w.getHeightValue(x,z);
  }
  if (oreNormal == null || oreCharged == null)   return;
  double oreDepthMultiplier=AEConfig.instance.quartzOresClusterAmount * sealevel / 64;
  int scale=(int)Math.round(r.nextGaussian() * Math.sqrt(oreDepthMultiplier) + oreDepthMultiplier);
  for (int x=0; x < (r.nextBoolean() ? scale * 2 : scale) / 2; ++x) {
    boolean isCharged=r.nextFloat() > AEConfig.instance.spawnChargedChance;
    WorldGenMinable whichOre=isCharged ? oreCharged : oreNormal;
    if (WorldGenRegistry.instance.isWorldGenEnabled(isCharged ? WorldGenType.ChargedCertusQuartz : WorldGenType.CertusQuartz,w)) {
      int cx=chunkX * 16 + r.nextInt(22);
      int cy=r.nextInt(40 * sealevel / 64) + r.nextInt(22 * sealevel / 64) + 12 * sealevel / 64;
      int cz=chunkZ * 16 + r.nextInt(22);
      whichOre.generate(w,r,cx,cy,cz);
    }
  }
}
Program: 30588
Project: 30588
Buggy source:
@Override public void readFromNBT(NBTTagCompound data){
  priority=data.getInteger("String_Node_Str");
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound data){
  isCached=false;
  priority=data.getInteger("String_Node_Str");
}
Program: 30589
Project: 30589
Buggy source:
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  isCached=false;
  updateState();
  try {
    gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
    IStorageGrid gs=gridProxy.getStorage();
    Platform.postChanges(gs,removed,added,mySrc);
  }
 catch (  GridAccessException e) {
  }
  markForUpdate();
}

Fixed version (ground truth):
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  if (isCached) {
    isCached=false;
    updateState();
  }
  try {
    gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
    IStorageGrid gs=gridProxy.getStorage();
    Platform.postChanges(gs,removed,added,mySrc);
  }
 catch (  GridAccessException e) {
  }
  markForUpdate();
}
Program: 30590
Project: 30590
Buggy source:
public void unduplicate(){
  for (  MaterialType mt : dmgToMaterial.values()) {
    if (mt.getOreName() != null) {
      ItemStack replacement=null;
      String names[]=mt.getOreName().split("String_Node_Str");
      for (      String name : names) {
        if (replacement != null)         break;
        ArrayList<ItemStack> options=OreDictionary.getOres(name);
        if (options != null && options.size() > 0) {
          for (          ItemStack is : options) {
            if (is != null && is.getItem() != null) {
              replacement=is.copy();
              break;
            }
          }
        }
      }
      if (replacement == null || AEConfig.instance.useAEVersion(mt)) {
        for (        String name : names)         OreDictionary.registerOre(name,mt.stack(1));
      }
 else {
        mt.itemInstance=replacement.getItem();
        mt.damageValue=replacement.getItemDamage();
      }
    }
  }
}

Fixed version (ground truth):
public void unduplicate(){
  for (  MaterialType mt : ImmutableSet.copyOf(dmgToMaterial.values())) {
    if (mt.getOreName() != null) {
      ItemStack replacement=null;
      String names[]=mt.getOreName().split("String_Node_Str");
      for (      String name : names) {
        if (replacement != null)         break;
        ArrayList<ItemStack> options=OreDictionary.getOres(name);
        if (options != null && options.size() > 0) {
          for (          ItemStack is : options) {
            if (is != null && is.getItem() != null) {
              replacement=is.copy();
              break;
            }
          }
        }
      }
      if (replacement == null || AEConfig.instance.useAEVersion(mt)) {
        for (        String name : names)         OreDictionary.registerOre(name,mt.stack(1));
      }
 else {
        if (mt.itemInstance == this)         dmgToMaterial.remove(mt.damageValue);
        mt.itemInstance=replacement.getItem();
        mt.damageValue=replacement.getItemDamage();
      }
    }
  }
}
Program: 30592
Project: 30592
Buggy source:
private boolean diveList(NetworkInventoryHandler<T> networkInventoryHandler){
  LinkedList cDepth=getDepth();
  if (cDepth.contains(networkInventoryHandler))   return true;
  cDepth.push(this);
  return false;
}

Fixed version (ground truth):
private boolean diveList(NetworkInventoryHandler<T> networkInventoryHandler,Actionable type){
  LinkedList cDepth=getDepth(type);
  if (cDepth.contains(networkInventoryHandler))   return true;
  cDepth.push(this);
  return false;
}
Program: 30593
Project: 30593
Buggy source:
private LinkedList getDepth(){
  LinkedList s=depth.get();
  if (s == null)   depth.set(s=new LinkedList());
  return s;
}

Fixed version (ground truth):
private LinkedList getDepth(Actionable type){
  ThreadLocal<LinkedList> depth=type == Actionable.MODULATE ? depthMod : depthSim;
  LinkedList s=depth.get();
  if (s == null)   depth.set(s=new LinkedList());
  return s;
}
Program: 30594
Project: 30594
Buggy source:
private void surface(NetworkInventoryHandler<T> networkInventoryHandler){
  if (getDepth().pop() != this)   throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
private void surface(NetworkInventoryHandler<T> networkInventoryHandler,Actionable type){
  if (getDepth(type).pop() != this)   throw new RuntimeException("String_Node_Str");
}
Program: 30595
Project: 30595
Buggy source:
@Override public T extractItems(T request,Actionable mode,BaseActionSource src){
  if (diveList(this))   return null;
  if (testPermission(src,SecurityPermissions.EXTRACT)) {
    surface(this);
    return null;
  }
  Iterator<List<IMEInventoryHandler<T>>> i=prorityInventory.descendingMap().values().iterator();
  T output=request.copy();
  request=request.copy();
  output.setStackSize(0);
  long req=request.getStackSize();
  while (i.hasNext()) {
    List<IMEInventoryHandler<T>> invList=i.next();
    Iterator<IMEInventoryHandler<T>> ii=invList.iterator();
    while (ii.hasNext() && output.getStackSize() < req) {
      IMEInventoryHandler<T> inv=ii.next();
      request.setStackSize(req - output.getStackSize());
      output.add(inv.extractItems(request,mode,src));
    }
  }
  surface(this);
  if (output.getStackSize() <= 0)   return null;
  return output;
}

Fixed version (ground truth):
@Override public T extractItems(T request,Actionable mode,BaseActionSource src){
  if (diveList(this,mode))   return null;
  if (testPermission(src,SecurityPermissions.EXTRACT)) {
    surface(this,mode);
    return null;
  }
  Iterator<List<IMEInventoryHandler<T>>> i=prorityInventory.descendingMap().values().iterator();
  T output=request.copy();
  request=request.copy();
  output.setStackSize(0);
  long req=request.getStackSize();
  while (i.hasNext()) {
    List<IMEInventoryHandler<T>> invList=i.next();
    Iterator<IMEInventoryHandler<T>> ii=invList.iterator();
    while (ii.hasNext() && output.getStackSize() < req) {
      IMEInventoryHandler<T> inv=ii.next();
      request.setStackSize(req - output.getStackSize());
      output.add(inv.extractItems(request,mode,src));
    }
  }
  surface(this,mode);
  if (output.getStackSize() <= 0)   return null;
  return output;
}
Program: 30596
Project: 30596
Buggy source:
private boolean diveIteration(NetworkInventoryHandler<T> networkInventoryHandler){
  if (getDepth().isEmpty()) {
    currentPass++;
    myPass=currentPass;
  }
 else {
    if (currentPass == myPass)     return true;
 else     myPass=currentPass;
  }
  getDepth().push(this);
  return false;
}

Fixed version (ground truth):
private boolean diveIteration(NetworkInventoryHandler<T> networkInventoryHandler,Actionable type){
  LinkedList cDepth=getDepth(type);
  if (cDepth.isEmpty()) {
    currentPass++;
    myPass=currentPass;
  }
 else {
    if (currentPass == myPass)     return true;
 else     myPass=currentPass;
  }
  cDepth.push(this);
  return false;
}
Program: 30597
Project: 30597
Buggy source:
@Override public T injectItems(T input,Actionable type,BaseActionSource src){
  if (diveList(this))   return input;
  if (testPermission(src,SecurityPermissions.INJECT)) {
    surface(this);
    return input;
  }
  Iterator<List<IMEInventoryHandler<T>>> i=prorityInventory.values().iterator();
  while (i.hasNext()) {
    List<IMEInventoryHandler<T>> invList=i.next();
    Iterator<IMEInventoryHandler<T>> ii=invList.iterator();
    while (ii.hasNext() && input != null) {
      IMEInventoryHandler<T> inv=ii.next();
      if (inv.validForPass(1) && inv.canAccept(input) && (inv.isPrioritized(input) || inv.extractItems(input,Actionable.SIMULATE,src) != null))       input=inv.injectItems(input,type,src);
    }
    ii=invList.iterator();
    while (ii.hasNext() && input != null) {
      IMEInventoryHandler<T> inv=ii.next();
      if (inv.validForPass(2) && inv.canAccept(input))       input=inv.injectItems(input,type,src);
    }
  }
  surface(this);
  return input;
}

Fixed version (ground truth):
@Override public T injectItems(T input,Actionable type,BaseActionSource src){
  if (diveList(this,type))   return input;
  if (testPermission(src,SecurityPermissions.INJECT)) {
    surface(this,type);
    return input;
  }
  Iterator<List<IMEInventoryHandler<T>>> i=prorityInventory.values().iterator();
  while (i.hasNext()) {
    List<IMEInventoryHandler<T>> invList=i.next();
    Iterator<IMEInventoryHandler<T>> ii=invList.iterator();
    while (ii.hasNext() && input != null) {
      IMEInventoryHandler<T> inv=ii.next();
      if (inv.validForPass(1) && inv.canAccept(input) && (inv.isPrioritized(input) || inv.extractItems(input,Actionable.SIMULATE,src) != null))       input=inv.injectItems(input,type,src);
    }
    ii=invList.iterator();
    while (ii.hasNext() && input != null) {
      IMEInventoryHandler<T> inv=ii.next();
      if (inv.validForPass(2) && inv.canAccept(input))       input=inv.injectItems(input,type,src);
    }
  }
  surface(this,type);
  return input;
}
Program: 30598
Project: 30598
Buggy source:
@Override public IItemList<T> getAvailableItems(IItemList out){
  if (diveIteration(this))   return out;
  for (  List<IMEInventoryHandler<T>> i : prorityInventory.values())   for (  IMEInventoryHandler<T> j : i)   out=j.getAvailableItems(out);
  surface(this);
  return out;
}

Fixed version (ground truth):
@Override public IItemList<T> getAvailableItems(IItemList out){
  if (diveIteration(this,Actionable.SIMULATE))   return out;
  for (  List<IMEInventoryHandler<T>> i : prorityInventory.values())   for (  IMEInventoryHandler<T> j : i)   out=j.getAvailableItems(out);
  surface(this,Actionable.SIMULATE);
  return out;
}
Program: 30600
Project: 30600
Buggy source:
@Override public void cleanup(){
  getWorldObj().setBlock(xCoord,yCoord,zCoord,Platform.air);
}

Fixed version (ground truth):
@Override public void cleanup(){
  if (AppEng.instance.isIntegrationEnabled(IntegrationType.ImmibisMicroblocks)) {
    IImmibisMicroblocks imb=(IImmibisMicroblocks)AppEng.instance.getIntegration(IntegrationType.ImmibisMicroblocks);
    if (imb != null && imb.leaveParts(this))     return;
  }
  getWorldObj().setBlock(xCoord,yCoord,zCoord,Platform.air);
}
Program: 30601
Project: 30601
Buggy source:
public static void openGUI(EntityPlayer p,TileEntity tile,ForgeDirection side,GuiBridge type){
  if (isClient())   return;
  int x=(int)p.posX, y=(int)p.posY, z=(int)p.posZ;
  if (tile != null) {
    x=tile.xCoord;
    y=tile.yCoord;
    z=tile.zCoord;
  }
  if ((type.getType().isItem() && tile == null) || type.hasPermissions(tile,x,y,z,side,p)) {
    if (tile == null)     p.openGui(AppEng.instance,type.ordinal() << 3,p.getEntityWorld(),x,y,z);
 else     p.openGui(AppEng.instance,type.ordinal() << 3 | (side.ordinal()),tile.getWorldObj(),x,y,z);
  }
}

Fixed version (ground truth):
public static void openGUI(EntityPlayer p,TileEntity tile,ForgeDirection side,GuiBridge type){
  if (isClient())   return;
  int x=(int)p.posX, y=(int)p.posY, z=(int)p.posZ;
  if (tile != null) {
    x=tile.xCoord;
    y=tile.yCoord;
    z=tile.zCoord;
  }
  if ((type.getType().isItem() && tile == null) || type.hasPermissions(tile,x,y,z,side,p)) {
    if (tile == null)     p.openGui(AppEng.instance,type.ordinal() << 4 | (1 << 3),p.getEntityWorld(),x,y,z);
 else     p.openGui(AppEng.instance,type.ordinal() << 4 | (side.ordinal()),tile.getWorldObj(),x,y,z);
  }
}
Program: 30602
Project: 30602
Buggy source:
@Override public void updateSetting(IConfigManager manager,Enum setting,Enum newValue){
  for (  Enum e : settings.getSettings()) {
    if (e == setting) {
      String Category=e.getClass().getSimpleName();
      Property p=this.get(Category,e.name(),settings.getSetting(e).name(),getListComment(newValue));
      p.set(newValue.name());
    }
  }
  if (updateable)   save();
}

Fixed version (ground truth):
@Override public void updateSetting(IConfigManager manager,Enum setting,Enum newValue){
  for (  Enum e : settings.getSettings()) {
    if (e == setting) {
      String Category="String_Node_Str";
      Property p=this.get(Category,e.name(),settings.getSetting(e).name(),getListComment(newValue));
      p.set(newValue.name());
    }
  }
  if (updateable)   save();
}
Program: 30603
Project: 30603
Buggy source:
private void resetCache(boolean fullReset){
  if (host == null || host.getTile() == null || host.getTile().getWorldObj() == null)   return;
  IMEInventory<IAEItemStack> in=getInternalHandler();
  IItemList<IAEItemStack> before=AEApi.instance().storage().createItemList();
  if (in != null)   before=in.getAvailableItems(before);
  cached=false;
  if (fullReset)   handlerHash=0;
  IMEInventory<IAEItemStack> out=getInternalHandler();
  if (monitor != null)   monitor.onTick();
  IItemList<IAEItemStack> after=AEApi.instance().storage().createItemList();
  if (out != null)   after=out.getAvailableItems(after);
  Platform.postListChanges(before,after,this,mySrc);
}

Fixed version (ground truth):
private void resetCache(boolean fullReset){
  if (host == null || host.getTile() == null || host.getTile().getWorldObj() == null || host.getTile().getWorldObj().isRemote)   return;
  IMEInventory<IAEItemStack> in=getInternalHandler();
  IItemList<IAEItemStack> before=AEApi.instance().storage().createItemList();
  if (in != null)   before=in.getAvailableItems(before);
  cached=false;
  if (fullReset)   handlerHash=0;
  IMEInventory<IAEItemStack> out=getInternalHandler();
  if (monitor != null)   monitor.onTick();
  IItemList<IAEItemStack> after=AEApi.instance().storage().createItemList();
  if (out != null)   after=out.getAvailableItems(after);
  Platform.postListChanges(before,after,this,mySrc);
}
Program: 30604
Project: 30604
Buggy source:
@Override public void readFromNBT(NBTTagCompound data){
  if (data.hasKey("String_Node_Str")) {
    ItemStack myPat=ItemStack.loadItemStackFromNBT(data.getCompoundTag("String_Node_Str"));
    if (myPat != null && myPat.getItem() instanceof ItemEncodedPattern) {
      World w=getWorldObj();
      ItemEncodedPattern iep=(ItemEncodedPattern)myPat.getItem();
      ICraftingPatternDetails ph=iep.getPatternForItem(myPat,w);
      if (ph != null && ph.isCraftable()) {
        forcePlan=true;
        myPlan=ph;
      }
    }
  }
  upgrades.readFromNBT(data,"String_Node_Str");
  inv.readFromNBT(data,"String_Node_Str");
  settings.readFromNBT(data);
  recalculatePlan();
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound data){
  if (data.hasKey("String_Node_Str")) {
    ItemStack myPat=ItemStack.loadItemStackFromNBT(data.getCompoundTag("String_Node_Str"));
    if (myPat != null && myPat.getItem() instanceof ItemEncodedPattern) {
      World w=getWorldObj();
      ItemEncodedPattern iep=(ItemEncodedPattern)myPat.getItem();
      ICraftingPatternDetails ph=iep.getPatternForItem(myPat,w);
      if (ph != null && ph.isCraftable()) {
        forcePlan=true;
        myPlan=ph;
        pushDirection=ForgeDirection.getOrientation(data.getInteger("String_Node_Str"));
      }
    }
  }
  upgrades.readFromNBT(data,"String_Node_Str");
  inv.readFromNBT(data,"String_Node_Str");
  settings.readFromNBT(data);
  recalculatePlan();
}
Program: 30606
Project: 30606
Buggy source:
@Override public void writeToNBT(NBTTagCompound data){
  if (forcePlan && myPlan != null) {
    ItemStack pattern=myPlan.getPattern();
    if (pattern != null) {
      NBTTagCompound pdata=new NBTTagCompound();
      pattern.writeToNBT(pdata);
      data.setTag("String_Node_Str",pdata);
    }
  }
  upgrades.writeToNBT(data,"String_Node_Str");
  inv.writeToNBT(data,"String_Node_Str");
  settings.writeToNBT(data);
}

Fixed version (ground truth):
@Override public void writeToNBT(NBTTagCompound data){
  if (forcePlan && myPlan != null) {
    ItemStack pattern=myPlan.getPattern();
    if (pattern != null) {
      NBTTagCompound pdata=new NBTTagCompound();
      pattern.writeToNBT(pdata);
      data.setTag("String_Node_Str",pdata);
      data.setInteger("String_Node_Str",pushDirection.ordinal());
    }
  }
  upgrades.writeToNBT(data,"String_Node_Str");
  inv.writeToNBT(data,"String_Node_Str");
  settings.writeToNBT(data);
}
Program: 30607
Project: 30607
Buggy source:
private void recalculatePlan(){
  reboot=true;
  if (forcePlan)   return;
  ItemStack is=inv.getStackInSlot(10);
  if (is != null && is.getItem() instanceof ItemEncodedPattern) {
    if (!Platform.isSameItem(is,myPattern)) {
      World w=getWorldObj();
      ItemEncodedPattern iep=(ItemEncodedPattern)is.getItem();
      ICraftingPatternDetails ph=iep.getPatternForItem(is,w);
      if (ph.isCraftable()) {
        progress=0;
        myPattern=is;
        myPlan=ph;
      }
    }
  }
 else {
    progress=0;
    forcePlan=false;
    myPlan=null;
    myPattern=null;
  }
  updateSleepyness();
}

Fixed version (ground truth):
private void recalculatePlan(){
  reboot=true;
  if (forcePlan)   return;
  ItemStack is=inv.getStackInSlot(10);
  if (is != null && is.getItem() instanceof ItemEncodedPattern) {
    if (!Platform.isSameItem(is,myPattern)) {
      World w=getWorldObj();
      ItemEncodedPattern iep=(ItemEncodedPattern)is.getItem();
      ICraftingPatternDetails ph=iep.getPatternForItem(is,w);
      if (ph.isCraftable()) {
        progress=0;
        myPattern=is;
        myPlan=ph;
      }
    }
  }
 else {
    progress=0;
    forcePlan=false;
    myPlan=null;
    myPattern=null;
    pushDirection=ForgeDirection.UNKNOWN;
  }
  updateSleepyness();
}
Program: 30609
Project: 30609
Buggy source:
public CraftingTreeNode(ICraftingGrid cc,CraftingJob job,IAEItemStack wat,CraftingTreeProcess par,int slot,int depth){
  what=wat;
  parent=par;
  this.slot=slot;
  this.world=job.getWorld();
  this.job=job;
  sim=false;
  for (  ICraftingPatternDetails details : cc.getCraftingFor(what)) {
    if (parent == null || parent.notRecurive(details))     nodes.add(new CraftingTreeProcess(cc,job,details,this,depth + 1,world));
  }
}

Fixed version (ground truth):
public CraftingTreeNode(ICraftingGrid cc,CraftingJob job,IAEItemStack wat,CraftingTreeProcess par,int slot,int depth){
  what=wat;
  parent=par;
  this.slot=slot;
  this.world=job.getWorld();
  this.job=job;
  sim=false;
  for (  ICraftingPatternDetails details : cc.getCraftingFor(what,parent == null ? null : parent.details,slot,world)) {
    if (parent == null || parent.notRecurive(details))     nodes.add(new CraftingTreeProcess(cc,job,details,this,depth + 1,world));
  }
}
Program: 30610
Project: 30610
Buggy source:
IAEItemStack getAmountCrafted(IAEItemStack what2){
  for (  IAEItemStack is : details.getCondencedOutputs()) {
    if (is.equals(what2)) {
      what2=what2.copy();
      what2.setStackSize(is.getStackSize());
      return what2;
    }
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
IAEItemStack getAmountCrafted(IAEItemStack what2){
  for (  IAEItemStack is : details.getCondencedOutputs()) {
    if (is.equals(what2)) {
      what2=what2.copy();
      what2.setStackSize(is.getStackSize());
      return what2;
    }
  }
  for (  IAEItemStack is : details.getCondencedOutputs()) {
    if (is.getItem() == what2.getItem() && (is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage())) {
      what2=is.copy();
      what2.setStackSize(is.getStackSize());
      return what2;
    }
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 30611
Project: 30611
Buggy source:
public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(IAEItemStack what){
  ImmutableSet<ICraftingPatternDetails> res=craftableItems.get(what);
  if (res == null)   return ImmutableSet.of();
  return res;
}

Fixed version (ground truth):
@Override public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(IAEItemStack whatToCraft,ICraftingPatternDetails details,int slotIndex,World world){
  ImmutableSet<ICraftingPatternDetails> res=craftableItems.get(whatToCraft);
  if (res == null) {
    if (details != null && details.isCraftable()) {
      for (      IAEItemStack ais : craftableItems.keySet()) {
        if (ais.getItem() == whatToCraft.getItem() && (!ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage())) {
          if (details.isValidItemForSlot(slotIndex,ais.getItemStack(),world)) {
            return craftableItems.get(ais);
          }
        }
      }
    }
    return ImmutableSet.of();
  }
  return res;
}
Program: 30613
Project: 30613
Buggy source:
@Override public void onUpdate(String field,Object oldValue,Object newValue){
  if (field.equals("String_Node_Str")) {
    getAndUpdateOutput();
    updateOrderOfOutputSlots();
  }
}

Fixed version (ground truth):
@Override public void onUpdate(String field,Object oldValue,Object newValue){
  super.onUpdate(field,oldValue,newValue);
  if (field.equals("String_Node_Str")) {
    getAndUpdateOutput();
    updateOrderOfOutputSlots();
  }
}
Program: 30616
Project: 30616
Buggy source:
private void pushItemsOut(EnumSet<ForgeDirection> possibleDirections){
  if (!hasItemsToSend())   return;
  TileEntity tile=iHost.getTileEntity();
  World w=tile.getWorldObj();
  Iterator<ItemStack> i=waitingToSend.iterator();
  while (i.hasNext()) {
    ItemStack whatToSend=i.next();
    for (    ForgeDirection s : possibleDirections) {
      TileEntity te=w.getTileEntity(tile.xCoord + s.offsetX,tile.yCoord + s.offsetY,tile.zCoord + s.offsetZ);
      if (te == null)       continue;
      InventoryAdaptor ad=InventoryAdaptor.getAdaptor(te,s.getOpposite());
      if (ad != null) {
        whatToSend=ad.addItems(whatToSend);
        if (whatToSend == null)         break;
      }
    }
    if (whatToSend == null)     i.remove();
  }
  if (waitingToSend.isEmpty())   waitingToSend=null;
}

Fixed version (ground truth):
private void pushItemsOut(EnumSet<ForgeDirection> possibleDirections){
  if (!hasItemsToSend())   return;
  TileEntity tile=iHost.getTileEntity();
  World w=tile.getWorldObj();
  Iterator<ItemStack> i=waitingToSend.iterator();
  while (i.hasNext()) {
    ItemStack whatToSend=i.next();
    for (    ForgeDirection s : possibleDirections) {
      TileEntity te=w.getTileEntity(tile.xCoord + s.offsetX,tile.yCoord + s.offsetY,tile.zCoord + s.offsetZ);
      if (te == null)       continue;
      InventoryAdaptor ad=InventoryAdaptor.getAdaptor(te,s.getOpposite());
      if (ad != null) {
        ItemStack Result=ad.addItems(whatToSend);
        if (Result == null)         whatToSend=null;
 else         whatToSend.stackSize-=whatToSend.stackSize - Result.stackSize;
        if (whatToSend == null)         break;
      }
    }
    if (whatToSend == null)     i.remove();
  }
  if (waitingToSend.isEmpty())   waitingToSend=null;
}
Program: 30617
Project: 30617
Buggy source:
public IAEItemStack getLow(FuzzyMode fuzzy,boolean ignoreMeta){
  AEItemStack bottom=new AEItemStack(this);
  AEItemDef newDef=bottom.def=bottom.def.copy();
  if (ignoreMeta) {
    newDef.dspDamage=newDef.damageValue=0;
    newDef.reHash();
    return bottom;
  }
  if (newDef.item.isDamageable()) {
    if (fuzzy == FuzzyMode.IGNORE_ALL) {
      newDef.dspDamage=0;
    }
 else {
      int low=fuzzy.calculateBreakPoint(def.maxDamage);
      newDef.dspDamage=low < def.dspDamage ? low : 0;
    }
    newDef.damageValue=newDef.dspDamage;
  }
  newDef.tagCompound=AEItemDef.lowTag;
  newDef.reHash();
  return bottom;
}

Fixed version (ground truth):
public IAEItemStack getLow(FuzzyMode fuzzy,boolean ignoreMeta){
  AEItemStack bottom=new AEItemStack(this);
  AEItemDef newDef=bottom.def=bottom.def.copy();
  if (ignoreMeta) {
    newDef.dspDamage=newDef.damageValue=0;
    newDef.reHash();
    return bottom;
  }
  if (newDef.item.isDamageable()) {
    if (fuzzy == FuzzyMode.IGNORE_ALL) {
      newDef.dspDamage=0;
    }
 else {
      int breakpoint=fuzzy.calculateBreakPoint(def.maxDamage);
      newDef.dspDamage=breakpoint < def.dspDamage ? breakpoint : 0;
    }
    newDef.damageValue=newDef.dspDamage;
  }
  newDef.tagCompound=AEItemDef.lowTag;
  newDef.reHash();
  return bottom;
}
Program: 30618
Project: 30618
Buggy source:
public IAEItemStack getHigh(FuzzyMode fuzzy,boolean ignoreMeta){
  AEItemStack top=new AEItemStack(this);
  AEItemDef newDef=top.def=top.def.copy();
  if (ignoreMeta) {
    newDef.dspDamage=newDef.damageValue=Integer.MAX_VALUE;
    newDef.reHash();
    return top;
  }
  if (newDef.item.isDamageable()) {
    if (fuzzy == FuzzyMode.IGNORE_ALL) {
      newDef.dspDamage=def.maxDamage + 1;
    }
 else {
      int high=fuzzy.calculateBreakPoint(def.maxDamage) + 1;
      newDef.dspDamage=high > def.dspDamage ? high : def.maxDamage + 1;
    }
    newDef.damageValue=top.def.dspDamage;
  }
  newDef.tagCompound=AEItemDef.highTag;
  newDef.reHash();
  return top;
}

Fixed version (ground truth):
public IAEItemStack getHigh(FuzzyMode fuzzy,boolean ignoreMeta){
  AEItemStack top=new AEItemStack(this);
  AEItemDef newDef=top.def=top.def.copy();
  if (ignoreMeta) {
    newDef.dspDamage=newDef.damageValue=Integer.MAX_VALUE;
    newDef.reHash();
    return top;
  }
  if (newDef.item.isDamageable()) {
    if (fuzzy == FuzzyMode.IGNORE_ALL) {
      newDef.dspDamage=def.maxDamage + 1;
    }
 else {
      int breakpoint=fuzzy.calculateBreakPoint(def.maxDamage);
      newDef.dspDamage=def.dspDamage < breakpoint ? breakpoint - 1 : def.maxDamage + 1;
    }
    newDef.damageValue=newDef.dspDamage;
  }
  newDef.tagCompound=AEItemDef.highTag;
  newDef.reHash();
  return top;
}
Program: 30619
Project: 30619
Buggy source:
protected void drawItem(int x,int y,ItemStack is){
  this.zLevel=100.0F;
  itemRender.zLevel=100.0F;
  GL11.glEnable(GL11.GL_LIGHTING);
  GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  RenderHelper.enableGUIStandardItemLighting();
  itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj,this.mc.renderEngine,is,x,y);
  GL11.glDisable(GL11.GL_LIGHTING);
  itemRender.zLevel=0.0F;
  this.zLevel=0.0F;
}

Fixed version (ground truth):
protected void drawItem(int x,int y,ItemStack is){
  this.zLevel=100.0F;
  itemRender.zLevel=100.0F;
  GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
  GL11.glEnable(GL11.GL_LIGHTING);
  GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  RenderHelper.enableGUIStandardItemLighting();
  itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj,this.mc.renderEngine,is,x,y);
  GL11.glPopAttrib();
  itemRender.zLevel=0.0F;
  this.zLevel=0.0F;
}
Program: 30620
Project: 30620
Buggy source:
public TileIOPort(){
  addNewHandler(new TileIOPortHandler());
  cm.registerSetting(Settings.REDSTONE_CONTROLLED,RedstoneMode.IGNORE);
  cm.registerSetting(Settings.FULLNESS_MODE,FullnessMode.EMPTY);
  cm.registerSetting(Settings.OPERATION_MODE,OperationMode.EMPTY);
}

Fixed version (ground truth):
public TileIOPort(){
  addNewHandler(new TileIOPortHandler());
  gridProxy.setFlags(GridFlags.REQUIRE_CHANNEL);
  cm.registerSetting(Settings.REDSTONE_CONTROLLED,RedstoneMode.IGNORE);
  cm.registerSetting(Settings.FULLNESS_MODE,FullnessMode.EMPTY);
  cm.registerSetting(Settings.OPERATION_MODE,OperationMode.EMPTY);
}
Program: 30622
Project: 30622
Buggy source:
TelDestination(World _dim,AxisAlignedBB srcBox,double _x,double _y,double _z){
  dim=_dim;
  x=Math.min(srcBox.maxX - 0.5,Math.max(srcBox.minX + 0.5,_x));
  y=Math.min(srcBox.maxY - 0.5,Math.max(srcBox.minY + 0.5,_y));
  z=Math.min(srcBox.maxZ - 0.5,Math.max(srcBox.minZ + 0.5,_z));
}

Fixed version (ground truth):
TelDestination(World _dim,AxisAlignedBB srcBox,double _x,double _y,double _z,int tileX,int tileY,int tileZ){
  dim=_dim;
  x=Math.min(srcBox.maxX - 0.5,Math.max(srcBox.minX + 0.5,_x + tileX));
  y=Math.min(srcBox.maxY - 0.5,Math.max(srcBox.minY + 0.5,_y + tileY));
  z=Math.min(srcBox.maxZ - 0.5,Math.max(srcBox.minZ + 0.5,_z + tileZ));
  xOff=tileX;
  yOff=tileY;
  zOff=tileZ;
}
Program: 30624
Project: 30624
Buggy source:
List<PartP2PLiquids> getOutputs(Fluid input){
  List<PartP2PLiquids> outs=new LinkedList<PartP2PLiquids>();
  try {
    for (    PartP2PLiquids l : getOutputs()) {
      IFluidHandler targ=l.getTarget();
      if (targ != null) {
        if (targ.canFill(side.getOpposite(),input))         outs.add(l);
      }
    }
  }
 catch (  GridAccessException e) {
  }
  return outs;
}

Fixed version (ground truth):
List<PartP2PLiquids> getOutputs(Fluid input){
  List<PartP2PLiquids> outs=new LinkedList<PartP2PLiquids>();
  try {
    for (    PartP2PLiquids l : getOutputs()) {
      IFluidHandler targ=l.getTarget();
      if (targ != null) {
        if (targ.canFill(l.side.getOpposite(),input))         outs.add(l);
      }
    }
  }
 catch (  GridAccessException e) {
  }
  return outs;
}
Program: 30625
Project: 30625
Buggy source:
private void regenList(NBTTagCompound data){
  byId.clear();
  diList.clear();
  IActionHost host=getActionHost();
  if (host != null) {
    IGridNode agn=host.getActionableNode();
    if (agn.isActive()) {
      for (      IGridNode gn : g.getMachines(TileInterface.class)) {
        IInterfaceHost ih=(IInterfaceHost)gn.getMachine();
        DualityInterface dual=ih.getInterfaceDuality();
        diList.put(ih,new InvTracker(dual,dual.getPatterns(),dual.getTermName()));
      }
      for (      IGridNode gn : g.getMachines(PartInterface.class)) {
        IInterfaceHost ih=(IInterfaceHost)gn.getMachine();
        DualityInterface dual=ih.getInterfaceDuality();
        diList.put(ih,new InvTracker(dual,dual.getPatterns(),dual.getTermName()));
      }
    }
  }
  data.setBoolean("String_Node_Str",true);
  for (  Entry<IInterfaceHost,InvTracker> en : diList.entrySet()) {
    InvTracker inv=en.getValue();
    byId.put(inv.which,inv);
    addItems(data,inv,0,inv.server.getSizeInventory());
  }
}

Fixed version (ground truth):
private void regenList(NBTTagCompound data){
  byId.clear();
  diList.clear();
  IActionHost host=getActionHost();
  if (host != null) {
    IGridNode agn=host.getActionableNode();
    if (agn.isActive()) {
      for (      IGridNode gn : g.getMachines(TileInterface.class)) {
        IInterfaceHost ih=(IInterfaceHost)gn.getMachine();
        DualityInterface dual=ih.getInterfaceDuality();
        if (gn.isActive())         diList.put(ih,new InvTracker(dual,dual.getPatterns(),dual.getTermName()));
      }
      for (      IGridNode gn : g.getMachines(PartInterface.class)) {
        IInterfaceHost ih=(IInterfaceHost)gn.getMachine();
        DualityInterface dual=ih.getInterfaceDuality();
        if (gn.isActive())         diList.put(ih,new InvTracker(dual,dual.getPatterns(),dual.getTermName()));
      }
    }
  }
  data.setBoolean("String_Node_Str",true);
  for (  Entry<IInterfaceHost,InvTracker> en : diList.entrySet()) {
    InvTracker inv=en.getValue();
    byId.put(inv.which,inv);
    addItems(data,inv,0,inv.server.getSizeInventory());
  }
}
Program: 30626
Project: 30626
Buggy source:
public void startJob(){
  GuiBridge OriginalGui=null;
  IActionHost ah=getActionHost();
  if (ah instanceof WirelessTerminalGuiObject)   OriginalGui=GuiBridge.GUI_WIRELESS_TERM;
  if (ah instanceof PartTerminal)   OriginalGui=GuiBridge.GUI_ME;
  if (ah instanceof PartCraftingTerminal)   OriginalGui=GuiBridge.GUI_CRAFTING_TERMINAL;
  if (ah instanceof PartPatternTerminal)   OriginalGui=GuiBridge.GUI_PATTERN_TERMINAL;
  if (result != null && simulation == false) {
    ICraftingGrid cc=getGrid().getCache(ICraftingGrid.class);
    ICraftingLink g=cc.submitJob(result,null,selectedCpu == -1 ? null : cpus.get(selectedCpu).cpu,getActionSrc());
    autoStart=false;
    if (g != null && OriginalGui != null && openContext != null) {
      TileEntity te=openContext.w.getTileEntity(openContext.x,openContext.y,openContext.z);
      Platform.openGUI(invPlayer.player,te,openContext.side,OriginalGui);
    }
  }
}

Fixed version (ground truth):
public void startJob(){
  GuiBridge OriginalGui=null;
  IActionHost ah=getActionHost();
  if (ah instanceof WirelessTerminalGuiObject)   OriginalGui=GuiBridge.GUI_WIRELESS_TERM;
  if (ah instanceof PartTerminal)   OriginalGui=GuiBridge.GUI_ME;
  if (ah instanceof PartCraftingTerminal)   OriginalGui=GuiBridge.GUI_CRAFTING_TERMINAL;
  if (ah instanceof PartPatternTerminal)   OriginalGui=GuiBridge.GUI_PATTERN_TERMINAL;
  if (result != null && simulation == false) {
    ICraftingGrid cc=getGrid().getCache(ICraftingGrid.class);
    ICraftingLink g=cc.submitJob(result,null,selectedCpu == -1 ? null : cpus.get(selectedCpu).cpu,getActionSrc());
    autoStart=false;
    if (g != null && OriginalGui != null && openContext != null) {
      try {
        NetworkHandler.instance.sendTo(new PacketSwitchGuis(OriginalGui),(EntityPlayerMP)invPlayer.player);
      }
 catch (      IOException e) {
      }
      TileEntity te=openContext.w.getTileEntity(openContext.x,openContext.y,openContext.z);
      Platform.openGUI(invPlayer.player,te,openContext.side,OriginalGui);
    }
  }
}
Program: 30627
Project: 30627
Buggy source:
public PacketSwitchGuis(GuiBridge newGui) throws IOException {
  this.newGui=newGui;
  AEBaseGui.switchingGuis=true;
  ByteBuf data=Unpooled.buffer();
  data.writeInt(getPacketID());
  data.writeInt(newGui.ordinal());
  configureWrite(data);
}

Fixed version (ground truth):
public PacketSwitchGuis(GuiBridge newGui) throws IOException {
  this.newGui=newGui;
  if (Platform.isClient())   AEBaseGui.switchingGuis=true;
  ByteBuf data=Unpooled.buffer();
  data.writeInt(getPacketID());
  data.writeInt(newGui.ordinal());
  configureWrite(data);
}
Program: 30628
Project: 30628
Buggy source:
@Override public void add(T option){
  if (option.isCraftable()) {
    option=(T)option.copy();
    option.setCraftable(false);
  }
  target.add(option);
}

Fixed version (ground truth):
@Override public void add(T option){
  if (option != null && option.isCraftable()) {
    option=(T)option.copy();
    option.setCraftable(false);
  }
  target.add(option);
}
Program: 30629
Project: 30629
Buggy source:
private ItemStack findNextColor(ItemStack is,ItemStack anchor,int scrollOffset){
  ItemStack newColor=null;
  IMEInventory<IAEItemStack> inv=AEApi.instance().registries().cell().getCellInventory(is,StorageChannel.ITEMS);
  if (inv != null) {
    IItemList<IAEItemStack> itemList=inv.getAvailableItems(AEApi.instance().storage().createItemList());
    if (anchor == null) {
      IAEItemStack firstItem=itemList.getFirstItem();
      if (firstItem != null)       newColor=firstItem.getItemStack();
    }
 else {
      LinkedList<IAEItemStack> list=new LinkedList<IAEItemStack>();
      for (      IAEItemStack i : itemList)       list.add(i);
      ItemSorters.Direction=SortDir.ASCENDING;
      ItemSorters.init();
      Collections.sort(list,ItemSorters.ConfigBased_SortByName);
      if (list.size() <= 0)       return null;
      IAEItemStack where=list.getFirst();
      int cycles=1 + list.size();
      while (cycles > 0 && !where.equals(anchor)) {
        list.addLast(list.removeFirst());
        cycles--;
        where=list.getFirst();
      }
      if (scrollOffset > 0)       list.addLast(list.removeFirst());
      if (scrollOffset < 0)       list.addFirst(list.removeLast());
      return list.get(0).getItemStack();
    }
  }
  if (newColor != null)   setColor(is,newColor);
  return newColor;
}

Fixed version (ground truth):
private ItemStack findNextColor(ItemStack is,ItemStack anchor,int scrollOffset){
  ItemStack newColor=null;
  IMEInventory<IAEItemStack> inv=AEApi.instance().registries().cell().getCellInventory(is,StorageChannel.ITEMS);
  if (inv != null) {
    IItemList<IAEItemStack> itemList=inv.getAvailableItems(AEApi.instance().storage().createItemList());
    if (anchor == null) {
      IAEItemStack firstItem=itemList.getFirstItem();
      if (firstItem != null)       newColor=firstItem.getItemStack();
    }
 else {
      LinkedList<IAEItemStack> list=new LinkedList<IAEItemStack>();
      for (      IAEItemStack i : itemList)       list.add(i);
      Collections.sort(list,new Comparator<IAEItemStack>(){
        public int compare(        IAEItemStack a,        IAEItemStack b){
          return ItemSorters.compareInt(a.getItemDamage(),b.getItemDamage());
        }
      }
);
      if (list.size() <= 0)       return null;
      IAEItemStack where=list.getFirst();
      int cycles=1 + list.size();
      while (cycles > 0 && !where.equals(anchor)) {
        list.addLast(list.removeFirst());
        cycles--;
        where=list.getFirst();
      }
      if (scrollOffset > 0)       list.addLast(list.removeFirst());
      if (scrollOffset < 0)       list.addFirst(list.removeLast());
      return list.get(0).getItemStack();
    }
  }
  if (newColor != null)   setColor(is,newColor);
  return newColor;
}
Program: 30630
Project: 30630
Buggy source:
private boolean canCraft(ICraftingPatternDetails details,IAEItemStack[] condencedInputs){
  for (  IAEItemStack g : condencedInputs) {
    if (details.isCraftable()) {
      boolean found=false;
      for (      IAEItemStack fuzz : inventory.getItemList().findFuzzy(g,FuzzyMode.IGNORE_ALL)) {
        fuzz=fuzz.copy();
        fuzz.setStackSize(g.getStackSize());
        IAEItemStack ais=inventory.extractItems(fuzz,Actionable.SIMULATE,machineSrc);
        ItemStack is=ais == null ? null : ais.getItemStack();
        if (is != null && is.stackSize == g.getStackSize()) {
          found=true;
          break;
        }
      }
      if (!found)       return false;
    }
 else {
      IAEItemStack ais=inventory.extractItems(g.copy(),Actionable.SIMULATE,machineSrc);
      ItemStack is=ais == null ? null : ais.getItemStack();
      if (is == null || is.stackSize < g.getStackSize())       return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean canCraft(ICraftingPatternDetails details,IAEItemStack[] condencedInputs){
  for (  IAEItemStack g : condencedInputs) {
    if (details.isCraftable()) {
      boolean found=false;
      for (      IAEItemStack fuzz : inventory.getItemList().findFuzzy(g,FuzzyMode.IGNORE_ALL)) {
        fuzz=fuzz.copy();
        fuzz.setStackSize(g.getStackSize());
        IAEItemStack ais=inventory.extractItems(fuzz,Actionable.SIMULATE,machineSrc);
        ItemStack is=ais == null ? null : ais.getItemStack();
        if (is != null && is.stackSize == g.getStackSize()) {
          found=true;
          break;
        }
 else         if (is != null) {
          g=g.copy();
          g.decStackSize(is.stackSize);
        }
      }
      if (!found)       return false;
    }
 else {
      IAEItemStack ais=inventory.extractItems(g.copy(),Actionable.SIMULATE,machineSrc);
      ItemStack is=ais == null ? null : ais.getItemStack();
      if (is == null || is.stackSize < g.getStackSize())       return false;
    }
  }
  return true;
}
Program: 30632
Project: 30632
Buggy source:
@Override public boolean changeColor(AEColor newColor,EntityPlayer who){
  if (getCableColor() != newColor) {
    ItemStack newPart=null;
    if (getCableConnectionType() == AECableType.GLASS)     newPart=AEApi.instance().parts().partCableGlass.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.COVERED)     newPart=AEApi.instance().parts().partCableCovered.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.SMART)     newPart=AEApi.instance().parts().partCableSmart.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.DENSE)     newPart=AEApi.instance().parts().partCableDense.stack(newColor,1);
    boolean hasPermission=true;
    try {
      hasPermission=proxy.getSecurity().hasPermission(who,SecurityPermissions.BUILD);
    }
 catch (    GridAccessException e) {
    }
    if (newPart != null && hasPermission) {
      if (Platform.isClient())       return true;
      getHost().removePart(ForgeDirection.UNKNOWN,false);
      getHost().addPart(newPart,ForgeDirection.UNKNOWN,who);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean changeColor(AEColor newColor,EntityPlayer who){
  if (getCableColor() != newColor) {
    ItemStack newPart=null;
    if (getCableConnectionType() == AECableType.GLASS)     newPart=AEApi.instance().parts().partCableGlass.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.COVERED)     newPart=AEApi.instance().parts().partCableCovered.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.SMART)     newPart=AEApi.instance().parts().partCableSmart.stack(newColor,1);
 else     if (getCableConnectionType() == AECableType.DENSE)     newPart=AEApi.instance().parts().partCableDense.stack(newColor,1);
    boolean hasPermission=true;
    try {
      hasPermission=proxy.getSecurity().hasPermission(who,SecurityPermissions.BUILD);
    }
 catch (    GridAccessException e) {
    }
    if (newPart != null && hasPermission) {
      if (Platform.isClient())       return true;
      getHost().removePart(ForgeDirection.UNKNOWN,true);
      getHost().addPart(newPart,ForgeDirection.UNKNOWN,who);
      return true;
    }
  }
  return false;
}
Program: 30633
Project: 30633
Buggy source:
public CraftingJob(World w,IGrid grid,BaseActionSource actionSrc,IAEItemStack what,ICraftingCallback callback){
  world=wrapWorld(w);
  output=what.copy();
  storage=AEApi.instance().storage().createItemList();
  prophecies=new HashSet();
  this.actionSrc=actionSrc;
  this.callback=callback;
  ICraftingGrid cc=grid.getCache(ICraftingGrid.class);
  IStorageGrid sg=grid.getCache(IStorageGrid.class);
  original=new MECraftingInventory(sg.getItemInventory(),false,false,false);
  availableCheck=new MECraftingInventory(sg.getItemInventory(),false,false,false);
  tree=getCraftingTree(cc,what);
}

Fixed version (ground truth):
public CraftingJob(World w,IGrid grid,BaseActionSource actionSrc,IAEItemStack what,ICraftingCallback callback){
  world=wrapWorld(w);
  output=what.copy();
  storage=AEApi.instance().storage().createItemList();
  prophecies=new HashSet();
  this.actionSrc=actionSrc;
  this.callback=callback;
  ICraftingGrid cc=grid.getCache(ICraftingGrid.class);
  IStorageGrid sg=grid.getCache(IStorageGrid.class);
  original=new MECraftingInventory(sg.getItemInventory(),false,false,false);
  tree=getCraftingTree(cc,what);
  availableCheck=null;
}
Program: 30635
Project: 30635
Buggy source:
public void finish(){
  if (callback != null)   callback.calculationComplete(this);
synchronized (monitor) {
    running=false;
    done=true;
    monitor.notify();
  }
}

Fixed version (ground truth):
public void finish(){
  if (callback != null)   callback.calculationComplete(this);
  availableCheck=null;
synchronized (monitor) {
    running=false;
    done=true;
    monitor.notify();
  }
}
Program: 30637
Project: 30637
Buggy source:
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  if (slot == 1) {
    icell=null;
    fcell=null;
    isCached=false;
    try {
      IStorageGrid gs=gridProxy.getStorage();
      Platform.postChanges(gs,removed,added,mySrc);
      gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
    }
 catch (    GridAccessException e) {
    }
    if (worldObj != null) {
      Platform.notifyBlocksOfNeighbors(worldObj,xCoord,yCoord,zCoord);
      markForUpdate();
    }
  }
}

Fixed version (ground truth):
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  if (slot == 1) {
    icell=null;
    fcell=null;
    isCached=false;
    try {
      gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
      IStorageGrid gs=gridProxy.getStorage();
      Platform.postChanges(gs,removed,added,mySrc);
    }
 catch (    GridAccessException e) {
    }
    if (worldObj != null) {
      Platform.notifyBlocksOfNeighbors(worldObj,xCoord,yCoord,zCoord);
      markForUpdate();
    }
  }
}
Program: 30638
Project: 30638
Buggy source:
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  isCached=false;
  updateState();
  try {
    IStorageGrid gs=gridProxy.getStorage();
    Platform.postChanges(gs,removed,added,mySrc);
    gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
  }
 catch (  GridAccessException e) {
  }
  markForUpdate();
}

Fixed version (ground truth):
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removed,ItemStack added){
  isCached=false;
  updateState();
  try {
    gridProxy.getGrid().postEvent(new MENetworkCellArrayUpdate());
    IStorageGrid gs=gridProxy.getStorage();
    Platform.postChanges(gs,removed,added,mySrc);
  }
 catch (  GridAccessException e) {
  }
  markForUpdate();
}
Program: 30640
Project: 30640
Buggy source:
private void updatePatterns(){
  for (  IAEItemStack out : craftableItems.keySet()) {
    out.reset();
    sg.postAlterationOfStoredItems(StorageChannel.ITEMS,out,new BaseActionSource());
  }
  craftingMethods.clear();
  craftableItems.clear();
  for (  ICraftingProvider cp : providers)   cp.provideCrafting(this);
  HashMap<IAEItemStack,Set<ICraftingPatternDetails>> tmpCraft=new HashMap();
  for (  ICraftingPatternDetails details : craftingMethods.keySet()) {
    for (    IAEItemStack out : details.getOutputs()) {
      out=out.copy();
      out.reset();
      out.setCraftable(true);
      Set<ICraftingPatternDetails> methods=tmpCraft.get(out);
      if (methods == null)       tmpCraft.put(out,methods=new TreeSet());
      methods.add(details);
      sg.postAlterationOfStoredItems(StorageChannel.ITEMS,out,new BaseActionSource());
    }
  }
  for (  Entry<IAEItemStack,Set<ICraftingPatternDetails>> e : tmpCraft.entrySet()) {
    craftableItems.put(e.getKey(),ImmutableSet.copyOf(e.getValue()));
  }
}

Fixed version (ground truth):
private void updatePatterns(){
  for (  IAEItemStack out : craftableItems.keySet()) {
    out.reset();
    sg.postAlterationOfStoredItems(StorageChannel.ITEMS,out,new BaseActionSource());
  }
  craftingMethods.clear();
  craftableItems.clear();
  for (  ICraftingProvider cp : providers)   cp.provideCrafting(this);
  HashMap<IAEItemStack,Set<ICraftingPatternDetails>> tmpCraft=new HashMap();
  for (  ICraftingPatternDetails details : craftingMethods.keySet()) {
    for (    IAEItemStack out : details.getOutputs()) {
      out=out.copy();
      out.reset();
      out.setCraftable(true);
      Set<ICraftingPatternDetails> methods=tmpCraft.get(out);
      if (methods == null)       tmpCraft.put(out,methods=new HashSet());
      methods.add(details);
      sg.postAlterationOfStoredItems(StorageChannel.ITEMS,out,new BaseActionSource());
    }
  }
  for (  Entry<IAEItemStack,Set<ICraftingPatternDetails>> e : tmpCraft.entrySet()) {
    craftableItems.put(e.getKey(),ImmutableSet.copyOf(e.getValue()));
  }
}