nus-yam/ex-repair huggingface dataset:
Program: 30642
Project: 30642
Buggy source:
public TunnelCollection<PartP2PTunnel> getOutputs(long freq,Class<? extends PartP2PTunnel> c){
  PartP2PTunnel in=inputs.get(freq);
  if (in == null)   return NullColl;
  return inputs.get(freq).getCollection(outputs.get(freq));
}

Fixed version (ground truth):
public TunnelCollection<PartP2PTunnel> getOutputs(long freq,Class<? extends PartP2PTunnel> c){
  PartP2PTunnel in=inputs.get(freq);
  if (in == null)   return NullColl;
  TunnelCollection<PartP2PTunnel> out=inputs.get(freq).getCollection(outputs.get(freq),c);
  if (out == null)   return NullColl;
  return out;
}
Program: 30643
Project: 30643
Buggy source:
public void updateFreq(PartP2PTunnel t,long NewFreq){
  outputs.remove(t.freq,t);
  inputs.remove(t.freq);
  t.freq=NewFreq;
  if (t.output)   outputs.put(t.freq,t);
 else   inputs.put(t.freq,t);
  updateTunnel(t.freq,t.output,true);
  updateTunnel(t.freq,!t.output,true);
}

Fixed version (ground truth):
public void updateFreq(PartP2PTunnel t,long NewFreq){
  if (outputs.containsValue(t))   outputs.remove(t.freq,t);
  if (inputs.containsValue(t))   inputs.remove(t.freq);
  t.freq=NewFreq;
  if (t.output)   outputs.put(t.freq,t);
 else   inputs.put(t.freq,t);
  updateTunnel(t.freq,t.output,true);
  updateTunnel(t.freq,!t.output,true);
}
Program: 30644
Project: 30644
Buggy source:
public TunnelCollection<T> getCollection(Collection<PartP2PTunnel> collection){
  type.setSource(collection);
  return type;
}

Fixed version (ground truth):
public TunnelCollection<T> getCollection(Collection<PartP2PTunnel> collection,Class<? extends PartP2PTunnel> c){
  if (type.matches(c)) {
    type.setSource(collection);
    return type;
  }
  return null;
}
Program: 30645
Project: 30645
Buggy source:
@Override public boolean onPartShiftActivate(EntityPlayer player,Vec3 pos){
  ItemStack is=player.inventory.getCurrentItem();
  if (is != null && is.getItem() instanceof IMemoryCard) {
    IMemoryCard mc=(IMemoryCard)is.getItem();
    NBTTagCompound data=new NBTTagCompound();
    long newFreq=freq;
    output=false;
    if (output || freq == 0) {
      newFreq=System.currentTimeMillis();
      try {
        proxy.getP2P().updateFreq(this,newFreq);
      }
 catch (      GridAccessException e) {
      }
    }
    onTunnelConfigChange();
    ItemStack p2pItem=getItemStack(PartItemStack.Wrench);
    String type=p2pItem.getUnlocalizedName();
    p2pItem.writeToNBT(data);
    data.setLong("String_Node_Str",freq);
    mc.setMemoryCardContents(is,type + "String_Node_Str",data);
    mc.notifyUser(player,MemoryCardMessages.SETTINGS_SAVED);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onPartShiftActivate(EntityPlayer player,Vec3 pos){
  ItemStack is=player.inventory.getCurrentItem();
  if (is != null && is.getItem() instanceof IMemoryCard) {
    IMemoryCard mc=(IMemoryCard)is.getItem();
    NBTTagCompound data=new NBTTagCompound();
    long newFreq=freq;
    boolean wasOutput=output;
    output=false;
    if (wasOutput || freq == 0)     newFreq=System.currentTimeMillis();
    try {
      proxy.getP2P().updateFreq(this,newFreq);
    }
 catch (    GridAccessException e) {
    }
    onTunnelConfigChange();
    ItemStack p2pItem=getItemStack(PartItemStack.Wrench);
    String type=p2pItem.getUnlocalizedName();
    p2pItem.writeToNBT(data);
    data.setLong("String_Node_Str",freq);
    mc.setMemoryCardContents(is,type + "String_Node_Str",data);
    mc.notifyUser(player,MemoryCardMessages.SETTINGS_SAVED);
    return true;
  }
  return false;
}
Program: 30647
Project: 30647
Buggy source:
public ToolQuartzAxe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(Type,AEFeature.QuartzAxe),this,Type.name());
}

Fixed version (ground truth):
public ToolQuartzAxe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(type=Type,AEFeature.QuartzAxe),this,Type.name());
}
Program: 30648
Project: 30648
Buggy source:
public ToolQuartzCuttingKnife(AEFeature type){
  super(ToolQuartzCuttingKnife.class,type.name());
  setfeature(EnumSet.of(type,AEFeature.QuartzKnife));
  setMaxDamage(50);
  setMaxStackSize(1);
}

Fixed version (ground truth):
public ToolQuartzCuttingKnife(AEFeature Type){
  super(ToolQuartzCuttingKnife.class,Type.name());
  setfeature(EnumSet.of(type=Type,AEFeature.QuartzKnife));
  setMaxDamage(50);
  setMaxStackSize(1);
}
Program: 30649
Project: 30649
Buggy source:
public ToolQuartzHoe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(Type,AEFeature.QuartzHoe),this,Type.name());
}

Fixed version (ground truth):
public ToolQuartzHoe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(type=Type,AEFeature.QuartzHoe),this,Type.name());
}
Program: 30650
Project: 30650
Buggy source:
public ToolQuartzPickaxe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(Type,AEFeature.QuartzPickaxe),this,Type.name());
}

Fixed version (ground truth):
public ToolQuartzPickaxe(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(type=Type,AEFeature.QuartzPickaxe),this,Type.name());
}
Program: 30651
Project: 30651
Buggy source:
public ToolQuartzSpade(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(Type,AEFeature.QuartzSpade),this,Type.name());
}

Fixed version (ground truth):
public ToolQuartzSpade(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(type=Type,AEFeature.QuartzSpade),this,Type.name());
}
Program: 30652
Project: 30652
Buggy source:
public ToolQuartzSword(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(Type,AEFeature.QuartzSword),this,Type.name());
}

Fixed version (ground truth):
public ToolQuartzSword(AEFeature Type){
  super(ToolMaterial.IRON);
  feature=new AEFeatureHandler(EnumSet.of(type=Type,AEFeature.QuartzSword),this,Type.name());
}
Program: 30653
Project: 30653
Buggy source:
public int getStorageBytes(){
switch (worldObj.getBlockMetadata(xCoord,yCoord,zCoord) & 3) {
default :
case 0:
    return 1 * 1024;
case 1:
  return 4 * 1024;
case 2:
return 16 * 1024;
case 3:
return 64 * 1024;
}
}

Fixed version (ground truth):
public int getStorageBytes(){
  if (worldObj == null)   return 0;
switch (worldObj.getBlockMetadata(xCoord,yCoord,zCoord) & 3) {
default :
case 0:
    return 1 * 1024;
case 1:
  return 4 * 1024;
case 2:
return 16 * 1024;
case 3:
return 64 * 1024;
}
}
Program: 30654
Project: 30654
Buggy source:
public boolean isAccelerator(){
  return (worldObj.getBlockMetadata(xCoord,yCoord,zCoord) & 3) == 1;
}

Fixed version (ground truth):
public boolean isAccelerator(){
  if (worldObj == null)   return false;
  return (worldObj.getBlockMetadata(xCoord,yCoord,zCoord) & 3) == 1;
}
Program: 30655
Project: 30655
Buggy source:
@Override public void onReady(){
  super.onReady();
  updateMultiBlock();
}

Fixed version (ground truth):
@Override public void onReady(){
  super.onReady();
  gridProxy.setVisualRepresentation(getItemFromTile(this));
  updateMultiBlock();
}
Program: 30656
Project: 30656
Buggy source:
@Override public boolean onActivated(World w,int x,int y,int z,EntityPlayer p,int side,float hitX,float hitY,float hitZ){
  if (Platform.isClient())   return true;
  TileCraftingTile tg=getTileEntity(w,x,y,z);
  if (tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive()) {
    Platform.openGUI(p,tg,ForgeDirection.getOrientation(side),GuiBridge.GUI_CRAFTING_CPU);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onActivated(World w,int x,int y,int z,EntityPlayer p,int side,float hitX,float hitY,float hitZ){
  TileCraftingTile tg=getTileEntity(w,x,y,z);
  if (tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive()) {
    if (Platform.isClient())     return true;
    Platform.openGUI(p,tg,ForgeDirection.getOrientation(side),GuiBridge.GUI_CRAFTING_CPU);
    return true;
  }
  return false;
}
Program: 30657
Project: 30657
Buggy source:
private boolean handleCrafting(int x,InventoryAdaptor d,IAEItemStack itemStack){
  try {
    if (getInstalledUpgrades(Upgrades.CRAFTING) > 0 && itemStack != null) {
      return craftingTracker.handleCrafting(x,itemStack.getStackSize(),itemStack,d,getTile().getWorldObj(),gridProxy.getGrid(),gridProxy.getCrafting(),mySrc);
    }
  }
 catch (  GridAccessException e) {
  }
  return false;
}

Fixed version (ground truth):
private boolean handleCrafting(int x,InventoryAdaptor d,IAEItemStack itemStack){
  try {
    if (getInstalledUpgrades(Upgrades.CRAFTING) > 0 && itemStack != null) {
      return craftingTracker.handleCrafting(x,itemStack.getStackSize(),itemStack,d,iHost.getTileEntity().getWorldObj(),gridProxy.getGrid(),gridProxy.getCrafting(),mySrc);
    }
  }
 catch (  GridAccessException e) {
  }
  return false;
}
Program: 30658
Project: 30658
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();
 else     whatToSend.stackSize=whatToSend.stackSize;
  }
  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) {
        whatToSend=ad.addItems(whatToSend);
        if (whatToSend == null)         break;
      }
    }
    if (whatToSend == null)     i.remove();
  }
  if (waitingToSend.isEmpty())   waitingToSend=null;
}
Program: 30659
Project: 30659
Buggy source:
@Override public boolean pushPattern(ICraftingPatternDetails patternDetails,InventoryCrafting table){
  if (hasItemsToSend())   return false;
  TileEntity tile=iHost.getTileEntity();
  World w=tile.getWorldObj();
  EnumSet<ForgeDirection> possibleDirections=iHost.getTargets();
  for (  ForgeDirection s : possibleDirections) {
    TileEntity te=w.getTileEntity(tile.xCoord + s.offsetX,tile.yCoord + s.offsetY,tile.zCoord + s.offsetZ);
    if (te instanceof ICraftingMachine) {
      ICraftingMachine cm=(ICraftingMachine)te;
      if (cm.acceptsPlans()) {
        if (cm.pushPattern(patternDetails,table,s.getOpposite()))         return true;
        continue;
      }
    }
    InventoryAdaptor ad=InventoryAdaptor.getAdaptor(te,s.getOpposite());
    if (ad != null) {
      for (int x=0; x < table.getSizeInventory(); x++) {
        ItemStack is=table.getStackInSlot(x);
        if (is != null) {
          addToSendList(ad.addItems(is));
        }
      }
      pushItemsOut(possibleDirections);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean pushPattern(ICraftingPatternDetails patternDetails,InventoryCrafting table){
  if (hasItemsToSend())   return false;
  TileEntity tile=iHost.getTileEntity();
  World w=tile.getWorldObj();
  EnumSet<ForgeDirection> possibleDirections=iHost.getTargets();
  for (  ForgeDirection s : possibleDirections) {
    TileEntity te=w.getTileEntity(tile.xCoord + s.offsetX,tile.yCoord + s.offsetY,tile.zCoord + s.offsetZ);
    if (te instanceof ICraftingMachine) {
      ICraftingMachine cm=(ICraftingMachine)te;
      if (cm.acceptsPlans()) {
        if (cm.pushPattern(patternDetails,table,s.getOpposite()))         return true;
        continue;
      }
    }
    InventoryAdaptor ad=InventoryAdaptor.getAdaptor(te,s.getOpposite());
    if (ad != null) {
      if (acceptsItems(ad,table)) {
        for (int x=0; x < table.getSizeInventory(); x++) {
          ItemStack is=table.getStackInSlot(x);
          if (is != null) {
            addToSendList(ad.addItems(is));
          }
        }
        pushItemsOut(possibleDirections);
        return true;
      }
    }
  }
  return false;
}
Program: 30660
Project: 30660
Buggy source:
public void readFromNBT(NBTTagCompound data){
  this.waitingToSend=null;
  NBTTagList waitingList=data.getTagList("String_Node_Str",10);
  if (waitingList != null) {
    for (int x=0; x < waitingList.tagCount(); x++) {
      NBTTagCompound c=waitingList.getCompoundTagAt(x);
      if (c != null) {
        ItemStack is=ItemStack.loadItemStackFromNBT(c);
        addToSendList(is);
      }
    }
  }
  craftingTracker.readFromNBT(data);
  config.readFromNBT(data,"String_Node_Str");
  patterns.readFromNBT(data,"String_Node_Str");
  storage.readFromNBT(data,"String_Node_Str");
  readConfig();
  updateCraftingList();
}

Fixed version (ground truth):
public void readFromNBT(NBTTagCompound data){
  this.waitingToSend=null;
  NBTTagList waitingList=data.getTagList("String_Node_Str",10);
  if (waitingList != null) {
    for (int x=0; x < waitingList.tagCount(); x++) {
      NBTTagCompound c=waitingList.getCompoundTagAt(x);
      if (c != null) {
        ItemStack is=ItemStack.loadItemStackFromNBT(c);
        addToSendList(is);
      }
    }
  }
  craftingTracker.readFromNBT(data);
  upgrades.readFromNBT(data,"String_Node_Str");
  config.readFromNBT(data,"String_Node_Str");
  patterns.readFromNBT(data,"String_Node_Str");
  storage.readFromNBT(data,"String_Node_Str");
  readConfig();
  updateCraftingList();
}
Program: 30661
Project: 30661
Buggy source:
public void writeToNBT(NBTTagCompound data){
  config.writeToNBT(data,"String_Node_Str");
  patterns.writeToNBT(data,"String_Node_Str");
  storage.writeToNBT(data,"String_Node_Str");
  craftingTracker.writeToNBT(data);
  NBTTagList waitingToSend=new NBTTagList();
  if (this.waitingToSend != null) {
    for (    ItemStack is : this.waitingToSend) {
      NBTTagCompound item=new NBTTagCompound();
      is.writeToNBT(item);
      waitingToSend.appendTag(item);
    }
  }
  data.setTag("String_Node_Str",waitingToSend);
}

Fixed version (ground truth):
public void writeToNBT(NBTTagCompound data){
  config.writeToNBT(data,"String_Node_Str");
  patterns.writeToNBT(data,"String_Node_Str");
  storage.writeToNBT(data,"String_Node_Str");
  upgrades.writeToNBT(data,"String_Node_Str");
  craftingTracker.writeToNBT(data);
  NBTTagList waitingToSend=new NBTTagList();
  if (this.waitingToSend != null) {
    for (    ItemStack is : this.waitingToSend) {
      NBTTagCompound item=new NBTTagCompound();
      is.writeToNBT(item);
      waitingToSend.appendTag(item);
    }
  }
  data.setTag("String_Node_Str",waitingToSend);
}
Program: 30662
Project: 30662
Buggy source:
@Override public void registerIcons(IIconRegister icoRegister){
  for (  MaterialType mat : MaterialType.values()) {
    if (mat.damageValue != -1) {
      String tex="String_Node_Str" + nameOf(new ItemStack(this,1,mat.damageValue));
      mat.IIcon=icoRegister.registerIcon(tex);
    }
  }
}

Fixed version (ground truth):
@Override public void registerIcons(IIconRegister icoRegister){
  for (  MaterialType mat : MaterialType.values()) {
    if (mat.damageValue != -1 && mat != MaterialType.InvalidType) {
      String tex="String_Node_Str" + nameOf(new ItemStack(this,1,mat.damageValue));
      mat.IIcon=icoRegister.registerIcon(tex);
    }
  }
}
Program: 30664
Project: 30664
Buggy source:
@Override public void initGui(){
  super.initGui();
  cancel=new GuiButton(0,this.guiLeft + 163,this.guiTop + ySize - 25,50,20,GuiText.Cancel.getLocal());
  buttonList.add(cancel);
}

Fixed version (ground truth):
@Override public void initGui(){
  super.initGui();
  setScrollBar();
  cancel=new GuiButton(0,this.guiLeft + 163,this.guiTop + ySize - 25,50,20,GuiText.Cancel.getLocal());
  buttonList.add(cancel);
}
Program: 30665
Project: 30665
Buggy source:
@Override public boolean alertDevice(IGridNode node){
  TickTracker tt=alertable.get(node);
  if (tt == null)   return false;
  sleeping.remove(node);
  awake.put(node,tt);
  tt.lastTick=tt.lastTick - tt.request.maxTickRate;
  upcomingTicks.add(tt);
  return true;
}

Fixed version (ground truth):
@Override public boolean alertDevice(IGridNode node){
  TickTracker tt=alertable.get(node);
  if (tt == null)   return false;
  sleeping.remove(node);
  awake.put(node,tt);
  tt.lastTick=tt.lastTick - tt.request.maxTickRate;
  tt.current_rate=tt.request.minTickRate;
  upcomingTicks.remove(tt);
  upcomingTicks.add(tt);
  return true;
}
Program: 30666
Project: 30666
Buggy source:
public void notifyNeightbors(){
  TileEntity te=iHost.getTileEntity();
  if (te != null && te.getWorldObj() != null) {
  }
}

Fixed version (ground truth):
public void notifyNeightbors(){
  if (gridProxy.isActive()) {
    try {
      gridProxy.getTick().wakeDevice(gridProxy.getNode());
    }
 catch (    GridAccessException e) {
    }
  }
  TileEntity te=iHost.getTileEntity();
  if (te != null && te.getWorldObj() != null) {
  }
}
Program: 30669
Project: 30669
Buggy source:
@Override public IAEItemStack injectCratedItems(ICraftingLink link,IAEItemStack items,Actionable mode){
  InventoryAdaptor d=getHandler();
  try {
    if (proxy.isActive()) {
      IEnergyGrid energy=proxy.getEnergy();
      double power=items.getStackSize();
      if (energy.extractAEPower(power,mode,PowerMultiplier.CONFIG) > power - 0.01) {
        if (mode == Actionable.MODULATE)         return AEItemStack.create(d.addItems(items.getItemStack()));
        return AEItemStack.create(d.simulateAdd(items.getItemStack()));
      }
    }
  }
 catch (  GridAccessException e) {
    AELog.error(e);
  }
  return items;
}

Fixed version (ground truth):
@Override public IAEItemStack injectCratedItems(ICraftingLink link,IAEItemStack items,Actionable mode){
  InventoryAdaptor d=getHandler();
  try {
    if (d != null && proxy.isActive()) {
      IEnergyGrid energy=proxy.getEnergy();
      double power=items.getStackSize();
      if (energy.extractAEPower(power,mode,PowerMultiplier.CONFIG) > power - 0.01) {
        if (mode == Actionable.MODULATE)         return AEItemStack.create(d.addItems(items.getItemStack()));
        return AEItemStack.create(d.simulateAdd(items.getItemStack()));
      }
    }
  }
 catch (  GridAccessException e) {
    AELog.error(e);
  }
  return items;
}
Program: 30670
Project: 30670
Buggy source:
public IAEItemStack injectItems(IAEItemStack input){
  if (tie == null || tie.req == null || tie.req.req == null)   return input;
  return tie.req.req.injectCratedItems(tie.req,input);
}

Fixed version (ground truth):
public IAEItemStack injectItems(IAEItemStack input,Actionable mode){
  if (tie == null || tie.req == null || tie.req.req == null)   return input;
  return tie.req.req.injectCratedItems(tie.req,input,mode);
}
Program: 30671
Project: 30671
Buggy source:
@Override public TickRateModulation tickingRequest(IGridNode node,int TicksSinceLastCall){
  if (hasItemsToSend())   pushItemsOut(EnumSet.allOf(ForgeDirection.class));
  boolean couldDoWork=updateStorage();
  return hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) : TickRateModulation.SLEEP;
}

Fixed version (ground truth):
@Override public TickRateModulation tickingRequest(IGridNode node,int TicksSinceLastCall){
  if (!gridProxy.isActive())   return TickRateModulation.SLEEP;
  if (hasItemsToSend())   pushItemsOut(EnumSet.allOf(ForgeDirection.class));
  boolean couldDoWork=updateStorage();
  return hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) : TickRateModulation.SLEEP;
}
Program: 30674
Project: 30674
Buggy source:
private void completeJob(){
  if (myLastLink != null)   ((CraftingLink)myLastLink).markDone();
  AELog.info("String_Node_Str");
  isComplete=true;
}

Fixed version (ground truth):
private void completeJob(){
  if (myLastLink != null)   ((CraftingLink)myLastLink).markDone();
  AELog.crafting("String_Node_Str");
  isComplete=true;
}
Program: 30676
Project: 30676
Buggy source:
public GuiPatternTerm(InventoryPlayer inventoryPlayer,ITerminalHost te){
  super(inventoryPlayer,te,new ContainerPatternTerm(inventoryPlayer,te));
  container=(ContainerPatternTerm)this.inventorySlots;
  reservedSpace=85;
}

Fixed version (ground truth):
public GuiPatternTerm(InventoryPlayer inventoryPlayer,ITerminalHost te){
  super(inventoryPlayer,te,new ContainerPatternTerm(inventoryPlayer,te));
  container=(ContainerPatternTerm)this.inventorySlots;
  reservedSpace=81;
}
Program: 30677
Project: 30677
Buggy source:
@Override public void initGui(){
  super.initGui();
  buttonList.add(tabCraftButton=new GuiTabButton(this.guiLeft + 173,this.guiTop + this.ySize - 179,new ItemStack(Blocks.crafting_table),GuiText.CraftingPattern.getLocal(),itemRender));
  buttonList.add(tabProcessButton=new GuiTabButton(this.guiLeft + 173,this.guiTop + this.ySize - 179,new ItemStack(Blocks.furnace),GuiText.ProcessingPattern.getLocal(),itemRender));
  buttonList.add(substitutionsBtn=new GuiImgButton(this.guiLeft + 84,this.guiTop + this.ySize - 163,Settings.ACTIONS,ActionItems.SUBSTITUTION));
  substitutionsBtn.halfSize=true;
  buttonList.add(clearBtn=new GuiImgButton(this.guiLeft + 74,this.guiTop + this.ySize - 163,Settings.ACTIONS,ActionItems.CLOSE));
  clearBtn.halfSize=true;
  buttonList.add(encodeBtn=new GuiImgButton(this.guiLeft + 147,this.guiTop + this.ySize - 144,Settings.ACTIONS,ActionItems.ENCODE));
}

Fixed version (ground truth):
@Override public void initGui(){
  super.initGui();
  buttonList.add(tabCraftButton=new GuiTabButton(this.guiLeft + 173,this.guiTop + this.ySize - 179,new ItemStack(Blocks.crafting_table),GuiText.CraftingPattern.getLocal(),itemRender));
  buttonList.add(tabProcessButton=new GuiTabButton(this.guiLeft + 173,this.guiTop + this.ySize - 179,new ItemStack(Blocks.furnace),GuiText.ProcessingPattern.getLocal(),itemRender));
  buttonList.add(substitutionsBtn=new GuiImgButton(this.guiLeft + 84,this.guiTop + this.ySize - 163,Settings.ACTIONS,ActionItems.SUBSTITUTION));
  substitutionsBtn.halfSize=true;
  buttonList.add(clearBtn=new GuiImgButton(this.guiLeft + 74,this.guiTop + this.ySize - 163,Settings.ACTIONS,ActionItems.CLOSE));
  clearBtn.halfSize=true;
  buttonList.add(encodeBtn=new GuiImgButton(this.guiLeft + 147,this.guiTop + this.ySize - 142,Settings.ACTIONS,ActionItems.ENCODE));
}
Program: 30678
Project: 30678
Buggy source:
@Override public void detectAndSendChanges(){
  super.detectAndSendChanges();
  if (Platform.isServer()) {
    if (craftingMode != ct.craftingMode) {
      craftingMode=ct.craftingMode;
      updateOrderOfOutputSlots();
    }
  }
}

Fixed version (ground truth):
@Override public void detectAndSendChanges(){
  super.detectAndSendChanges();
  if (Platform.isServer()) {
    if (craftingMode != ct.isCraftingRecipe()) {
      craftingMode=ct.isCraftingRecipe();
      updateOrderOfOutputSlots();
    }
  }
}
Program: 30679
Project: 30679
Buggy source:
@Override public boolean isSlotEnabled(int idx){
  if (idx == 1)   return Platform.isServer() ? ct.craftingMode == false : craftingMode == false;
  if (idx == 2)   return Platform.isServer() ? ct.craftingMode == true : craftingMode == true;
  return false;
}

Fixed version (ground truth):
@Override public boolean isSlotEnabled(int idx){
  if (idx == 1)   return Platform.isServer() ? ct.isCraftingRecipe() == false : craftingMode == false;
  if (idx == 2)   return Platform.isServer() ? ct.isCraftingRecipe() == true : craftingMode == true;
  return false;
}
Program: 30681
Project: 30681
Buggy source:
@Override public void readFromNBT(NBTTagCompound data){
  super.readFromNBT(data);
  craftingMode=data.getBoolean("String_Node_Str");
  pattern.readFromNBT(data,"String_Node_Str");
  output.readFromNBT(data,"String_Node_Str");
  crafting.readFromNBT(data,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound data){
  super.readFromNBT(data);
  setCraftingRecipe(data.getBoolean("String_Node_Str"));
  pattern.readFromNBT(data,"String_Node_Str");
  output.readFromNBT(data,"String_Node_Str");
  crafting.readFromNBT(data,"String_Node_Str");
}
Program: 30682
Project: 30682
Buggy source:
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removedStack,ItemStack newStack){
  host.markForSave();
}

Fixed version (ground truth):
@Override public void onChangeInventory(IInventory inv,int slot,InvOperation mc,ItemStack removedStack,ItemStack newStack){
  if (inv == pattern && slot == 1) {
    ItemStack is=pattern.getStackInSlot(1);
    if (is != null && is.getItem() instanceof ICraftingPatternItem) {
      ICraftingPatternItem pattern=(ICraftingPatternItem)is.getItem();
      ICraftingPatternDetails details=pattern.getPatternForItem(is,this.getHost().getTile().getWorldObj());
      if (details != null) {
        setCraftingRecipe(details.isCraftable());
        for (int x=0; x < crafting.getSizeInventory() && x < details.getInputs().length; x++) {
          IAEItemStack aeis=details.getInputs()[x];
          crafting.setInventorySlotContents(x,aeis == null ? null : aeis.getItemStack());
        }
        for (int x=0; x < output.getSizeInventory() && x < details.getOutputs().length; x++) {
          IAEItemStack aeis=details.getOutputs()[x];
          output.setInventorySlotContents(x,aeis == null ? null : aeis.getItemStack());
        }
      }
    }
  }
 else   if (inv == crafting) {
    fixCraftingRecipes();
  }
  host.markForSave();
}
Program: 30683
Project: 30683
Buggy source:
@Override public void writeToNBT(NBTTagCompound data){
  super.writeToNBT(data);
  data.setBoolean("String_Node_Str",craftingMode);
  pattern.writeToNBT(data,"String_Node_Str");
  output.writeToNBT(data,"String_Node_Str");
  crafting.writeToNBT(data,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void writeToNBT(NBTTagCompound data){
  super.writeToNBT(data);
  data.setBoolean("String_Node_Str",isCraftingRecipe());
  pattern.writeToNBT(data,"String_Node_Str");
  output.writeToNBT(data,"String_Node_Str");
  crafting.writeToNBT(data,"String_Node_Str");
}
Program: 30685
Project: 30685
Buggy source:
public boolean isAccelerator(){
  return worldObj.getBlockMetadata(xCoord,yCoord,zCoord) == 1;
}

Fixed version (ground truth):
public boolean isAccelerator(){
  return (worldObj.getBlockMetadata(xCoord,yCoord,zCoord) & 3) == 1;
}
Program: 30686
Project: 30686
Buggy source:
public void gridChanged(){
  try {
    items.setInternal(gridProxy.getStorage().getItemInventory());
    fluids.setInternal(gridProxy.getStorage().getFluidInventory());
  }
 catch (  GridAccessException gae) {
    items.setInternal(new NullInventory());
    fluids.setInternal(new NullInventory());
  }
  TileEntity te=iHost.getTileEntity();
  te.getWorldObj().notifyBlocksOfNeighborChange(te.xCoord,te.yCoord,te.zCoord,Platform.air);
}

Fixed version (ground truth):
public void gridChanged(){
  try {
    items.setInternal(gridProxy.getStorage().getItemInventory());
    fluids.setInternal(gridProxy.getStorage().getFluidInventory());
  }
 catch (  GridAccessException gae) {
    items.setInternal(new NullInventory());
    fluids.setInternal(new NullInventory());
  }
  notifyNeightbors();
}
Program: 30687
Project: 30687
Buggy source:
private void readConfig(){
  boolean hadConfig=hasConfig;
  hasConfig=false;
  for (  ItemStack p : config) {
    if (p != null) {
      hasConfig=true;
      break;
    }
  }
  boolean had=hasWorkToDo();
  for (int x=0; x < 8; x++)   updatePlan(x);
  boolean has=hasWorkToDo();
  if (had != has) {
    try {
      if (has)       gridProxy.getTick().alertDevice(gridProxy.getNode());
 else       gridProxy.getTick().sleepDevice(gridProxy.getNode());
    }
 catch (    GridAccessException e) {
    }
  }
  TileEntity te=iHost.getTileEntity();
  if (hadConfig != hasConfig && te != null && te.getWorldObj() != null) {
    te.getWorldObj().notifyBlocksOfNeighborChange(te.xCoord,te.yCoord,te.zCoord,Platform.air);
  }
}

Fixed version (ground truth):
private void readConfig(){
  boolean hadConfig=hasConfig;
  hasConfig=false;
  for (  ItemStack p : config) {
    if (p != null) {
      hasConfig=true;
      break;
    }
  }
  boolean had=hasWorkToDo();
  for (int x=0; x < 8; x++)   updatePlan(x);
  boolean has=hasWorkToDo();
  if (had != has) {
    try {
      if (has)       gridProxy.getTick().alertDevice(gridProxy.getNode());
 else       gridProxy.getTick().sleepDevice(gridProxy.getNode());
    }
 catch (    GridAccessException e) {
    }
  }
  notifyNeightbors();
}
Program: 30688
Project: 30688
Buggy source:
public void gridChanged(){
  try {
    items.setInternal(gridProxy.getStorage().getItemInventory());
    fluids.setInternal(gridProxy.getStorage().getFluidInventory());
  }
 catch (  GridAccessException gae) {
    items.setInternal(new NullInventory());
    fluids.setInternal(new NullInventory());
  }
  TileEntity te=iHost.getTileEntity();
  te.getWorldObj().notifyBlocksOfNeighborChange(te.xCoord,te.yCoord,te.zCoord,Platform.air);
}

Fixed version (ground truth):
public void gridChanged(){
  try {
    items.setInternal(gridProxy.getStorage().getItemInventory());
    fluids.setInternal(gridProxy.getStorage().getFluidInventory());
  }
 catch (  GridAccessException gae) {
    items.setInternal(new NullInventory());
    fluids.setInternal(new NullInventory());
  }
  notifyNeightbors();
}
Program: 30689
Project: 30689
Buggy source:
private void readConfig(){
  boolean hadConfig=hasConfig;
  hasConfig=false;
  for (  ItemStack p : config) {
    if (p != null) {
      hasConfig=true;
      break;
    }
  }
  boolean had=hasWorkToDo();
  for (int x=0; x < 8; x++)   updatePlan(x);
  boolean has=hasWorkToDo();
  if (had != has) {
    try {
      if (has)       gridProxy.getTick().alertDevice(gridProxy.getNode());
 else       gridProxy.getTick().sleepDevice(gridProxy.getNode());
    }
 catch (    GridAccessException e) {
    }
  }
  TileEntity te=iHost.getTileEntity();
  if (hadConfig != hasConfig && te != null && te.getWorldObj() != null) {
    te.getWorldObj().notifyBlocksOfNeighborChange(te.xCoord,te.yCoord,te.zCoord,Platform.air);
  }
}

Fixed version (ground truth):
private void readConfig(){
  boolean hadConfig=hasConfig;
  hasConfig=false;
  for (  ItemStack p : config) {
    if (p != null) {
      hasConfig=true;
      break;
    }
  }
  boolean had=hasWorkToDo();
  for (int x=0; x < 8; x++)   updatePlan(x);
  boolean has=hasWorkToDo();
  if (had != has) {
    try {
      if (has)       gridProxy.getTick().alertDevice(gridProxy.getNode());
 else       gridProxy.getTick().sleepDevice(gridProxy.getNode());
    }
 catch (    GridAccessException e) {
    }
  }
  notifyNeightbors();
}
Program: 30690
Project: 30690
Buggy source:
@Override public boolean onItemUseFirst(ItemStack stack,EntityPlayer player,World world,int x,int y,int z,int side,float hitX,float hitY,float hitZ){
  if (player.isSneaking()) {
    if (Platform.isClient())     return false;
    InventoryPlayer pinv=player.inventory;
    IMEInventory<IAEItemStack> inv=AEApi.instance().registries().cell().getCellInventory(stack,StorageChannel.ITEMS);
    if (inv != null && pinv.getCurrentItem() == stack) {
      InventoryAdaptor ia=InventoryAdaptor.getAdaptor(pinv,ForgeDirection.UNKNOWN);
      IItemList<IAEItemStack> list=inv.getAvailableItems(StorageChannel.ITEMS.createList());
      if (list.isEmpty() && ia != null) {
        pinv.setInventorySlotContents(pinv.currentItem,null);
        ItemStack extraA=ia.addItems(AEApi.instance().materials().materialEmptyStorageCell.stack(1));
        ItemStack extraB=ia.addItems(component.stack(1));
        if (extraA != null)         player.dropPlayerItemWithRandomChoice(extraA,false);
        if (extraB != null)         player.dropPlayerItemWithRandomChoice(extraB,false);
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onItemUseFirst(ItemStack stack,EntityPlayer player,World world,int x,int y,int z,int side,float hitX,float hitY,float hitZ){
  if (player.isSneaking()) {
    if (Platform.isClient())     return false;
    InventoryPlayer pinv=player.inventory;
    IMEInventory<IAEItemStack> inv=AEApi.instance().registries().cell().getCellInventory(stack,StorageChannel.ITEMS);
    if (inv != null && pinv.getCurrentItem() == stack) {
      InventoryAdaptor ia=InventoryAdaptor.getAdaptor(player,ForgeDirection.UNKNOWN);
      IItemList<IAEItemStack> list=inv.getAvailableItems(StorageChannel.ITEMS.createList());
      if (list.isEmpty() && ia != null) {
        pinv.setInventorySlotContents(pinv.currentItem,null);
        ItemStack extraB=ia.addItems(component.stack(1));
        ItemStack extraA=ia.addItems(AEApi.instance().materials().materialEmptyStorageCell.stack(1));
        if (extraA != null)         player.dropPlayerItemWithRandomChoice(extraA,false);
        if (extraB != null)         player.dropPlayerItemWithRandomChoice(extraB,false);
        if (player.inventoryContainer != null)         player.inventoryContainer.detectAndSendChanges();
        return true;
      }
    }
  }
  return false;
}
Program: 30691
Project: 30691
Buggy source:
@Override protected boolean checkHotbarKeys(int p_146983_1_){
  Slot theSlot;
  try {
    theSlot=ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class,this,"String_Node_Str","String_Node_Str","String_Node_Str");
  }
 catch (  Throwable t) {
    return false;
  }
  if (this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null) {
    for (int j=0; j < 9; ++j) {
      if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) {
        if (theSlot.getSlotStackLimit() == 64) {
          this.handleMouseClick(theSlot,theSlot.slotNumber,j,2);
          return true;
        }
 else {
          try {
            for (            Slot s : (List<Slot>)inventorySlots.inventorySlots) {
              if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer)inventorySlots).getPlayerInv()) {
                NetworkHandler.instance.sendToServer(new PacketSwapSlots(s.slotNumber,theSlot.slotNumber));
                return true;
              }
            }
          }
 catch (          IOException e) {
            AELog.error(e);
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean checkHotbarKeys(int p_146983_1_){
  Slot theSlot;
  try {
    theSlot=ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class,this,"String_Node_Str","String_Node_Str","String_Node_Str");
  }
 catch (  Throwable t) {
    return false;
  }
  if (this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null) {
    for (int j=0; j < 9; ++j) {
      if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) {
        for (        Slot s : (List<Slot>)inventorySlots.inventorySlots) {
          if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer)inventorySlots).getPlayerInv()) {
            if (!s.canTakeStack(((AEBaseContainer)inventorySlots).getPlayerInv().player)) {
              return false;
            }
          }
        }
        if (theSlot.getSlotStackLimit() == 64) {
          this.handleMouseClick(theSlot,theSlot.slotNumber,j,2);
          return true;
        }
 else {
          try {
            for (            Slot s : (List<Slot>)inventorySlots.inventorySlots) {
              if (s.getSlotIndex() == j && s.inventory == ((AEBaseContainer)inventorySlots).getPlayerInv()) {
                NetworkHandler.instance.sendToServer(new PacketSwapSlots(s.slotNumber,theSlot.slotNumber));
                return true;
              }
            }
          }
 catch (          IOException e) {
            AELog.error(e);
          }
        }
      }
    }
  }
  return false;
}
Program: 30692
Project: 30692
Buggy source:
@Override public void partChanged(){
  if (tile() instanceof TIInventoryTile)   ((TIInventoryTile)tile()).rebuildSlotMap();
  if (world() != null)   world().notifyBlocksOfNeighborChange(x(),y(),z(),Platform.air);
}

Fixed version (ground truth):
@Override public void partChanged(){
  notifyNeighbors();
}
Program: 30693
Project: 30693
Buggy source:
@Override public void addNode(IGridNode node,IGridHost machine){
  if (machine instanceof PartP2PTunnel) {
    if (machine instanceof PartP2PTunnelME) {
      if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL))       return;
    }
    PartP2PTunnel t=(PartP2PTunnel)machine;
    if (t.output)     outputs.put(t.freq,t);
 else     inputs.put(t.freq,t);
    updateTunnel(t.freq,!t.output);
  }
}

Fixed version (ground truth):
@Override public void addNode(IGridNode node,IGridHost machine){
  if (machine instanceof PartP2PTunnel) {
    if (machine instanceof PartP2PTunnelME) {
      if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL))       return;
    }
    PartP2PTunnel t=(PartP2PTunnel)machine;
    if (t.output)     outputs.put(t.freq,t);
 else     inputs.put(t.freq,t);
    updateTunnel(t.freq,!t.output,false);
  }
}
Program: 30694
Project: 30694
Buggy source:
public void updateFreq(PartP2PTunnel t,long NewFreq){
  outputs.remove(t.freq,t);
  inputs.remove(t.freq);
  t.freq=NewFreq;
  if (t.output)   outputs.put(t.freq,t);
 else   inputs.put(t.freq,t);
  updateTunnel(t.freq,t.output);
  updateTunnel(t.freq,!t.output);
}

Fixed version (ground truth):
public void updateFreq(PartP2PTunnel t,long NewFreq){
  outputs.remove(t.freq,t);
  inputs.remove(t.freq);
  t.freq=NewFreq;
  if (t.output)   outputs.put(t.freq,t);
 else   inputs.put(t.freq,t);
  updateTunnel(t.freq,t.output,true);
  updateTunnel(t.freq,!t.output,true);
}
Program: 30695
Project: 30695
Buggy source:
private void updateTunnel(long freq,boolean updateOutputs){
  for (  PartP2PTunnel p : outputs.get(freq))   p.onChange();
  PartP2PTunnel in=inputs.get(freq);
  if (in != null)   in.onChange();
}

Fixed version (ground truth):
private void updateTunnel(long freq,boolean updateOutputs,boolean configChange){
  for (  PartP2PTunnel p : outputs.get(freq)) {
    if (configChange)     p.onTunnelConfigChange();
    p.onTunnelNetworkChange();
  }
  PartP2PTunnel in=inputs.get(freq);
  if (in != null) {
    if (configChange)     in.onTunnelConfigChange();
    in.onTunnelNetworkChange();
  }
}
Program: 30696
Project: 30696
Buggy source:
@Override public void removeNode(IGridNode node,IGridHost machine){
  if (machine instanceof PartP2PTunnel) {
    if (machine instanceof PartP2PTunnelME) {
      if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL))       return;
    }
    PartP2PTunnel t=(PartP2PTunnel)machine;
    if (t.output)     outputs.remove(t.freq,t);
 else     inputs.remove(t.freq);
    updateTunnel(t.freq,!t.output);
  }
}

Fixed version (ground truth):
@Override public void removeNode(IGridNode node,IGridHost machine){
  if (machine instanceof PartP2PTunnel) {
    if (machine instanceof PartP2PTunnelME) {
      if (!node.hasFlag(GridFlags.REQUIRE_CHANNEL))       return;
    }
    PartP2PTunnel t=(PartP2PTunnel)machine;
    if (t.output)     outputs.remove(t.freq,t);
 else     inputs.remove(t.freq);
    updateTunnel(t.freq,!t.output,false);
  }
}
Program: 30697
Project: 30697
Buggy source:
public void addToWorld(){
  if (inWorld)   return;
  inWorld=true;
  TileEntity te=getTile();
  hasRedstone=te.getWorldObj().isBlockIndirectlyGettingPowered(te.xCoord,te.yCoord,te.zCoord);
  for (int x=6; x >= 0; x--) {
    ForgeDirection s=ForgeDirection.getOrientation(x);
    IPart part=getPart(s);
    if (part != null) {
      part.setPartHostInfo(s,this,te);
      part.addToWorld();
      if (s != ForgeDirection.UNKNOWN) {
        IGridNode sn=part.getGridNode();
        if (sn != null) {
          IPart center=getPart(ForgeDirection.UNKNOWN);
          if (center != null) {
            IGridNode cn=center.getGridNode();
            if (cn != null) {
              try {
                AEApi.instance().createGridConnection(cn,sn);
              }
 catch (              FailedConnection e) {
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void addToWorld(){
  if (inWorld)   return;
  inWorld=true;
  TileEntity te=getTile();
  hasRedstone=te.getWorldObj().isBlockIndirectlyGettingPowered(te.xCoord,te.yCoord,te.zCoord);
  for (int x=6; x >= 0; x--) {
    ForgeDirection s=ForgeDirection.getOrientation(x);
    IPart part=getPart(s);
    if (part != null) {
      part.setPartHostInfo(s,this,te);
      part.addToWorld();
      if (s != ForgeDirection.UNKNOWN) {
        IGridNode sn=part.getGridNode();
        if (sn != null) {
          IPart center=getPart(ForgeDirection.UNKNOWN);
          if (center != null) {
            IGridNode cn=center.getGridNode();
            if (cn != null) {
              try {
                AEApi.instance().createGridConnection(cn,sn);
              }
 catch (              FailedConnection e) {
              }
            }
          }
        }
      }
    }
  }
  partChanged();
}
Program: 30698
Project: 30698
Buggy source:
public void removeFromWorld(){
  if (!inWorld)   return;
  inWorld=false;
  for (  ForgeDirection s : ForgeDirection.values()) {
    IPart part=getPart(s);
    if (part != null)     part.removeFromWorld();
  }
}

Fixed version (ground truth):
public void removeFromWorld(){
  if (!inWorld)   return;
  inWorld=false;
  for (  ForgeDirection s : ForgeDirection.values()) {
    IPart part=getPart(s);
    if (part != null)     part.removeFromWorld();
  }
  partChanged();
}
Program: 30699
Project: 30699
Buggy source:
final private void addToENet(){
  if (getEnergySinkWorld() == null)   return;
  removeFromENet();
  if (!isInIC2() && Platform.isServer()) {
    getLayerFlags().add(LayerFlags.IC2_ENET);
    MinecraftForge.EVENT_BUS.post(new ic2.api.energy.event.EnergyTileLoadEvent((IEnergySink)getEnergySinkTile()));
  }
}

Fixed version (ground truth):
final private void addToENet(){
  if (getEnergySinkWorld() == null)   return;
  removeFromENet();
  if (!isInIC2() && Platform.isServer() && isTileValid()) {
    getLayerFlags().add(LayerFlags.IC2_ENET);
    MinecraftForge.EVENT_BUS.post(new ic2.api.energy.event.EnergyTileLoadEvent((IEnergySink)getEnergySinkTile()));
  }
}
Program: 30700
Project: 30700
Buggy source:
final private boolean interestedInIC2(){
  int interested=0;
  for (  ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
    IPart part=getPart(dir);
    if (part instanceof IEnergyTile) {
      interested++;
    }
  }
  return interested == 1;
}

Fixed version (ground truth):
final private boolean interestedInIC2(){
  if (!((IPartHost)this).isInWorld())   return false;
  int interested=0;
  for (  ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
    IPart part=getPart(dir);
    if (part instanceof IEnergyTile) {
      interested++;
    }
  }
  return interested == 1;
}
Program: 30701
Project: 30701
Buggy source:
final private void addToENet(){
  if (getEnergySourceWorld() == null)   return;
  removeFromENet();
  if (!isInIC2() && Platform.isServer()) {
    getLayerFlags().add(LayerFlags.IC2_ENET);
    MinecraftForge.EVENT_BUS.post(new ic2.api.energy.event.EnergyTileLoadEvent((IEnergySink)getEnergySourceTile()));
  }
}

Fixed version (ground truth):
final private void addToENet(){
  if (getEnergySourceWorld() == null)   return;
  removeFromENet();
  if (!isInIC2() && Platform.isServer() && isTileValid()) {
    getLayerFlags().add(LayerFlags.IC2_ENET);
    MinecraftForge.EVENT_BUS.post(new ic2.api.energy.event.EnergyTileLoadEvent((IEnergySink)getEnergySourceTile()));
  }
}
Program: 30702
Project: 30702
Buggy source:
final private boolean interestedInIC2(){
  int interested=0;
  for (  ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
    IPart part=getPart(dir);
    if (part instanceof IEnergyTile) {
      interested++;
    }
  }
  return interested == 1;
}

Fixed version (ground truth):
final private boolean interestedInIC2(){
  if (!((IPartHost)this).isInWorld())   return false;
  int interested=0;
  for (  ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
    IPart part=getPart(dir);
    if (part instanceof IEnergyTile) {
      interested++;
    }
  }
  return interested == 1;
}
Program: 30703
Project: 30703
Buggy source:
@MENetworkEventSubscribe public void changeStateA(MENetworkBootingStatusChange bs){
  if (!output) {
    cachedInv=null;
    int olderSize=oldSize;
    oldSize=getDest().getSizeInventory();
    if (olderSize != oldSize) {
      getHost().partChanged();
      tile.getWorldObj().notifyBlocksOfNeighborChange(tile.xCoord,tile.yCoord,tile.zCoord,Platform.air);
    }
  }
}

Fixed version (ground truth):
@MENetworkEventSubscribe public void changeStateA(MENetworkBootingStatusChange bs){
  if (!output) {
    cachedInv=null;
    int olderSize=oldSize;
    oldSize=getDest().getSizeInventory();
    if (olderSize != oldSize) {
      getHost().notifyNeighbors();
    }
  }
}
Program: 30704
Project: 30704
Buggy source:
@MENetworkEventSubscribe public void changeStateB(MENetworkChannelsChanged bs){
  if (!output) {
    cachedInv=null;
    int olderSize=oldSize;
    oldSize=getDest().getSizeInventory();
    if (olderSize != oldSize) {
      getHost().partChanged();
      tile.getWorldObj().notifyBlocksOfNeighborChange(tile.xCoord,tile.yCoord,tile.zCoord,Platform.air);
    }
  }
}

Fixed version (ground truth):
@MENetworkEventSubscribe public void changeStateB(MENetworkChannelsChanged bs){
  if (!output) {
    cachedInv=null;
    int olderSize=oldSize;
    oldSize=getDest().getSizeInventory();
    if (olderSize != oldSize) {
      getHost().notifyNeighbors();
    }
  }
}
Program: 30705
Project: 30705
Buggy source:
@Override public void onNeighborChanged(){
  cachedInv=null;
  PartP2PItems input=getInput();
  if (input != null && output)   input.onChange();
}

Fixed version (ground truth):
@Override public void onNeighborChanged(){
  cachedInv=null;
  PartP2PItems input=getInput();
  if (input != null && output)   input.onTunnelNetworkChange();
}
Program: 30706
Project: 30706
Buggy source:
@Override public void onNeighborChanged(){
  cachedTank=null;
  if (output) {
    PartP2PLiquids in=getInput();
    if (in != null)     in.onChange();
  }
}

Fixed version (ground truth):
@Override public void onNeighborChanged(){
  cachedTank=null;
  if (output) {
    PartP2PLiquids in=getInput();
    if (in != null)     in.onTunnelNetworkChange();
  }
}
Program: 30708
Project: 30708
Buggy source:
@Override public boolean onPartShiftActivate(EntityPlayer player,Vec3 pos){
  ItemStack is=player.inventory.getCurrentItem();
  if (is != null && is.getItem() instanceof IMemoryCard) {
    IMemoryCard mc=(IMemoryCard)is.getItem();
    NBTTagCompound data=new NBTTagCompound();
    long newFreq=freq;
    output=false;
    if (output || freq == 0) {
      newFreq=System.currentTimeMillis();
      try {
        proxy.getP2P().updateFreq(this,newFreq);
      }
 catch (      GridAccessException e) {
      }
    }
    onChange();
    ItemStack p2pItem=getItemStack(PartItemStack.Wrench);
    String type=p2pItem.getUnlocalizedName();
    p2pItem.writeToNBT(data);
    data.setLong("String_Node_Str",freq);
    mc.setMemoryCardContents(is,type + "String_Node_Str",data);
    mc.notifyUser(player,MemoryCardMessages.SETTINGS_SAVED);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onPartShiftActivate(EntityPlayer player,Vec3 pos){
  ItemStack is=player.inventory.getCurrentItem();
  if (is != null && is.getItem() instanceof IMemoryCard) {
    IMemoryCard mc=(IMemoryCard)is.getItem();
    NBTTagCompound data=new NBTTagCompound();
    long newFreq=freq;
    output=false;
    if (output || freq == 0) {
      newFreq=System.currentTimeMillis();
      try {
        proxy.getP2P().updateFreq(this,newFreq);
      }
 catch (      GridAccessException e) {
      }
    }
    onTunnelConfigChange();
    ItemStack p2pItem=getItemStack(PartItemStack.Wrench);
    String type=p2pItem.getUnlocalizedName();
    p2pItem.writeToNBT(data);
    data.setLong("String_Node_Str",freq);
    mc.setMemoryCardContents(is,type + "String_Node_Str",data);
    mc.notifyUser(player,MemoryCardMessages.SETTINGS_SAVED);
    return true;
  }
  return false;
}