nus-yam/ex-repair huggingface dataset:
Program: 27529
Project: 27529
Buggy source:
public static SpawnEntityEvent callEntityJoinWorldEvent(Event event){
  SpawnEntityEvent spongeEvent=(SpawnEntityEvent)event;
  ListIterator<org.spongepowered.api.entity.Entity> iterator=spongeEvent.getEntities().listIterator();
  if (spongeEvent.getEntities().size() == 0) {
    return spongeEvent;
  }
  boolean canCancelEvent=true;
  while (iterator.hasNext()) {
    org.spongepowered.api.entity.Entity entity=iterator.next();
    EntityJoinWorldEvent forgeEvent=new EntityJoinWorldEvent((Entity)entity,(net.minecraft.world.World)entity.getLocation().getExtent());
    boolean prev=StaticMixinForgeHelper.preventInternalForgeEntityListener;
    StaticMixinForgeHelper.preventInternalForgeEntityListener=true;
    ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
    StaticMixinForgeHelper.preventInternalForgeEntityListener=prev;
    Entity mcEntity=(Entity)entity;
    if (mcEntity.isDead) {
      canCancelEvent=false;
    }
    if (forgeEvent.isCanceled()) {
      iterator.remove();
    }
  }
  if (spongeEvent.getEntities().size() == 0 && canCancelEvent) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}

Fixed version (ground truth):
private static SpawnEntityEvent callEntityJoinWorldEvent(Event event){
  SpawnEntityEvent spongeEvent=(SpawnEntityEvent)event;
  ListIterator<org.spongepowered.api.entity.Entity> iterator=spongeEvent.getEntities().listIterator();
  if (spongeEvent.getEntities().isEmpty()) {
    return spongeEvent;
  }
  boolean canCancelEvent=true;
  while (iterator.hasNext()) {
    org.spongepowered.api.entity.Entity entity=iterator.next();
    EntityJoinWorldEvent forgeEvent=new EntityJoinWorldEvent((Entity)entity,(net.minecraft.world.World)entity.getLocation().getExtent());
    boolean prev=StaticMixinForgeHelper.preventInternalForgeEntityListener;
    StaticMixinForgeHelper.preventInternalForgeEntityListener=true;
    ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
    StaticMixinForgeHelper.preventInternalForgeEntityListener=prev;
    Entity mcEntity=(Entity)entity;
    if (mcEntity.isDead) {
      canCancelEvent=false;
    }
    if (forgeEvent.isCanceled()) {
      iterator.remove();
    }
  }
  if (spongeEvent.getEntities().isEmpty() && canCancelEvent) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}
Program: 27530
Project: 27530
Buggy source:
public static NotifyNeighborBlockEvent callNeighborNotifyEvent(Event event){
  NotifyNeighborBlockEvent spongeEvent=(NotifyNeighborBlockEvent)event;
  LocatableBlock locatableBlock=spongeEvent.getCause().first(LocatableBlock.class).orElse(null);
  TileEntity tileEntitySource=spongeEvent.getCause().first(TileEntity.class).orElse(null);
  Location<World> sourceLocation=null;
  IBlockState state=null;
  if (locatableBlock != null) {
    Location<World> location=locatableBlock.getLocation();
    sourceLocation=location;
    state=(IBlockState)locatableBlock.getBlockState();
  }
 else   if (tileEntitySource != null) {
    sourceLocation=tileEntitySource.getLocation();
    state=(IBlockState)sourceLocation.getBlock();
  }
 else {
    return spongeEvent;
  }
  EnumSet<EnumFacing> facings=EnumSet.noneOf(EnumFacing.class);
  for (  Map.Entry<Direction,BlockState> mapEntry : spongeEvent.getNeighbors().entrySet()) {
    if (mapEntry.getKey() != Direction.NONE) {
      facings.add(DirectionFacingProvider.getInstance().get(mapEntry.getKey()).get());
    }
  }
  if (facings.isEmpty()) {
    return spongeEvent;
  }
  BlockPos pos=((IMixinLocation)(Object)sourceLocation).getBlockPos();
  net.minecraft.world.World world=(net.minecraft.world.World)sourceLocation.getExtent();
  final NeighborNotifyEvent forgeEvent=new NeighborNotifyEvent(world,pos,state,facings,false);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}

Fixed version (ground truth):
private static NotifyNeighborBlockEvent callNeighborNotifyEvent(Event event){
  NotifyNeighborBlockEvent spongeEvent=(NotifyNeighborBlockEvent)event;
  LocatableBlock locatableBlock=spongeEvent.getCause().first(LocatableBlock.class).orElse(null);
  TileEntity tileEntitySource=spongeEvent.getCause().first(TileEntity.class).orElse(null);
  Location<World> sourceLocation;
  IBlockState state;
  if (locatableBlock != null) {
    sourceLocation=locatableBlock.getLocation();
    state=(IBlockState)locatableBlock.getBlockState();
  }
 else   if (tileEntitySource != null) {
    sourceLocation=tileEntitySource.getLocation();
    state=(IBlockState)sourceLocation.getBlock();
  }
 else {
    return spongeEvent;
  }
  EnumSet<EnumFacing> facings=EnumSet.noneOf(EnumFacing.class);
  for (  Map.Entry<Direction,BlockState> mapEntry : spongeEvent.getNeighbors().entrySet()) {
    if (mapEntry.getKey() != Direction.NONE) {
      facings.add(DirectionFacingProvider.getInstance().get(mapEntry.getKey()).get());
    }
  }
  if (facings.isEmpty()) {
    return spongeEvent;
  }
  BlockPos pos=((IMixinLocation)(Object)sourceLocation).getBlockPos();
  net.minecraft.world.World world=(net.minecraft.world.World)sourceLocation.getExtent();
  final NeighborNotifyEvent forgeEvent=new NeighborNotifyEvent(world,pos,state,facings,false);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
  return spongeEvent;
}
Program: 27531
Project: 27531
Buggy source:
public static SleepingEvent.Pre createSleepingEventPre(PlayerSleepInBedEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getEntity().getEntityWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  BlockSnapshot bedSnapshot=((World)world).createSnapshot(pos.getX(),pos.getY(),pos.getZ());
  Sponge.getCauseStackManager().pushCause(forgeEvent.getEntity());
  return SpongeEventFactory.createSleepingEventPre(Sponge.getCauseStackManager().getCurrentCause(),bedSnapshot,(org.spongepowered.api.entity.Entity)forgeEvent.getEntity());
}

Fixed version (ground truth):
private static SleepingEvent.Pre createSleepingEventPre(PlayerSleepInBedEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getEntity().getEntityWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  BlockSnapshot bedSnapshot=((World)world).createSnapshot(pos.getX(),pos.getY(),pos.getZ());
  Sponge.getCauseStackManager().pushCause(forgeEvent.getEntity());
  return SpongeEventFactory.createSleepingEventPre(Sponge.getCauseStackManager().getCurrentCause(),bedSnapshot,(org.spongepowered.api.entity.Entity)forgeEvent.getEntity());
}
Program: 27533
Project: 27533
Buggy source:
public static MessageChannelEvent.Chat createMessageChannelEventChat(ServerChatEvent forgeEvent){
  final ITextComponent forgeComponent=forgeEvent.getComponent();
  final MessageFormatter formatter=new MessageFormatter();
  MessageChannel channel;
  Text[] chat=SpongeTexts.splitChatMessage((TextComponentTranslation)forgeComponent);
  if (chat[1] == null) {
    chat[1]=chat[0] != null ? chat[0] : SpongeTexts.toText(forgeComponent);
    chat[0]=null;
  }
  if (chat[0] != null) {
    formatter.getHeader().add(new DefaultHeaderApplier(chat[0]));
  }
  formatter.getBody().add(new DefaultBodyApplier(chat[1]));
  Text rawSpongeMessage=Text.of(forgeEvent.getMessage());
  MessageChannel originalChannel=channel=((Player)forgeEvent.getPlayer()).getMessageChannel();
  Sponge.getCauseStackManager().pushCause(forgeEvent.getPlayer());
  return SpongeEventFactory.createMessageChannelEventChat(Sponge.getCauseStackManager().getCurrentCause(),originalChannel,Optional.ofNullable(channel),formatter,rawSpongeMessage,false);
}

Fixed version (ground truth):
private static MessageChannelEvent.Chat createMessageChannelEventChat(ServerChatEvent forgeEvent){
  final ITextComponent forgeComponent=forgeEvent.getComponent();
  final MessageFormatter formatter=new MessageFormatter();
  MessageChannel channel;
  Text[] chat=SpongeTexts.splitChatMessage((TextComponentTranslation)forgeComponent);
  if (chat[1] == null) {
    chat[1]=chat[0] != null ? chat[0] : SpongeTexts.toText(forgeComponent);
    chat[0]=null;
  }
  if (chat[0] != null) {
    formatter.getHeader().add(new DefaultHeaderApplier(chat[0]));
  }
  formatter.getBody().add(new DefaultBodyApplier(chat[1]));
  Text rawSpongeMessage=Text.of(forgeEvent.getMessage());
  MessageChannel originalChannel=channel=((Player)forgeEvent.getPlayer()).getMessageChannel();
  Sponge.getCauseStackManager().pushCause(forgeEvent.getPlayer());
  return SpongeEventFactory.createMessageChannelEventChat(Sponge.getCauseStackManager().getCurrentCause(),originalChannel,Optional.ofNullable(channel),formatter,rawSpongeMessage,false);
}
Program: 27534
Project: 27534
Buggy source:
@Override public boolean post(Event spongeEvent,boolean allowClientThread){
  if (!allowClientThread & Sponge.getGame().getPlatform().getExecutionType().isClient()) {
    return false;
  }
  final boolean useCauseStackManager=shouldUseCauseStackManager(allowClientThread);
  if (spongeEvent.getClass().getInterfaces().length > 0) {
    Class<? extends net.minecraftforge.fml.common.eventhandler.Event> clazz=SpongeForgeEventFactory.getForgeEventClass(spongeEvent);
    if (clazz != null) {
      return post(spongeEvent,clazz,useCauseStackManager);
    }
  }
  return post(spongeEvent,getHandlerCache(spongeEvent).getListeners(),false,true,useCauseStackManager);
}

Fixed version (ground truth):
@Override public boolean post(Event spongeEvent,boolean allowClientThread){
  this.extendedPost(spongeEvent,allowClientThread);
  return spongeEvent instanceof Cancellable && ((Cancellable)spongeEvent).isCancelled();
}
Program: 27535
Project: 27535
Buggy source:
/** 
 * @author
 * @reason Forge compatibility
 */
@Overwrite public static void registerPortalAgentType(@Nullable Teleporter teleporter){
  if (teleporter == null) {
    return;
  }
  if (PortalAgentTypes.DEFAULT.equals(((PortalAgent)teleporter).getType())) {
    return;
  }
  PortalAgentRegistryModule.getInstance().validatePortalAgent(teleporter);
}

Fixed version (ground truth):
/** 
 * @author
 * @reason Forge compatibility
 */
@Overwrite public static void registerPortalAgentType(@Nullable IMixinITeleporter teleporter){
  if (teleporter == null) {
    return;
  }
  if (PortalAgentTypes.DEFAULT.equals(((PortalAgent)teleporter).getType())) {
    return;
  }
  PortalAgentRegistryModule.getInstance().validatePortalAgent(teleporter);
}
Program: 27536
Project: 27536
Buggy source:
@Inject(method="String_Node_Str",at=@At("String_Node_Str"),cancellable=true) public void onGetWorldDirectory(CallbackInfoReturnable<File> cir){
  final ModContainer activeContainer=Loader.instance().activeModContainer();
  if ((activeContainer != null && activeContainer != SpongeMod.instance && !(activeContainer instanceof PluginContainerExtension))) {
    if (this.modWorldDirectory != null) {
      cir.setReturnValue(this.modWorldDirectory);
    }
 else {
      this.modWorldDirectory=new File("String_Node_Str",Sponge.getServer().getDefaultWorldName());
      cir.setReturnValue(this.modWorldDirectory);
    }
  }
}

Fixed version (ground truth):
@Inject(method="String_Node_Str",at=@At("String_Node_Str"),cancellable=true) public void onGetWorldDirectory(CallbackInfoReturnable<File> cir){
  final ModContainer activeContainer=Loader.instance().activeModContainer();
  if ((activeContainer != null && activeContainer != SpongeMod.instance && !(activeContainer instanceof PluginContainerExtension))) {
    if (this.modWorldDirectory != null) {
      cir.setReturnValue(this.modWorldDirectory);
    }
 else {
      final String defaultWorldName=Sponge.getServer().getDefaultWorldName();
      final String defaultWorldPath=Sponge.getPlatform().getType().isClient() ? "String_Node_Str" + File.separator + defaultWorldName : defaultWorldName;
      this.modWorldDirectory=SpongeImpl.getGameDir().resolve(defaultWorldPath).toFile();
      cir.setReturnValue(this.modWorldDirectory);
    }
  }
}
Program: 27537
Project: 27537
Buggy source:
@Subscribe public void onStateEvent(FMLStateEvent event){
  if (!event.getClass().equals(FMLConstructionEvent.class)) {
    SpongeImpl.getGame().getEventManager().post((Event)event);
  }
}

Fixed version (ground truth):
@Subscribe public void onStateEvent(FMLStateEvent event){
  if (!event.getClass().equals(FMLConstructionEvent.class)) {
    SpongeImpl.postEvent((Event)event,true);
  }
}
Program: 27538
Project: 27538
Buggy source:
@Override public boolean post(Event spongeEvent){
  if (spongeEvent.getClass().getInterfaces().length > 0) {
    Class<? extends net.minecraftforge.fml.common.eventhandler.Event> clazz=SpongeForgeEventFactory.getForgeEventClass(spongeEvent);
    if (clazz != null) {
      return post(spongeEvent,clazz);
    }
  }
  return post(spongeEvent,getHandlerCache(spongeEvent).getListeners(),false,true);
}

Fixed version (ground truth):
@Override public boolean post(Event spongeEvent,boolean allowClientThread){
  if (!allowClientThread & Sponge.getGame().getPlatform().getExecutionType().isClient()) {
    return false;
  }
  final boolean useCauseStackManager=shouldUseCauseStackManager(allowClientThread);
  if (spongeEvent.getClass().getInterfaces().length > 0) {
    Class<? extends net.minecraftforge.fml.common.eventhandler.Event> clazz=SpongeForgeEventFactory.getForgeEventClass(spongeEvent);
    if (clazz != null) {
      return post(spongeEvent,clazz,useCauseStackManager);
    }
  }
  return post(spongeEvent,getHandlerCache(spongeEvent).getListeners(),false,true,useCauseStackManager);
}
Program: 27540
Project: 27540
Buggy source:
@Override public org.spongepowered.api.event.Event postForgeAndCreateSpongeEvent(Event forgeEvent){
  org.spongepowered.api.event.Event spongeEvent;
  try (final CauseStackManager.StackFrame frame=Sponge.getCauseStackManager().pushCauseFrame()){
    spongeEvent=SpongeForgeEventFactory.createSpongeEvent(forgeEvent);
    IEventListener[] listeners=forgeEvent.getListenerList().getListeners(this.busID);
    boolean cancelled=((SpongeModEventManager)SpongeImpl.getGame().getEventManager()).post(spongeEvent,forgeEvent,listeners);
    if (!cancelled) {
      SpongeForgeEventFactory.onForgePost(forgeEvent);
    }
  }
   return spongeEvent;
}

Fixed version (ground truth):
@Override public org.spongepowered.api.event.Event postForgeAndCreateSpongeEvent(Event forgeEvent){
  org.spongepowered.api.event.Event spongeEvent;
  try (final CauseStackManager.StackFrame frame=Sponge.getCauseStackManager().pushCauseFrame()){
    spongeEvent=SpongeForgeEventFactory.createSpongeEvent(forgeEvent);
    IEventListener[] listeners=forgeEvent.getListenerList().getListeners(this.busID);
    boolean cancelled=((SpongeModEventManager)SpongeImpl.getGame().getEventManager()).post(spongeEvent,forgeEvent,listeners,true);
    if (!cancelled) {
      SpongeForgeEventFactory.onForgePost(forgeEvent);
    }
  }
   return spongeEvent;
}
Program: 27541
Project: 27541
Buggy source:
public static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  return SpongeEventFactory.createLoadChunkEvent(Cause.of(NamedCause.source(forgeEvent.getWorld())),(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
public static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  return SpongeEventFactory.createLoadChunkEvent(Sponge.getCauseStackManager().getCurrentCause(),(Chunk)forgeEvent.getChunk());
}
Program: 27543
Project: 27543
Buggy source:
@SuppressWarnings("String_Node_Str") public static DropItemEvent.Destruct callLivingDropsEvent(Event event){
  DropItemEvent.Destruct spongeEvent=(DropItemEvent.Destruct)event;
  Object source=spongeEvent.getCause().root();
  Optional<DamageSource> damageSource=spongeEvent.getCause().first(DamageSource.class);
  if (!(source instanceof EntitySpawnCause) || !damageSource.isPresent()) {
    callEntityJoinWorldEvent(spongeEvent);
    return spongeEvent;
  }
  EntitySpawnCause spawnCause=(EntitySpawnCause)source;
  Entity entity=EntityUtil.toNative(spawnCause.getEntity());
  if (entity == null || !(entity instanceof EntityLivingBase)) {
    return spongeEvent;
  }
  LivingDropsEvent forgeEvent=null;
  if (entity instanceof EntityPlayer) {
    EntityPlayer player=(EntityPlayer)entity;
    forgeEvent=new PlayerDropsEvent(player,(net.minecraft.util.DamageSource)damageSource.get(),(List<EntityItem>)(List<?>)spongeEvent.getEntities(),((IMixinEntityLivingBase)entity).getRecentlyHit() > 0);
  }
 else {
    forgeEvent=new LivingDropsEvent((EntityLivingBase)entity,(net.minecraft.util.DamageSource)damageSource.get(),(List<EntityItem>)(List<?>)spongeEvent.getEntities(),0,((IMixinEntityLivingBase)entity).getRecentlyHit() > 0);
  }
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
 else {
    callEntityJoinWorldEvent(spongeEvent);
  }
  return spongeEvent;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static DropItemEvent.Destruct callLivingDropsEvent(Event event){
  DropItemEvent.Destruct spongeEvent=(DropItemEvent.Destruct)event;
  final Cause cause=spongeEvent.getCause();
  Object source=cause.root();
  Optional<DamageSource> damageSource=cause.first(DamageSource.class);
  final Optional<Entity> spawnEntity=cause.first(Entity.class);
  final Optional<SpawnType> spawnType=cause.getContext().get(EventContextKeys.SPAWN_TYPE);
  if (!spawnType.isPresent() || !damageSource.isPresent() || !spawnEntity.isPresent()) {
    callEntityJoinWorldEvent(spongeEvent);
    return spongeEvent;
  }
  Entity entity=spawnEntity.get();
  if (entity == null || !(entity instanceof EntityLivingBase)) {
    return spongeEvent;
  }
  LivingDropsEvent forgeEvent=null;
  if (entity instanceof EntityPlayer) {
    EntityPlayer player=(EntityPlayer)entity;
    forgeEvent=new PlayerDropsEvent(player,(net.minecraft.util.DamageSource)damageSource.get(),(List<EntityItem>)(List<?>)spongeEvent.getEntities(),((IMixinEntityLivingBase)entity).getRecentlyHit() > 0);
  }
 else {
    forgeEvent=new LivingDropsEvent((EntityLivingBase)entity,(net.minecraft.util.DamageSource)damageSource.get(),(List<EntityItem>)(List<?>)spongeEvent.getEntities(),0,((IMixinEntityLivingBase)entity).getRecentlyHit() > 0);
  }
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    spongeEvent.setCancelled(true);
  }
 else {
    callEntityJoinWorldEvent(spongeEvent);
  }
  return spongeEvent;
}
Program: 27544
Project: 27544
Buggy source:
public static DropItemEvent.Dispense callItemTossEvent(Event event){
  DropItemEvent.Dispense spongeEvent=(DropItemEvent.Dispense)event;
  Object source=spongeEvent.getCause().root();
  if (spongeEvent.getEntities().size() <= 0) {
    return spongeEvent;
  }
  if (!(source instanceof EntitySpawnCause)) {
    callEntityJoinWorldEvent(spongeEvent);
    return spongeEvent;
  }
  EntitySpawnCause spawnCause=(EntitySpawnCause)source;
  Entity entity=EntityUtil.toNative(spawnCause.getEntity());
  EntityItem item=(EntityItem)spongeEvent.getEntities().get(0);
  if (entity == null || item == null || item.getItem() == null || !(entity instanceof Player)) {
    return spongeEvent;
  }
  ItemTossEvent forgeEvent=new ItemTossEvent(item,(EntityPlayerMP)entity);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    if (item.isDead) {
      return spongeEvent;
    }
    spongeEvent.setCancelled(true);
  }
 else {
    callEntityJoinWorldEvent(spongeEvent);
  }
  return spongeEvent;
}

Fixed version (ground truth):
public static DropItemEvent.Dispense callItemTossEvent(Event event){
  DropItemEvent.Dispense spongeEvent=(DropItemEvent.Dispense)event;
  if (spongeEvent.getEntities().size() <= 0) {
    return spongeEvent;
  }
  final Cause cause=spongeEvent.getCause();
  Object source=cause.root();
  Optional<DamageSource> damageSource=cause.first(DamageSource.class);
  final Optional<Entity> spawnEntity=cause.first(Entity.class);
  final Optional<SpawnType> spawnType=cause.getContext().get(EventContextKeys.SPAWN_TYPE);
  if (!spawnType.isPresent() || !damageSource.isPresent() || !spawnEntity.isPresent()) {
    callEntityJoinWorldEvent(spongeEvent);
    return spongeEvent;
  }
  Entity entity=spawnEntity.get();
  EntityItem item=(EntityItem)spongeEvent.getEntities().get(0);
  if (entity == null || item == null || item.getItem() == null || !(entity instanceof Player)) {
    return spongeEvent;
  }
  ItemTossEvent forgeEvent=new ItemTossEvent(item,(EntityPlayerMP)entity);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(forgeEvent,true);
  if (forgeEvent.isCanceled()) {
    if (item.isDead) {
      return spongeEvent;
    }
    spongeEvent.setCancelled(true);
  }
 else {
    callEntityJoinWorldEvent(spongeEvent);
  }
  return spongeEvent;
}
Program: 27546
Project: 27546
Buggy source:
public static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  return SpongeEventFactory.createUnloadChunkEvent(Cause.of(NamedCause.source(forgeEvent.getWorld())),(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
public static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  return SpongeEventFactory.createUnloadChunkEvent(Sponge.getCauseStackManager().getCurrentCause(),(Chunk)forgeEvent.getChunk());
}
Program: 27547
Project: 27547
Buggy source:
public static ChangeBlockEvent.Pre createChangeBlockEventPre(BlockEvent.BreakEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  final CauseTracker causeTracker=CauseTracker.getInstance();
  final PhaseData data=causeTracker.getCurrentPhaseData();
  Cause.Builder builder=null;
  User owner=data.context.getOwner().orElse(null);
  User notifier=data.context.getNotifier().orElse(null);
  EntityPlayer player=forgeEvent.getPlayer();
  if (SpongeImplHooks.isFakePlayer(player)) {
    if (owner != null) {
      builder=Cause.source(owner);
      builder.named(NamedCause.FAKE_PLAYER,player);
    }
 else     if (notifier != null) {
      builder=Cause.source(notifier);
      builder.named(NamedCause.FAKE_PLAYER,player);
    }
 else {
      builder=Cause.builder().named(NamedCause.FAKE_PLAYER,player);
    }
  }
  if (builder == null) {
    builder=Cause.source(player);
  }
  if (owner != null) {
    builder.owner(owner);
  }
  if (notifier != null) {
    builder.notifier(notifier);
  }
  builder.named(NamedCause.PLAYER_BREAK,world);
  ChangeBlockEvent.Pre spongeEvent=SpongeEventFactory.createChangeBlockEventPre(builder.build(),ImmutableList.of(new Location<>((World)world,pos.getX(),pos.getY(),pos.getZ())));
  return spongeEvent;
}

Fixed version (ground truth):
public static ChangeBlockEvent.Pre createChangeBlockEventPre(BlockEvent.BreakEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  final CauseTracker causeTracker=CauseTracker.getInstance();
  final PhaseData data=causeTracker.getCurrentPhaseData();
  User owner=data.context.getOwner().orElse(null);
  User notifier=data.context.getNotifier().orElse(null);
  EntityPlayer player=forgeEvent.getPlayer();
  if (SpongeImplHooks.isFakePlayer(player)) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.FAKE_PLAYER,EntityUtil.toPlayer(player));
  }
  Sponge.getCauseStackManager().pushCause(player);
  if (owner != null) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.OWNER,owner);
  }
  if (notifier != null) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.NOTIFIER,notifier);
  }
  Sponge.getCauseStackManager().addContext(EventContextKeys.PLAYER_BREAK,(World)world);
  return SpongeEventFactory.createChangeBlockEventPre(Sponge.getCauseStackManager().getCurrentCause(),ImmutableList.of(new Location<>((World)world,pos.getX(),pos.getY(),pos.getZ())));
}
Program: 27548
Project: 27548
Buggy source:
public static ChangeBlockEvent.Place createChangeBlockEventPlace(BlockEvent.MultiPlaceEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getWorld();
  if (world.isRemote) {
    return null;
  }
  ImmutableList.Builder<Transaction<BlockSnapshot>> builder=new ImmutableList.Builder<Transaction<BlockSnapshot>>();
  for (  net.minecraftforge.common.util.BlockSnapshot blockSnapshot : forgeEvent.getReplacedBlockSnapshots()) {
    final BlockPos snapshotPos=blockSnapshot.getPos();
    BlockSnapshot originalSnapshot=((IMixinBlockSnapshot)blockSnapshot).createSpongeBlockSnapshot();
    BlockSnapshot finalSnapshot=((World)world).createSnapshot(snapshotPos.getX(),snapshotPos.getY(),snapshotPos.getZ());
    builder.add(new Transaction<>(originalSnapshot,finalSnapshot));
  }
  ChangeBlockEvent.Place spongeEvent=SpongeEventFactory.createChangeBlockEventPlace(Cause.source(forgeEvent.getPlayer()).build(),builder.build());
  return spongeEvent;
}

Fixed version (ground truth):
public static ChangeBlockEvent.Place createChangeBlockEventPlace(BlockEvent.MultiPlaceEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getWorld();
  if (world.isRemote) {
    return null;
  }
  ImmutableList.Builder<Transaction<BlockSnapshot>> builder=new ImmutableList.Builder<Transaction<BlockSnapshot>>();
  for (  net.minecraftforge.common.util.BlockSnapshot blockSnapshot : forgeEvent.getReplacedBlockSnapshots()) {
    final BlockPos snapshotPos=blockSnapshot.getPos();
    BlockSnapshot originalSnapshot=((IMixinBlockSnapshot)blockSnapshot).createSpongeBlockSnapshot();
    BlockSnapshot finalSnapshot=((World)world).createSnapshot(snapshotPos.getX(),snapshotPos.getY(),snapshotPos.getZ());
    builder.add(new Transaction<>(originalSnapshot,finalSnapshot));
  }
  Sponge.getCauseStackManager().pushCause(forgeEvent.getPlayer());
  return SpongeEventFactory.createChangeBlockEventPlace(Sponge.getCauseStackManager().getCurrentCause(),builder.build());
}
Program: 27549
Project: 27549
Buggy source:
public static SleepingEvent.Pre createSleepingEventPre(PlayerSleepInBedEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getEntity().getEntityWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  BlockSnapshot bedSnapshot=((World)world).createSnapshot(pos.getX(),pos.getY(),pos.getZ());
  SleepingEvent.Pre spongeEvent=SpongeEventFactory.createSleepingEventPre(Cause.source(forgeEvent.getEntity()).build(),bedSnapshot,(org.spongepowered.api.entity.Entity)forgeEvent.getEntity());
  return spongeEvent;
}

Fixed version (ground truth):
public static SleepingEvent.Pre createSleepingEventPre(PlayerSleepInBedEvent forgeEvent){
  final net.minecraft.world.World world=forgeEvent.getEntity().getEntityWorld();
  if (world.isRemote) {
    return null;
  }
  final BlockPos pos=forgeEvent.getPos();
  BlockSnapshot bedSnapshot=((World)world).createSnapshot(pos.getX(),pos.getY(),pos.getZ());
  Sponge.getCauseStackManager().pushCause(forgeEvent.getEntity());
  return SpongeEventFactory.createSleepingEventPre(Sponge.getCauseStackManager().getCurrentCause(),bedSnapshot,(org.spongepowered.api.entity.Entity)forgeEvent.getEntity());
}
Program: 27550
Project: 27550
Buggy source:
public static MessageChannelEvent.Chat createMessageChannelEventChat(ServerChatEvent forgeEvent){
  final ITextComponent forgeComponent=forgeEvent.getComponent();
  final MessageFormatter formatter=new MessageFormatter();
  MessageChannel channel;
  Text[] chat=SpongeTexts.splitChatMessage((TextComponentTranslation)forgeComponent);
  if (chat[1] == null) {
    chat[1]=chat[0] != null ? chat[0] : SpongeTexts.toText(forgeComponent);
    chat[0]=null;
  }
  if (chat[0] != null) {
    formatter.getHeader().add(new DefaultHeaderApplier(chat[0]));
  }
  formatter.getBody().add(new DefaultBodyApplier(chat[1]));
  Text rawSpongeMessage=Text.of(forgeEvent.getMessage());
  MessageChannel originalChannel=channel=((Player)forgeEvent.getPlayer()).getMessageChannel();
  MessageChannelEvent.Chat spongeEvent=SpongeEventFactory.createMessageChannelEventChat(Cause.source(forgeEvent.getPlayer()).build(),originalChannel,Optional.ofNullable(channel),formatter,rawSpongeMessage,false);
  return spongeEvent;
}

Fixed version (ground truth):
public static MessageChannelEvent.Chat createMessageChannelEventChat(ServerChatEvent forgeEvent){
  final ITextComponent forgeComponent=forgeEvent.getComponent();
  final MessageFormatter formatter=new MessageFormatter();
  MessageChannel channel;
  Text[] chat=SpongeTexts.splitChatMessage((TextComponentTranslation)forgeComponent);
  if (chat[1] == null) {
    chat[1]=chat[0] != null ? chat[0] : SpongeTexts.toText(forgeComponent);
    chat[0]=null;
  }
  if (chat[0] != null) {
    formatter.getHeader().add(new DefaultHeaderApplier(chat[0]));
  }
  formatter.getBody().add(new DefaultBodyApplier(chat[1]));
  Text rawSpongeMessage=Text.of(forgeEvent.getMessage());
  MessageChannel originalChannel=channel=((Player)forgeEvent.getPlayer()).getMessageChannel();
  Sponge.getCauseStackManager().pushCause(forgeEvent.getPlayer());
  return SpongeEventFactory.createMessageChannelEventChat(Sponge.getCauseStackManager().getCurrentCause(),originalChannel,Optional.ofNullable(channel),formatter,rawSpongeMessage,false);
}
Program: 27552
Project: 27552
Buggy source:
@Inject(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str"),cancellable=true) private void onCatchFirePreCheckOther(World world,BlockPos pos,int chance,Random random,int age,EnumFacing facing,CallbackInfo callbackInfo){
  if (!world.isRemote) {
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)world,pos,NamedCause.of(NamedCause.FIRE_SPREAD,world)).isCancelled()) {
      callbackInfo.cancel();
    }
  }
}

Fixed version (ground truth):
@Inject(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str"),cancellable=true) private void onCatchFirePreCheckOther(World world,BlockPos pos,int chance,Random random,int age,EnumFacing facing,CallbackInfo callbackInfo){
  if (!world.isRemote) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.FIRE_SPREAD,(org.spongepowered.api.world.World)world);
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)world,pos).isCancelled()) {
      callbackInfo.cancel();
    }
  }
}
Program: 27553
Project: 27553
Buggy source:
@Inject(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str"),cancellable=true) private void onCatchFirePreCheck(World world,BlockPos pos,int chance,Random random,int age,EnumFacing facing,CallbackInfo callbackInfo){
  if (!world.isRemote) {
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)world,pos,NamedCause.of(NamedCause.FIRE_SPREAD,world)).isCancelled()) {
      callbackInfo.cancel();
    }
  }
}

Fixed version (ground truth):
@Inject(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str"),cancellable=true) private void onCatchFirePreCheck(World world,BlockPos pos,int chance,Random random,int age,EnumFacing facing,CallbackInfo callbackInfo){
  if (!world.isRemote) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.FIRE_SPREAD,(org.spongepowered.api.world.World)world);
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)world,pos).isCancelled()) {
      callbackInfo.cancel();
    }
  }
}
Program: 27554
Project: 27554
Buggy source:
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onBreakBlock(Block block,IBlockState state,net.minecraft.world.World worldIn,BlockPos pos){
  if (CauseTracker.ENABLED && !worldIn.isRemote) {
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)worldIn,pos,NamedCause.of("String_Node_Str",worldIn)).isCancelled()) {
      return;
    }
    final CauseTracker causeTracker=CauseTracker.getInstance();
    final IPhaseState currentState=causeTracker.getCurrentState();
    final boolean isBlockAlready=currentState.getPhase() != TrackingPhases.BLOCK;
    final boolean isWorldGen=currentState.getPhase().isWorldGeneration(currentState);
    if (isBlockAlready && !isWorldGen) {
      final LocatableBlock locatable=LocatableBlock.builder().location(new Location<World>((World)worldIn,pos.getX(),pos.getY(),pos.getZ())).state((BlockState)state).build();
      causeTracker.switchToPhase(BlockPhase.State.BLOCK_DECAY,PhaseContext.start().source(locatable).addCaptures().complete());
    }
    block.beginLeavesDecay(state,worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.completePhase(BlockPhase.State.BLOCK_DECAY);
    }
  }
 else {
    block.beginLeavesDecay(state,worldIn,pos);
  }
}

Fixed version (ground truth):
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onBreakBlock(Block block,IBlockState state,net.minecraft.world.World worldIn,BlockPos pos){
  if (CauseTracker.ENABLED && !worldIn.isRemote) {
    Sponge.getCauseStackManager().addContext(EventContextKeys.LEAVES_DECAY,(World)worldIn);
    if (SpongeCommonEventFactory.callChangeBlockEventPre((IMixinWorldServer)worldIn,pos).isCancelled()) {
      return;
    }
    final CauseTracker causeTracker=CauseTracker.getInstance();
    final IPhaseState currentState=causeTracker.getCurrentState();
    final boolean isBlockAlready=currentState.getPhase() != TrackingPhases.BLOCK;
    final boolean isWorldGen=currentState.getPhase().isWorldGeneration(currentState);
    if (isBlockAlready && !isWorldGen) {
      final LocatableBlock locatable=LocatableBlock.builder().location(new Location<World>((World)worldIn,pos.getX(),pos.getY(),pos.getZ())).state((BlockState)state).build();
      causeTracker.switchToPhase(BlockPhase.State.BLOCK_DECAY,PhaseContext.start().source(locatable).addCaptures().complete());
    }
    block.beginLeavesDecay(state,worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.completePhase(BlockPhase.State.BLOCK_DECAY);
    }
  }
 else {
    block.beginLeavesDecay(state,worldIn,pos);
  }
}
Program: 27556
Project: 27556
Buggy source:
public static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  return SpongeEventFactory.createLoadChunkEvent(Sponge.getCauseStackManager().getCurrentCause(),(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
public static LoadChunkEvent createLoadChunkEvent(ChunkEvent.Load forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createLoadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}
Program: 27557
Project: 27557
Buggy source:
public static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  return SpongeEventFactory.createUnloadChunkEvent(Sponge.getCauseStackManager().getCurrentCause(),(Chunk)forgeEvent.getChunk());
}

Fixed version (ground truth):
public static UnloadChunkEvent createUnloadChunkEvent(ChunkEvent.Unload forgeEvent){
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  if (isMainThread) {
    Sponge.getCauseStackManager().pushCause(forgeEvent.getWorld());
  }
  final Cause cause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),forgeEvent.getWorld());
  return SpongeEventFactory.createUnloadChunkEvent(cause,(Chunk)forgeEvent.getChunk());
}
Program: 27559
Project: 27559
Buggy source:
@SubscribeEvent(priority=EventPriority.HIGHEST) public void onCustomPacketRegistration(CustomPacketRegistrationEvent<?> event){
  Set<String> channels=((IMixinNetPlayHandler)event.getHandler()).getRegisteredChannels();
  ;
  try (final CauseStackManager.CauseStackFrame causeStackFrame=Sponge.getCauseStackManager().pushCauseFrame()){
    if (event.getHandler() instanceof NetHandlerPlayServer) {
      Sponge.getCauseStackManager().pushCause(((NetHandlerPlayServer)event.getHandler()).player);
    }
    Sponge.getCauseStackManager().addContext(NET_HANDLER,event.getHandler());
    if (event.getOperation().equals("String_Node_Str")) {
      channels.addAll(event.getRegistrations());
      for (      String channel : event.getRegistrations()) {
        SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventRegister(Sponge.getCauseStackManager().getCurrentCause(),channel));
      }
    }
 else     if (event.getOperation().equals("String_Node_Str")) {
      channels.removeAll(event.getRegistrations());
      for (      String channel : event.getRegistrations()) {
        SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventUnregister(Sponge.getCauseStackManager().getCurrentCause(),channel));
      }
    }
  }
 }

Fixed version (ground truth):
@SubscribeEvent(priority=EventPriority.HIGHEST) public void onCustomPacketRegistration(CustomPacketRegistrationEvent<?> event){
  Set<String> channels=((IMixinNetPlayHandler)event.getHandler()).getRegisteredChannels();
  ;
  final boolean isMainThread=Sponge.isServerAvailable() && Sponge.getServer().isMainThread();
  try (final CauseStackManager.CauseStackFrame frame=isMainThread ? Sponge.getCauseStackManager().pushCauseFrame() : null){
    if (isMainThread) {
      if (event.getHandler() instanceof NetHandlerPlayServer) {
        Sponge.getCauseStackManager().pushCause(((NetHandlerPlayServer)event.getHandler()).player);
      }
      Sponge.getCauseStackManager().addContext(NET_HANDLER,event.getHandler());
    }
    if (event.getOperation().equals("String_Node_Str")) {
      channels.addAll(event.getRegistrations());
      for (      String channel : event.getRegistrations()) {
        final Cause currentCause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),Sponge.getGame());
        SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventRegister(currentCause,channel));
      }
    }
 else     if (event.getOperation().equals("String_Node_Str")) {
      channels.removeAll(event.getRegistrations());
      for (      String channel : event.getRegistrations()) {
        final Cause currentCause=isMainThread ? Sponge.getCauseStackManager().getCurrentCause() : Cause.of(EventContext.empty(),Sponge.getGame());
        SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventUnregister(currentCause,channel));
      }
    }
  }
 }
Program: 27560
Project: 27560
Buggy source:
private static LoadWorldEvent callWorldLoadEvent(Event event){
  LoadWorldEvent spongeEvent=(LoadWorldEvent)event;
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(new WorldEvent.Load((net.minecraft.world.World)spongeEvent.getTargetWorld()),true);
  return spongeEvent;
}

Fixed version (ground truth):
private static LoadWorldEvent callWorldLoadEvent(Event event){
  LoadWorldEvent spongeEvent=(LoadWorldEvent)event;
  ((IMixinWorld)spongeEvent.getTargetWorld()).setCallingWorldEvent(true);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(new WorldEvent.Load((net.minecraft.world.World)spongeEvent.getTargetWorld()),true);
  ((IMixinWorld)spongeEvent.getTargetWorld()).setCallingWorldEvent(false);
  return spongeEvent;
}
Program: 27561
Project: 27561
Buggy source:
private static SaveWorldEvent callWorldSaveEvent(Event event){
  SaveWorldEvent spongeEvent=(SaveWorldEvent)event;
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(new WorldEvent.Save((net.minecraft.world.World)spongeEvent.getTargetWorld()),true);
  return spongeEvent;
}

Fixed version (ground truth):
private static SaveWorldEvent callWorldSaveEvent(Event event){
  SaveWorldEvent spongeEvent=(SaveWorldEvent)event;
  ((IMixinWorld)spongeEvent.getTargetWorld()).setCallingWorldEvent(true);
  ((IMixinEventBus)MinecraftForge.EVENT_BUS).post(new WorldEvent.Save((net.minecraft.world.World)spongeEvent.getTargetWorld()),true);
  ((IMixinWorld)spongeEvent.getTargetWorld()).setCallingWorldEvent(false);
  return spongeEvent;
}
Program: 27562
Project: 27562
Buggy source:
/** 
 * @author blood - August 10th, 2016
 * @reason Constructs a WorldProvider instance in order to locate the save folder name to use.
 * @return The path if available
 */
@Overwrite public static Optional<Path> getWorldFolder(DimensionType dimensionType,int dimensionId){
  if (dimensionType == null) {
    return Optional.empty();
  }
  Path path=dimensionPathByDimensionId.get(dimensionId);
  if (path == null) {
    try {
      WorldProvider provider=dimensionType.createDimension();
      provider.setDimension(dimensionId);
      String worldFolder=provider.getSaveFolder();
      path=SpongeImpl.getGame().getSavesDirectory().resolve(SpongeImpl.getServer().getFolderName()).resolve(worldFolder);
      WorldManager.registerDimensionPath(dimensionId,path);
    }
 catch (    Throwable t) {
      return Optional.empty();
    }
  }
  return Optional.ofNullable(path);
}

Fixed version (ground truth):
/** 
 * @author blood - August 10th, 2016
 * @reason Constructs a WorldProvider instance in order to locate the save folder name to use.
 * @return The path if available
 */
@Overwrite public static Path getWorldFolder(DimensionType dimensionType,int dimensionId){
  Path path=dimensionPathByDimensionId.get(dimensionId);
  if (path != null) {
    return path;
  }
  if (dimensionType == null) {
    return null;
  }
  try {
    WorldProvider provider=dimensionType.createDimension();
    provider.setDimension(dimensionId);
    String worldFolder=provider.getSaveFolder();
    path=SpongeImpl.getGame().getSavesDirectory().resolve(SpongeImpl.getServer().getFolderName()).resolve(worldFolder);
    WorldManager.registerDimensionPath(dimensionId,path);
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
  return path;
}
Program: 27564
Project: 27564
Buggy source:
@Overwrite public static void registerDimension(int id,DimensionType type){
  WorldManager.registerDimension(id,type,false);
}

Fixed version (ground truth):
@Overwrite public static void registerDimension(int id,DimensionType type){
  WorldManager.registerDimension(id,type);
}
Program: 27565
Project: 27565
Buggy source:
/** 
 * @author Simon816Remove call to firePlayerLoggedOut because SpongeCommon's MixinNetHandlerPlayServer.onDisconnectPlayer fires the event already. NOTE: ANY call to playerLoggedOut will need to fire the PlayerLoggedOutEvent manually!
 */
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onFirePlayerLoggedOutCall(FMLCommonHandler thisCtx,EntityPlayer playerIn){
}

Fixed version (ground truth):
/** 
 * @author Simon816
 * @author dualspiralRemove call to firePlayerLoggedOut under ordinary circumstances because SpongeCommon's MixinNetHandlerPlayServer.onDisconnectHandler fires the event already. There is a special case where this event is reinstated - if Sponge's ClientConnectionEvent#Login event is cancelled - which we can detect because the EntityPlayerMP's NetHandlerPlayServer has not been reinstated at this stage. In that scenario, we fire Forge's event as a matter of compatibility with mods that might have started their setup with players. NOTE: ANY call to playerLoggedOut will need to fire the PlayerLoggedOutEvent manually!
 */
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onFirePlayerLoggedOutCall(FMLCommonHandler thisCtx,EntityPlayer playerIn){
  if (playerIn instanceof EntityPlayerMP && ((EntityPlayerMP)playerIn).connection == null) {
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedOut(playerIn);
  }
}
Program: 27566
Project: 27566
Buggy source:
public static ChunkEvent.Unload createChunkUnloadEvent(Event event){
  UnloadChunkEvent spongeEvent=(UnloadChunkEvent)event;
  ChunkEvent.Unload forgeEvent=new ChunkEvent.Unload(((Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}

Fixed version (ground truth):
public static ChunkEvent.Unload createChunkUnloadEvent(Event event){
  UnloadChunkEvent spongeEvent=(UnloadChunkEvent)event;
  ChunkEvent.Unload forgeEvent=new ChunkEvent.Unload(((net.minecraft.world.chunk.Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}
Program: 27567
Project: 27567
Buggy source:
public static ChunkEvent createChunkEvent(Event event){
  TargetChunkEvent spongeEvent=(TargetChunkEvent)event;
  ChunkEvent forgeEvent=new ChunkEvent(((Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}

Fixed version (ground truth):
public static ChunkEvent createChunkEvent(Event event){
  TargetChunkEvent spongeEvent=(TargetChunkEvent)event;
  ChunkEvent forgeEvent=new ChunkEvent(((net.minecraft.world.chunk.Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}
Program: 27568
Project: 27568
Buggy source:
public static ChunkEvent.Load createChunkLoadEvent(Event event){
  LoadChunkEvent spongeEvent=(LoadChunkEvent)event;
  ChunkEvent.Load forgeEvent=new ChunkEvent.Load(((Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}

Fixed version (ground truth):
public static ChunkEvent.Load createChunkLoadEvent(Event event){
  LoadChunkEvent spongeEvent=(LoadChunkEvent)event;
  ChunkEvent.Load forgeEvent=new ChunkEvent.Load(((net.minecraft.world.chunk.Chunk)spongeEvent.getTargetChunk()));
  return forgeEvent;
}
Program: 27569
Project: 27569
Buggy source:
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onBreakBlock(Block block,IBlockState state,World worldIn,BlockPos pos){
  if (CauseTracker.ENABLED && !worldIn.isRemote) {
    IMixinWorldServer spongeWorld=(IMixinWorldServer)worldIn;
    final CauseTracker causeTracker=spongeWorld.getCauseTracker();
    final boolean isBlockAlready=causeTracker.getStack().current() != TrackingPhases.BLOCK;
    final IPhaseState currentState=causeTracker.getStack().peek().state;
    final boolean isWorldGen=currentState.getPhase().isWorldGeneration(currentState);
    final IBlockState blockState=worldIn.getBlockState(pos);
    final IBlockState actualState=blockState.getActualState(worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.switchToPhase(BlockPhase.State.BLOCK_DECAY,PhaseContext.start().add(NamedCause.source(spongeWorld.createSpongeBlockSnapshot(blockState,actualState,pos,3))).addCaptures().complete());
    }
    block.beginLeavesDecay(blockState,worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.completePhase();
    }
  }
 else {
    block.beginLeavesDecay(state,worldIn,pos);
  }
}

Fixed version (ground truth):
@Redirect(method="String_Node_Str",at=@At(value="String_Node_Str",target="String_Node_Str",remap=false)) public void onBreakBlock(Block block,IBlockState state,World worldIn,BlockPos pos){
  if (CauseTracker.ENABLED && !worldIn.isRemote) {
    IMixinWorldServer spongeWorld=(IMixinWorldServer)worldIn;
    final CauseTracker causeTracker=spongeWorld.getCauseTracker();
    final IPhaseState currentState=causeTracker.getCurrentState();
    final boolean isBlockAlready=currentState.getPhase() != TrackingPhases.BLOCK;
    final boolean isWorldGen=currentState.getPhase().isWorldGeneration(currentState);
    final IBlockState blockState=worldIn.getBlockState(pos);
    final IBlockState actualState=blockState.getActualState(worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.switchToPhase(BlockPhase.State.BLOCK_DECAY,PhaseContext.start().add(NamedCause.source(spongeWorld.createSpongeBlockSnapshot(blockState,actualState,pos,3))).addCaptures().complete());
    }
    block.beginLeavesDecay(blockState,worldIn,pos);
    if (isBlockAlready && !isWorldGen) {
      causeTracker.completePhase();
    }
  }
 else {
    block.beginLeavesDecay(state,worldIn,pos);
  }
}