nus-yam/ex-repair huggingface dataset:
Program: 156324
Project: 156324
Buggy source:
@Override public void update(){
  if (world.isRemote) {
    amountLast=amount;
    if (amount != target) {
      int delta=target - amount;
      long msgDelta=lastMessage - lastMessageMinus1;
      msgDelta=MathUtil.clamp((int)msgDelta,1,60);
      if (Math.abs(delta) < msgDelta) {
        amount+=delta;
      }
 else {
        amount+=delta / (int)msgDelta;
      }
    }
    return;
  }
  if (lastSentFluid != (tank.getFluid() != null)) {
    if (tracker.markTimeIfDelay(world)) {
      lastSentFluid=tank.getFluid() != null;
      lastSentAmount=tank.getFluidAmount();
      sendNetworkUpdate(NET_RENDER_DATA);
    }
  }
 else   if (lastSentAmount != tank.getFluidAmount()) {
    if (tracker.markTimeIfDelay(world)) {
      lastSentAmount=tank.getFluidAmount();
      world.notifyNeighborsOfStateChange(pos,world.getBlockState(pos).getBlock(),false);
      sendNetworkUpdate(NET_FLUID_DELTA);
    }
  }
}

Fixed version (ground truth):
@Override public void update(){
  smoothedTank.tick(getWorld());
}
Program: 156325
Project: 156325
Buggy source:
@Override public int fill(FluidStack resource,boolean doFill){
  if (resource == null || resource.amount <= 0) {
    return 0;
  }
  int filled=0;
  List<Tank> tanks=getTanks();
  for (  Tank t : tanks) {
    FluidStack current=t.getFluid();
    if (current != null && !current.isFluidEqual(resource)) {
      return 0;
    }
  }
  for (  Tank t : tanks) {
    int tankFilled=t.fill(resource,doFill);
    if (tankFilled > 0) {
      resource.amount-=tankFilled;
      filled+=tankFilled;
      if (resource.amount == 0) {
        break;
      }
    }
  }
  return filled;
}

Fixed version (ground truth):
@Override public int fill(FluidStack resource,boolean doFill){
  if (resource == null || resource.amount <= 0) {
    return 0;
  }
  int filled=0;
  List<TileTank> tanks=getTanks();
  for (  TileTank t : tanks) {
    FluidStack current=t.tank.getFluid();
    if (current != null && !current.isFluidEqual(resource)) {
      return 0;
    }
  }
  for (  TileTank t : tanks) {
    int tankFilled=t.tank.fill(resource,doFill);
    if (tankFilled > 0) {
      if (isPlayerInteracting) {
        t.sendNetworkUpdate(NET_RENDER_DATA);
      }
      resource.amount-=tankFilled;
      filled+=tankFilled;
      if (resource.amount == 0) {
        break;
      }
    }
  }
  return filled;
}
Program: 156326
Project: 156326
Buggy source:
@Override public FluidStack drain(IFluidFilter filter,int maxDrain,boolean doDrain){
  if (maxDrain <= 0) {
    return null;
  }
  List<Tank> tanks=getTanks();
  Collections.reverse(tanks);
  FluidStack total=null;
  for (  Tank t : tanks) {
    int realMax=maxDrain - (total == null ? 0 : total.amount);
    if (realMax <= 0) {
      break;
    }
    FluidStack drained=t.drain(filter,realMax,doDrain);
    if (drained == null)     continue;
    if (total == null) {
      total=drained.copy();
      total.amount=0;
    }
    total.amount+=drained.amount;
  }
  return total;
}

Fixed version (ground truth):
@Override public FluidStack drain(IFluidFilter filter,int maxDrain,boolean doDrain){
  if (maxDrain <= 0) {
    return null;
  }
  List<TileTank> tanks=getTanks();
  Collections.reverse(tanks);
  FluidStack total=null;
  for (  TileTank t : tanks) {
    int realMax=maxDrain - (total == null ? 0 : total.amount);
    if (realMax <= 0) {
      break;
    }
    FluidStack drained=t.tank.drain(filter,realMax,doDrain);
    if (drained == null)     continue;
    if (isPlayerInteracting) {
      t.sendNetworkUpdate(NET_RENDER_DATA);
    }
    if (total == null) {
      total=drained.copy();
      total.amount=0;
    }
    total.amount+=drained.amount;
  }
  return total;
}
Program: 156327
Project: 156327
Buggy source:
@Override public void readPayload(int id,PacketBufferBC buffer,Side side,MessageContext ctx) throws IOException {
  super.readPayload(id,buffer,side,ctx);
  if (side == Side.CLIENT) {
    if (id == NET_RENDER_DATA) {
      tank.readFromBuffer(buffer);
      target=tank.getClientAmount();
      lastMessageMinus1=lastMessage=world.getTotalWorldTime();
    }
 else     if (id == NET_FLUID_DELTA) {
      target=buffer.readInt();
      lastMessageMinus1=lastMessage;
      lastMessage=world.getTotalWorldTime();
    }
  }
}

Fixed version (ground truth):
@Override public void readPayload(int id,PacketBufferBC buffer,Side side,MessageContext ctx) throws IOException {
  super.readPayload(id,buffer,side,ctx);
  if (side == Side.CLIENT) {
    if (id == NET_RENDER_DATA) {
      readPayload(NET_FLUID_DELTA,buffer,side,ctx);
      smoothedTank.resetSmoothing(getWorld());
    }
 else     if (id == NET_FLUID_DELTA) {
      smoothedTank.handleMessage(getWorld(),buffer);
    }
  }
}
Program: 156328
Project: 156328
Buggy source:
@Override public IFluidTankProperties[] getTankProperties(){
  List<Tank> tanks=getTanks();
  Tank bottom=tanks.get(0);
  FluidStack total=bottom.getFluid();
  int capacity=0;
  if (total == null) {
    for (    Tank t : tanks) {
      capacity+=t.getCapacity();
    }
  }
 else {
    total=total.copy();
    total.amount=0;
    for (    Tank t : tanks) {
      FluidStack other=t.getFluid();
      if (other != null) {
        total.amount+=other.amount;
      }
      capacity+=t.getCapacity();
    }
  }
  return new IFluidTankProperties[]{new FluidTankProperties(total,capacity)};
}

Fixed version (ground truth):
@Override public IFluidTankProperties[] getTankProperties(){
  List<TileTank> tanks=getTanks();
  TileTank bottom=tanks.get(0);
  FluidStack total=bottom.tank.getFluid();
  int capacity=0;
  if (total == null) {
    for (    TileTank t : tanks) {
      capacity+=t.tank.getCapacity();
    }
  }
 else {
    total=total.copy();
    total.amount=0;
    for (    TileTank t : tanks) {
      FluidStack other=t.tank.getFluid();
      if (other != null) {
        total.amount+=other.amount;
      }
      capacity+=t.tank.getCapacity();
    }
  }
  return new IFluidTankProperties[]{new FluidTankProperties(total,capacity)};
}
Program: 156329
Project: 156329
Buggy source:
@Override public void writePayload(int id,PacketBufferBC buffer,Side side){
  super.writePayload(id,buffer,side);
  if (side == Side.SERVER) {
    if (id == NET_RENDER_DATA) {
      tank.writeToBuffer(buffer);
    }
 else     if (id == NET_FLUID_DELTA) {
      buffer.writeInt(tank.getFluidAmount());
    }
  }
}

Fixed version (ground truth):
@Override public void writePayload(int id,PacketBufferBC buffer,Side side){
  super.writePayload(id,buffer,side);
  if (side == Side.SERVER) {
    if (id == NET_RENDER_DATA) {
      writePayload(NET_FLUID_DELTA,buffer,side);
    }
 else     if (id == NET_FLUID_DELTA) {
      smoothedTank.writeInit(buffer);
    }
  }
}
Program: 156330
Project: 156330
Buggy source:
@Override @SideOnly(Side.CLIENT) public void getDebugInfo(List<String> left,List<String> right,EnumFacing side){
  left.add("String_Node_Str" + tank.getDebugString());
  if (world.isRemote) {
    left.add("String_Node_Str" + amount + "String_Node_Str"+ target);
    left.add("String_Node_Str" + lastMessage + "String_Node_Str"+ lastMessageMinus1+ "String_Node_Str"+ (lastMessage - lastMessageMinus1));
  }
 else {
    left.add("String_Node_Str" + tank.getFluidAmount() + "String_Node_Str"+ ((tank.getFluid() != null) ? "String_Node_Str" : "String_Node_Str"));
    left.add("String_Node_Str" + lastSentAmount + "String_Node_Str"+ (lastSentFluid ? "String_Node_Str" : "String_Node_Str"));
  }
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public void getDebugInfo(List<String> left,List<String> right,EnumFacing side){
  left.add("String_Node_Str" + tank.getDebugString());
  smoothedTank.getDebugInfo(left,right,side);
}
Program: 156331
Project: 156331
Buggy source:
private List<Tank> getTanks(){
  List<Tank> tanks=new ArrayList<>();
  BlockPos currentPos=pos;
  while (true) {
    Tank tankUp=getTank(currentPos);
    if (tankUp != null) {
      tanks.add(tankUp);
    }
 else {
      break;
    }
    currentPos=currentPos.up();
  }
  currentPos=pos.down();
  while (true) {
    Tank tankBelow=getTank(currentPos);
    if (tankBelow != null) {
      tanks.add(0,tankBelow);
    }
 else {
      break;
    }
    currentPos=currentPos.down();
  }
  return tanks;
}

Fixed version (ground truth):
private List<TileTank> getTanks(){
  List<TileTank> tanks=new ArrayList<>();
  BlockPos currentPos=pos;
  while (true) {
    TileTank tankUp=getTank(currentPos);
    if (tankUp != null) {
      tanks.add(tankUp);
    }
 else {
      break;
    }
    currentPos=currentPos.up();
  }
  currentPos=pos.down();
  while (true) {
    TileTank tankBelow=getTank(currentPos);
    if (tankBelow != null) {
      tanks.add(0,tankBelow);
    }
 else {
      break;
    }
    currentPos=currentPos.down();
  }
  return tanks;
}
Program: 156332
Project: 156332
Buggy source:
public static Fluid getFluid(Block block){
  return FluidRegistry.lookupFluidForBlock(block);
}

Fixed version (ground truth):
public static Fluid getFluid(Block block){
  if (block instanceof IFluidBlock) {
    return FluidRegistry.getFluid(((IFluidBlock)block).getFluid().getName());
  }
  return FluidRegistry.lookupFluidForBlock(block);
}
Program: 156333
Project: 156333
Buggy source:
public TileFiller(){
  caps.addProvider(new MjCapabilityHelper(new MjBatteryReciver(battery)));
  pattern=BCCoreStatements.PATTERN_NONE;
  params=new IStatementParameter[0];
}

Fixed version (ground truth):
public TileFiller(){
  caps.addProvider(new MjCapabilityHelper(new MjBatteryReciver(battery)));
  pattern=BCCoreStatements.PATTERN_NONE;
  params=new IStatementParameter[0];
  StackInsertionChecker checker=(slot,stack) -> Filling.INSTANCE.getItemBlocks().contains(stack.getItem());
  StackInsertionFunction insertor=StackInsertionFunction.getDefaultInserter();
  ItemHandlerSimple handler=new ItemHandlerSimple(27,checker,insertor,this::onSlotChange);
  invResources=itemManager.addInvHandler("String_Node_Str",handler,EnumAccess.BOTH,EnumPipePart.VALUES);
}
Program: 156334
Project: 156334
Buggy source:
@Override public void setPattern(IFillerPattern pattern,IStatementParameter[] params){
  this.pattern=pattern;
  this.params=params;
  template=pattern.createTemplate(box,params);
}

Fixed version (ground truth):
@Override public void setPattern(IFillerPattern pattern,IStatementParameter[] params){
  this.pattern=pattern;
  this.params=params;
  template=pattern.createTemplate(this,params);
}
Program: 156335
Project: 156335
Buggy source:
@Override @SideOnly(Side.CLIENT) public TextureAtlasSprite getGuiSprite(){
  EnumFacing dir=getDirection();
  if (dir == null) {
    return null;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public ISprite getGuiSprite(){
  EnumFacing dir=getDirection();
  if (dir == null) {
    return null;
  }
 else {
    return null;
  }
}
Program: 156336
Project: 156336
Buggy source:
@Override public TextureAtlasSprite getGuiSprite(){
  return null;
}

Fixed version (ground truth):
@Override public ISprite getGuiSprite(){
  return null;
}
Program: 156337
Project: 156337
Buggy source:
/** 
 * Gets a stack insertion function that will insert up to full stacks into a given slot. This is just  {@link #getInsertionFunction(int)} with an argument of 64. 
 */
public static StackInsertionFunction getDefaultInserter(){
  return getInsertionFunction(64);
}

Fixed version (ground truth):
/** 
 * Gets a stack insertion function that will insert up to full stacks into a given slot. This is just  {@link #getInsertionFunction(int)} with an argument of 64. 
 */
public static StackInsertionFunction getDefaultInserter(){
  return getInsertionFunction(Integer.MAX_VALUE);
}
Program: 156338
Project: 156338
Buggy source:
@Override @SideOnly(Side.CLIENT) public TextureAtlasSprite getGuiSprite(){
  if (colour == null) {
    return null;
  }
  return BCTransportSprites.getPipeSignal(active,colour).getSprite();
}

Fixed version (ground truth):
@Override @SideOnly(Side.CLIENT) public ISprite getGuiSprite(){
  if (colour == null) {
    return null;
  }
  return BCTransportSprites.getPipeSignal(active,colour);
}
Program: 156339
Project: 156339
Buggy source:
@Mod.EventHandler public static void preInit(FMLPreInitializationEvent event){
  File cfgFolder=event.getModConfigurationDirectory();
  cfgFolder=new File(cfgFolder,"String_Node_Str");
  BCCoreConfig.preInit(cfgFolder);
  BCCoreProxy.getProxy().fmlPreInit();
  CreativeTabBC tab=CreativeTabManager.createTab("String_Node_Str");
  BCCoreItems.preInit();
  BCCoreBlocks.preInit();
  BCCoreStatements.preInit();
  tab.setItem(BCCoreItems.wrench);
  NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE,BCCoreProxy.getProxy());
  MinecraftForge.EVENT_BUS.register(ListTooltipHandler.INSTANCE);
  OreDictionary.registerOre("String_Node_Str",Blocks.CRAFTING_TABLE);
  MinecraftForge.EVENT_BUS.register(BCCoreEventDist.INSTANCE);
  BCMessageHandler.addMessageType(MessageVolumeBoxes.class,MessageVolumeBoxes.HANDLER,Side.CLIENT);
}

Fixed version (ground truth):
@Mod.EventHandler public static void preInit(FMLPreInitializationEvent event){
  File cfgFolder=event.getModConfigurationDirectory();
  cfgFolder=new File(cfgFolder,"String_Node_Str");
  BCCoreConfig.preInit(cfgFolder);
  CreativeTabBC tab=CreativeTabManager.createTab("String_Node_Str");
  BCCoreItems.preInit();
  BCCoreBlocks.preInit();
  BCCoreStatements.preInit();
  BCCoreProxy.getProxy().fmlPreInit();
  tab.setItem(BCCoreItems.wrench);
  NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE,BCCoreProxy.getProxy());
  MinecraftForge.EVENT_BUS.register(ListTooltipHandler.INSTANCE);
  OreDictionary.registerOre("String_Node_Str",Blocks.CRAFTING_TABLE);
  MinecraftForge.EVENT_BUS.register(BCCoreEventDist.INSTANCE);
  BCMessageHandler.addMessageType(MessageVolumeBoxes.class,MessageVolumeBoxes.HANDLER,Side.CLIENT);
}
Program: 156340
Project: 156340
Buggy source:
public static void fmlPreInit(){
  MinecraftForge.EVENT_BUS.register(BCCoreModels.class);
}

Fixed version (ground truth):
public static void fmlPreInit(){
  MinecraftForge.EVENT_BUS.register(BCCoreModels.class);
  ModelLoader.setCustomStateMapper(BCCoreBlocks.engine,b -> ImmutableMap.of());
}
Program: 156341
Project: 156341
Buggy source:
@Override public void fmlInit(){
  ClientRegistry.bindTileEntitySpecialRenderer(TileMarkerVolume.class,RenderMarkerVolume.INSTANCE);
  ClientRegistry.bindTileEntitySpecialRenderer(TileEngineRedstone_BC8.class,RenderEngineWood.INSTANCE);
  ClientRegistry.bindTileEntitySpecialRenderer(TileEngineCreative.class,RenderEngineCreative.INSTANCE);
  MinecraftForge.EVENT_BUS.register(RenderTickListener.class);
}

Fixed version (ground truth):
@Override public void fmlInit(){
  BCCoreModels.fmlInit();
  MinecraftForge.EVENT_BUS.register(RenderTickListener.class);
}
Program: 156342
Project: 156342
Buggy source:
@Override protected BlockStateContainer createBlockState(){
  return new BlockStateContainer(this,getEngineProperty(),BuildCraftProperties.ENERGY_STAGE,BuildCraftProperties.BLOCK_FACING_6);
}

Fixed version (ground truth):
@Override protected BlockStateContainer createBlockState(){
  return new BlockStateContainer(this,getEngineProperty());
}
Program: 156343
Project: 156343
Buggy source:
public TileBuilder(){
  for (int i=1; i <= 4; i++) {
    tankManager.add(new Tank("String_Node_Str" + i,Fluid.BUCKET_VOLUME * 8,this));
  }
  caps.addProvider(mjCapHelper);
  caps.addCapability(CapUtil.CAP_FLUIDS,tankManager,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileBuilder(){
  for (int i=1; i <= 4; i++) {
    tankManager.add(new Tank("String_Node_Str" + i,Fluid.BUCKET_VOLUME * 8,this));
  }
  caps.addProvider(mjCapHelper);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankManager,EnumPipePart.VALUES);
}
Program: 156344
Project: 156344
Buggy source:
public TileQuarry(){
  caps.addProvider(mjCapHelper);
  caps.addCapability(CapUtil.CAP_ITEM_TRANSACTOR,AutomaticProvidingTransactor.INSTANCE,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileQuarry(){
  caps.addProvider(mjCapHelper);
  caps.addCapabilityInstance(CapUtil.CAP_ITEM_TRANSACTOR,AutomaticProvidingTransactor.INSTANCE,EnumPipePart.VALUES);
}
Program: 156345
Project: 156345
Buggy source:
public TileMarkerVolume(){
  caps.addCapability(TilesAPI.CAP_TILE_AREA_PROVIDER,this,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileMarkerVolume(){
  caps.addCapabilityInstance(TilesAPI.CAP_TILE_AREA_PROVIDER,this,EnumPipePart.VALUES);
}
Program: 156346
Project: 156346
Buggy source:
public TileAutoWorkbenchBase(int slots){
  invBlueprint=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.NONE);
  invMaterials=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.INSERT,EnumPipePart.VALUES);
  invResult=itemManager.addInvHandler("String_Node_Str",1,EnumAccess.EXTRACT,EnumPipePart.VALUES);
  invOverflow=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.EXTRACT,EnumPipePart.VALUES);
  itemStackCache=new HashMap<>();
  caps.addCapability(TilesAPI.CAP_HAS_WORK,this::hasWork,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileAutoWorkbenchBase(int slots){
  invBlueprint=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.NONE);
  invMaterials=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.INSERT,EnumPipePart.VALUES);
  invResult=itemManager.addInvHandler("String_Node_Str",1,EnumAccess.EXTRACT,EnumPipePart.VALUES);
  invOverflow=itemManager.addInvHandler("String_Node_Str",slots,EnumAccess.EXTRACT,EnumPipePart.VALUES);
  itemStackCache=new HashMap<>();
  caps.addCapabilityInstance(TilesAPI.CAP_HAS_WORK,this::hasWork,EnumPipePart.VALUES);
}
Program: 156347
Project: 156347
Buggy source:
public TileAutoWorkbenchFluids(){
  super(4);
  caps.addCapability(CapUtil.CAP_FLUIDS,tankManager,EnumPipePart.CENTER);
  caps.addCapability(CapUtil.CAP_FLUIDS,tank1,EnumPipePart.DOWN,EnumPipePart.NORTH,EnumPipePart.WEST);
  caps.addCapability(CapUtil.CAP_FLUIDS,tank2,EnumPipePart.UP,EnumPipePart.SOUTH,EnumPipePart.EAST);
}

Fixed version (ground truth):
public TileAutoWorkbenchFluids(){
  super(4);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankManager,EnumPipePart.CENTER);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tank1,EnumPipePart.DOWN,EnumPipePart.NORTH,EnumPipePart.WEST);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tank2,EnumPipePart.UP,EnumPipePart.SOUTH,EnumPipePart.EAST);
}
Program: 156348
Project: 156348
Buggy source:
public TileDistiller_BC8(){
  tankIn.setCanDrain(false);
  tankOutGas.setCanFill(false);
  tankOutLiquid.setCanFill(false);
  caps.addCapability(CapUtil.CAP_FLUIDS,tankIn,EnumPipePart.HORIZONTALS);
  caps.addCapability(CapUtil.CAP_FLUIDS,tankOutGas,EnumPipePart.UP);
  caps.addCapability(CapUtil.CAP_FLUIDS,tankOutLiquid,EnumPipePart.DOWN);
  caps.addProvider(mjCapHelper);
}

Fixed version (ground truth):
public TileDistiller_BC8(){
  tankIn.setCanDrain(false);
  tankOutGas.setCanFill(false);
  tankOutLiquid.setCanFill(false);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankIn,EnumPipePart.HORIZONTALS);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankOutGas,EnumPipePart.UP);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankOutLiquid,EnumPipePart.DOWN);
  caps.addProvider(mjCapHelper);
}
Program: 156349
Project: 156349
Buggy source:
public TileHeatExchangeEnd(){
  caps.addCapability(CapUtil.CAP_FLUIDS,tankHeatableOut,EnumPipePart.UP);
  caps.addCapability(CapUtil.CAP_FLUIDS,this::getTankForSide,EnumPipePart.HORIZONTALS);
}

Fixed version (ground truth):
public TileHeatExchangeEnd(){
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankHeatableOut,EnumPipePart.UP);
  caps.addCapability(CapUtil.CAP_FLUIDS,this::getTankForSide,EnumPipePart.HORIZONTALS);
}
Program: 156350
Project: 156350
Buggy source:
public TileHeatExchangeStart(){
  caps.addCapability(CapUtil.CAP_FLUIDS,tankHeatableIn,EnumPipePart.DOWN);
  caps.addCapability(CapUtil.CAP_FLUIDS,this::getTankForSide,EnumPipePart.HORIZONTALS);
}

Fixed version (ground truth):
public TileHeatExchangeStart(){
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tankHeatableIn,EnumPipePart.DOWN);
  caps.addCapability(CapUtil.CAP_FLUIDS,this::getTankForSide,EnumPipePart.HORIZONTALS);
}
Program: 156351
Project: 156351
Buggy source:
public TileMiner(){
  caps.addProvider(mjCapHelper);
  caps.addCapability(TilesAPI.CAP_HAS_WORK,() -> !isComplete,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileMiner(){
  caps.addProvider(mjCapHelper);
  caps.addCapabilityInstance(TilesAPI.CAP_HAS_WORK,() -> !isComplete,EnumPipePart.VALUES);
}
Program: 156352
Project: 156352
Buggy source:
public TilePump(){
  tank.setCanFill(false);
  caps.addCapability(CapUtil.CAP_FLUIDS,tank,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TilePump(){
  tank.setCanFill(false);
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tank,EnumPipePart.VALUES);
}
Program: 156353
Project: 156353
Buggy source:
public TileTank(){
  caps.addCapability(CapUtil.CAP_FLUIDS,this,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileTank(){
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,this,EnumPipePart.VALUES);
}
Program: 156354
Project: 156354
Buggy source:
public TileLaserTableBase(){
  caps.addCapability(TilesAPI.CAP_HAS_WORK,this,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileLaserTableBase(){
  caps.addCapabilityInstance(TilesAPI.CAP_HAS_WORK,this,EnumPipePart.VALUES);
}
Program: 156355
Project: 156355
Buggy source:
public TilePipeHolder(){
  for (  EnumFacing side : EnumFacing.VALUES) {
    pluggables.put(side,new PluggableHolder(this,side));
  }
  caps.addCapability(PipeApi.CAP_PIPE_HOLDER,this,EnumPipePart.VALUES);
  caps.addCapability(PipeApi.CAP_PIPE,this::getPipe,EnumPipePart.VALUES);
  caps.addCapability(PipeApi.CAP_PLUG,this::getPluggable,EnumPipePart.FACES);
}

Fixed version (ground truth):
public TilePipeHolder(){
  for (  EnumFacing side : EnumFacing.VALUES) {
    pluggables.put(side,new PluggableHolder(this,side));
  }
  caps.addCapabilityInstance(PipeApi.CAP_PIPE_HOLDER,this,EnumPipePart.VALUES);
  caps.addCapability(PipeApi.CAP_PIPE,this::getPipe,EnumPipePart.VALUES);
  caps.addCapability(PipeApi.CAP_PLUG,this::getPluggable,EnumPipePart.FACES);
}
Program: 156356
Project: 156356
Buggy source:
public TileFloodGate(){
  caps.addCapability(CapUtil.CAP_FLUIDS,tank,EnumPipePart.VALUES);
}

Fixed version (ground truth):
public TileFloodGate(){
  caps.addCapabilityInstance(CapUtil.CAP_FLUIDS,tank,EnumPipePart.VALUES);
}
Program: 156358
Project: 156358
Buggy source:
@Override public void initGui(){
  super.initGui();
  buttonList.add(new GuiButtonSmall(this,0,rootElement.getX() + 7,rootElement.getY() + 38,100,"String_Node_Str").setToolTip(ToolTip.createLocalized("String_Node_Str")).setBehaviour(IButtonBehaviour.TOGGLE).setActive(container.inverted).registerListener((button,buttonId) -> {
    container.inverted=button.isButtonActive();
    container.sendDataToServer();
  }
));
}

Fixed version (ground truth):
@Override public void initGui(){
  super.initGui();
  buttonList.add(new GuiButtonSmall(this,0,rootElement.getX() + 7,rootElement.getY() + 38,100,"String_Node_Str").setToolTip(ToolTip.createLocalized("String_Node_Str")).setBehaviour(IButtonBehaviour.TOGGLE).setActive(container.inverted).registerListener((button,buttonId,buttonKey) -> {
    container.inverted=button.isButtonActive();
    container.sendDataToServer();
  }
));
}
Program: 156359
Project: 156359
Buggy source:
/** 
 * @return True if this task has been completed, or cancelled. 
 */
public final boolean addPower(long microJoules){
  power+=microJoules;
  if (power >= getTarget()) {
    if (!finish()) {
      battery.addPower(Math.min(power,battery.getCapacity() - battery.getStored()));
    }
    return true;
  }
 else {
    return onReceivePower();
  }
}

Fixed version (ground truth):
/** 
 * @return True if this task has been completed, or cancelled. 
 */
public final boolean addPower(long microJoules){
  power+=microJoules;
  if (power >= getTarget()) {
    if (!finish()) {
      battery.addPower(Math.min(power,battery.getCapacity() - battery.getStored()),false);
    }
    return true;
  }
 else {
    return onReceivePower();
  }
}
Program: 156360
Project: 156360
Buggy source:
@Override public void update(){
  if (world.isRemote) {
    tubeLengthLast=tubeLengthCurrent;
    if (Math.abs(tubeLengthWanted - tubeLengthCurrent) <= 0.1) {
      tubeLengthCurrent=tubeLengthWanted;
    }
 else {
      tubeLengthCurrent=tubeLengthCurrent + Math.min(Math.abs((tubeLengthWanted - tubeLengthCurrent) / 10D),0.1) * (tubeLengthWanted > tubeLengthCurrent ? 1 : -1);
    }
    return;
  }
  if (!battery.isFull()) {
    battery.addPower(MjAPI.MJ);
  }
  battery.tick(getWorld(),getPos());
  if (true) {
    sendNetworkUpdate(NET_LED_STATUS);
  }
  initCurrentPos();
  mine();
}

Fixed version (ground truth):
@Override public void update(){
  if (world.isRemote) {
    tubeLengthLast=tubeLengthCurrent;
    if (Math.abs(tubeLengthWanted - tubeLengthCurrent) <= 0.1) {
      tubeLengthCurrent=tubeLengthWanted;
    }
 else {
      tubeLengthCurrent=tubeLengthCurrent + Math.min(Math.abs((tubeLengthWanted - tubeLengthCurrent) / 10D),0.1) * (tubeLengthWanted > tubeLengthCurrent ? 1 : -1);
    }
    return;
  }
  if (!battery.isFull()) {
    battery.addPower(MjAPI.MJ,false);
  }
  battery.tick(getWorld(),getPos());
  if (true) {
    sendNetworkUpdate(NET_LED_STATUS);
  }
  initCurrentPos();
  mine();
}
Program: 156361
Project: 156361
Buggy source:
@Override public long receivePower(long microJoules,boolean simulate){
  if (simulate) {
    if (battery.isFull()) {
      return microJoules;
    }
 else {
      return 0;
    }
  }
  return battery.addPowerChecking(microJoules);
}

Fixed version (ground truth):
@Override public long receivePower(long microJoules,boolean simulate){
  return battery.addPowerChecking(microJoules,simulate);
}
Program: 156362
Project: 156362
Buggy source:
@Override public void reconfigure(){
  PipeEventPower.Configure configure=new PipeEventPower.Configure(pipe.getHolder(),this);
  configure.setMaxPower(maxPower);
  configure.setPowerLoss(powerLoss);
  configure.setPowerResistance(powerResistance);
  configure.setReceiver(isReceiver);
  pipe.getHolder().fireEvent(configure);
  maxPower=configure.getMaxPower();
  if (maxPower <= 0) {
    maxPower=DEFAULT_MAX_POWER;
  }
  powerLoss=MathUtil.clamp(configure.getPowerLoss(),-1,maxPower);
  powerResistance=MathUtil.clamp(configure.getPowerResistance(),-1,MjAPI.MJ);
  if (powerLoss < 0) {
    if (powerResistance < 0) {
      powerResistance=MjAPI.MJ / 100;
    }
    powerLoss=maxPower * powerResistance / MjAPI.MJ;
  }
 else   if (powerResistance < 0) {
    powerResistance=powerLoss * MjAPI.MJ / maxPower;
  }
  isReceiver=configure.isReceiver();
}

Fixed version (ground truth):
@Override public void reconfigure(){
  PipeEventPower.Configure configure=new PipeEventPower.Configure(pipe.getHolder(),this);
  configure.setReceiver(isReceiver);
  configure.setMaxPower(maxPower);
  configure.setPowerLoss(powerLoss);
  configure.setPowerResistance(powerResistance);
  pipe.getHolder().fireEvent(configure);
  isReceiver=configure.isReceiver();
  maxPower=configure.getMaxPower();
  if (maxPower <= 0) {
    maxPower=DEFAULT_MAX_POWER;
  }
  powerLoss=MathUtil.clamp(configure.getPowerLoss(),-1,maxPower);
  powerResistance=MathUtil.clamp(configure.getPowerResistance(),-1,MjAPI.MJ);
  if (powerLoss < 0) {
    if (powerResistance < 0) {
      powerResistance=MjAPI.MJ / 100;
    }
    powerLoss=maxPower * powerResistance / MjAPI.MJ;
  }
 else   if (powerResistance < 0) {
    powerResistance=powerLoss * MjAPI.MJ / maxPower;
  }
}
Program: 156363
Project: 156363
Buggy source:
@Override public IMessage handleWidgetDataServer(MessageContext ctx,PacketBufferBC buffer) throws IOException {
  EnumDyeColor colour=MessageUtil.readEnumOrNull(buffer,EnumDyeColor.class);
  System.out.println("String_Node_Str" + colour + "String_Node_Str"+ index);
  if (colour == null) {
    container.behaviour.slotColours.remove(index);
  }
 else {
    container.behaviour.slotColours.put(index,colour);
  }
  container.behaviour.pipe.getHolder().scheduleNetworkGuiUpdate(PipeMessageReceiver.BEHAVIOUR);
  return null;
}

Fixed version (ground truth):
@Override public IMessage handleWidgetDataServer(MessageContext ctx,PacketBufferBC buffer) throws IOException {
  EnumDyeColor colour=MessageUtil.readEnumOrNull(buffer,EnumDyeColor.class);
  if (colour == null) {
    container.behaviour.slotColours.remove(index);
  }
 else {
    container.behaviour.slotColours.put(index,colour);
  }
  container.behaviour.pipe.getHolder().scheduleNetworkGuiUpdate(PipeMessageReceiver.BEHAVIOUR);
  return null;
}
Program: 156364
Project: 156364
Buggy source:
@Override protected int extractItems(IFlowItems flow,EnumFacing dir,int count){
  if (currentSlot == null)   return 0;
  EnumDyeColor colour=slotColours.get(currentSlot);
  System.out.println("String_Node_Str" + currentSlot + "String_Node_Str"+ colour);
  return flow.tryExtractItems(count,dir,colour,filter);
}

Fixed version (ground truth):
@Override protected int extractItems(IFlowItems flow,EnumFacing dir,int count){
  if (currentSlot == null)   return 0;
  return flow.tryExtractItems(count,dir,slotColours.get(currentSlot),filter);
}
Program: 156365
Project: 156365
Buggy source:
@PipeEventHandler public void sideCheck(PipeEventItem.SideCheck event){
  if (isFilter) {
    if (event.colour == colour) {
      event.increasePriority(side);
    }
 else     if (event.colour != null) {
      event.disallow(side);
    }
 else {
      event.decreasePriority(side);
    }
  }
}

Fixed version (ground truth):
@PipeEventHandler public void sideCheck(PipeEventItem.SideCheck event){
  sideCheckAnyPos(event,side);
}
Program: 156366
Project: 156366
Buggy source:
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  if (nbt.hasKey("String_Node_Str")) {
    try {
      pipe=new Pipe(this,nbt.getCompoundTag("String_Node_Str"));
      eventBus.registerHandler(pipe.behaviour);
      eventBus.registerHandler(pipe.flow);
    }
 catch (    LoadingException e) {
      e.printStackTrace();
    }
  }
  NBTTagCompound plugs=nbt.getCompoundTag("String_Node_Str");
  for (  EnumFacing face : EnumFacing.VALUES) {
    pluggables.get(face).readFromNbt(plugs.getCompoundTag(face.getName()));
  }
  wireManager.readFromNbt(nbt.getCompoundTag("String_Node_Str"));
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  if (nbt.hasKey("String_Node_Str")) {
    try {
      pipe=new Pipe(this,nbt.getCompoundTag("String_Node_Str"));
      eventBus.registerHandler(pipe.behaviour);
      eventBus.registerHandler(pipe.flow);
      if (pipe.flow instanceof IFlowItems) {
        eventBus.registerHandler(FilterEventHandler.class);
      }
    }
 catch (    LoadingException e) {
      e.printStackTrace();
    }
  }
  NBTTagCompound plugs=nbt.getCompoundTag("String_Node_Str");
  for (  EnumFacing face : EnumFacing.VALUES) {
    pluggables.get(face).readFromNbt(plugs.getCompoundTag(face.getName()));
  }
  wireManager.readFromNbt(nbt.getCompoundTag("String_Node_Str"));
}
Program: 156368
Project: 156368
Buggy source:
@Override public void onPlacedBy(EntityLivingBase placer,ItemStack stack){
  super.onPlacedBy(placer,stack);
  Item item=stack.getItem();
  if (item instanceof IPipeItem) {
    PipeDefinition definition=((IPipeItem)item).getDefiniton();
    this.pipe=new Pipe(this,definition);
    eventBus.registerHandler(pipe.behaviour);
    eventBus.registerHandler(pipe.flow);
    int meta=stack.getMetadata();
    if (meta > 0 && meta <= 16) {
      pipe.setColour(EnumDyeColor.byMetadata(meta - 1));
    }
  }
  scheduleRenderUpdate();
}

Fixed version (ground truth):
@Override public void onPlacedBy(EntityLivingBase placer,ItemStack stack){
  super.onPlacedBy(placer,stack);
  Item item=stack.getItem();
  if (item instanceof IPipeItem) {
    PipeDefinition definition=((IPipeItem)item).getDefiniton();
    this.pipe=new Pipe(this,definition);
    eventBus.registerHandler(pipe.behaviour);
    eventBus.registerHandler(pipe.flow);
    if (pipe.flow instanceof IFlowItems) {
      eventBus.registerHandler(FilterEventHandler.class);
    }
    int meta=stack.getMetadata();
    if (meta > 0 && meta <= 16) {
      pipe.setColour(EnumDyeColor.byMetadata(meta - 1));
    }
  }
  scheduleRenderUpdate();
}
Program: 156370
Project: 156370
Buggy source:
/** 
 * Used by   {@link MessageObjectCacheReply.Handler} to read an object in.
 * @param id
 * @param buffer
 * @throws IOException 
 */
void readObjectClient(int id,PacketBufferBC buffer) throws IOException {
  Link link=clientRetrieve(id);
  link.actual=readObject(buffer);
}

Fixed version (ground truth):
/** 
 * Used by   {@link MessageObjectCacheReply.Handler} to read an object in.
 * @param id
 * @param buffer
 * @throws IOException 
 */
void readObjectClient(int id,PacketBufferBC buffer) throws IOException {
  Link link=clientRetrieve(id);
  link.actual=readObject(buffer);
  if (DEBUG_CPLX) {
    BCLog.logger.info("String_Node_Str" + getNameAndId() + "String_Node_Str"+ id+ "String_Node_Str"+ link.actual);
  }
}
Program: 156371
Project: 156371
Buggy source:
@PipeEventHandler public static void reachCentre(PipeEventItem.ReachCenter reachCenter){
  reachCenter.stack.setCount(0);
}

Fixed version (ground truth):
@PipeEventHandler public static void reachCentre(PipeEventItem.ReachCenter reachCenter){
  reachCenter.getStack().setCount(0);
}
Program: 156373
Project: 156373
Buggy source:
@Override public void onTick(){
  World world=pipe.getHolder().getPipeWorld();
  List<TravellingItem> toTick=items.advance();
  if (world.isRemote) {
    for (    TravellingItem item : toTick) {
      if (item.state == EnumTravelState.CLIENT_RUNNING) {
        if (item.motion != null) {
          runItemInstructions(item);
        }
 else {
          item.state=EnumTravelState.CLIENT_WAITING;
          items.add(2,item);
        }
      }
 else       if (item.state == EnumTravelState.CLIENT_WAITING) {
        if (item.motion != null) {
          runItemInstructions(item);
        }
 else {
        }
      }
 else {
      }
    }
    return;
  }
  for (  TravellingItem item : toTick) {
    if (item.state == EnumTravelState.SERVER_TO_CENTER) {
      onItemReachCenter(item);
    }
 else {
      onItemReachEnd(item);
    }
  }
}

Fixed version (ground truth):
@Override public void onTick(){
  World world=pipe.getHolder().getPipeWorld();
  List<TravellingItem> toTick=items.advance();
  if (world.isRemote) {
    return;
  }
  for (  TravellingItem item : toTick) {
    if (item.toCenter) {
      onItemReachCenter(item);
    }
 else {
      onItemReachEnd(item);
    }
  }
}
Program: 156374
Project: 156374
Buggy source:
private void onItemReachEnd(TravellingItem item){
  EnumFacing to=item.to;
  if (to == null) {
    dropItem(item);
  }
 else {
    PipeEventItem.ReachEnd event=new PipeEventItem.ReachEnd(pipe.getHolder(),this,item.stack,item.from,to,item.colour);
    pipe.getHolder().fireEvent(event);
    item.stack=event.stack;
    item.colour=event.colour;
    ConnectedType type=pipe.getConnectedType(to);
    ItemStack leftOver=item.stack;
    if (type == ConnectedType.PIPE) {
      IPipe oPipe=pipe.getConnectedPipe(to);
      PipeFlow flow=oPipe.getFlow();
      if (flow instanceof IInjectable) {
        IInjectable oItemFlow=(IInjectable)flow;
        leftOver=oItemFlow.injectItem(item.stack,true,to.getOpposite(),item.colour,item.speed);
      }
    }
 else     if (type == ConnectedType.TILE) {
      TileEntity tile=pipe.getConnectedTile(to);
      IItemTransactor trans=ItemTransactorHelper.getTransactor(tile,to.getOpposite());
      leftOver=trans.insert(item.stack,false,false);
    }
    if (!leftOver.isEmpty()) {
      if (item.toTryOrder == null || item.toTryOrder.isEmpty()) {
        dropItem(item,leftOver);
      }
 else {
        if (item.tried == null) {
          item.tried=new ArrayList<>(6);
        }
        item.tried.add(to);
        insertItemImpl(leftOver,item.colour,item.speed,item.to,item.toTryOrder,item.tried);
      }
    }
  }
}

Fixed version (ground truth):
private void onItemReachEnd(TravellingItem item){
  IPipeHolder holder=pipe.getHolder();
  PipeEventItem.ReachEnd reachEnd=new PipeEventItem.ReachEnd(holder,this,item.colour,item.stack,item.side);
  item.colour=reachEnd.colour;
  item.stack=reachEnd.getStack();
  ItemStack excess=item.stack;
  if (excess.isEmpty()) {
    return;
  }
  if (pipe.isConnected(item.side)) {
    ConnectedType type=pipe.getConnectedType(item.side);
switch (type) {
case PIPE:
{
        IPipe oPipe=pipe.getConnectedPipe(item.side);
        if (oPipe == null) {
          break;
        }
        PipeFlow flow=oPipe.getFlow();
        if (flow instanceof IFlowItems) {
          IFlowItems oFlow=(IFlowItems)flow;
          excess=oFlow.injectItem(excess,true,item.side.getOpposite(),item.colour,item.speed);
          if (excess.isEmpty()) {
            return;
          }
        }
        break;
      }
case TILE:
{
      TileEntity tile=pipe.getConnectedTile(item.side);
      IInjectable injectable=ItemTransactorHelper.getInjectable(tile,item.side.getOpposite());
      excess=injectable.injectItem(excess,true,item.side.getOpposite(),item.colour,item.speed);
      if (excess.isEmpty()) {
        return;
      }
      IItemTransactor transactor=ItemTransactorHelper.getTransactor(tile,item.side.getOpposite());
      excess=transactor.insert(excess,false,false);
      if (excess.isEmpty()) {
        return;
      }
      break;
    }
}
}
if (excess.isEmpty()) {
return;
}
item.tried.add(item.side);
item.toCenter=true;
item.stack=excess;
item.genTimings(holder.getPipeWorld().getTotalWorldTime(),getPipeLength(item.side));
items.add(item.timeToDest,item);
sendItemDataToClient(item);
}
Program: 156375
Project: 156375
Buggy source:
/** 
 * Used internally to split up manual insertions from controlled extractions. 
 */
private void insertItemEvents(@Nonnull ItemStack toInsert,EnumDyeColor colour,double speed,EnumFacing from){
  IPipeHolder holder=pipe.getHolder();
  PipeEventItem.BeforeInsert beforeInsert=new PipeEventItem.BeforeInsert(holder,this,colour,from,toInsert);
  holder.fireEvent(beforeInsert);
  colour=beforeInsert.colour;
  PipeEventItem.SideCheck sideCheck=new PipeEventItem.SideCheck(holder,this,colour,from,toInsert);
  sideCheck.disallow(from);
  for (  EnumFacing face : EnumFacing.VALUES) {
    if (face == from) {
      continue;
    }
    if (!pipe.isConnected(face)) {
      sideCheck.disallow(face);
    }
  }
  holder.fireEvent(sideCheck);
  List<EnumSet<EnumFacing>> order=sideCheck.getOrder();
  if (order.isEmpty()) {
    PipeEventItem.TryBounce bounce=new PipeEventItem.TryBounce(holder,this,colour,from,toInsert);
    holder.fireEvent(bounce);
    if (bounce.canBounce) {
      order=ImmutableList.of(EnumSet.of(from));
    }
 else {
      insertItemImpl(toInsert,colour,speed,from,null,null);
      return;
    }
  }
  PipeEventItem.ItemEntry toSplit=new PipeEventItem.ItemEntry(colour,toInsert,from);
  PipeEventItem.Split split=new PipeEventItem.Split(holder,this,order,toSplit);
  holder.fireEvent(split);
  ImmutableList<PipeEventItem.ItemEntry> splitList=ImmutableList.copyOf(split.items);
  PipeEventItem.FindDest findDest=new PipeEventItem.FindDest(holder,this,order,splitList);
  holder.fireEvent(findDest);
  for (  PipeEventItem.ItemEntry item : findDest.items) {
    PipeEventItem.ModifySpeed modifySpeed=new PipeEventItem.ModifySpeed(holder,this,item,speed);
    modifySpeed.modifyTo(0.04,0.01);
    holder.fireEvent(modifySpeed);
    double target=modifySpeed.targetSpeed;
    double maxDelta=modifySpeed.maxSpeedChange;
    double nSpeed=speed;
    if (nSpeed < target) {
      nSpeed+=maxDelta;
      if (nSpeed > target) {
        nSpeed=target;
      }
    }
 else     if (nSpeed > target) {
      nSpeed-=maxDelta;
      if (nSpeed < target) {
        nSpeed=target;
      }
    }
    if (item.to == null) {
      item.to=findDest.generateRandomOrder();
    }
    insertItemImpl(item.stack,item.colour,nSpeed,from,item.to,null);
  }
}

Fixed version (ground truth):
/** 
 * Used internally to split up manual insertions from controlled extractions. 
 */
private void insertItemEvents(@Nonnull ItemStack toInsert,EnumDyeColor colour,double speed,EnumFacing from){
  IPipeHolder holder=pipe.getHolder();
  PipeEventItem.OnInsert onInsert=new PipeEventItem.OnInsert(holder,this,colour,toInsert,from);
  holder.fireEvent(onInsert);
  if (onInsert.getStack().isEmpty()) {
    return;
  }
  World world=pipe.getHolder().getPipeWorld();
  long now=world.getTotalWorldTime();
  TravellingItem item=new TravellingItem(toInsert);
  item.side=from;
  item.toCenter=true;
  item.speed=speed;
  item.colour=onInsert.colour;
  item.stack=onInsert.getStack();
  item.genTimings(now,getPipeLength(from));
  items.add(item.timeToDest,item);
  sendItemDataToClient(item);
}
Program: 156376
Project: 156376
Buggy source:
@Override public void readPayload(int id,PacketBuffer bufIn,Side side) throws IOException {
  PacketBufferBC buffer=PacketBufferBC.asPacketBufferBc(bufIn);
  if (side == Side.CLIENT) {
    if (id == NET_CREATE_ITEM) {
      EnumFacing from=buffer.readEnumValue(EnumFacing.class);
      EnumFacing to=MessageUtil.readEnumOrNull(buffer,EnumFacing.class);
      EnumDyeColor colour=MessageUtil.readEnumOrNull(buffer,EnumDyeColor.class);
      int delay=buffer.readInt();
      int stackId=buffer.readInt();
      int stackSize=buffer.readShort();
      Supplier<ItemStack> link=BuildCraftObjectCaches.retrieveItemStack(stackId);
      TravellingItem item=new TravellingItem(link,stackSize);
      item.from=from;
      item.to=to;
      item.colour=colour;
      long now=pipe.getHolder().getPipeWorld().getTotalWorldTime();
      item.tickStarted=now;
      item.tickFinished=now + delay;
      item.state=EnumTravelState.CLIENT_RUNNING;
      items.add(delay,item);
    }
  }
}

Fixed version (ground truth):
@Override public void readPayload(int id,PacketBuffer bufIn,Side msgSide) throws IOException {
  PacketBufferBC buffer=PacketBufferBC.asPacketBufferBc(bufIn);
  if (msgSide == Side.CLIENT) {
    if (id == NET_CREATE_ITEM) {
      int stackId=buffer.readInt();
      Supplier<ItemStack> link=BuildCraftObjectCaches.retrieveItemStack(stackId);
      int count=buffer.readUnsignedShort();
      TravellingItem item=new TravellingItem(link,count);
      item.toCenter=buffer.readBoolean();
      item.side=buffer.readEnumValue(EnumFacing.class);
      item.colour=MessageUtil.readEnumOrNull(buffer,EnumDyeColor.class);
      item.timeToDest=buffer.readUnsignedShort();
      item.tickStarted=pipe.getHolder().getPipeWorld().getTotalWorldTime() + 1;
      item.tickFinished=item.tickStarted + item.timeToDest;
      items.add(item.timeToDest + 1,item);
    }
  }
}
Program: 156377
Project: 156377
Buggy source:
private void dropItem(TravellingItem item,ItemStack stack){
  if (stack == null) {
    return;
  }
  EnumFacing to=item.from.getOpposite();
  IPipeHolder holder=pipe.getHolder();
  World world=holder.getPipeWorld();
  BlockPos pos=holder.getPipePos();
  double x=pos.getX() + 0.5;
  double y=pos.getY() + 0.5;
  double z=pos.getZ() + 0.5;
  EntityItem ent=new EntityItem(world,x,y,z,stack);
  ent.motionX=to.getFrontOffsetX() * 0.04;
  ent.motionY=to.getFrontOffsetY() * 0.04;
  ent.motionZ=to.getFrontOffsetZ() * 0.04;
  world.spawnEntity(ent);
}

Fixed version (ground truth):
private void dropItem(ItemStack stack,EnumFacing side,EnumFacing motion){
  if (stack == null || stack.isEmpty()) {
    return;
  }
  IPipeHolder holder=pipe.getHolder();
  World world=holder.getPipeWorld();
  BlockPos pos=holder.getPipePos();
  double x=pos.getX() + 0.5;
  double y=pos.getY() + 0.5;
  double z=pos.getZ() + 0.5;
  if (side != null) {
    x+=side.getFrontOffsetX() * 0.4;
    y+=side.getFrontOffsetY() * 0.4;
    z+=side.getFrontOffsetZ() * 0.4;
  }
  EntityItem ent=new EntityItem(world,x,y,z,stack);
  if (motion != null) {
    ent.motionX=motion.getFrontOffsetX() * 0.04;
    ent.motionY=motion.getFrontOffsetY() * 0.04;
    ent.motionZ=motion.getFrontOffsetZ() * 0.04;
  }
  world.spawnEntity(ent);
}
Program: 156378
Project: 156378
Buggy source:
private double getPipeLength(EnumFacing to){
  if (to == null) {
    return 0;
  }
  if (pipe.isConnected(to)) {
    return 0.5;
  }
 else {
    return 0.25;
  }
}

Fixed version (ground truth):
private double getPipeLength(EnumFacing side){
  if (side == null) {
    return 0;
  }
  if (pipe.isConnected(side)) {
    return 0.5;
  }
 else {
    return 0.25;
  }
}
Program: 156379
Project: 156379
Buggy source:
public TravellingItem(NBTTagCompound nbt,long tickNow){
  stack=new ItemStack(nbt.getCompoundTag("String_Node_Str"));
  int c=nbt.getByte("String_Node_Str");
  this.colour=c == 0 ? null : EnumDyeColor.byMetadata(c - 1);
  this.state=nbt.getBoolean("String_Node_Str") ? EnumTravelState.SERVER_TO_CENTER : EnumTravelState.SERVER_TO_EXIT;
  this.speed=nbt.getDouble("String_Node_Str");
  if (speed < 0.001) {
    speed=0.001;
  }
  tickStarted=nbt.getInteger("String_Node_Str") + tickNow;
  tickFinished=nbt.getInteger("String_Node_Str") + tickNow;
  timeToCenter=nbt.getInteger("String_Node_Str");
  timeToExit=nbt.getInteger("String_Node_Str");
  int f=nbt.getInteger("String_Node_Str");
  from=f == 0 ? null : EnumFacing.getFront(f - 1);
  int t=nbt.getInteger("String_Node_Str");
  to=t == 0 ? null : EnumFacing.getFront(t - 1);
  int[] toTry=nbt.getIntArray("String_Node_Str");
  if (toTry.length > 0) {
    toTryOrder=new ArrayList<>(toTry.length);
    for (    int i : toTry) {
      toTryOrder.add(EnumFacing.getFront(i));
    }
  }
  int[] triedArr=nbt.getIntArray("String_Node_Str");
  if (triedArr.length > 0) {
    tried=new ArrayList<>(triedArr.length);
    for (    int i : toTry) {
      tried.add(EnumFacing.getFront(i));
    }
  }
}

Fixed version (ground truth):
public TravellingItem(NBTTagCompound nbt,long tickNow){
  stack=new ItemStack(nbt.getCompoundTag("String_Node_Str"));
  int c=nbt.getByte("String_Node_Str");
  this.colour=c == 0 ? null : EnumDyeColor.byMetadata(c - 1);
  this.toCenter=nbt.getBoolean("String_Node_Str");
  this.speed=nbt.getDouble("String_Node_Str");
  if (speed < 0.001) {
    speed=0.001;
  }
  tickStarted=nbt.getInteger("String_Node_Str") + tickNow;
  tickFinished=nbt.getInteger("String_Node_Str") + tickNow;
  timeToDest=nbt.getInteger("String_Node_Str");
  side=NBTUtilBC.readEnum(nbt.getTag("String_Node_Str"),EnumFacing.class);
  if (side == null || timeToDest == 0) {
    toCenter=true;
  }
  tried=NBTUtilBC.readEnumSet(nbt.getTag("String_Node_Str"),EnumFacing.class);
}
Program: 156380
Project: 156380
Buggy source:
public EnumFacing getRenderDirection(long tick,float partialTicks){
  long diff=tickFinished - tickStarted;
  long afterTick=tick - tickStarted;
  float interp=(afterTick + partialTicks) / diff;
  interp=Math.max(0,Math.min(1,interp));
  if (interp < 0.5) {
    return from.getOpposite();
  }
 else {
    return to;
  }
}

Fixed version (ground truth):
public EnumFacing getRenderDirection(long tick,float partialTicks){
  long diff=tickFinished - tickStarted;
  long afterTick=tick - tickStarted;
  float interp=(afterTick + partialTicks) / diff;
  interp=Math.max(0,Math.min(1,interp));
  if (toCenter) {
    return side == null ? null : side.getOpposite();
  }
 else {
    return side;
  }
}
Program: 156381
Project: 156381
Buggy source:
public boolean isVisible(){
  return state != EnumTravelState.CLIENT_INVALID;
}

Fixed version (ground truth):
public boolean isVisible(){
  return true;
}