nus-yam/ex-repair huggingface dataset:
Program: 156752
Project: 156752
Buggy source:
@Override public boolean renderWorldBlock(IBlockAccess world,int x,int y,int z,Block block,int modelId,RenderBlocks renderer){
  TileEntity tile=world.getTileEntity(x,y,z);
  if (tile instanceof TileGenericPipe) {
    TileGenericPipe pipeTile=(TileGenericPipe)tile;
    renderPipe(renderer,world,pipeTile,x,y,z);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean renderWorldBlock(IBlockAccess world,int x,int y,int z,Block block,int modelId,RenderBlocks renderer){
  TileEntity tile=world.getTileEntity(x,y,z);
  Tessellator.instance.addVertexWithUV(x,y,z,0,0);
  Tessellator.instance.addVertexWithUV(x,y,z,0,0);
  Tessellator.instance.addVertexWithUV(x,y,z,0,0);
  Tessellator.instance.addVertexWithUV(x,y,z,0,0);
  if (tile instanceof TileGenericPipe) {
    TileGenericPipe pipeTile=(TileGenericPipe)tile;
    renderPipe(renderer,world,pipeTile,x,y,z);
  }
  return true;
}
Program: 156755
Project: 156755
Buggy source:
public MapWorld(World world,File location){
  this.world=world;
  regionMap=new TLongObjectHashMap<MapRegion>();
  queuedChunks=new PriorityQueue<QueuedXZ>(new Comparator<QueuedXZ>(){
    @Override public int compare(    QueuedXZ c1,    QueuedXZ c2){
      return c1.p - c2.p;
    }
  }
);
  String saveFolder=world.provider.getSaveFolder();
  if (saveFolder == null) {
    saveFolder="String_Node_Str";
  }
  this.location=new File(location,saveFolder);
  try {
    this.location.mkdirs();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public MapWorld(World world,File location){
  this.world=world;
  regionMap=new TLongObjectHashMap<MapRegion>();
  queuedChunks=new PriorityQueue<QueuedXZ>(11,new Comparator<QueuedXZ>(){
    @Override public int compare(    QueuedXZ c1,    QueuedXZ c2){
      return c1.p - c2.p;
    }
  }
);
  String saveFolder=world.provider.getSaveFolder();
  if (saveFolder == null) {
    saveFolder="String_Node_Str";
  }
  this.location=new File(location,saveFolder);
  try {
    this.location.mkdirs();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 156756
Project: 156756
Buggy source:
@Override public void delegateAIEnded(AIRobot ai){
  if (ai instanceof AIRobotSearchRandomBlock) {
    if (!ai.success()) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
 else {
      releaseBlockFound();
      AIRobotSearchRandomBlock searchAI=(AIRobotSearchRandomBlock)ai;
      if (searchAI.takeResource()) {
        blockFound=searchAI.blockFound;
        searchAI.path.removeLast();
        startDelegateAI(new AIRobotGotoBlock(robot,searchAI.path));
      }
 else {
        startDelegateAI(new AIRobotGotoSleep(robot));
      }
    }
  }
 else   if (ai instanceof AIRobotGotoBlock) {
    startDelegateAI(new AIRobotUseToolOnBlock(robot,blockFound));
  }
 else   if (ai instanceof AIRobotUseToolOnBlock) {
    releaseBlockFound();
  }
 else   if (ai instanceof AIRobotFetchAndEquipItemStack) {
    if (robot.getHeldItem() == null) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
  }
}

Fixed version (ground truth):
@Override public void delegateAIEnded(AIRobot ai){
  if (ai instanceof AIRobotSearchRandomBlock) {
    if (!ai.success()) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
 else {
      releaseBlockFound();
      AIRobotSearchRandomBlock searchAI=(AIRobotSearchRandomBlock)ai;
      if (searchAI.takeResource()) {
        blockFound=searchAI.blockFound;
        if (searchAI.path.size() > 1) {
          searchAI.path.removeLast();
        }
        startDelegateAI(new AIRobotGotoBlock(robot,searchAI.path));
      }
 else {
        startDelegateAI(new AIRobotGotoSleep(robot));
      }
    }
  }
 else   if (ai instanceof AIRobotGotoBlock) {
    startDelegateAI(new AIRobotUseToolOnBlock(robot,blockFound));
  }
 else   if (ai instanceof AIRobotUseToolOnBlock) {
    releaseBlockFound();
  }
 else   if (ai instanceof AIRobotFetchAndEquipItemStack) {
    if (robot.getHeldItem() == null) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
  }
}
Program: 156757
Project: 156757
Buggy source:
@Override public void delegateAIEnded(AIRobot ai){
  if (ai instanceof AIRobotSearchRandomBlock) {
    if (!ai.success()) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
 else {
      releaseBlockFound();
      AIRobotSearchRandomBlock searchAI=(AIRobotSearchRandomBlock)ai;
      if (searchAI.takeResource()) {
        blockFound=searchAI.blockFound;
        searchAI.path.removeLast();
        startDelegateAI(new AIRobotGotoBlock(robot,searchAI.path));
      }
 else {
        startDelegateAI(new AIRobotGotoSleep(robot));
      }
    }
  }
 else   if (ai instanceof AIRobotGotoBlock) {
    startDelegateAI(new AIRobotUseToolOnBlock(robot,blockFound));
  }
 else   if (ai instanceof AIRobotUseToolOnBlock) {
    releaseBlockFound();
  }
 else   if (ai instanceof AIRobotFetchAndEquipItemStack) {
    if (robot.getHeldItem() == null) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
  }
}

Fixed version (ground truth):
@Override public void delegateAIEnded(AIRobot ai){
  if (ai instanceof AIRobotSearchRandomBlock) {
    if (!ai.success()) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
 else {
      releaseBlockFound();
      AIRobotSearchRandomBlock searchAI=(AIRobotSearchRandomBlock)ai;
      if (searchAI.takeResource()) {
        blockFound=searchAI.blockFound;
        if (searchAI.path.size() > 1) {
          searchAI.path.removeLast();
        }
        startDelegateAI(new AIRobotGotoBlock(robot,searchAI.path));
      }
 else {
        startDelegateAI(new AIRobotGotoSleep(robot));
      }
    }
  }
 else   if (ai instanceof AIRobotGotoBlock) {
    startDelegateAI(new AIRobotUseToolOnBlock(robot,blockFound));
  }
 else   if (ai instanceof AIRobotUseToolOnBlock) {
    releaseBlockFound();
  }
 else   if (ai instanceof AIRobotFetchAndEquipItemStack) {
    if (robot.getHeldItem() == null) {
      startDelegateAI(new AIRobotGotoSleep(robot));
    }
  }
}
Program: 156758
Project: 156758
Buggy source:
@Override public void run(){
  while (true) {
    try {
      Thread.sleep(10);
    }
 catch (    Exception e) {
    }
    while (!packets.isEmpty()) {
      packets.remove().run();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    try {
      Thread.sleep(10);
    }
 catch (    Exception e) {
    }
    while (!packets.isEmpty()) {
      SendRequest r=packets.remove();
      for (      EntityPlayerMP player : (List<EntityPlayerMP>)MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
        if (r.isValid(player)) {
          NetHandlerPlayServer handler=player.playerNetServerHandler;
          if (handler == null) {
            continue;
          }
          NetworkManager manager=handler.netManager;
          if (manager == null || !manager.isChannelOpen()) {
            continue;
          }
          manager.scheduleOutboundPacket(r.source.channels.get(Side.SERVER).generatePacketFrom(r.packet));
        }
      }
    }
  }
}
Program: 156759
Project: 156759
Buggy source:
LocationSendRequest(BuildCraftMod source,Packet packet,int dimensionId,int x,int y,int z,int md){
  super(source,packet);
  this.dimensionId=dimensionId;
  this.x=x;
  this.y=y;
  this.z=z;
  this.md=md;
}

Fixed version (ground truth):
LocationSendRequest(BuildCraftMod source,Packet packet,int dimensionId,int x,int y,int z,int md){
  super(source,packet);
  this.dimensionId=dimensionId;
  this.x=x;
  this.y=y;
  this.z=z;
  this.md=md * md;
}
Program: 156760
Project: 156760
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void initGui(){
  super.initGui();
  Keyboard.enableRepeatEvents(true);
  optionRotate=new GuiBetterButton(0,guiLeft + 5,guiTop + 30,79,"String_Node_Str");
  buttonList.add(optionRotate);
  optionExcavate=new GuiBetterButton(1,guiLeft + 5,guiTop + 55,79,"String_Node_Str");
  buttonList.add(optionExcavate);
  optionAllowCreative=new GuiBetterButton(2,guiLeft + 5,guiTop + 80,79,"String_Node_Str");
  optionAllowCreative.setToolTip(new ToolTip(500,new ToolTipLine(StringUtils.localize("String_Node_Str")),new ToolTipLine(StringUtils.localize("String_Node_Str"))));
  buttonList.add(optionAllowCreative);
  textField=new GuiTextField(this.fontRendererObj,TEXT_X,TEXT_Y,TEXT_WIDTH,TEXT_HEIGHT);
  textField.setMaxStringLength(BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE);
  textField.setText(architect.name);
  textField.setFocused(true);
  updateButtons();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void initGui(){
  super.initGui();
  Keyboard.enableRepeatEvents(true);
  optionRotate=new GuiBetterButton(0,guiLeft + 5,guiTop + 30,79,"String_Node_Str");
  buttonList.add(optionRotate);
  optionExcavate=new GuiBetterButton(1,guiLeft + 5,guiTop + 55,79,"String_Node_Str");
  buttonList.add(optionExcavate);
  optionAllowCreative=new GuiBetterButton(2,guiLeft + 5,guiTop + 80,79,"String_Node_Str");
  optionAllowCreative.setToolTip(new ToolTip(500,new ToolTipLine(StringUtils.localize("String_Node_Str")),new ToolTipLine(StringUtils.localize("String_Node_Str"))));
  buttonList.add(optionAllowCreative);
  textField=new GuiTextField(this.fontRendererObj,TEXT_X,TEXT_Y,TEXT_WIDTH,TEXT_HEIGHT);
  textField.setMaxStringLength(DefaultProps.MAX_NAME_SIZE);
  textField.setText(architect.name);
  textField.setFocused(true);
  updateButtons();
}
Program: 156761
Project: 156761
Buggy source:
@Override protected void drawGuiContainerForegroundLayer(int par1,int par2){
  String title=StringUtils.localize("String_Node_Str");
  fontRendererObj.drawString(title,getCenteredOffset(title),6,0x404040);
  int c=0;
  for (  LibraryId bpt : library.currentPage) {
    String name=bpt.name;
    if (name.length() > BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE) {
      name=name.substring(0,BuildCraftBuilders.MAX_BLUEPRINTS_NAME_SIZE);
    }
    if (c == library.selected) {
      int l1=8;
      int i2=24;
      drawGradientRect(l1,i2 + 9 * c,l1 + 146,i2 + 9 * (c + 1),0x80ffffff,0x80ffffff);
    }
    fontRendererObj.drawString(name,9,25 + 9 * c,LibraryAPI.getHandler(bpt.extension).getTextColor());
    c++;
  }
}

Fixed version (ground truth):
@Override protected void drawGuiContainerForegroundLayer(int par1,int par2){
  String title=StringUtils.localize("String_Node_Str");
  fontRendererObj.drawString(title,getCenteredOffset(title),6,0x404040);
  int c=0;
  for (  LibraryId bpt : library.currentPage) {
    String name=bpt.name;
    if (name.length() > DefaultProps.MAX_NAME_SIZE) {
      name=name.substring(0,DefaultProps.MAX_NAME_SIZE);
    }
    if (c == library.selected) {
      int l1=8;
      int i2=24;
      drawGradientRect(l1,i2 + 9 * c,l1 + 146,i2 + 9 * (c + 1),0x80ffffff,0x80ffffff);
    }
    fontRendererObj.drawString(name,9,25 + 9 * c,LibraryAPI.getHandler(bpt.extension).getTextColor());
    c++;
  }
}
Program: 156763
Project: 156763
Buggy source:
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  scan=nbt.getBoolean("String_Node_Str");
  chunkIt=nbt.getInteger("String_Node_Str");
  colors=nbt.getByteArray("String_Node_Str");
  if (colors.length != RESOLUTION * RESOLUTION || chunkIt >= RESOLUTION_CHUNKS * RESOLUTION_CHUNKS) {
    colors=new byte[RESOLUTION * RESOLUTION];
    scan=true;
    chunkIt=0;
  }
  inv.readFromNBT(nbt.getCompoundTag("String_Node_Str"));
  for (int i=0; i < selectedAreas.length; ++i) {
    if (nbt.hasKey("String_Node_Str" + i + "String_Node_Str")) {
      selectedAreas[i]=new ZonePlan();
      selectedAreas[i].readFromNBT(nbt.getCompoundTag("String_Node_Str" + i + "String_Node_Str"));
    }
  }
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  scan=nbt.getBoolean("String_Node_Str");
  chunkIt=nbt.getInteger("String_Node_Str");
  colors=nbt.getByteArray("String_Node_Str");
  mapName=nbt.getString("String_Node_Str");
  if (mapName == null) {
    mapName="String_Node_Str";
  }
  if (colors.length != RESOLUTION * RESOLUTION || chunkIt >= RESOLUTION_CHUNKS * RESOLUTION_CHUNKS) {
    colors=new byte[RESOLUTION * RESOLUTION];
    scan=true;
    chunkIt=0;
  }
  inv.readFromNBT(nbt.getCompoundTag("String_Node_Str"));
  for (int i=0; i < selectedAreas.length; ++i) {
    if (nbt.hasKey("String_Node_Str" + i + "String_Node_Str")) {
      selectedAreas[i]=new ZonePlan();
      selectedAreas[i].readFromNBT(nbt.getCompoundTag("String_Node_Str" + i + "String_Node_Str"));
    }
  }
}
Program: 156764
Project: 156764
Buggy source:
@Override public void readData(ByteBuf stream){
  progress=stream.readShort();
}

Fixed version (ground truth):
@Override public void readData(ByteBuf stream){
  progress=stream.readShort();
  mapName=NetworkUtils.readUTF(stream);
}
Program: 156765
Project: 156765
Buggy source:
@Override public void writeData(ByteBuf stream){
  stream.writeShort(progress);
}

Fixed version (ground truth):
@Override public void writeData(ByteBuf stream){
  stream.writeShort(progress);
  NetworkUtils.writeUTF(stream,mapName);
}
Program: 156766
Project: 156766
Buggy source:
@Override public void updateEntity(){
  super.updateEntity();
  if (worldObj.isRemote) {
    return;
  }
  if (scan && zonePlannerScanning.markTimeIfDelay(worldObj)) {
    int[] coords=getCoords();
    Chunk chunk=worldObj.getChunkFromChunkCoords(coords[0],coords[1]);
    loadChunk(chunk);
    if (chunkIt > RESOLUTION_CHUNKS * RESOLUTION_CHUNKS) {
      scan=false;
      chunkIt=0;
    }
 else {
      chunkIt++;
    }
  }
  if (inv.getStackInSlot(0) != null && inv.getStackInSlot(1) == null && inv.getStackInSlot(0).getItem() instanceof ItemMapLocation) {
    if (progress < CRAFT_TIME) {
      progress++;
      if (worldObj.getTotalWorldTime() % 5 == 0) {
        sendNetworkUpdate();
      }
    }
 else {
      ItemStack stack=inv.decrStackSize(0,1);
      if (selectedAreas[currentSelectedArea] != null) {
        ItemMapLocation.setZone(stack,selectedAreas[currentSelectedArea]);
      }
      inv.setInventorySlotContents(1,stack);
    }
  }
 else   if (progress != 0) {
    progress=0;
    sendNetworkUpdate();
  }
}

Fixed version (ground truth):
@Override public void updateEntity(){
  super.updateEntity();
  if (worldObj.isRemote) {
    return;
  }
  if (scan && zonePlannerScanning.markTimeIfDelay(worldObj)) {
    int[] coords=getCoords();
    Chunk chunk=worldObj.getChunkFromChunkCoords(coords[0],coords[1]);
    loadChunk(chunk);
    if (chunkIt > RESOLUTION_CHUNKS * RESOLUTION_CHUNKS) {
      scan=false;
      chunkIt=0;
    }
 else {
      chunkIt++;
    }
  }
  if (inv.getStackInSlot(0) != null && inv.getStackInSlot(1) == null && inv.getStackInSlot(0).getItem() instanceof ItemMapLocation) {
    if (progress < CRAFT_TIME) {
      progress++;
      if (worldObj.getTotalWorldTime() % 5 == 0) {
        sendNetworkUpdate();
      }
    }
 else {
      ItemStack stack=inv.decrStackSize(0,1);
      if (selectedAreas[currentSelectedArea] != null) {
        ItemMapLocation.setZone(stack,selectedAreas[currentSelectedArea]);
        ((INamedItem)stack.getItem()).setName(stack,mapName);
      }
      inv.setInventorySlotContents(1,stack);
    }
  }
 else   if (progress != 0) {
    progress=0;
    sendNetworkUpdate();
  }
}
Program: 156767
Project: 156767
Buggy source:
@Override public void writeToNBT(NBTTagCompound nbt){
  super.writeToNBT(nbt);
  nbt.setBoolean("String_Node_Str",scan);
  nbt.setInteger("String_Node_Str",chunkIt);
  nbt.setByteArray("String_Node_Str",colors);
  NBTTagCompound invNBT=new NBTTagCompound();
  inv.writeToNBT(invNBT);
  nbt.setTag("String_Node_Str",invNBT);
  for (int i=0; i < selectedAreas.length; ++i) {
    if (selectedAreas[i] != null) {
      NBTTagCompound subNBT=new NBTTagCompound();
      selectedAreas[i].writeToNBT(subNBT);
      nbt.setTag("String_Node_Str" + i + "String_Node_Str",subNBT);
    }
  }
}

Fixed version (ground truth):
@Override public void writeToNBT(NBTTagCompound nbt){
  super.writeToNBT(nbt);
  nbt.setBoolean("String_Node_Str",scan);
  nbt.setInteger("String_Node_Str",chunkIt);
  nbt.setByteArray("String_Node_Str",colors);
  nbt.setString("String_Node_Str",mapName);
  NBTTagCompound invNBT=new NBTTagCompound();
  inv.writeToNBT(invNBT);
  nbt.setTag("String_Node_Str",invNBT);
  for (int i=0; i < selectedAreas.length; ++i) {
    if (selectedAreas[i] != null) {
      NBTTagCompound subNBT=new NBTTagCompound();
      selectedAreas[i].writeToNBT(subNBT);
      nbt.setTag("String_Node_Str" + i + "String_Node_Str",subNBT);
    }
  }
}
Program: 156768
Project: 156768
Buggy source:
@Override public void receiveCommand(String command,Side side,Object sender,ByteBuf stream){
  if (side.isClient()) {
    if ("String_Node_Str".equals(command)) {
      currentAreaSelection=new ZonePlan();
      currentAreaSelection.readData(stream);
      gui.refreshSelectedArea();
    }
 else     if ("String_Node_Str".equals(command)) {
      int size=stream.readUnsignedMedium();
      for (int i=0; i < size; ++i) {
        mapTexture.colorMap[i]=0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
      }
    }
  }
 else   if (side.isServer()) {
    if ("String_Node_Str".equals(command)) {
      final int index=stream.readUnsignedByte();
      BuildCraftCore.instance.sendToPlayer((EntityPlayer)sender,new PacketCommand(this,"String_Node_Str",new CommandWriter(){
        public void write(        ByteBuf data){
          map.selectArea(index).writeData(data);
        }
      }
));
    }
 else     if ("String_Node_Str".equals(command)) {
      final int index=stream.readUnsignedByte();
      ZonePlan plan=new ZonePlan();
      plan.readData(stream);
      map.setArea(index,plan);
    }
 else     if ("String_Node_Str".equals(command)) {
      computeMap(stream.readInt(),stream.readInt(),stream.readUnsignedShort(),stream.readUnsignedShort(),stream.readUnsignedByte(),(EntityPlayer)sender);
    }
  }
}

Fixed version (ground truth):
@Override public void receiveCommand(String command,Side side,Object sender,ByteBuf stream){
  if (side.isClient()) {
    if ("String_Node_Str".equals(command)) {
      currentAreaSelection=new ZonePlan();
      currentAreaSelection.readData(stream);
      gui.refreshSelectedArea();
    }
 else     if ("String_Node_Str".equals(command)) {
      int size=stream.readUnsignedMedium();
      for (int i=0; i < size; ++i) {
        mapTexture.colorMap[i]=0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
      }
    }
  }
 else   if (side.isServer()) {
    if ("String_Node_Str".equals(command)) {
      final int index=stream.readUnsignedByte();
      BuildCraftCore.instance.sendToPlayer((EntityPlayer)sender,new PacketCommand(this,"String_Node_Str",new CommandWriter(){
        public void write(        ByteBuf data){
          map.selectArea(index).writeData(data);
        }
      }
));
    }
 else     if ("String_Node_Str".equals(command)) {
      final int index=stream.readUnsignedByte();
      ZonePlan plan=new ZonePlan();
      plan.readData(stream);
      map.setArea(index,plan);
    }
 else     if ("String_Node_Str".equals(command)) {
      computeMap(stream.readInt(),stream.readInt(),stream.readUnsignedShort(),stream.readUnsignedShort(),stream.readUnsignedByte(),(EntityPlayer)sender);
    }
 else     if ("String_Node_Str".equals(command)) {
      map.mapName=NetworkUtils.readUTF(stream);
    }
  }
}
Program: 156769
Project: 156769
Buggy source:
public ContainerZonePlan(IInventory playerInventory,TileZonePlan iZonePlan){
  super(0);
  map=iZonePlan;
  addSlotToContainer(new Slot(iZonePlan,0,233,20));
  addSlotToContainer(new SlotOutput(iZonePlan,1,233,68));
  for (int l=0; l < 3; l++) {
    for (int k1=0; k1 < 9; k1++) {
      addSlotToContainer(new Slot(playerInventory,k1 + l * 9 + 9,88 + k1 * 18,138 + l * 18));
    }
  }
  for (int i1=0; i1 < 9; i1++) {
    addSlotToContainer(new Slot(playerInventory,i1,88 + i1 * 18,196));
  }
}

Fixed version (ground truth):
public ContainerZonePlan(IInventory playerInventory,TileZonePlan iZonePlan){
  super(0);
  map=iZonePlan;
  addSlotToContainer(new Slot(iZonePlan,0,233,20));
  addSlotToContainer(new SlotOutput(iZonePlan,1,233,68));
  for (int l=0; l < 3; l++) {
    for (int k1=0; k1 < 9; k1++) {
      addSlotToContainer(new Slot(playerInventory,k1 + l * 9 + 9,88 + k1 * 18,146 + l * 18));
    }
  }
  for (int i1=0; i1 < 9; i1++) {
    addSlotToContainer(new Slot(playerInventory,i1,88 + i1 * 18,204));
  }
}
Program: 156770
Project: 156770
Buggy source:
private boolean isCarryingList(){
  ItemStack stack=mc.thePlayer.inventory.getItemStack();
  return stack != null && stack.getItem() != null && stack.getItem() instanceof ItemList;
}

Fixed version (ground truth):
private boolean isCarryingList(){
  ItemStack stack=mc.thePlayer.inventory.getItemStack();
  return stack != null && stack.getItem() instanceof ItemList;
}
Program: 156771
Project: 156771
Buggy source:
@Override protected void mouseClicked(int x,int y,int b){
  super.mouseClicked(x,y,b);
  if (isCarryingList()) {
    return;
  }
  AdvancedSlot slot=getSlotAtLocation(x,y);
  ContainerList container=(ContainerList)getContainer();
  if (slot instanceof MainSlot) {
    container.setStack(((MainSlot)slot).lineIndex,0,mc.thePlayer.inventory.getItemStack());
  }
 else   if (slot instanceof SecondarySlot) {
    container.setStack(((SecondarySlot)slot).lineIndex,((SecondarySlot)slot).slotIndex,mc.thePlayer.inventory.getItemStack());
  }
 else   if (slot instanceof Button) {
    Button button=(Button)slot;
    container.switchButton(button.line,button.kind);
  }
  textField.mouseClicked(x - guiLeft,y - guiTop,b);
}

Fixed version (ground truth):
@Override protected void mouseClicked(int x,int y,int b){
  super.mouseClicked(x,y,b);
  if (isCarryingList() || !hasListEquipped()) {
    return;
  }
  AdvancedSlot slot=getSlotAtLocation(x,y);
  ContainerList container=(ContainerList)getContainer();
  if (slot instanceof MainSlot) {
    container.setStack(((MainSlot)slot).lineIndex,0,mc.thePlayer.inventory.getItemStack());
  }
 else   if (slot instanceof SecondarySlot) {
    container.setStack(((SecondarySlot)slot).lineIndex,((SecondarySlot)slot).slotIndex,mc.thePlayer.inventory.getItemStack());
  }
 else   if (slot instanceof Button) {
    Button button=(Button)slot;
    container.switchButton(button.line,button.kind);
  }
  textField.mouseClicked(x - guiLeft,y - guiTop,b);
}
Program: 156772
Project: 156772
Buggy source:
/** 
 * This can be use to provide a rough estimate of how much power is contained in a pipe. Measured in RF. Max should be around (throughput * internalPower.length * 2), ie 112 MJ for a Cobblestone Pipe.
 * @return RF
 */
public int getCurrentPowerAmount(){
  int amount=0;
  for (  int d : internalPower) {
    amount+=d;
  }
  for (  int d : internalNextPower) {
    amount+=d;
  }
  return amount;
}

Fixed version (ground truth):
/** 
 * This can be use to provide a rough estimate of how much power is contained in a pipe. Measured in RF. Max should be around (throughput * internalPower.length * 2), ie 1120 RF for a Cobblestone Pipe.
 * @return RF
 */
public int getCurrentPowerAmount(){
  int amount=0;
  for (  int d : internalPower) {
    amount+=d;
  }
  for (  int d : internalNextPower) {
    amount+=d;
  }
  return amount;
}
Program: 156774
Project: 156774
Buggy source:
public PipeTransportPower(){
  for (int i=0; i < 6; ++i) {
    powerQuery[i]=0;
  }
  for (int i=0; i < 3; ++i) {
    movementStage[i]=(float)Math.random();
  }
}

Fixed version (ground truth):
public PipeTransportPower(){
  for (int i=0; i < 6; ++i) {
    powerQuery[i]=0;
  }
}
Program: 156775
Project: 156775
Buggy source:
private void step(){
  if (container != null && container.getWorldObj() != null && currentDate != container.getWorldObj().getTotalWorldTime()) {
    currentDate=container.getWorldObj().getTotalWorldTime();
    powerQuery=nextPowerQuery;
    nextPowerQuery=new int[6];
    int[] next=internalPower;
    internalPower=internalNextPower;
    internalNextPower=internalPower;
  }
}

Fixed version (ground truth):
private void step(){
  if (container != null && container.getWorldObj() != null && currentDate != container.getWorldObj().getTotalWorldTime()) {
    currentDate=container.getWorldObj().getTotalWorldTime();
    powerQuery=nextPowerQuery;
    nextPowerQuery=new int[6];
    int[] next=internalPower;
    internalPower=internalNextPower;
    internalNextPower=next;
  }
}
Program: 156777
Project: 156777
Buggy source:
public void setStack(int slot,ItemStack stack){
  stacks[slot]=stack;
  if (stack != null) {
    stacks[slot]=stacks[slot].copy();
    stacks[slot].stackSize=1;
  }
  if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT && slot == 0) {
    relatedItems.clear();
    ores.clear();
    if (stack == null) {
      isOre=false;
    }
 else {
      setClientPreviewLists();
    }
  }
}

Fixed version (ground truth):
public void setStack(int slot,ItemStack stack){
  stacks[slot]=stack;
  if (stack != null) {
    stacks[slot]=stacks[slot].copy();
    stacks[slot].stackSize=1;
  }
  if (slot == 0) {
    relatedItems.clear();
    ores.clear();
    if (stack == null) {
      isOre=false;
    }
 else {
      if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
        setClientPreviewLists();
      }
 else {
        isOre=OreDictionary.getOreIDs(stacks[0]).length > 0;
      }
    }
  }
}
Program: 156778
Project: 156778
Buggy source:
@Override public void update(){
  PipeTransportPower powerProvider=(PipeTransportPower)((DockingStation)robot.getDockingStation()).getPipe().pipe.transport;
  int amount=robot.getBattery().receiveEnergy(1000,false);
  powerProvider.requestEnergy(robot.getDockingStation().side(),amount);
  robot.getBattery().receiveEnergy(powerProvider.consumePower(robot.getDockingStation().side(),amount),false);
  if (robot.getEnergy() >= EntityRobotBase.MAX_ENERGY) {
    terminate();
  }
}

Fixed version (ground truth):
@Override public void update(){
  PipeTransportPower powerProvider=(PipeTransportPower)((DockingStation)robot.getDockingStation()).getPipe().pipe.transport;
  int amount=robot.getBattery().receiveEnergy(1000,true);
  powerProvider.requestEnergy(robot.getDockingStation().side(),amount);
  robot.getBattery().receiveEnergy(powerProvider.consumePower(robot.getDockingStation().side(),amount),false);
  if (robot.getEnergy() >= EntityRobotBase.MAX_ENERGY) {
    terminate();
  }
}
Program: 156780
Project: 156780
Buggy source:
public boolean findTarget(boolean doSet){
  if (worldObj.isRemote) {
    return false;
  }
  boolean columnVisitListIsUpdated=false;
  if (visitList.isEmpty()) {
    createColumnVisitList();
    columnVisitListIsUpdated=true;
  }
  if (!doSet) {
    return !visitList.isEmpty();
  }
  if (visitList.isEmpty()) {
    return false;
  }
  int[] nextTarget=visitList.removeFirst();
  if (!columnVisitListIsUpdated) {
    for (int y=nextTarget[1] + 1; y < yCoord + 3; y++) {
      Block block=worldObj.getBlock(nextTarget[0],y,nextTarget[2]);
      if (BlockUtils.isAnObstructingBlock(block,worldObj,nextTarget[0],y,nextTarget[2])) {
        createColumnVisitList();
        columnVisitListIsUpdated=true;
        nextTarget=null;
        break;
      }
    }
  }
  if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) {
    nextTarget=visitList.removeFirst();
  }
 else   if (columnVisitListIsUpdated && nextTarget == null) {
    return false;
  }
  setTarget(nextTarget[0],nextTarget[1] + 1,nextTarget[2]);
  return true;
}

Fixed version (ground truth):
public boolean findTarget(boolean doSet){
  if (worldObj.isRemote) {
    return false;
  }
  boolean columnVisitListIsUpdated=false;
  if (visitList.isEmpty()) {
    createColumnVisitList();
    columnVisitListIsUpdated=true;
  }
  if (!doSet) {
    return !visitList.isEmpty();
  }
  if (visitList.isEmpty()) {
    return false;
  }
  int[] nextTarget=visitList.removeFirst();
  if (!columnVisitListIsUpdated) {
    for (int y=nextTarget[1] + 1; y < yCoord + 3; y++) {
      Block block=worldObj.getBlock(nextTarget[0],y,nextTarget[2]);
      if (BlockUtils.isAnObstructingBlock(block,worldObj,nextTarget[0],y,nextTarget[2]) || !BuildCraftAPI.isSoftBlock(worldObj,nextTarget[0],y,nextTarget[2])) {
        createColumnVisitList();
        columnVisitListIsUpdated=true;
        nextTarget=null;
        break;
      }
    }
  }
  if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) {
    nextTarget=visitList.removeFirst();
  }
 else   if (columnVisitListIsUpdated && nextTarget == null) {
    return false;
  }
  setTarget(nextTarget[0],nextTarget[1] + 1,nextTarget[2]);
  return true;
}
Program: 156781
Project: 156781
Buggy source:
@SuppressWarnings("String_Node_Str") public void positionReached(){
  if (worldObj.isRemote) {
    return;
  }
  if (isQuarriableBlock(targetX,targetY - 1,targetZ)) {
    if (BuildCraftAPI.isSoftBlock(worldObj,targetX,targetY - 1,targetZ)) {
      miner=null;
      stage=Stage.IDLE;
      worldObj.setBlockToAir(targetX,targetY - 1,targetZ);
    }
 else {
      miner=new BlockMiner(worldObj,this,targetX,targetY - 1,targetZ);
      stage=Stage.DIGGING;
    }
  }
 else {
    stage=Stage.IDLE;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void positionReached(){
  if (worldObj.isRemote) {
    return;
  }
  if (isQuarriableBlock(targetX,targetY - 1,targetZ)) {
    miner=new BlockMiner(worldObj,this,targetX,targetY - 1,targetZ);
    stage=Stage.DIGGING;
  }
 else {
    stage=Stage.IDLE;
  }
}
Program: 156782
Project: 156782
Buggy source:
private boolean isQuarriableBlock(int bx,int by,int bz){
  Block block=worldObj.getBlock(bx,by,bz);
  return BlockUtils.canChangeBlock(block,worldObj,bx,by,bz) && BlockUtils.isAnObstructingBlock(block,worldObj,bx,by,bz);
}

Fixed version (ground truth):
private boolean isQuarriableBlock(int bx,int by,int bz){
  Block block=worldObj.getBlock(bx,by,bz);
  return BlockUtils.canChangeBlock(block,worldObj,bx,by,bz) && !BuildCraftAPI.isSoftBlock(worldObj,bx,by,bz);
}
Program: 156783
Project: 156783
Buggy source:
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  Gate gate : gates) {
    if (gate != null) {
      result.add(gate.getGateItem());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}
Program: 156784
Project: 156784
Buggy source:
/** 
 * Shifts the coordinates around effectively rotating something. Zero state is DOWN then -> NORTH -> WEST Note - To obtain Position, do a mirrorY() before rotating
 * @param targetArray the array that should be rotated
 */
public static void rotate(float[][] targetArray){
  for (int i=0; i < 2; i++) {
    float temp=targetArray[2][i];
    targetArray[2][i]=targetArray[1][i];
    targetArray[1][i]=targetArray[0][i];
    targetArray[0][i]=temp;
  }
}

Fixed version (ground truth):
/** 
 * Shifts the coordinates around effectively rotating something. Zero state is DOWN then -&gt; NORTH -&gt; WEST Note - To obtain Position, do a mirrorY() before rotating
 * @param targetArray the array that should be rotated
 */
public static void rotate(float[][] targetArray){
  for (int i=0; i < 2; i++) {
    float temp=targetArray[2][i];
    targetArray[2][i]=targetArray[1][i];
    targetArray[1][i]=targetArray[0][i];
    targetArray[0][i]=temp;
  }
}
Program: 156785
Project: 156785
Buggy source:
@Override public void onEntityCollidedWithBlock(World world,int x,int y,int z,Entity entity){
  if (!dense || entity == null)   return;
  entity.motionY=Math.min(0.0,entity.motionY);
  if (entity.motionY < -0.05) {
    entity.motionY*=0.05;
  }
  entity.motionX=Math.max(-0.05,Math.min(0.05,entity.motionX * 0.05));
  entity.motionY-=0.05;
  entity.motionZ=Math.max(-0.05,Math.min(0.05,entity.motionZ * 0.05));
}

Fixed version (ground truth):
@Override public void onEntityCollidedWithBlock(World world,int x,int y,int z,Entity entity){
  if (!dense || entity == null) {
    return;
  }
  entity.motionY=Math.min(0.0,entity.motionY);
  if (entity.motionY < -0.05) {
    entity.motionY*=0.05;
  }
  entity.motionX=Math.max(-0.05,Math.min(0.05,entity.motionX * 0.05));
  entity.motionY-=0.05;
  entity.motionZ=Math.max(-0.05,Math.min(0.05,entity.motionZ * 0.05));
}
Program: 156786
Project: 156786
Buggy source:
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  Gate gate : gates) {
    if (gate != null) {
      result.add(gate.getGateItem());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}
Program: 156787
Project: 156787
Buggy source:
@Override public void rotateLeft(IBuilderContext context){
  int status=meta - (meta & 7);
  meta-=status;
  super.rotateLeft(context);
  meta+=status;
}

Fixed version (ground truth):
@Override public void rotateLeft(IBuilderContext context){
  int status=meta & 8;
  meta-=status;
  super.rotateLeft(context);
  meta+=status;
}
Program: 156789
Project: 156789
Buggy source:
public boolean findTarget(boolean doSet){
  if (worldObj.isRemote) {
    return false;
  }
  boolean columnVisitListIsUpdated=false;
  if (visitList.isEmpty()) {
    createColumnVisitList();
    columnVisitListIsUpdated=true;
  }
  if (!doSet) {
    return !visitList.isEmpty();
  }
  if (visitList.isEmpty()) {
    return false;
  }
  int[] nextTarget=visitList.removeFirst();
  if (!columnVisitListIsUpdated) {
    for (int y=nextTarget[1] + 1; y < yCoord + 3; y++) {
      Block block=worldObj.getBlock(nextTarget[0],y,nextTarget[2]);
      if (BlockUtils.isAnObstructingBlock(block,worldObj,nextTarget[0],y,nextTarget[2]) || !BuildCraftAPI.isSoftBlock(worldObj,nextTarget[0],y,nextTarget[2])) {
        createColumnVisitList();
        columnVisitListIsUpdated=true;
        nextTarget=null;
        break;
      }
    }
  }
  if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) {
    nextTarget=visitList.removeFirst();
  }
 else   if (columnVisitListIsUpdated && nextTarget == null) {
    return false;
  }
  setTarget(nextTarget[0],nextTarget[1] + 1,nextTarget[2]);
  return true;
}

Fixed version (ground truth):
public boolean findTarget(boolean doSet){
  if (worldObj.isRemote) {
    return false;
  }
  boolean columnVisitListIsUpdated=false;
  if (visitList.isEmpty()) {
    createColumnVisitList();
    columnVisitListIsUpdated=true;
  }
  if (!doSet) {
    return !visitList.isEmpty();
  }
  if (visitList.isEmpty()) {
    return false;
  }
  int[] nextTarget=visitList.removeFirst();
  if (!columnVisitListIsUpdated) {
    for (int y=nextTarget[1] + 1; y < yCoord + 3; y++) {
      Block block=worldObj.getBlock(nextTarget[0],y,nextTarget[2]);
      if (BlockUtils.isAnObstructingBlock(block,worldObj,nextTarget[0],y,nextTarget[2])) {
        createColumnVisitList();
        columnVisitListIsUpdated=true;
        nextTarget=null;
        break;
      }
    }
  }
  if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) {
    nextTarget=visitList.removeFirst();
  }
 else   if (columnVisitListIsUpdated && nextTarget == null) {
    return false;
  }
  setTarget(nextTarget[0],nextTarget[1] + 1,nextTarget[2]);
  return true;
}
Program: 156790
Project: 156790
Buggy source:
@SuppressWarnings("String_Node_Str") public void positionReached(){
  if (worldObj.isRemote) {
    return;
  }
  if (isQuarriableBlock(targetX,targetY - 1,targetZ)) {
    miner=new BlockMiner(worldObj,this,targetX,targetY - 1,targetZ);
    stage=Stage.DIGGING;
  }
 else {
    stage=Stage.IDLE;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void positionReached(){
  if (worldObj.isRemote) {
    return;
  }
  if (isQuarriableBlock(targetX,targetY - 1,targetZ)) {
    if (BuildCraftAPI.isSoftBlock(worldObj,targetX,targetY - 1,targetZ)) {
      miner=null;
      stage=Stage.IDLE;
      worldObj.setBlockToAir(targetX,targetY - 1,targetZ);
    }
 else {
      miner=new BlockMiner(worldObj,this,targetX,targetY - 1,targetZ);
      stage=Stage.DIGGING;
    }
  }
 else {
    stage=Stage.IDLE;
  }
}
Program: 156791
Project: 156791
Buggy source:
private boolean isQuarriableBlock(int bx,int by,int bz){
  Block block=worldObj.getBlock(bx,by,bz);
  return BlockUtils.canChangeBlock(block,worldObj,bx,by,bz) && !BuildCraftAPI.isSoftBlock(worldObj,bx,by,bz);
}

Fixed version (ground truth):
private boolean isQuarriableBlock(int bx,int by,int bz){
  Block block=worldObj.getBlock(bx,by,bz);
  return BlockUtils.canChangeBlock(block,worldObj,bx,by,bz) && BlockUtils.isAnObstructingBlock(block,worldObj,bx,by,bz);
}
Program: 156792
Project: 156792
Buggy source:
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  Gate gate : gates) {
    if (gate != null) {
      result.add(gate.getGateItem());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
public ArrayList<ItemStack> computeItemDrop(){
  ArrayList<ItemStack> result=new ArrayList<ItemStack>();
  for (  PipeWire pipeWire : PipeWire.VALUES) {
    if (wireSet[pipeWire.ordinal()]) {
      result.add(pipeWire.getStack());
    }
  }
  for (  ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
    if (container.hasPipePluggable(direction)) {
      for (      ItemStack stack : container.getPipePluggable(direction).getDropItems(container)) {
        result.add(stack);
      }
    }
  }
  return result;
}
Program: 156793
Project: 156793
Buggy source:
private boolean addOrStripPipePluggable(World world,int x,int y,int z,ItemStack stack,EntityPlayer player,ForgeDirection side,Pipe<?> pipe){
  RaytraceResult rayTraceResult=doRayTrace(world,x,y,z,player);
  ForgeDirection pSide=rayTraceResult.sideHit;
  if (pSide == ForgeDirection.UNKNOWN || pSide == null) {
    pSide=side;
  }
  IPipePluggableItem pluggableItem=(IPipePluggableItem)stack.getItem();
  PipePluggable pluggable=pluggableItem.createPipePluggable(pipe,rayTraceResult.sideHit,stack);
  if (player.isSneaking()) {
    if (pipe.container.hasPipePluggable(pSide) && rayTraceResult != null && rayTraceResult.hitPart == Part.Pluggable && pluggable.getClass().isInstance(pipe.container.getPipePluggable(pSide))) {
      return pipe.container.dropSideItems(pSide);
    }
  }
  if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) {
    if (pluggable == null) {
      return false;
    }
    if (!pipe.container.hasPipePluggable(pSide)) {
      pipe.container.setPluggable(pSide,pluggable);
      if (!player.capabilities.isCreativeMode) {
        stack.stackSize--;
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean addOrStripPipePluggable(World world,int x,int y,int z,ItemStack stack,EntityPlayer player,ForgeDirection side,Pipe<?> pipe){
  RaytraceResult rayTraceResult=doRayTrace(world,x,y,z,player);
  ForgeDirection placementSide=rayTraceResult != null && rayTraceResult.sideHit != ForgeDirection.UNKNOWN ? rayTraceResult.sideHit : side;
  IPipePluggableItem pluggableItem=(IPipePluggableItem)stack.getItem();
  PipePluggable pluggable=pluggableItem.createPipePluggable(pipe,placementSide,stack);
  if (pluggable == null) {
    return false;
  }
  if (player.isSneaking()) {
    if (pipe.container.hasPipePluggable(side) && rayTraceResult != null && rayTraceResult.hitPart == Part.Pluggable && pluggable.getClass().isInstance(pipe.container.getPipePluggable(side))) {
      return pipe.container.dropSideItems(side);
    }
  }
  if (rayTraceResult != null && rayTraceResult.hitPart == Part.Pipe) {
    if (!pipe.container.hasPipePluggable(placementSide)) {
      pipe.container.setPluggable(placementSide,pluggable);
      if (!player.capabilities.isCreativeMode) {
        stack.stackSize--;
      }
      return true;
    }
  }
  return false;
}
Program: 156794
Project: 156794
Buggy source:
public void addGateExpansion(IGateExpansion expansion){
  if (!expansions.containsKey(expansion)) {
    expansions.put(expansion,expansion.makeController(pipe.container));
  }
}

Fixed version (ground truth):
public void addGateExpansion(IGateExpansion expansion){
  if (!expansions.containsKey(expansion)) {
    expansions.put(expansion,expansion.makeController(pipe != null ? pipe.container : null));
  }
}
Program: 156795
Project: 156795
Buggy source:
@Override public void afterStateUpdated(byte stateId){
  if (!worldObj.isRemote) {
    return;
  }
switch (stateId) {
case 0:
    if (pipe == null && coreState.pipeId != 0) {
      initialize(BlockGenericPipe.createPipe((Item)Item.itemRegistry.getObjectById(coreState.pipeId)));
    }
  if (pipe == null) {
    break;
  }
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
break;
case 1:
{
if (renderState.needsRenderUpdate()) {
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
renderState.clean();
}
break;
}
case 2:
{
for (int i=0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
final PipePluggable pluggable=getPipePluggable(ForgeDirection.getOrientation(i));
if (pluggable != null && pluggable instanceof GatePluggable) {
final GatePluggable gatePluggable=(GatePluggable)pluggable;
Gate gate=pipe.gates[i];
if (gate == null || gate.logic != gatePluggable.logic || gate.material != gatePluggable.material) {
  pipe.gates[i]=GateFactory.makeGate(pipe,gatePluggable.material,gatePluggable.logic,ForgeDirection.getOrientation(i));
}
}
 else {
pipe.gates[i]=null;
}
}
syncGateExpansions();
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
sideProperties.pluggables=pluggableState.getPluggables();
break;
}
}
}

Fixed version (ground truth):
@Override public void afterStateUpdated(byte stateId){
  if (!worldObj.isRemote) {
    return;
  }
switch (stateId) {
case 0:
    if (pipe == null && coreState.pipeId != 0) {
      initialize(BlockGenericPipe.createPipe((Item)Item.itemRegistry.getObjectById(coreState.pipeId)));
    }
  if (pipe == null) {
    break;
  }
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
break;
case 1:
{
if (renderState.needsRenderUpdate()) {
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
renderState.clean();
}
break;
}
case 2:
{
worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord);
sideProperties.pluggables=pluggableState.getPluggables();
for (int i=0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
final PipePluggable pluggable=getPipePluggable(ForgeDirection.getOrientation(i));
if (pluggable != null && pluggable instanceof GatePluggable) {
final GatePluggable gatePluggable=(GatePluggable)pluggable;
Gate gate=pipe.gates[i];
if (gate == null || gate.logic != gatePluggable.getLogic() || gate.material != gatePluggable.getMaterial()) {
  pipe.gates[i]=GateFactory.makeGate(pipe,gatePluggable.getMaterial(),gatePluggable.getLogic(),ForgeDirection.getOrientation(i));
}
}
 else {
pipe.gates[i]=null;
}
}
syncGateExpansions();
break;
}
}
}
Program: 156796
Project: 156796
Buggy source:
private void syncGateExpansions(){
  resyncGateExpansions=false;
  for (int i=0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
    Gate gate=pipe.gates[i];
    if (gate == null) {
      continue;
    }
    GatePluggable gatePluggable=(GatePluggable)sideProperties.pluggables[i];
    if (gatePluggable.expansions.length > 0) {
      for (      IGateExpansion expansion : gatePluggable.expansions) {
        if (expansion != null) {
          if (!gate.expansions.containsKey(expansion)) {
            gate.addGateExpansion(expansion);
          }
        }
 else {
          resyncGateExpansions=true;
        }
      }
    }
  }
}

Fixed version (ground truth):
private void syncGateExpansions(){
  resyncGateExpansions=false;
  for (int i=0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
    Gate gate=pipe.gates[i];
    if (gate == null) {
      continue;
    }
    GatePluggable gatePluggable=(GatePluggable)sideProperties.pluggables[i];
    if (gatePluggable.getExpansions().length > 0) {
      for (      IGateExpansion expansion : gatePluggable.getExpansions()) {
        if (expansion != null) {
          if (!gate.expansions.containsKey(expansion)) {
            gate.addGateExpansion(expansion);
          }
        }
 else {
          resyncGateExpansions=true;
        }
      }
    }
  }
}
Program: 156798
Project: 156798
Buggy source:
@Override public void writeData(ByteBuf buf){
  buf.writeByte(material.ordinal());
  buf.writeByte(logic.ordinal());
  buf.writeBoolean(realGate.isGateActive());
  buf.writeBoolean(realGate.isGatePulsing());
  final int expansionsSize=expansions.length;
  buf.writeInt(expansionsSize);
  for (  IGateExpansion expansion : expansions) {
    buf.writeShort(GateExpansions.getExpansionID(expansion));
  }
}

Fixed version (ground truth):
@Override public void writeData(ByteBuf buf){
  buf.writeByte(material.ordinal());
  buf.writeByte(logic.ordinal());
  buf.writeBoolean(realGate != null ? realGate.isGateActive() : false);
  buf.writeBoolean(realGate != null ? realGate.isGatePulsing() : false);
  final int expansionsSize=expansions.length;
  buf.writeInt(expansionsSize);
  for (  IGateExpansion expansion : expansions) {
    buf.writeShort(GateExpansions.getExpansionID(expansion));
  }
}
Program: 156799
Project: 156799
Buggy source:
@Override public void onAttachedPipe(IPipeContainer pipe,ForgeDirection direction){
  TileGenericPipe pipeReal=(TileGenericPipe)pipe;
  if (!pipeReal.getWorld().isRemote) {
    Gate gate=pipeReal.pipe.gates[direction.ordinal()];
    if (gate == null || gate.material != material || gate.logic != logic) {
      pipeReal.pipe.gates[direction.ordinal()]=GateFactory.makeGate(pipeReal.pipe,material,logic,direction);
      pipeReal.scheduleRenderUpdate();
    }
    this.realGate=pipeReal.pipe.gates[direction.ordinal()];
  }
}

Fixed version (ground truth):
@Override public void onAttachedPipe(IPipeContainer pipe,ForgeDirection direction){
  TileGenericPipe pipeReal=(TileGenericPipe)pipe;
  if (!pipeReal.getWorld().isRemote) {
    if (instantiatedGate != null) {
      pipeReal.pipe.gates[direction.ordinal()]=instantiatedGate;
    }
 else {
      Gate gate=pipeReal.pipe.gates[direction.ordinal()];
      if (gate == null || gate.material != material || gate.logic != logic) {
        pipeReal.pipe.gates[direction.ordinal()]=GateFactory.makeGate(pipeReal.pipe,material,logic,direction);
        for (        IGateExpansion expansion : expansions) {
          pipeReal.pipe.gates[direction.ordinal()].addGateExpansion(expansion);
        }
        pipeReal.scheduleRenderUpdate();
      }
    }
    realGate=pipeReal.pipe.gates[direction.ordinal()];
  }
}