nus-yam/ex-repair huggingface dataset:
Program: 165722
Project: 165722
Buggy source:
private void queueWork(){
  GlobalCoordinate gc=new GlobalCoordinate(getPos(),getWorld().provider.getDimension());
  if (endergenicsAdded.contains(gc)) {
    return;
  }
  EndergenicTileEntity endergenicWithInjector=findEndergenicWithInjector();
  if (endergenicWithInjector != null) {
    EndergenicTileEntity loop=endergenicWithInjector;
    while (loop != null) {
      addToQueue(loop,new GlobalCoordinate(loop.getPos(),getWorld().provider.getDimension()));
      loop=loop.getDestinationTE();
      if (loop == endergenicWithInjector) {
        loop=null;
      }
    }
  }
  addToQueue(this,gc);
}

Fixed version (ground truth):
private void queueWork(){
  GlobalCoordinate gc=new GlobalCoordinate(getPos(),getWorld().provider.getDimension());
  if (endergenicsAdded.contains(gc)) {
    return;
  }
  EndergenicTileEntity endergenicWithInjector=findEndergenicWithInjector(getPos());
  if (endergenicWithInjector != null) {
    EndergenicTileEntity loop=endergenicWithInjector;
    while (loop != null) {
      addToQueue(loop,new GlobalCoordinate(loop.getPos(),getWorld().provider.getDimension()));
      loop=loop.getDestinationTE();
      if (loop == endergenicWithInjector) {
        loop=null;
      }
    }
  }
  addToQueue(this,gc);
}
Program: 165724
Project: 165724
Buggy source:
@Override public void update(){
  if (badCounter > 0) {
    badCounter--;
    markDirty();
  }
  if (goodCounter > 0) {
    goodCounter--;
    markDirty();
  }
  if (!getWorld().isRemote) {
    checkStateServer();
  }
}

Fixed version (ground truth):
@Override public void update(){
  if (badCounter > 0) {
    badCounter--;
    markDirty();
  }
  if (goodCounter > 0) {
    goodCounter--;
    markDirty();
  }
  if (!getWorld().isRemote) {
    todoEndergenics.add(this);
  }
}
Program: 165725
Project: 165725
Buggy source:
private EndergenicTileEntity findEndergenicWithInjector(BlockPos start){
  if (hasInjector()) {
    return this;
  }
  if (destination == null) {
    return null;
  }
  if (destination == start) {
    return null;
  }
  TileEntity te=getWorld().getTileEntity(destination);
  if (te instanceof EndergenicTileEntity) {
    return ((EndergenicTileEntity)te).findEndergenicWithInjector(start);
  }
  return null;
}

Fixed version (ground truth):
private EndergenicTileEntity findEndergenicWithInjector(Set<BlockPos> done){
  if (hasInjector()) {
    return this;
  }
  if (destination == null) {
    return null;
  }
  done.add(getPos());
  if (done.contains(destination)) {
    return null;
  }
  TileEntity te=getWorld().getTileEntity(destination);
  if (te instanceof EndergenicTileEntity) {
    return ((EndergenicTileEntity)te).findEndergenicWithInjector(done);
  }
  return null;
}
Program: 165726
Project: 165726
Buggy source:
private void queueWork(){
  GlobalCoordinate gc=new GlobalCoordinate(getPos(),getWorld().provider.getDimension());
  if (endergenicsAdded.contains(gc)) {
    return;
  }
  EndergenicTileEntity endergenicWithInjector=findEndergenicWithInjector(getPos());
  if (endergenicWithInjector != null) {
    EndergenicTileEntity loop=endergenicWithInjector;
    while (loop != null) {
      addToQueue(loop,new GlobalCoordinate(loop.getPos(),getWorld().provider.getDimension()));
      loop=loop.getDestinationTE();
      if (loop == endergenicWithInjector) {
        loop=null;
      }
    }
  }
  addToQueue(this,gc);
}

Fixed version (ground truth):
private void queueWork(){
  GlobalCoordinate gc=new GlobalCoordinate(getPos(),getWorld().provider.getDimension());
  if (endergenicsAdded.contains(gc)) {
    return;
  }
  EndergenicTileEntity endergenicWithInjector=findEndergenicWithInjector(new HashSet<>());
  if (endergenicWithInjector != null) {
    EndergenicTileEntity loop=endergenicWithInjector;
    while (loop != null) {
      addToQueue(loop,new GlobalCoordinate(loop.getPos(),getWorld().provider.getDimension()));
      loop=loop.getDestinationTE();
      if (loop == endergenicWithInjector) {
        loop=null;
      }
    }
  }
  addToQueue(this,gc);
}
Program: 165727
Project: 165727
Buggy source:
@Callback(doc="String_Node_Str") public Object[] getPearls(Context c,Arguments a){
  int ret=0;
  InventoryHelper inventoryHelper=tile.getInventoryHelper();
  for (int i=0; i < inventoryHelper.getCount(); ++i) {
    ItemStack stack=inventoryHelper.getStackInSlot(i);
    if (stack != null && Items.ENDER_PEARL.equals(stack.getItem()) && stack.stackSize > 0) {
      ret+=stack.stackSize;
    }
  }
  return new Object[]{ret};
}

Fixed version (ground truth):
@Callback(doc="String_Node_Str") public Object[] getPearls(Context c,Arguments a){
  int ret=0;
  InventoryHelper inventoryHelper=tile.getInventoryHelper();
  for (int i=0; i < inventoryHelper.getCount(); ++i) {
    ItemStack stack=inventoryHelper.getStackInSlot(i);
    if (ItemStackTools.isValid(stack) && Items.ENDER_PEARL.equals(stack.getItem()) && ItemStackTools.getStackSize(stack) > 0) {
      ret+=ItemStackTools.getStackSize(stack);
    }
  }
  return new Object[]{ret};
}
Program: 165728
Project: 165728
Buggy source:
public ModuleElevatorInfo(ByteBuf buf){
  level=buf.readInt();
  maxLevel=buf.readInt();
  pos=NetworkTools.readPos(buf);
  int s=buf.readByte();
  heights=new ArrayList<>(s);
  for (int i=0; i < s; i++) {
    heights.add((int)buf.readByte());
  }
}

Fixed version (ground truth):
public ModuleElevatorInfo(ByteBuf buf){
  level=buf.readInt();
  maxLevel=buf.readInt();
  pos=NetworkTools.readPos(buf);
  int s=buf.readByte();
  heights=new ArrayList<>(s);
  for (int i=0; i < s; i++) {
    heights.add((int)buf.readShort());
  }
}
Program: 165729
Project: 165729
Buggy source:
@Override public void writeToBuf(ByteBuf buf){
  buf.writeInt(level);
  buf.writeInt(maxLevel);
  NetworkTools.writePos(buf,pos);
  buf.writeByte(heights.size());
  for (  Integer height : heights) {
    buf.writeByte(height);
  }
}

Fixed version (ground truth):
@Override public void writeToBuf(ByteBuf buf){
  buf.writeInt(level);
  buf.writeInt(maxLevel);
  NetworkTools.writePos(buf,pos);
  buf.writeByte(heights.size());
  for (  Integer height : heights) {
    buf.writeShort(height);
  }
}
Program: 165731
Project: 165731
Buggy source:
public static Shape getShape(ItemStack stack){
  NBTTagCompound tagCompound=stack.getTagCompound();
  if (tagCompound == null) {
    return Shape.SHAPE_SOLIDBOX;
  }
  int shape=tagCompound.getInteger("String_Node_Str");
  Shape s=Shape.getShape(shape);
  if (s == null) {
    return Shape.SHAPE_SOLIDBOX;
  }
  return s;
}

Fixed version (ground truth):
public static Shape getShape(ItemStack stack){
  NBTTagCompound tagCompound=stack.getTagCompound();
  if (tagCompound == null) {
    return Shape.SHAPE_SOLIDBOX;
  }
  if (!tagCompound.hasKey("String_Node_Str")) {
    return Shape.SHAPE_SOLIDBOX;
  }
  int shape=tagCompound.getInteger("String_Node_Str");
  Shape s=Shape.getShape(shape);
  if (s == null) {
    return Shape.SHAPE_SOLIDBOX;
  }
  return s;
}
Program: 165732
Project: 165732
Buggy source:
@Override public ItemStack decrStackSize(int index,int amount){
  if (index == ShieldContainer.SLOT_SHAPE && inventoryHelper.getStackInSlot(index) != null && amount > 0) {
    decomposeShield();
  }
  ItemStack stackInSlot=inventoryHelper.getStackInSlot(index);
  if (ItemStackTools.isValid(stackInSlot)) {
    if (ItemStackTools.getStackSize(stackInSlot) <= amount) {
      ItemStack old=ItemStackTools.safeCopy(stackInSlot);
      inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,ItemStackTools.getEmptyStack());
      markDirty();
      return old;
    }
    ItemStack its=stackInSlot.splitStack(amount);
    if (ItemStackTools.isEmpty(stackInSlot)) {
      inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,ItemStackTools.getEmptyStack());
    }
    markDirty();
    return its;
  }
  return null;
}

Fixed version (ground truth):
@Override public ItemStack decrStackSize(int index,int amount){
  if (index == ShieldContainer.SLOT_SHAPE && ItemStackTools.isValid(inventoryHelper.getStackInSlot(index)) && amount > 0) {
    decomposeShield();
  }
  ItemStack stackInSlot=inventoryHelper.getStackInSlot(index);
  if (ItemStackTools.isValid(stackInSlot)) {
    if (ItemStackTools.getStackSize(stackInSlot) <= amount) {
      ItemStack old=ItemStackTools.safeCopy(stackInSlot);
      inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,ItemStackTools.getEmptyStack());
      markDirty();
      return old;
    }
    ItemStack its=stackInSlot.splitStack(amount);
    if (ItemStackTools.isEmpty(stackInSlot)) {
      inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,ItemStackTools.getEmptyStack());
    }
    markDirty();
    return its;
  }
  return ItemStackTools.getEmptyStack();
}
Program: 165733
Project: 165733
Buggy source:
private boolean isShapedShield(){
  return inventoryHelper.getStackInSlot(ShieldContainer.SLOT_SHAPE) != null;
}

Fixed version (ground truth):
private boolean isShapedShield(){
  return ItemStackTools.isValid(inventoryHelper.getStackInSlot(ShieldContainer.SLOT_SHAPE));
}
Program: 165734
Project: 165734
Buggy source:
public void applyDamageToEntity(Entity entity){
  DamageSource source;
  int rf;
  if (DamageTypeMode.DAMAGETYPE_GENERIC.equals(damageMode)) {
    rf=ShieldConfiguration.rfDamage;
    source=DamageSourceTools.getGenericSource();
  }
 else {
    rf=ShieldConfiguration.rfDamagePlayer;
    if (killer == null) {
      killer=FakePlayerFactory.get(DimensionManager.getWorld(0),new GameProfile(new UUID(111,222),"String_Node_Str"));
    }
    FakePlayer fakePlayer=killer;
    ItemStack shards=getStackInSlot(ShieldContainer.SLOT_SHARD);
    if (ItemStackTools.isValid(shards) && ItemStackTools.getStackSize(shards) >= ShieldConfiguration.shardsPerLootingKill) {
      decrStackSize(ShieldContainer.SLOT_SHARD,ShieldConfiguration.shardsPerLootingKill);
      if (lootingSword == null) {
        lootingSword=EnvironmentalSetup.createEnchantedItem(Items.DIAMOND_SWORD,Enchantments.LOOTING,ShieldConfiguration.lootingKillBonus);
      }
      lootingSword.setItemDamage(0);
      fakePlayer.setHeldItem(EnumHand.MAIN_HAND,lootingSword);
    }
 else {
      fakePlayer.setHeldItem(EnumHand.MAIN_HAND,ItemStackTools.getEmptyStack());
    }
    source=DamageSource.causePlayerDamage(fakePlayer);
  }
  rf=(int)(rf * costFactor * (4.0f - getInfusedFactor()) / 4.0f);
  if (getEnergyStored(EnumFacing.DOWN) < rf) {
    return;
  }
  consumeEnergy(rf);
  float damage=ShieldConfiguration.damage;
  damage*=damageFactor;
  damage=damage * (1.0f + getInfusedFactor() / 2.0f);
  entity.attackEntityFrom(source,damage);
}

Fixed version (ground truth):
public void applyDamageToEntity(Entity entity){
  DamageSource source;
  int rf;
  if (DamageTypeMode.DAMAGETYPE_GENERIC.equals(damageMode)) {
    rf=ShieldConfiguration.rfDamage;
    source=DamageSourceTools.getGenericSource();
  }
 else {
    rf=ShieldConfiguration.rfDamagePlayer;
    if (killer == null) {
      killer=FakePlayerFactory.get(DimensionManager.getWorld(0),new GameProfile(new UUID(111,222),"String_Node_Str"));
    }
    FakePlayer fakePlayer=killer;
    ItemStack shards=getStackInSlot(ShieldContainer.SLOT_SHARD);
    if (ItemStackTools.isValid(shards) && ItemStackTools.getStackSize(shards) >= ShieldConfiguration.shardsPerLootingKill) {
      decrStackSize(ShieldContainer.SLOT_SHARD,ShieldConfiguration.shardsPerLootingKill);
      if (ItemStackTools.isEmpty(lootingSword)) {
        lootingSword=EnvironmentalSetup.createEnchantedItem(Items.DIAMOND_SWORD,Enchantments.LOOTING,ShieldConfiguration.lootingKillBonus);
      }
      lootingSword.setItemDamage(0);
      fakePlayer.setHeldItem(EnumHand.MAIN_HAND,lootingSword);
    }
 else {
      fakePlayer.setHeldItem(EnumHand.MAIN_HAND,ItemStackTools.getEmptyStack());
    }
    source=DamageSource.causePlayerDamage(fakePlayer);
  }
  rf=(int)(rf * costFactor * (4.0f - getInfusedFactor()) / 4.0f);
  if (getEnergyStored(EnumFacing.DOWN) < rf) {
    return;
  }
  consumeEnergy(rf);
  float damage=ShieldConfiguration.damage;
  damage*=damageFactor;
  damage=damage * (1.0f + getInfusedFactor() / 2.0f);
  entity.attackEntityFrom(source,damage);
}
Program: 165737
Project: 165737
Buggy source:
private static ItemStack getModule(TileEntity tileEntity){
  if (tileEntity instanceof StorageTerminalTileEntity) {
    StorageTerminalTileEntity terminalTileEntity=(StorageTerminalTileEntity)tileEntity;
    return terminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
  }
  return null;
}

Fixed version (ground truth):
private static ItemStack getModule(TileEntity tileEntity){
  if (tileEntity instanceof StorageTerminalTileEntity) {
    StorageTerminalTileEntity terminalTileEntity=(StorageTerminalTileEntity)tileEntity;
    return terminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
  }
  return ItemStackTools.getEmptyStack();
}
Program: 165738
Project: 165738
Buggy source:
@Override public void fromBytes(ByteBuf buf){
  pos=NetworkTools.readPos(buf);
  viewMode=NetworkTools.readString(buf);
  sortMode=NetworkTools.readString(buf);
  groupMode=buf.readBoolean();
  filter=NetworkTools.readString(buf);
  maxSize=buf.readInt();
  numStacks=buf.readInt();
  int s=buf.readInt();
  items=new ArrayList<>(s);
  for (int i=0; i < s; i++) {
    int slotIdx=buf.readInt();
    if (slotIdx < 0) {
      items.add(Pair.of(-slotIdx - 1,null));
    }
 else {
      ItemStack stack=NetworkTools.readItemStack(buf);
      items.add(Pair.of(slotIdx,stack));
    }
  }
}

Fixed version (ground truth):
@Override public void fromBytes(ByteBuf buf){
  pos=NetworkTools.readPos(buf);
  viewMode=NetworkTools.readString(buf);
  sortMode=NetworkTools.readString(buf);
  groupMode=buf.readBoolean();
  filter=NetworkTools.readString(buf);
  maxSize=buf.readInt();
  numStacks=buf.readInt();
  int s=buf.readInt();
  items=new ArrayList<>(s);
  for (int i=0; i < s; i++) {
    int slotIdx=buf.readInt();
    if (slotIdx < 0) {
      items.add(Pair.of(-slotIdx - 1,ItemStackTools.getEmptyStack()));
    }
 else {
      ItemStack stack=NetworkTools.readItemStack(buf);
      items.add(Pair.of(slotIdx,stack));
    }
  }
}
Program: 165739
Project: 165739
Buggy source:
@SubscribeEvent public void onPlayerInteractEvent(PlayerInteractEvent event){
  if (event instanceof PlayerInteractEvent.LeftClickBlock) {
    checkCreativeClick(event);
  }
  ItemStack heldItem=event.getEntityPlayer().getHeldItem(event.getHand());
  if (heldItem == null || heldItem.getItem() == null) {
    return;
  }
  if (event.getEntityPlayer().isSneaking() && WrenchChecker.isAWrench(heldItem.getItem())) {
    World world=event.getWorld();
    int x=event.getPos().getX();
    int y=event.getPos().getY();
    int z=event.getPos().getZ();
    Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(world.provider.getDimension(),x,y,z);
    if (BlockProtectors.checkHarvestProtection(x,y,z,world,protectors)) {
      event.setCanceled(true);
    }
  }
}

Fixed version (ground truth):
@SubscribeEvent public void onPlayerInteractEvent(PlayerInteractEvent event){
  if (event instanceof PlayerInteractEvent.LeftClickBlock) {
    checkCreativeClick(event);
  }
  ItemStack heldItem=event.getEntityPlayer().getHeldItem(event.getHand());
  if (heldItem == null || heldItem.getItem() == null) {
    return;
  }
  if (event.getEntityPlayer().isSneaking() && WrenchChecker.isAWrench(heldItem.getItem())) {
    World world=event.getWorld();
    int x=event.getPos().getX();
    int y=event.getPos().getY();
    int z=event.getPos().getZ();
    Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(world,x,y,z);
    if (BlockProtectors.checkHarvestProtection(x,y,z,world,protectors)) {
      event.setCanceled(true);
    }
  }
}
Program: 165740
Project: 165740
Buggy source:
@SubscribeEvent public void onDetonate(ExplosionEvent.Detonate event){
  Explosion explosion=event.getExplosion();
  Vec3d explosionVector=explosion.getPosition();
  Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(event.getWorld().provider.getDimension(),(int)explosionVector.xCoord,(int)explosionVector.yCoord,(int)explosionVector.zCoord);
  if (protectors.isEmpty()) {
    return;
  }
  List<BlockPos> affectedBlocks=event.getAffectedBlocks();
  List<BlockPos> toremove=new ArrayList<>();
  int rf=0;
  for (  GlobalCoordinate protector : protectors) {
    BlockPos pos=protector.getCoordinate();
    TileEntity te=event.getWorld().getTileEntity(pos);
    if (te instanceof BlockProtectorTileEntity) {
      BlockProtectorTileEntity blockProtectorTileEntity=(BlockProtectorTileEntity)te;
      for (      BlockPos block : affectedBlocks) {
        BlockPos relative=blockProtectorTileEntity.absoluteToRelative(block);
        boolean b=blockProtectorTileEntity.isProtected(relative);
        if (b) {
          Vec3d blockVector=new Vec3d(block);
          double distanceTo=explosionVector.distanceTo(blockVector);
          int rfneeded=blockProtectorTileEntity.attemptExplosionProtection((float)(distanceTo / explosion.explosionSize),explosion.explosionSize);
          if (rfneeded > 0) {
            toremove.add(block);
            rf+=rfneeded;
          }
 else {
            blockProtectorTileEntity.removeProtection(relative);
          }
        }
      }
    }
  }
  affectedBlocks.removeAll(toremove);
}

Fixed version (ground truth):
@SubscribeEvent public void onDetonate(ExplosionEvent.Detonate event){
  Explosion explosion=event.getExplosion();
  Vec3d explosionVector=explosion.getPosition();
  Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(event.getWorld(),(int)explosionVector.xCoord,(int)explosionVector.yCoord,(int)explosionVector.zCoord);
  if (protectors.isEmpty()) {
    return;
  }
  List<BlockPos> affectedBlocks=event.getAffectedBlocks();
  List<BlockPos> toremove=new ArrayList<>();
  int rf=0;
  for (  GlobalCoordinate protector : protectors) {
    BlockPos pos=protector.getCoordinate();
    TileEntity te=event.getWorld().getTileEntity(pos);
    if (te instanceof BlockProtectorTileEntity) {
      BlockProtectorTileEntity blockProtectorTileEntity=(BlockProtectorTileEntity)te;
      for (      BlockPos block : affectedBlocks) {
        BlockPos relative=blockProtectorTileEntity.absoluteToRelative(block);
        boolean b=blockProtectorTileEntity.isProtected(relative);
        if (b) {
          Vec3d blockVector=new Vec3d(block);
          double distanceTo=explosionVector.distanceTo(blockVector);
          int rfneeded=blockProtectorTileEntity.attemptExplosionProtection((float)(distanceTo / explosion.explosionSize),explosion.explosionSize);
          if (rfneeded > 0) {
            toremove.add(block);
            rf+=rfneeded;
          }
 else {
            blockProtectorTileEntity.removeProtection(relative);
          }
        }
      }
    }
  }
  affectedBlocks.removeAll(toremove);
}
Program: 165741
Project: 165741
Buggy source:
@SubscribeEvent public void onBlockBreakEvent(BlockEvent.BreakEvent event){
  int x=event.getPos().getX();
  int y=event.getPos().getY();
  int z=event.getPos().getZ();
  World world=event.getWorld();
  Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(world.provider.getDimension(),x,y,z);
  if (BlockProtectors.checkHarvestProtection(x,y,z,world,protectors)) {
    event.setCanceled(true);
  }
}

Fixed version (ground truth):
@SubscribeEvent public void onBlockBreakEvent(BlockEvent.BreakEvent event){
  int x=event.getPos().getX();
  int y=event.getPos().getY();
  int z=event.getPos().getZ();
  World world=event.getWorld();
  Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(world,x,y,z);
  if (BlockProtectors.checkHarvestProtection(x,y,z,world,protectors)) {
    event.setCanceled(true);
  }
}
Program: 165742
Project: 165742
Buggy source:
@Override public boolean canEntityDestroy(IBlockState state,IBlockAccess world,BlockPos pos,Entity entity){
  boolean b=super.canEntityDestroy(state,world,pos,entity);
  if (b) {
    Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(entity.dimension,pos.getX(),pos.getY(),pos.getZ());
    if (BlockProtectors.checkHarvestProtection(pos.getX(),pos.getY(),pos.getZ(),world,protectors)) {
      return false;
    }
  }
  return b;
}

Fixed version (ground truth):
@Override public boolean canEntityDestroy(IBlockState state,IBlockAccess world,BlockPos pos,Entity entity){
  boolean b=super.canEntityDestroy(state,world,pos,entity);
  if (b) {
    Collection<GlobalCoordinate> protectors=BlockProtectors.getProtectors(entity.getEntityWorld(),pos.getX(),pos.getY(),pos.getZ());
    if (BlockProtectors.checkHarvestProtection(pos.getX(),pos.getY(),pos.getZ(),world,protectors)) {
      return false;
    }
  }
  return b;
}
Program: 165744
Project: 165744
Buggy source:
private IBlockState findAndConsumeBlock(IInventory inventory,IBlockState state){
  if (state == null) {
    List<Integer> slots=new ArrayList<>();
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
        slots.add(i);
      }
    }
    if (slots.isEmpty()) {
      return null;
    }
    int randomSlot=slots.get(random.nextInt(slots.size()));
    ItemStack stack=inventory.getStackInSlot(randomSlot);
    ItemBlock itemBlock=(ItemBlock)stack.getItem();
    inventory.decrStackSize(randomSlot,1);
    return itemBlock.getBlock().getStateFromMeta(stack.getItemDamage());
  }
 else {
    Block block=state.getBlock();
    int meta=block.getMetaFromState(state);
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
        ItemBlock itemBlock=(ItemBlock)stack.getItem();
        if (itemBlock.getBlock() == block && (stack.getItemDamage() == meta)) {
          inventory.decrStackSize(i,1);
          return itemBlock.getBlock().getStateFromMeta(stack.getItemDamage());
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private IBlockState findAndConsumeBlock(IInventory inventory,IBlockState state){
  if (state == null) {
    List<Integer> slots=new ArrayList<>();
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
        slots.add(i);
      }
    }
    if (slots.isEmpty()) {
      return null;
    }
    int randomSlot=slots.get(random.nextInt(slots.size()));
    ItemStack extracted=inventory.decrStackSize(randomSlot,1);
    if (extracted == null) {
      return null;
    }
    ItemBlock itemBlock=(ItemBlock)extracted.getItem();
    return itemBlock.getBlock().getStateFromMeta(extracted.getItemDamage());
  }
 else {
    Block block=state.getBlock();
    int meta=block.getMetaFromState(state);
    for (int i=0; i < inventory.getSizeInventory(); i++) {
      ItemStack stack=inventory.getStackInSlot(i);
      if (stack != null && stack.stackSize > 0 && stack.getItem() instanceof ItemBlock) {
        ItemBlock itemBlock=(ItemBlock)stack.getItem();
        if (itemBlock.getBlock() == block && (stack.getItemDamage() == meta)) {
          ItemStack extracted=inventory.decrStackSize(i,1);
          if (extracted == null) {
            return null;
          }
          itemBlock=(ItemBlock)extracted.getItem();
          return itemBlock.getBlock().getStateFromMeta(extracted.getItemDamage());
        }
      }
    }
  }
  return null;
}
Program: 165745
Project: 165745
Buggy source:
private ItemStack decrStackSizeHelper(int index,int amount){
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return null;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return null;
    }
    return storageTileEntity.decrStackSizeRemote(si,index,amount);
  }
 else {
    return inventoryHelper.decrStackSize(index,amount);
  }
}

Fixed version (ground truth):
private ItemStack decrStackSizeHelper(int index,int amount){
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return null;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return null;
    }
    storageTileEntity.updateVersion();
    return storageTileEntity.decrStackSizeRemote(si,index,amount);
  }
 else {
    return inventoryHelper.decrStackSize(index,amount);
  }
}
Program: 165746
Project: 165746
Buggy source:
private void setInventorySlotContentsHelper(int limit,int index,ItemStack stack){
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return;
    }
    storageTileEntity.updateRemoteSlot(si,limit,index,stack);
  }
 else {
    inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,stack);
  }
}

Fixed version (ground truth):
private void setInventorySlotContentsHelper(int limit,int index,ItemStack stack){
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return;
    }
    storageTileEntity.updateVersion();
    storageTileEntity.updateRemoteSlot(si,limit,index,stack);
  }
 else {
    inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,stack);
  }
}
Program: 165747
Project: 165747
Buggy source:
@Override public ItemStack removeStackFromSlot(int index){
  version++;
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return null;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return null;
    }
    return storageTileEntity.removeStackFromSlotRemote(si,index);
  }
 else {
    return inventoryHelper.removeStackFromSlot(index);
  }
}

Fixed version (ground truth):
@Override public ItemStack removeStackFromSlot(int index){
  version++;
  if (isStorageAvailableRemotely(index)) {
    index-=ModularStorageContainer.SLOT_STORAGE;
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return null;
    }
    int si=storageTileEntity.findRemoteIndex(remoteId);
    if (si == -1) {
      return null;
    }
    storageTileEntity.updateVersion();
    return storageTileEntity.removeStackFromSlotRemote(si,index);
  }
 else {
    return inventoryHelper.removeStackFromSlot(index);
  }
}
Program: 165748
Project: 165748
Buggy source:
@Override public int getVersion(){
  return version;
}

Fixed version (ground truth):
@Override public int getVersion(){
  if (isRemote()) {
    RemoteStorageTileEntity storageTileEntity=getRemoteStorage(remoteId);
    if (storageTileEntity == null) {
      return version;
    }
    return storageTileEntity.getVersion();
  }
 else {
    return version;
  }
}
Program: 165749
Project: 165749
Buggy source:
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  readBufferFromNBT(tagCompound,inventoryHelper);
  for (int i=0; i < 4; i++) {
    int max=tagCompound.getInteger("String_Node_Str" + i);
    setMaxSize(i,max);
    readSlotsFromNBT(tagCompound,"String_Node_Str" + i,i);
    global[i]=tagCompound.getBoolean("String_Node_Str" + i);
    updateStackCount(i);
  }
}

Fixed version (ground truth):
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  readBufferFromNBT(tagCompound,inventoryHelper);
  version=tagCompound.getInteger("String_Node_Str");
  for (int i=0; i < 4; i++) {
    int max=tagCompound.getInteger("String_Node_Str" + i);
    setMaxSize(i,max);
    readSlotsFromNBT(tagCompound,"String_Node_Str" + i,i);
    global[i]=tagCompound.getBoolean("String_Node_Str" + i);
    updateStackCount(i);
  }
}
Program: 165750
Project: 165750
Buggy source:
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  writeBufferToNBT(tagCompound,inventoryHelper);
  for (int i=0; i < 4; i++) {
    writeSlotsToNBT(tagCompound,"String_Node_Str" + i,i);
    tagCompound.setInteger("String_Node_Str" + i,maxsize[i]);
    tagCompound.setBoolean("String_Node_Str" + i,global[i]);
  }
}

Fixed version (ground truth):
@Override public void writeRestorableToNBT(NBTTagCompound tagCompound){
  super.writeRestorableToNBT(tagCompound);
  writeBufferToNBT(tagCompound,inventoryHelper);
  tagCompound.setInteger("String_Node_Str",version);
  for (int i=0; i < 4; i++) {
    writeSlotsToNBT(tagCompound,"String_Node_Str" + i,i);
    tagCompound.setInteger("String_Node_Str" + i,maxsize[i]);
    tagCompound.setBoolean("String_Node_Str" + i,global[i]);
  }
}
Program: 165751
Project: 165751
Buggy source:
private boolean pumpBlock(int rfNeeded,BlockPos srcPos,Block block){
  IBlockState srcState=worldObj.getBlockState(srcPos);
  Fluid fluid=FluidRegistry.lookupFluidForBlock(srcState.getBlock());
  if (fluid == null) {
    return false;
  }
  int xCoord=getPos().getX();
  int yCoord=getPos().getY();
  int zCoord=getPos().getZ();
  if (block.getBlockHardness(srcState,worldObj,srcPos) >= 0) {
    FakePlayer fakePlayer=FakePlayerFactory.getMinecraft(DimensionManager.getWorld(0));
    if (block.canEntityDestroy(srcState,worldObj,srcPos,fakePlayer)) {
      if (checkAndInsertFluids(fluid)) {
        boolean clear=getCardType() == ShapeCardItem.CARD_PUMP_CLEAR;
        if (clear) {
          worldObj.setBlockToAir(srcPos);
        }
 else {
          worldObj.setBlockState(srcPos,getDirtOrCobble().getDefaultState(),2);
        }
        if (!silent) {
          SoundTools.playSound(worldObj,block.getSoundType().breakSound,srcPos.getX(),srcPos.getY(),srcPos.getZ(),1.0f,1.0f);
        }
      }
      return false;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean pumpBlock(int rfNeeded,BlockPos srcPos,Block block){
  Fluid fluid=FluidRegistry.lookupFluidForBlock(block);
  if (fluid == null) {
    return false;
  }
  if (!(block instanceof BlockStaticLiquid)) {
    return false;
  }
  IBlockState srcState=worldObj.getBlockState(srcPos);
  if (block.getMetaFromState(srcState) != 0) {
    return false;
  }
  if (block.getBlockHardness(srcState,worldObj,srcPos) >= 0) {
    FakePlayer fakePlayer=FakePlayerFactory.getMinecraft(DimensionManager.getWorld(0));
    if (block.canEntityDestroy(srcState,worldObj,srcPos,fakePlayer)) {
      if (checkAndInsertFluids(fluid)) {
        consumeEnergy(rfNeeded);
        boolean clear=getCardType() == ShapeCardItem.CARD_PUMP_CLEAR;
        if (clear) {
          worldObj.setBlockToAir(srcPos);
        }
 else {
          worldObj.setBlockState(srcPos,getDirtOrCobble().getDefaultState(),2);
        }
        if (!silent) {
          SoundTools.playSound(worldObj,block.getSoundType().breakSound,srcPos.getX(),srcPos.getY(),srcPos.getZ(),1.0f,1.0f);
        }
      }
      return false;
    }
  }
  return false;
}
Program: 165753
Project: 165753
Buggy source:
@SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox(){
  int xCoord=getPos().getX();
  int yCoord=getPos().getY();
  int zCoord=getPos().getZ();
  return new AxisAlignedBB(xCoord - 1,yCoord - 1,zCoord - 1,xCoord + size + 1,yCoord + size + 1,zCoord + size + 1);
}

Fixed version (ground truth):
@SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox(){
  int xCoord=getPos().getX();
  int yCoord=getPos().getY();
  int zCoord=getPos().getZ();
  return new AxisAlignedBB(xCoord - 1,yCoord - size - 1,zCoord - 1,xCoord + size + 1,yCoord + 1,zCoord + size + 1);
}
Program: 165754
Project: 165754
Buggy source:
private void requestItem(ItemStack stack,int amount){
  network.sendToServer(new PacketRequestItem(tileEntity.getDimension(),tileEntity.getStorageScannerPos(),getSelectedContainerPos(),stack,amount));
  getInventoryOnServer();
}

Fixed version (ground truth):
private void requestItem(ItemStack stack,int amount){
  BlockPos selectedContainerPos=getSelectedContainerPos();
  if (selectedContainerPos == null) {
    return;
  }
  network.sendToServer(new PacketRequestItem(tileEntity.getDimension(),tileEntity.getStorageScannerPos(),selectedContainerPos,stack,amount));
  getInventoryOnServer();
}
Program: 165756
Project: 165756
Buggy source:
public void handle(PacketCycleStorage message,MessageContext ctx){
  EntityPlayerMP playerEntity=ctx.getServerHandler().playerEntity;
  ItemStack heldItem=playerEntity.getHeldItem(EnumHand.MAIN_HAND);
  if (heldItem == null) {
    return;
  }
  NBTTagCompound tagCompound=heldItem.getTagCompound();
  if (tagCompound == null) {
    return;
  }
  int id=tagCompound.getInteger("String_Node_Str");
  RemoteStorageTileEntity remoteStorage=RemoteStorageIdRegistry.getRemoteStorage(playerEntity.worldObj,id);
  if (remoteStorage != null) {
    id=remoteStorage.cycle(id);
    tagCompound.setInteger("String_Node_Str",id);
    remoteStorage.markDirty();
  }
 else {
    Logging.message(playerEntity,TextFormatting.YELLOW + "String_Node_Str");
  }
}

Fixed version (ground truth):
public void handle(PacketCycleStorage message,MessageContext ctx){
  EntityPlayerMP playerEntity=ctx.getServerHandler().playerEntity;
  ItemStack heldItem=playerEntity.getHeldItem(EnumHand.MAIN_HAND);
  if (heldItem == null) {
    return;
  }
  NBTTagCompound tagCompound=heldItem.getTagCompound();
  if (tagCompound == null) {
    return;
  }
  int id=tagCompound.getInteger("String_Node_Str");
  RemoteStorageTileEntity remoteStorage=RemoteStorageIdRegistry.getRemoteStorage(playerEntity.worldObj,id);
  if (remoteStorage != null) {
    id=remoteStorage.cycle(id);
    tagCompound.setInteger("String_Node_Str",id);
    int si=remoteStorage.findRemoteIndex(id);
    if (si != -1) {
      int maxStacks=remoteStorage.getMaxStacks(si);
      tagCompound.setInteger("String_Node_Str",maxStacks);
    }
    remoteStorage.markDirty();
  }
 else {
    Logging.message(playerEntity,TextFormatting.YELLOW + "String_Node_Str");
  }
}
Program: 165757
Project: 165757
Buggy source:
@Override public void update(){
  if (!worldObj.isRemote) {
    boolean newout=isPlatformHere();
    if (newout != redstoneOut) {
      redstoneOut=newout;
      setRedstoneState(redstoneOut);
    }
    if (isMoving()) {
      markDirty();
      double d=calculateSpeed();
      boolean stopped=handlePlatformMovement(d);
      if (stopped) {
        stopMoving();
        moveEntities(0,true);
        clearMovement();
      }
 else {
        moveEntities(d,false);
      }
      return;
    }
    if ((powerLevel > 0) == prevIn) {
      return;
    }
    prevIn=(powerLevel > 0);
    markDirty();
    if (powerLevel > 0) {
      movePlatformHere();
    }
  }
 else {
    if (isMoving()) {
      handleClientMovement();
    }
    handleSound();
  }
}

Fixed version (ground truth):
@Override public void update(){
  if (!worldObj.isRemote) {
    boolean newout=isPlatformHere();
    if (newout != redstoneOut) {
      redstoneOut=newout;
      setRedstoneState();
    }
    if (isMoving()) {
      markDirty();
      double d=calculateSpeed();
      boolean stopped=handlePlatformMovement(d);
      if (stopped) {
        stopMoving();
        moveEntities(0,true);
        clearMovement();
      }
 else {
        moveEntities(d,false);
      }
      return;
    }
    if ((powerLevel > 0) == prevIn) {
      return;
    }
    prevIn=(powerLevel > 0);
    markDirty();
    if (powerLevel > 0) {
      movePlatformHere();
    }
  }
 else {
    if (isMoving()) {
      handleClientMovement();
    }
    handleSound();
  }
}
Program: 165758
Project: 165758
Buggy source:
protected void setRedstoneState(boolean newout){
  markDirty();
  worldObj.notifyNeighborsOfStateChange(this.pos,this.getBlockType());
}

Fixed version (ground truth):
private void setRedstoneState(){
  markDirty();
  worldObj.notifyNeighborsOfStateChange(this.pos,this.getBlockType());
}
Program: 165759
Project: 165759
Buggy source:
private boolean firstValidItem(){
  while (true) {
    if (inventoryIndex >= inventories.size()) {
      return false;
    }
    IInventory inventory=inventories.get(inventoryIndex).getLeft();
    if (slotIndex < inventory.getSizeInventory()) {
      return true;
    }
 else {
      slotIndex=0;
      inventoryIndex++;
    }
  }
}

Fixed version (ground truth):
private boolean firstValidItem(){
  while (true) {
    if (inventoryIndex >= inventories.size()) {
      return false;
    }
    IInventory inventory=inventories.get(inventoryIndex).getLeft();
    int offset=inventories.get(inventoryIndex).getRight();
    if (slotIndex < offset) {
      slotIndex=offset;
    }
    if (slotIndex < inventory.getSizeInventory()) {
      return true;
    }
 else {
      slotIndex=0;
      inventoryIndex++;
    }
  }
}
Program: 165760
Project: 165760
Buggy source:
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    private boolean firstValidItem(){
      while (true) {
        if (inventoryIndex >= inventories.size()) {
          return false;
        }
        IInventory inventory=inventories.get(inventoryIndex).getLeft();
        if (slotIndex < inventory.getSizeInventory()) {
          return true;
        }
 else {
          slotIndex=0;
          inventoryIndex++;
        }
      }
    }
    @Override public boolean hasNext(){
      return firstValidItem();
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      IInventory inventory=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(inventory,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
      slotIndex++;
      return result;
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    private boolean firstValidItem(){
      while (true) {
        if (inventoryIndex >= inventories.size()) {
          return false;
        }
        IInventory inventory=inventories.get(inventoryIndex).getLeft();
        int offset=inventories.get(inventoryIndex).getRight();
        if (slotIndex < offset) {
          slotIndex=offset;
        }
        if (slotIndex < inventory.getSizeInventory()) {
          return true;
        }
 else {
          slotIndex=0;
          inventoryIndex++;
        }
      }
    }
    @Override public boolean hasNext(){
      return firstValidItem();
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      IInventory inventory=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(inventory,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
      slotIndex++;
      return result;
    }
  }
;
}
Program: 165761
Project: 165761
Buggy source:
@Override public Pair<IItemKey,ItemStack> next(){
  IInventory inventory=inventories.get(inventoryIndex).getLeft();
  ItemKey key=new ItemKey(inventory,slotIndex);
  Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
  slotIndex++;
  if (slotIndex >= inventory.getSizeInventory()) {
    inventoryIndex++;
    if (inventoryIndex < inventories.size()) {
      slotIndex=inventories.get(inventoryIndex).getRight();
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public Pair<IItemKey,ItemStack> next(){
  IInventory inventory=inventories.get(inventoryIndex).getLeft();
  ItemKey key=new ItemKey(inventory,slotIndex);
  Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
  slotIndex++;
  return result;
}
Program: 165762
Project: 165762
Buggy source:
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    @Override public boolean hasNext(){
      return inventoryIndex < inventories.size() && slotIndex < inventories.get(inventoryIndex).getLeft().getSizeInventory();
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      IInventory inventory=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(inventory,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
      slotIndex++;
      if (slotIndex >= inventory.getSizeInventory()) {
        inventoryIndex++;
        if (inventoryIndex < inventories.size()) {
          slotIndex=inventories.get(inventoryIndex).getRight();
        }
      }
      return result;
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    private boolean firstValidItem(){
      while (true) {
        if (inventoryIndex >= inventories.size()) {
          return false;
        }
        IInventory inventory=inventories.get(inventoryIndex).getLeft();
        if (slotIndex < inventory.getSizeInventory()) {
          return true;
        }
 else {
          slotIndex=0;
          inventoryIndex++;
        }
      }
    }
    @Override public boolean hasNext(){
      return firstValidItem();
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      IInventory inventory=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(inventory,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,inventory.getStackInSlot(slotIndex));
      slotIndex++;
      return result;
    }
  }
;
}
Program: 165763
Project: 165763
Buggy source:
@Override public boolean hasNext(){
  return inventoryIndex < inventories.size() && slotIndex < inventories.get(inventoryIndex).getLeft().getSizeInventory();
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return firstValidItem();
}
Program: 165764
Project: 165764
Buggy source:
@Override public Pair<IItemKey,ItemStack> next(){
  Object te=inventories.get(inventoryIndex).getLeft();
  ItemKey key=new ItemKey(te,slotIndex);
  Pair<IItemKey,ItemStack> result=Pair.of(key,getStackInSlot(te,slotIndex));
  slotIndex++;
  if (slotIndex >= getSizeInventory(te)) {
    inventoryIndex++;
    if (inventoryIndex < inventories.size()) {
      slotIndex=inventories.get(inventoryIndex).getRight();
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public Pair<IItemKey,ItemStack> next(){
  Object te=inventories.get(inventoryIndex).getLeft();
  ItemKey key=new ItemKey(te,slotIndex);
  Pair<IItemKey,ItemStack> result=Pair.of(key,getStackInSlot(te,slotIndex));
  slotIndex++;
  return result;
}
Program: 165765
Project: 165765
Buggy source:
@Override public boolean hasNext(){
  if (inventoryIndex >= inventories.size()) {
    return false;
  }
  Object te=inventories.get(inventoryIndex).getLeft();
  return slotIndex < getSizeInventory(te);
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  return firstValidItem();
}
Program: 165766
Project: 165766
Buggy source:
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    @Override public boolean hasNext(){
      if (inventoryIndex >= inventories.size()) {
        return false;
      }
      Object te=inventories.get(inventoryIndex).getLeft();
      return slotIndex < getSizeInventory(te);
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      Object te=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(te,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,getStackInSlot(te,slotIndex));
      slotIndex++;
      if (slotIndex >= getSizeInventory(te)) {
        inventoryIndex++;
        if (inventoryIndex < inventories.size()) {
          slotIndex=inventories.get(inventoryIndex).getRight();
        }
      }
      return result;
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterable<Pair<IItemKey,ItemStack>> getItems(){
  return () -> new Iterator<Pair<IItemKey,ItemStack>>(){
    private int inventoryIndex=0;
    private int slotIndex=0;
    private boolean firstValidItem(){
      while (true) {
        if (inventoryIndex >= inventories.size()) {
          return false;
        }
        Object inventory=inventories.get(inventoryIndex).getLeft();
        if (slotIndex < getSizeInventory(inventory)) {
          return true;
        }
 else {
          slotIndex=0;
          inventoryIndex++;
        }
      }
    }
    @Override public boolean hasNext(){
      return firstValidItem();
    }
    @Override public Pair<IItemKey,ItemStack> next(){
      Object te=inventories.get(inventoryIndex).getLeft();
      ItemKey key=new ItemKey(te,slotIndex);
      Pair<IItemKey,ItemStack> result=Pair.of(key,getStackInSlot(te,slotIndex));
      slotIndex++;
      return result;
    }
  }
;
}
Program: 165767
Project: 165767
Buggy source:
@Override public ItemStack decrStackSize(int index,int amount){
  checkSyringe=true;
  return inventoryHelper.decrStackSize(index,amount);
}

Fixed version (ground truth):
@Override public ItemStack decrStackSize(int index,int amount){
  checkSyringe=true;
  prevMobId=mobId;
  return inventoryHelper.decrStackSize(index,amount);
}
Program: 165768
Project: 165768
Buggy source:
@Override public void setInventorySlotContents(int index,ItemStack stack){
  checkSyringe=true;
  inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,stack);
}

Fixed version (ground truth):
@Override public void setInventorySlotContents(int index,ItemStack stack){
  checkSyringe=true;
  prevMobId=mobId;
  inventoryHelper.setInventorySlotContents(getInventoryStackLimit(),index,stack);
}
Program: 165769
Project: 165769
Buggy source:
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  readBufferFromNBT(tagCompound,inventoryHelper);
  matter[0]=tagCompound.getFloat("String_Node_Str");
  matter[1]=tagCompound.getFloat("String_Node_Str");
  matter[2]=tagCompound.getFloat("String_Node_Str");
  checkSyringe=tagCompound.getBoolean("String_Node_Str");
  if (tagCompound.hasKey("String_Node_Str")) {
    mobId=tagCompound.getString("String_Node_Str");
  }
 else {
    mobId=null;
  }
}

Fixed version (ground truth):
@Override public void readRestorableFromNBT(NBTTagCompound tagCompound){
  super.readRestorableFromNBT(tagCompound);
  readBufferFromNBT(tagCompound,inventoryHelper);
  matter[0]=tagCompound.getFloat("String_Node_Str");
  matter[1]=tagCompound.getFloat("String_Node_Str");
  matter[2]=tagCompound.getFloat("String_Node_Str");
  if (tagCompound.hasKey("String_Node_Str")) {
    mobId=tagCompound.getString("String_Node_Str");
  }
 else {
    mobId=null;
  }
}