nus-yam/ex-repair huggingface dataset:
Program: 171547
Project: 171547
Buggy source:
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (BlockUtil.isIRRail(world,pos)) {
    TileRailBase te=TileRailBase.get(world,pos);
    if (te != null) {
      Augment augment=te.getAugment();
      if (augment != null) {
        te.setAugment(null);
        if (!world.isRemote) {
          ItemStack stack=new ItemStack(ImmersiveRailroading.ITEM_AUGMENT,1);
          ItemAugmentType.set(stack,augment);
          ItemGauge.set(stack,Gauge.from(te.getTrackGauge()));
          world.spawnEntity(new EntityItem(world,pos.getX(),pos.getY(),pos.getZ(),stack));
        }
      }
    }
  }
 else {
    if (!world.isRemote) {
      for (      String key : MultiblockRegistry.keys()) {
        MultiblockRegistry.get(key).tryCreate(world,pos);
      }
    }
  }
  return EnumActionResult.PASS;
}

Fixed version (ground truth):
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (BlockUtil.isIRRail(world,pos)) {
    TileRailBase te=TileRailBase.get(world,pos);
    if (te != null) {
      Augment augment=te.getAugment();
      if (augment != null) {
        te.setAugment(null);
        if (!world.isRemote) {
          ItemStack stack=new ItemStack(ImmersiveRailroading.ITEM_AUGMENT,1);
          ItemAugmentType.set(stack,augment);
          ItemGauge.set(stack,Gauge.from(te.getTrackGauge()));
          world.spawnEntity(new EntityItem(world,pos.getX(),pos.getY(),pos.getZ(),stack));
        }
        return EnumActionResult.SUCCESS;
      }
    }
  }
 else {
    for (    String key : MultiblockRegistry.keys()) {
      if (MultiblockRegistry.get(key).tryCreate(world,pos)) {
        System.out.print("String_Node_Str");
        return EnumActionResult.SUCCESS;
      }
    }
  }
  return EnumActionResult.PASS;
}
Program: 171548
Project: 171548
Buggy source:
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (!world.isRemote) {
    ItemStack item=player.getHeldItem(hand);
    String current=ItemMultiblockType.get(item);
    BlockPos realPos=pos;
    if (facing == EnumFacing.DOWN) {
      realPos=realPos.down();
    }
    if (facing == EnumFacing.UP) {
      realPos=realPos.up();
    }
    MultiblockRegistry.get(current).place(world,player,realPos,BlockUtil.rotFromFacing(EnumFacing.fromAngle(player.rotationYawHead + 180)));
  }
  return EnumActionResult.PASS;
}

Fixed version (ground truth):
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (!world.isRemote) {
    ItemStack item=player.getHeldItem(hand);
    String current=ItemMultiblockType.get(item);
    BlockPos realPos=pos;
    if (facing == EnumFacing.DOWN) {
      realPos=realPos.down();
    }
    if (facing == EnumFacing.UP) {
      realPos=realPos.up();
    }
    MultiblockRegistry.get(current).place(world,player,realPos,BlockUtil.rotFromFacing(EnumFacing.fromAngle(player.rotationYawHead + 180)));
  }
  return EnumActionResult.SUCCESS;
}
Program: 171549
Project: 171549
Buggy source:
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (!world.isRemote) {
    if (BlockUtil.isIRRail(world,pos)) {
      TileRailBase te=TileRailBase.get(world,pos);
      if (te != null) {
        ItemStack stack=player.getHeldItem(hand);
        if (te.getAugment() == null && (player.isCreative() || Gauge.from(te.getTrackGauge()) == ItemGauge.get(stack))) {
          Augment augment=ItemAugmentType.get(stack);
          TileRail parent=te.getParentTile();
          if (parent == null) {
            return EnumActionResult.FAIL;
          }
switch (augment) {
case WATER_TROUGH:
            if (parent.getRotationQuarter() != 0) {
              return EnumActionResult.FAIL;
            }
          if (parent.getType() != TrackItems.STRAIGHT) {
            return EnumActionResult.FAIL;
          }
        break;
case SPEED_RETARDER:
switch (parent.getType()) {
case SWITCH:
case TURN:
        return EnumActionResult.FAIL;
default :
      break;
  }
default :
break;
}
te.setAugment(augment);
if (!player.isCreative()) {
stack.setCount(stack.getCount() - 1);
;
}
return EnumActionResult.SUCCESS;
}
}
}
}
return EnumActionResult.PASS;
}

Fixed version (ground truth):
@Override public EnumActionResult onItemUse(EntityPlayer player,World world,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  if (BlockUtil.isIRRail(world,pos)) {
    TileRailBase te=TileRailBase.get(world,pos);
    if (te != null) {
      ItemStack stack=player.getHeldItem(hand);
      if (te.getAugment() == null && (player.isCreative() || Gauge.from(te.getTrackGauge()) == ItemGauge.get(stack))) {
        Augment augment=ItemAugmentType.get(stack);
        TileRail parent=te.getParentTile();
        if (parent == null) {
          return EnumActionResult.FAIL;
        }
switch (augment) {
case WATER_TROUGH:
          if (parent.getRotationQuarter() != 0) {
            return EnumActionResult.FAIL;
          }
        if (parent.getType() != TrackItems.STRAIGHT) {
          return EnumActionResult.FAIL;
        }
      break;
case SPEED_RETARDER:
switch (parent.getType()) {
case SWITCH:
case TURN:
      return EnumActionResult.FAIL;
default :
    break;
}
default :
break;
}
if (!world.isRemote) {
te.setAugment(augment);
if (!player.isCreative()) {
stack.setCount(stack.getCount() - 1);
;
}
}
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
Program: 171550
Project: 171550
Buggy source:
public boolean tryCreate(World world,BlockPos pos){
  for (  BlockPos activationLocation : this.componentPositions) {
    for (    Rotation rot : Rotation.values()) {
      BlockPos origin=pos.subtract(activationLocation.rotate(rot));
      boolean valid=true;
      for (      BlockPos offset : this.componentPositions) {
        valid=valid && checkValid(world,origin,offset,rot);
      }
      if (valid) {
        instance(world,origin,rot).onCreate();
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean tryCreate(World world,BlockPos pos){
  for (  BlockPos activationLocation : this.componentPositions) {
    for (    Rotation rot : Rotation.values()) {
      BlockPos origin=pos.subtract(activationLocation.rotate(rot));
      boolean valid=true;
      for (      BlockPos offset : this.componentPositions) {
        valid=valid && checkValid(world,origin,offset,rot);
      }
      if (valid) {
        if (!world.isRemote) {
          instance(world,origin,rot).onCreate();
        }
        return true;
      }
    }
  }
  return false;
}
Program: 171552
Project: 171552
Buggy source:
public double getCouplerPosition(CouplerType coupler,Gauge gauge){
switch (coupler) {
case FRONT:
    return gauge.scale() * (this.frontBounds + couplerOffsetFront);
case BACK:
  return gauge.scale() * (this.rearBounds + couplerOffsetRear);
default :
return 0;
}
}

Fixed version (ground truth):
public double getCouplerPosition(CouplerType coupler,Gauge gauge){
switch (coupler) {
case FRONT:
    return gauge.scale() * (this.frontBounds);
case BACK:
  return gauge.scale() * (this.rearBounds);
default :
return 0;
}
}
Program: 171554
Project: 171554
Buggy source:
public Vec3d getCouplerPosition(CouplerType coupler,TickPos pos){
  if (coupler == CouplerType.FRONT) {
    if (couplerFrontPosition == null) {
      couplerFrontPosition=predictRearBogeyPosition(pos,(float)(this.getDefinition().getLength(gauge) / 2 + Config.couplerRange + this.getDefinition().getBogeyRear(gauge))).add(pos.position).addVector(0,1,0);
    }
    return couplerFrontPosition;
  }
 else {
    if (couplerRearPosition == null) {
      couplerRearPosition=predictFrontBogeyPosition(pos,(float)(this.getDefinition().getLength(gauge) / 2 + Config.couplerRange - this.getDefinition().getBogeyFront(gauge))).add(pos.position).addVector(0,1,0);
    }
    return couplerRearPosition;
  }
}

Fixed version (ground truth):
public Vec3d getCouplerPosition(CouplerType coupler,TickPos pos){
  if (coupler == CouplerType.FRONT) {
    if (couplerFrontPosition == null) {
      couplerFrontPosition=predictRearBogeyPosition(pos,(float)(this.getDefinition().frontBounds - this.getDefinition().getBogeyFront(gauge))).add(pos.position).addVector(0,1,0);
    }
    return couplerFrontPosition;
  }
 else {
    if (couplerRearPosition == null) {
      couplerRearPosition=predictFrontBogeyPosition(pos,(float)(this.getDefinition().rearBounds + this.getDefinition().getBogeyRear(gauge))).add(pos.position).addVector(0,1,0);
    }
    return couplerRearPosition;
  }
}
Program: 171556
Project: 171556
Buggy source:
public double getCouplerPosition(CouplerType coupler,Gauge gauge){
switch (coupler) {
case FRONT:
    return gauge.scale() * (this.frontBounds + Config.couplerRange);
case BACK:
  return gauge.scale() * (this.rearBounds + Config.couplerRange);
default :
return 0;
}
}

Fixed version (ground truth):
public double getCouplerPosition(CouplerType coupler,Gauge gauge){
switch (coupler) {
case FRONT:
    return gauge.scale() * (this.frontBounds);
case BACK:
  return gauge.scale() * (this.rearBounds);
default :
return 0;
}
}
Program: 171557
Project: 171557
Buggy source:
public static boolean canBeReplaced(World world,BlockPos pos,boolean allowFlex){
  Block block=world.getBlockState(pos).getBlock();
  if (block == null) {
    return true;
  }
  if (block.isReplaceable(world,pos)) {
    return true;
  }
  if (block instanceof IGrowable && !(block instanceof BlockGrass)) {
    return true;
  }
  if (block instanceof IPlantable) {
    return true;
  }
  if (block instanceof BlockLiquid) {
    return true;
  }
  if (block instanceof BlockSnow) {
    return true;
  }
  if (block == ImmersiveRailroading.BLOCK_RAIL_PREVIEW) {
    return true;
  }
  if (allowFlex && block instanceof BlockRailBase) {
    TileRailBase te=TileRailBase.get(world,pos);
    return te != null && te.isFlexible();
  }
  return false;
}

Fixed version (ground truth):
public static boolean canBeReplaced(World world,BlockPos pos,boolean allowFlex){
  if (world.isAirBlock(pos)) {
    return true;
  }
  Block block=world.getBlockState(pos).getBlock();
  if (block == null) {
    return true;
  }
  if (block.isReplaceable(world,pos)) {
    return true;
  }
  if (block instanceof IGrowable && !(block instanceof BlockGrass)) {
    return true;
  }
  if (block instanceof IPlantable) {
    return true;
  }
  if (block instanceof BlockLiquid) {
    return true;
  }
  if (block instanceof BlockSnow) {
    return true;
  }
  if (block == ImmersiveRailroading.BLOCK_RAIL_PREVIEW) {
    return true;
  }
  if (allowFlex && block instanceof BlockRailBase) {
    TileRailBase te=TileRailBase.get(world,pos);
    return te != null && te.isFlexible();
  }
  return false;
}
Program: 171558
Project: 171558
Buggy source:
public void handleTickPosPacket(List<TickPos> newPositions){
  if (newPositions.size() != 0) {
    if (this.ticksExisted > 5) {
      ImmersiveRailroading.proxy.addTickMetric(tickPosID - newPositions.get(0).tickID);
    }
    this.tickPosID=newPositions.get(0).tickID;
  }
  this.positions=newPositions;
}

Fixed version (ground truth):
public void handleTickPosPacket(List<TickPos> newPositions){
  if (newPositions.size() != 0) {
    this.clearPositionCache();
    if (this.ticksExisted > 5) {
      ImmersiveRailroading.proxy.addTickMetric(tickPosID - newPositions.get(0).tickID);
    }
    this.tickPosID=newPositions.get(0).tickID;
  }
  this.positions=newPositions;
}
Program: 171560
Project: 171560
Buggy source:
public Vec3d getCouplerPosition(CouplerType coupler){
  if (coupler == CouplerType.FRONT) {
    return predictRearBogeyPosition((float)(this.getDefinition().getLength() / 2 + Config.couplerRange + this.getDefinition().getBogeyRear())).add(this.getPositionVector()).addVector(0,1,0);
  }
 else {
    return predictFrontBogeyPosition((float)(this.getDefinition().getLength() / 2 + Config.couplerRange - this.getDefinition().getBogeyFront())).add(this.getPositionVector()).addVector(0,1,0);
  }
}

Fixed version (ground truth):
public Vec3d getCouplerPosition(CouplerType coupler,TickPos pos){
  if (coupler == CouplerType.FRONT) {
    return predictRearBogeyPosition(pos,(float)(this.getDefinition().getLength() / 2 + Config.couplerRange + this.getDefinition().getBogeyRear())).add(pos.position).addVector(0,1,0);
  }
 else {
    return predictFrontBogeyPosition(pos,(float)(this.getDefinition().getLength() / 2 + Config.couplerRange - this.getDefinition().getBogeyFront())).add(pos.position).addVector(0,1,0);
  }
}
Program: 171562
Project: 171562
Buggy source:
public PosRot predictRearBogeyPosition(float offset){
  MovementSimulator sim=new MovementSimulator(world,getCurrentTickPosOrFake(),this.getDefinition().getBogeyFront(),this.getDefinition().getBogeyRear());
  Vec3d rear=sim.rearBogeyPosition();
  Vec3d nextRear=rear;
  while (offset > 0) {
    nextRear=sim.nextPosition(nextRear,this.rotationYaw + 180,VecUtil.fromYaw(Math.min(0.1,offset),this.getRearYaw() + 180));
    offset-=0.1;
  }
  Vec3d rearDelta=rear.subtractReverse(nextRear);
  return new PosRot(nextRear.subtractReverse(this.getPositionVector()),VecUtil.toYaw(rearDelta));
}

Fixed version (ground truth):
public PosRot predictRearBogeyPosition(TickPos pos,float offset){
  MovementSimulator sim=new MovementSimulator(world,pos,this.getDefinition().getBogeyFront(),this.getDefinition().getBogeyRear());
  Vec3d rear=sim.rearBogeyPosition();
  Vec3d nextRear=rear;
  while (offset > 0) {
    nextRear=sim.nextPosition(nextRear,pos.rotationYaw + 180,VecUtil.fromYaw(Math.min(0.1,offset),pos.rearYaw + 180));
    offset-=0.1;
  }
  Vec3d rearDelta=rear.subtractReverse(nextRear);
  return new PosRot(nextRear.subtractReverse(pos.position),VecUtil.toYaw(rearDelta));
}
Program: 171563
Project: 171563
Buggy source:
public PosRot predictFrontBogeyPosition(float offset){
  MovementSimulator sim=new MovementSimulator(world,getCurrentTickPosOrFake(),this.getDefinition().getBogeyFront(),this.getDefinition().getBogeyRear());
  Vec3d front=sim.frontBogeyPosition();
  Vec3d nextFront=front;
  while (offset > 0) {
    nextFront=sim.nextPosition(nextFront,this.rotationYaw,VecUtil.fromYaw(Math.min(0.1,offset),this.getFrontYaw()));
    offset-=0.1;
  }
  Vec3d frontDelta=front.subtractReverse(nextFront);
  return new PosRot(nextFront.subtractReverse(this.getPositionVector()),VecUtil.toYaw(frontDelta));
}

Fixed version (ground truth):
public PosRot predictFrontBogeyPosition(TickPos pos,float offset){
  MovementSimulator sim=new MovementSimulator(world,pos,this.getDefinition().getBogeyFront(),this.getDefinition().getBogeyRear());
  Vec3d front=sim.frontBogeyPosition();
  Vec3d nextFront=front;
  while (offset > 0) {
    nextFront=sim.nextPosition(nextFront,pos.rotationYaw,VecUtil.fromYaw(Math.min(0.1,offset),pos.frontYaw));
    offset-=0.1;
  }
  Vec3d frontDelta=front.subtractReverse(nextFront);
  return new PosRot(nextFront.subtractReverse(pos.position),VecUtil.toYaw(frontDelta));
}
Program: 171564
Project: 171564
Buggy source:
private TickPos getCurrentTickPosOrFake(){
  if (this.getTickPos(this.tickPosID) != null) {
    return this.getTickPos(this.tickPosID);
  }
  return new TickPos(0,Speed.fromMetric(0),this.getPositionVector(),this.getFrontYaw(),this.getRearYaw(),this.rotationYaw,this.rotationPitch,false,false);
}

Fixed version (ground truth):
protected TickPos getCurrentTickPosOrFake(){
  if (this.getTickPos(this.tickPosID) != null) {
    return this.getTickPos(this.tickPosID);
  }
  return new TickPos(0,Speed.fromMetric(0),this.getPositionVector(),this.getFrontYaw(),this.getRearYaw(),this.rotationYaw,this.rotationPitch,false,false);
}
Program: 171566
Project: 171566
Buggy source:
public void setComponents(List<ItemComponentType> items){
  this.builtItems=new ArrayList<ItemComponentType>(items);
  this.isBuilt=getMissingItemComponents().isEmpty();
  if (!world.isRemote) {
    this.sendToObserving(new BuildableStockSyncPacket(this));
  }
  if (this.isBuilt()) {
    this.onAssemble();
  }
 else {
    this.onDissassemble();
  }
}

Fixed version (ground truth):
public void setComponents(List<ItemComponentType> items){
  this.builtItems=new ArrayList<ItemComponentType>(items);
  this.isBuilt=false;
  this.isBuilt=getMissingItemComponents().isEmpty();
  if (!world.isRemote) {
    this.sendToObserving(new BuildableStockSyncPacket(this));
  }
  if (this.isBuilt()) {
    this.onAssemble();
  }
 else {
    this.onDissassemble();
  }
}
Program: 171567
Project: 171567
Buggy source:
public BlockPos getParent(){
  return parent.add(pos);
}

Fixed version (ground truth):
public BlockPos getParent(){
  if (parent == null) {
    ImmersiveRailroading.logger.warn("String_Node_Str");
    world.setBlockToAir(pos);
    return null;
  }
  return parent.add(pos);
}
Program: 171568
Project: 171568
Buggy source:
public int costBed(){
  int fillCount=0;
  for (  TrackBase track : tracks) {
    if (world.isAirBlock(track.getPos().down())) {
      fillCount+=1;
    }
  }
  return (int)((int)(this.tracks.size() * 0.1) + (this.info.railBedFill ? fillCount : 0) * Config.BedCostMultiplier);
}

Fixed version (ground truth):
public int costBed(){
  int fillCount=0;
  for (  TrackBase track : tracks) {
    if (BlockUtil.canBeReplaced(world,track.getPos().down(),false)) {
      fillCount+=1;
    }
  }
  return (int)((int)(this.tracks.size() * 0.1) + (this.info.railBedFill ? fillCount : 0) * Config.BedCostMultiplier);
}
Program: 171569
Project: 171569
Buggy source:
public TileEntity placeTrack(){
  PosRot pos=getPos();
  if (builder.info.railBedFill && builder.world.isAirBlock(pos.down()) && builder.info.railBed.getItem() != Items.AIR) {
    builder.world.setBlockState(pos.down(),BlockUtil.itemToBlockState(builder.info.railBed));
  }
  NBTTagCompound replaced=null;
  IBlockState state=builder.world.getBlockState(pos);
  Block removed=state.getBlock();
  TileRailBase te=null;
  if (removed != null) {
    if (removed instanceof BlockRailBase) {
      te=(TileRailBase)builder.world.getTileEntity(pos);
      replaced=te.serializeNBT();
    }
 else {
      removed.dropBlockAsItem(builder.world,pos,state,0);
    }
  }
  if (te != null) {
    te.setWillBeReplaced(true);
  }
  builder.world.setBlockState(pos,getBlockState(),3);
  if (te != null) {
    te.setWillBeReplaced(false);
  }
  TileRailBase tr=(TileRailBase)builder.world.getTileEntity(pos);
  tr.setReplaced(replaced);
  if (parent != null) {
    tr.setParent(parent);
  }
 else {
    tr.setParent(builder.getParentPos());
  }
  tr.setHeight(getHeight());
  return tr;
}

Fixed version (ground truth):
public TileEntity placeTrack(){
  PosRot pos=getPos();
  if (builder.info.railBedFill && BlockUtil.canBeReplaced(builder.world,pos.down(),false) && builder.info.railBed.getItem() != Items.AIR) {
    builder.world.setBlockState(pos.down(),BlockUtil.itemToBlockState(builder.info.railBed));
  }
  NBTTagCompound replaced=null;
  IBlockState state=builder.world.getBlockState(pos);
  Block removed=state.getBlock();
  TileRailBase te=null;
  if (removed != null) {
    if (removed instanceof BlockRailBase) {
      te=(TileRailBase)builder.world.getTileEntity(pos);
      replaced=te.serializeNBT();
    }
 else {
      removed.dropBlockAsItem(builder.world,pos,state,0);
    }
  }
  if (te != null) {
    te.setWillBeReplaced(true);
  }
  builder.world.setBlockState(pos,getBlockState(),3);
  if (te != null) {
    te.setWillBeReplaced(false);
  }
  TileRailBase tr=(TileRailBase)builder.world.getTileEntity(pos);
  tr.setReplaced(replaced);
  if (parent != null) {
    tr.setParent(parent);
  }
 else {
    tr.setParent(builder.getParentPos());
  }
  tr.setHeight(getHeight());
  return tr;
}
Program: 171570
Project: 171570
Buggy source:
@SuppressWarnings("String_Node_Str") public boolean canPlaceTrack(){
  PosRot pos=getPos();
  IBlockState down=builder.world.getBlockState(pos.down());
  boolean downOK=down.isTopSolid() || (down.getBlock() == Blocks.AIR && builder.info.railBedFill);
  return BlockUtil.canBeReplaced(builder.world,pos,flexible || builder.overrideFlexible) && downOK;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public boolean canPlaceTrack(){
  PosRot pos=getPos();
  IBlockState down=builder.world.getBlockState(pos.down());
  boolean downOK=down.isTopSolid() || (BlockUtil.canBeReplaced(builder.world,pos.down(),false) && builder.info.railBedFill && builder.info.railBed.getItem() != Items.AIR);
  return BlockUtil.canBeReplaced(builder.world,pos,flexible || builder.overrideFlexible) && downOK;
}
Program: 171571
Project: 171571
Buggy source:
public static boolean canBeReplaced(World world,BlockPos pos,boolean allowFlex){
  Block block=world.getBlockState(pos).getBlock();
  if (block == null) {
    return true;
  }
  if (block.isReplaceable(world,pos)) {
    return true;
  }
  if (block instanceof BlockFlower || block == Blocks.DOUBLE_PLANT || block instanceof BlockMushroom) {
    return true;
  }
  if (block == ImmersiveRailroading.BLOCK_RAIL_PREVIEW) {
    return true;
  }
  if (allowFlex && block instanceof BlockRailBase) {
    TileRailBase te=(TileRailBase)world.getTileEntity(pos);
    return te.isFlexible();
  }
  return false;
}

Fixed version (ground truth):
public static boolean canBeReplaced(World world,BlockPos pos,boolean allowFlex){
  Block block=world.getBlockState(pos).getBlock();
  if (block == null) {
    return true;
  }
  if (block.isReplaceable(world,pos)) {
    return true;
  }
  if (block instanceof IGrowable && !(block instanceof BlockGrass)) {
    return true;
  }
  if (block instanceof BlockLiquid) {
    return true;
  }
  if (block == ImmersiveRailroading.BLOCK_RAIL_PREVIEW) {
    return true;
  }
  if (allowFlex && block instanceof BlockRailBase) {
    TileRailBase te=(TileRailBase)world.getTileEntity(pos);
    return te.isFlexible();
  }
  return false;
}
Program: 171572
Project: 171572
Buggy source:
@SubscribeEvent public static void onClick(MouseEvent event){
  if ((event.getButton() == 0 || event.getButton() == 1) && event.isButtonstate()) {
    Entity entity=Minecraft.getMinecraft().objectMouseOver.entityHit;
    if (entity != null && entity instanceof EntityRidableRollingStock) {
      ImmersiveRailroading.net.sendToServer(new MousePressPacket(event.getButton(),entity.world.provider.getDimension(),entity.getEntityId()));
      event.setCanceled(true);
      return;
    }
    Entity riding=Minecraft.getMinecraft().player.getRidingEntity();
    if (riding != null && riding instanceof EntityRidableRollingStock) {
      ImmersiveRailroading.net.sendToServer(new MousePressPacket(event.getButton(),riding.world.provider.getDimension(),riding.getEntityId()));
      event.setCanceled(true);
      return;
    }
  }
}

Fixed version (ground truth):
@SubscribeEvent public static void onClick(MouseEvent event){
  if ((event.getButton() == 0 || event.getButton() == 1) && event.isButtonstate()) {
    if (Minecraft.getMinecraft().objectMouseOver == null) {
      return;
    }
    Entity entity=Minecraft.getMinecraft().objectMouseOver.entityHit;
    if (entity != null && entity instanceof EntityRidableRollingStock) {
      ImmersiveRailroading.net.sendToServer(new MousePressPacket(event.getButton(),entity.world.provider.getDimension(),entity.getEntityId()));
      event.setCanceled(true);
      return;
    }
    Entity riding=Minecraft.getMinecraft().player.getRidingEntity();
    if (riding != null && riding instanceof EntityRidableRollingStock) {
      ImmersiveRailroading.net.sendToServer(new MousePressPacket(event.getButton(),riding.world.provider.getDimension(),riding.getEntityId()));
      event.setCanceled(true);
      return;
    }
  }
}
Program: 171573
Project: 171573
Buggy source:
@SubscribeEvent public static void onOverlayEvent(RenderGameOverlayEvent.Pre event){
  new SteamLocomotiveOverlay().draw();
  new DieselLocomotiveOverlay().draw();
}

Fixed version (ground truth):
@SubscribeEvent public static void onOverlayEvent(RenderGameOverlayEvent.Pre event){
  if (event.getType() == ElementType.CHAT) {
    new SteamLocomotiveOverlay().draw();
    new DieselLocomotiveOverlay().draw();
  }
}
Program: 171575
Project: 171575
Buggy source:
@Override public void onNeighborChange(IBlockAccess world,BlockPos pos,BlockPos neighbor){
  TileRailBase tileEntity=(TileRailBase)world.getTileEntity(pos);
  if (tileEntity.getWorld().isRemote) {
    System.out.println("String_Node_Str");
    return;
  }
  boolean isOriginAir=tileEntity.getParentTile() == null || tileEntity.getParentTile().getParentTile() == null;
  boolean isOnRealBlock=world.isSideSolid(pos.down(),EnumFacing.UP,false);
  if (isOriginAir || !isOnRealBlock) {
    if (tryBreakRail(world,pos)) {
      tileEntity.getWorld().destroyBlock(pos,true);
    }
    return;
  }
  IBlockState up=world.getBlockState(pos.up());
  if (up.getBlock() == Blocks.SNOW_LAYER) {
    tileEntity.getWorld().setBlockToAir(pos.up());
    tileEntity.handleSnowTick();
  }
  if (tileEntity.getParentTile() != null && tileEntity.getParentTile().getParentTile() != null) {
    tileEntity.getParentTile().setSwitchState(SwitchUtil.getSwitchState(tileEntity.getParentTile()));
  }
}

Fixed version (ground truth):
@Override public void onNeighborChange(IBlockAccess world,BlockPos pos,BlockPos neighbor){
  TileRailBase tileEntity=(TileRailBase)world.getTileEntity(pos);
  if (tileEntity.getWorld().isRemote) {
    System.out.println("String_Node_Str");
    return;
  }
  boolean isOriginAir=tileEntity.getParentTile() == null || tileEntity.getParentTile().getParentTile() == null;
  boolean isOnRealBlock=world.isSideSolid(pos.down(),EnumFacing.UP,false);
  if (isOriginAir || !isOnRealBlock) {
    if (tryBreakRail(world,pos)) {
      tileEntity.getWorld().destroyBlock(pos,true);
    }
    return;
  }
  IBlockState up=world.getBlockState(pos.up());
  if (up.getBlock() == Blocks.SNOW_LAYER) {
    tileEntity.getWorld().setBlockToAir(pos.up());
    tileEntity.handleSnowTick();
  }
  if (tileEntity.getParentTile() != null && tileEntity.getParentTile().getParentTile() != null) {
    SwitchState state=SwitchUtil.getSwitchState(tileEntity.getParentTile());
    if (state != SwitchState.NONE) {
      tileEntity.getParentTile().setSwitchState(state);
    }
  }
}
Program: 171577
Project: 171577
Buggy source:
@Override public void setDead(){
  this.decouple();
  super.setDead();
}

Fixed version (ground truth):
@Override public void setDead(){
  if (!world.isRemote) {
    try {
      throw new Exception("String_Node_Str");
    }
 catch (    Exception e) {
      ImmersiveRailroading.logger.catching(e);
    }
    this.decouple();
  }
  super.setDead();
}
Program: 171578
Project: 171578
Buggy source:
public static SwitchState getSwitchState(TileRail rail){
  TileRail parent=rail.getParentTile();
  if (rail.getType() != TrackItems.TURN) {
    return SwitchState.NONE;
  }
  if (parent.getType() != TrackItems.SWITCH) {
    return SwitchState.NONE;
  }
  for (  EnumFacing facing : EnumFacing.HORIZONTALS) {
    if (rail.getWorld().isBlockIndirectlyGettingPowered(new BlockPos(rail.getPlacementPosition()).offset(facing)) > 0) {
      return SwitchState.TURN;
    }
  }
  return SwitchState.STRAIGHT;
}

Fixed version (ground truth):
public static SwitchState getSwitchState(TileRail rail){
  if (rail == null) {
    return SwitchState.NONE;
  }
  if (!rail.isLoaded()) {
    return SwitchState.NONE;
  }
  TileRail parent=rail.getParentTile();
  if (parent == null || !parent.isLoaded()) {
    return SwitchState.NONE;
  }
  if (rail.getType() != TrackItems.TURN) {
    return SwitchState.NONE;
  }
  if (parent.getType() != TrackItems.SWITCH) {
    return SwitchState.NONE;
  }
  for (  EnumFacing facing : EnumFacing.HORIZONTALS) {
    if (rail.getWorld().isBlockIndirectlyGettingPowered(new BlockPos(rail.getPlacementPosition()).offset(facing)) > 0) {
      return SwitchState.TURN;
    }
  }
  return SwitchState.STRAIGHT;
}
Program: 171579
Project: 171579
Buggy source:
@Override public void getDrops(NonNullList<ItemStack> drops,IBlockAccess world,BlockPos pos,IBlockState state,int fortune){
  TileRail tileEntity=(TileRail)world.getTileEntity(pos);
  if (tileEntity != null) {
    ItemStack stack=new ItemStack(this,1,tileEntity.getType().getMeta());
    ItemRail.setLength(stack,tileEntity.getLength());
    drops.add(stack);
  }
}

Fixed version (ground truth):
@Override public void getDrops(NonNullList<ItemStack> drops,IBlockAccess world,BlockPos pos,IBlockState state,int fortune){
  TileRail tileEntity=(TileRail)world.getTileEntity(pos);
  if (tileEntity != null && tileEntity.getType() != null) {
    ItemStack stack=new ItemStack(this,1,tileEntity.getType().getMeta());
    ItemRail.setLength(stack,tileEntity.getLength());
    drops.add(stack);
  }
}
Program: 171580
Project: 171580
Buggy source:
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt){
  nbt.setByte("String_Node_Str",(byte)facing.getIndex());
  nbt.setString("String_Node_Str",type.name());
  setNBTVec3d(nbt,"String_Node_Str",center);
  nbt.setInteger("String_Node_Str",switchState.ordinal());
  setNBTVec3d(nbt,"String_Node_Str",placementPosition);
  nbt.setInteger("String_Node_Str",length);
  nbt.setInteger("String_Node_Str",rotationQuarter);
  nbt.setInteger("String_Node_Str",direction.ordinal());
  nbt.setInteger("String_Node_Str",turnQuarters);
  return super.writeToNBT(nbt);
}

Fixed version (ground truth):
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt){
  if (facing == null) {
    ImmersiveRailroading.logger.error("String_Node_Str");
    return super.writeToNBT(nbt);
  }
  nbt.setByte("String_Node_Str",(byte)facing.getIndex());
  nbt.setString("String_Node_Str",type.name());
  setNBTVec3d(nbt,"String_Node_Str",center);
  nbt.setInteger("String_Node_Str",switchState.ordinal());
  setNBTVec3d(nbt,"String_Node_Str",placementPosition);
  nbt.setInteger("String_Node_Str",length);
  nbt.setInteger("String_Node_Str",rotationQuarter);
  nbt.setInteger("String_Node_Str",direction.ordinal());
  nbt.setInteger("String_Node_Str",turnQuarters);
  return super.writeToNBT(nbt);
}
Program: 171582
Project: 171582
Buggy source:
@SubscribeEvent public static void onKeyInput(InputEvent.KeyInputEvent event){
  EntityPlayerSP player=Minecraft.getMinecraft().player;
  for (  KeyTypes key : KeyTypes.values()) {
    KeyBinding binding=keys.get(key);
    if (binding.isKeyDown()) {
      EntityRidableRollingStock riding=(EntityRidableRollingStock)player.getRidingEntity();
      if (riding != null) {
        ImmersiveRailroading.net.sendToServer(new KeyPressPacket(key,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
      }
    }
  }
}

Fixed version (ground truth):
@SubscribeEvent public static void onKeyInput(InputEvent.KeyInputEvent event){
  EntityPlayerSP player=Minecraft.getMinecraft().player;
  if (!player.isRiding()) {
    return;
  }
  if (!(player.getRidingEntity() instanceof EntityRidableRollingStock)) {
    return;
  }
  EntityRidableRollingStock riding=(EntityRidableRollingStock)player.getRidingEntity();
  for (  KeyTypes key : keys.keySet()) {
    KeyBinding binding=keys.get(key);
    if (binding.isKeyDown()) {
      ImmersiveRailroading.net.sendToServer(new KeyPressPacket(key,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
    }
  }
  if (player.movementInput.leftKeyDown) {
    ImmersiveRailroading.net.sendToServer(new KeyPressPacket(KeyTypes.PLAYER_LEFT,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
  }
  if (player.movementInput.rightKeyDown) {
    ImmersiveRailroading.net.sendToServer(new KeyPressPacket(KeyTypes.PLAYER_RIGHT,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
  }
  if (player.movementInput.forwardKeyDown) {
    ImmersiveRailroading.net.sendToServer(new KeyPressPacket(KeyTypes.PLAYER_FORWARD,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
  }
  if (player.movementInput.backKeyDown) {
    ImmersiveRailroading.net.sendToServer(new KeyPressPacket(KeyTypes.PLAYER_BACKWARD,riding.getEntityWorld().provider.getDimension(),player.getEntityId(),riding.getEntityId()));
  }
}
Program: 171583
Project: 171583
Buggy source:
@Override public void onNeighborChange(IBlockAccess world,BlockPos pos,BlockPos neighbor){
  TileRailBase tileEntity=(TileRailBase)world.getTileEntity(pos);
  boolean isOriginAir=tileEntity.getParent() == null || world.isAirBlock(tileEntity.getParent());
  boolean isOnRealBlock=world.isSideSolid(pos.down(),EnumFacing.UP,false);
  if (isOriginAir || !isOnRealBlock) {
    tileEntity.getWorld().destroyBlock(pos,true);
    return;
  }
  IBlockState up=world.getBlockState(pos.up());
  if (up.getBlock() == Blocks.SNOW_LAYER) {
    tileEntity.getWorld().setBlockToAir(pos.up());
    tileEntity.handleSnowTick();
  }
  tileEntity.getParentTile().setSwitchState(SwitchUtil.getSwitchState(tileEntity.getParentTile()));
}

Fixed version (ground truth):
@Override public void onNeighborChange(IBlockAccess world,BlockPos pos,BlockPos neighbor){
  TileRailBase tileEntity=(TileRailBase)world.getTileEntity(pos);
  boolean isOriginAir=tileEntity.getParentTile() == null || tileEntity.getParentTile().getParentTile() == null;
  boolean isOnRealBlock=world.isSideSolid(pos.down(),EnumFacing.UP,false);
  if (isOriginAir || !isOnRealBlock) {
    tileEntity.getWorld().destroyBlock(pos,true);
    return;
  }
  IBlockState up=world.getBlockState(pos.up());
  if (up.getBlock() == Blocks.SNOW_LAYER) {
    tileEntity.getWorld().setBlockToAir(pos.up());
    tileEntity.handleSnowTick();
  }
  if (tileEntity.getParentTile() != null && tileEntity.getParentTile().getParentTile() != null) {
    tileEntity.getParentTile().setSwitchState(SwitchUtil.getSwitchState(tileEntity.getParentTile()));
  }
}
Program: 171584
Project: 171584
Buggy source:
@Override public void onUpdate(){
  super.onUpdate();
  if (!this.world.isRemote && this.ticksExisted % 20 == 0) {
    this.sendToObserving(new MRSSyncPacket(this));
  }
  List<Entity> entitiesWithin=world.getEntitiesWithinAABB(Entity.class,this.getCollisionBoundingBox());
  for (  Entity entity : entitiesWithin) {
    if (entity instanceof EntityMoveableRollingStock) {
      continue;
    }
    if (entity.getRidingEntity() instanceof EntityMoveableRollingStock) {
      continue;
    }
    entity.motionX=this.motionX * 2;
    entity.motionY=0;
    entity.motionZ=this.motionZ * 2;
    entity.onUpdate();
    double speedDamage=this.getCurrentSpeed().metric() / Config.entitySpeedDamage;
    if (speedDamage > 1) {
      entity.attackEntityFrom((new DamageSource("String_Node_Str")).setDamageBypassesArmor(),(float)speedDamage);
    }
  }
  AxisAlignedBB bb=this.getCollisionBoundingBox();
  bb=bb.offset(0,this.getDefinition().getHeight() + 1,0);
  List<Entity> entitiesAbove=world.getEntitiesWithinAABB(Entity.class,bb);
  for (  Entity entity : entitiesAbove) {
    if (entity instanceof EntityMoveableRollingStock) {
      continue;
    }
    if (this.isPassenger(entity)) {
      continue;
    }
    Vec3d pos=entity.getPositionVector();
    pos=pos.addVector(this.motionX,this.motionY,this.motionZ);
    entity.setPosition(pos.x,pos.y,pos.z);
  }
}

Fixed version (ground truth):
@Override public void onUpdate(){
  super.onUpdate();
  if (!this.world.isRemote && this.ticksExisted % 20 == 0) {
    this.syncMRS();
  }
  List<Entity> entitiesWithin=world.getEntitiesWithinAABB(Entity.class,this.getCollisionBoundingBox());
  for (  Entity entity : entitiesWithin) {
    if (entity instanceof EntityMoveableRollingStock) {
      continue;
    }
    if (entity.getRidingEntity() instanceof EntityMoveableRollingStock) {
      continue;
    }
    entity.motionX=this.motionX * 2;
    entity.motionY=0;
    entity.motionZ=this.motionZ * 2;
    entity.onUpdate();
    double speedDamage=this.getCurrentSpeed().metric() / Config.entitySpeedDamage;
    if (speedDamage > 1) {
      entity.attackEntityFrom((new DamageSource("String_Node_Str")).setDamageBypassesArmor(),(float)speedDamage);
    }
  }
  AxisAlignedBB bb=this.getCollisionBoundingBox();
  bb=bb.offset(0,this.getDefinition().getHeight() + 1,0);
  List<Entity> entitiesAbove=world.getEntitiesWithinAABB(Entity.class,bb);
  for (  Entity entity : entitiesAbove) {
    if (entity instanceof EntityMoveableRollingStock) {
      continue;
    }
    if (this.isPassenger(entity)) {
      continue;
    }
    Vec3d pos=entity.getPositionVector();
    pos=pos.addVector(this.motionX,this.motionY,this.motionZ);
    entity.setPosition(pos.x,pos.y,pos.z);
  }
}
Program: 171585
Project: 171585
Buggy source:
@Override public EnumActionResult onItemUse(EntityPlayer player,World worldIn,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  ItemStack stack=player.getHeldItem(hand);
  TileEntity te=worldIn.getTileEntity(pos);
  if (te instanceof TileRailBase && !((TileRailBase)te).getParentTile().getType().isTurn()) {
    if (!worldIn.isRemote) {
      EntityRollingStockDefinition def=DefinitionManager.getDefinition(defFromStack(stack));
      EntityRollingStock stock=def.spawn(worldIn,pos.add(0,0.7,0),EnumFacing.fromAngle(player.rotationYawHead));
      if (stock instanceof EntityMoveableRollingStock) {
        ((EntityMoveableRollingStock)stock).moveRollingStock(stock.getDefinition().getCouplerPosition(CouplerType.BACK) - Config.couplerRange);
        ((EntityMoveableRollingStock)stock).zeroSpeed();
      }
    }
    return EnumActionResult.PASS;
  }
  if (worldIn.isRemote) {
    player.sendMessage(new TextComponentTranslation("String_Node_Str"));
  }
  return EnumActionResult.FAIL;
}

Fixed version (ground truth):
@Override public EnumActionResult onItemUse(EntityPlayer player,World worldIn,BlockPos pos,EnumHand hand,EnumFacing facing,float hitX,float hitY,float hitZ){
  ItemStack stack=player.getHeldItem(hand);
  TileEntity te=worldIn.getTileEntity(pos);
  if (te instanceof TileRailBase && !((TileRailBase)te).getParentTile().getType().isTurn()) {
    if (!worldIn.isRemote) {
      EntityRollingStockDefinition def=DefinitionManager.getDefinition(defFromStack(stack));
      EntityRollingStock stock=def.spawn(worldIn,pos.add(0,0.7,0),EnumFacing.fromAngle(player.rotationYawHead));
      if (stock instanceof EntityMoveableRollingStock) {
        ((EntityMoveableRollingStock)stock).moveRollingStock(stock.getDefinition().getCouplerPosition(CouplerType.BACK) - Config.couplerRange);
        ((EntityMoveableRollingStock)stock).zeroSpeed();
        ((EntityMoveableRollingStock)stock).syncMRS();
      }
    }
    return EnumActionResult.PASS;
  }
  if (worldIn.isRemote) {
    player.sendMessage(new TextComponentTranslation("String_Node_Str"));
  }
  return EnumActionResult.FAIL;
}
Program: 171586
Project: 171586
Buggy source:
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  if (nbttagcompound.hasKey("String_Node_Str")) {
    LinkFront=UUID.fromString(nbttagcompound.getString("String_Node_Str"));
    System.out.println("String_Node_Str");
  }
  if (nbttagcompound.hasKey("String_Node_Str")) {
    LinkBack=UUID.fromString(nbttagcompound.getString("String_Node_Str"));
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  if (nbttagcompound.hasKey("String_Node_Str")) {
    LinkFront=UUID.fromString(nbttagcompound.getString("String_Node_Str"));
    System.out.println(String.format("String_Node_Str",this.getPersistentID(),LinkFront));
  }
  if (nbttagcompound.hasKey("String_Node_Str")) {
    LinkBack=UUID.fromString(nbttagcompound.getString("String_Node_Str"));
    System.out.println(String.format("String_Node_Str",this.getPersistentID(),LinkBack));
  }
}
Program: 171587
Project: 171587
Buggy source:
private void recursiveMove(EntityLinkableRollingStock prev){
  for (  CouplerType coupler : CouplerType.values()) {
    EntityLinkableRollingStock coupled=this.getLinkedCart(coupler);
    Vec3d myOffset=this.getCouplerPosition(coupler);
    if (coupled == null || coupled == prev) {
      return;
    }
    Vec3d otherOffset=null;
    for (    CouplerType otherCoupler : CouplerType.values()) {
      if (coupled.getLinkedCart(otherCoupler) == this) {
        otherOffset=coupled.getCouplerPosition(otherCoupler);
      }
    }
    if (otherOffset == null) {
      ImmersiveRailroading.logger.warn("String_Node_Str",this.getPersistentID(),coupled.getPersistentID());
      return;
    }
    double distance=myOffset.distanceTo(otherOffset);
    if (distance > 1) {
      ImmersiveRailroading.logger.warn(String.format("String_Node_Str",this.getPersistentID(),coupled.getPersistentID()));
      ImmersiveRailroading.logger.warn(String.format("String_Node_Str",myOffset,otherOffset));
      return;
    }
    Vec3d nextPosForward=otherOffset.add(VecUtil.fromYaw(distance,coupled.rotationYaw));
    Vec3d nextPosReverse=otherOffset.add(VecUtil.fromYaw(-distance,coupled.rotationYaw));
    if (myOffset.distanceTo(nextPosForward) > myOffset.distanceTo(nextPosReverse)) {
      distance=-distance;
    }
    coupled.moveRollingStock(distance);
    coupled.recursiveMove(this);
  }
}

Fixed version (ground truth):
private void recursiveMove(EntityLinkableRollingStock prev){
  for (  CouplerType coupler : CouplerType.values()) {
    EntityLinkableRollingStock coupled=this.getLinkedCart(coupler);
    Vec3d myOffset=this.getCouplerPosition(coupler);
    if (coupled == null || coupled == prev) {
      continue;
    }
    Vec3d otherOffset=null;
    for (    CouplerType otherCoupler : CouplerType.values()) {
      if (coupled.getLinkedCart(otherCoupler) == this) {
        otherOffset=coupled.getCouplerPosition(otherCoupler);
      }
    }
    if (otherOffset == null) {
      ImmersiveRailroading.logger.warn("String_Node_Str",this.getPersistentID(),coupled.getPersistentID());
      continue;
    }
    double distance=myOffset.distanceTo(otherOffset);
    if (distance > 1) {
    }
    Vec3d nextPosForward=otherOffset.add(VecUtil.fromYaw(distance,coupled.rotationYaw));
    Vec3d nextPosReverse=otherOffset.add(VecUtil.fromYaw(-distance,coupled.rotationYaw));
    if (myOffset.distanceTo(nextPosForward) > myOffset.distanceTo(nextPosReverse)) {
      distance=-distance;
    }
    coupled.moveRollingStock(distance);
    coupled.recursiveMove(this);
  }
}
Program: 171588
Project: 171588
Buggy source:
@Override public void onUpdate(){
  super.onUpdate();
  for (  CouplerType coupler : CouplerType.values()) {
    if (!this.isLinked(coupler)) {
      for (      EntityLinkableRollingStock potentialLink : this.potentialLinks(coupler)) {
        for (        CouplerType potentialCoupler : CouplerType.values()) {
          if (!potentialLink.isLinked(potentialCoupler)) {
            if (potentialLink.potentialLinks(potentialCoupler).contains(this)) {
              System.out.println(String.format("String_Node_Str",this.getPersistentID(),potentialLink.getPersistentID()));
              this.setCoupledUUID(coupler,potentialLink.getPersistentID());
              this.setCoupledCart(coupler,potentialLink);
              potentialLink.setCoupledUUID(potentialCoupler,this.getPersistentID());
              potentialLink.setCoupledCart(potentialCoupler,this);
            }
          }
        }
        if (this.isLinked(coupler)) {
          break;
        }
        ImmersiveRailroading.logger.info(String.format("String_Node_Str",coupler,this.getPersistentID(),potentialLink.getPersistentID()));
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onUpdate(){
  super.onUpdate();
  for (  CouplerType coupler : CouplerType.values()) {
    if (!this.isLinked(coupler)) {
      for (      EntityLinkableRollingStock potentialLink : this.potentialLinks(coupler)) {
        for (        CouplerType potentialCoupler : CouplerType.values()) {
          if (!potentialLink.isLinked(potentialCoupler)) {
            if (potentialLink.potentialLinks(potentialCoupler).contains(this)) {
              System.out.println(String.format("String_Node_Str",this.getPersistentID(),potentialLink.getPersistentID()));
              this.setCoupledUUID(coupler,potentialLink.getPersistentID());
              this.setCoupledCart(coupler,potentialLink);
              potentialLink.setCoupledUUID(potentialCoupler,this.getPersistentID());
              potentialLink.setCoupledCart(potentialCoupler,this);
              break;
            }
          }
        }
        if (this.isLinked(coupler)) {
          break;
        }
        ImmersiveRailroading.logger.info(String.format("String_Node_Str",coupler,this.getPersistentID(),potentialLink.getPersistentID()));
      }
    }
  }
}
Program: 171589
Project: 171589
Buggy source:
public static EntityLinkableRollingStock findByUUID(World world,UUID uuid){
  for (  Object e : world.getLoadedEntityList()) {
    if (e instanceof EntityLinkableRollingStock) {
      EntityLinkableRollingStock train=(EntityLinkableRollingStock)e;
      if (train.getPersistentID() == uuid) {
        return train;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public static EntityLinkableRollingStock findByUUID(World world,UUID uuid){
  for (  Object e : world.getLoadedEntityList()) {
    if (e instanceof EntityLinkableRollingStock) {
      EntityLinkableRollingStock train=(EntityLinkableRollingStock)e;
      if (train.getPersistentID().equals(uuid)) {
        return train;
      }
    }
  }
  return null;
}
Program: 171590
Project: 171590
Buggy source:
@Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){
  super.writeEntityToNBT(nbttagcompound);
  nbttagcompound.setFloat("String_Node_Str",frontYaw);
  nbttagcompound.setFloat("String_Node_Str",rearYaw);
}

Fixed version (ground truth):
@Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){
  super.writeEntityToNBT(nbttagcompound);
  if (frontYaw != null) {
    nbttagcompound.setFloat("String_Node_Str",frontYaw);
  }
  if (rearYaw != null) {
    nbttagcompound.setFloat("String_Node_Str",rearYaw);
  }
}
Program: 171591
Project: 171591
Buggy source:
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  frontYaw=nbttagcompound.getFloat("String_Node_Str");
  rearYaw=nbttagcompound.getFloat("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  if (nbttagcompound.hasKey("String_Node_Str")) {
    frontYaw=nbttagcompound.getFloat("String_Node_Str");
  }
  if (nbttagcompound.hasKey("String_Node_Str")) {
    rearYaw=nbttagcompound.getFloat("String_Node_Str");
  }
}
Program: 171592
Project: 171592
Buggy source:
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  cargoItems.setSize(this.getInventorySize());
  cargoItems.deserializeNBT((NBTTagCompound)nbttagcompound.getTag("String_Node_Str"));
  handleMass();
}

Fixed version (ground truth):
@Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound){
  super.readEntityFromNBT(nbttagcompound);
  cargoItems.setSize(this.getInventorySize());
  cargoItems.deserializeNBT((NBTTagCompound)nbttagcompound.getTag("String_Node_Str"));
}
Program: 171593
Project: 171593
Buggy source:
@Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){
  super.writeEntityToNBT(nbttagcompound);
  this.theTank.writeToNBT(nbttagcompound.getCompoundTag("String_Node_Str"));
}

Fixed version (ground truth):
@Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound){
  super.writeEntityToNBT(nbttagcompound);
  if (theTank != null) {
    this.theTank.writeToNBT(nbttagcompound.getCompoundTag("String_Node_Str"));
  }
}