Program: 12778
Project: 12778
Buggy source:
/** 
 * puts player to sleep on specified bed if possible
 */
public EntityPlayer.EnumStatus sleepInCoffinAt(int p_71018_1_,int p_71018_2_,int p_71018_3_){
  PlayerSleepInBedEvent event=new PlayerSleepInBedEvent(this.player,p_71018_1_,p_71018_2_,p_71018_3_);
  MinecraftForge.EVENT_BUS.post(event);
  if (event.result != null) {
    return event.result;
  }
  if (!this.player.worldObj.isRemote) {
    if (this.player.isPlayerSleeping() || !this.isEntityAlive()) {
      return EntityPlayer.EnumStatus.OTHER_PROBLEM;
    }
    if (!this.player.worldObj.provider.isSurfaceWorld()) {
      return EntityPlayer.EnumStatus.NOT_POSSIBLE_HERE;
    }
    if (!this.player.worldObj.isDaytime()) {
      return EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW;
    }
    if (Math.abs(this.player.posX - (double)p_71018_1_) > 3.0D || Math.abs(this.player.posY - (double)p_71018_2_) > 2.0D || Math.abs(this.player.posZ - (double)p_71018_3_) > 3.0D) {
      return EntityPlayer.EnumStatus.TOO_FAR_AWAY;
    }
    double d0=8.0D;
    double d1=5.0D;
    List list=this.player.worldObj.getEntitiesWithinAABB(EntityMob.class,AxisAlignedBB.getBoundingBox((double)p_71018_1_ - d0,(double)p_71018_2_ - d1,(double)p_71018_3_ - d0,(double)p_71018_1_ + d0,(double)p_71018_2_ + d1,(double)p_71018_3_ + d0));
    if (!list.isEmpty()) {
      return EntityPlayer.EnumStatus.NOT_SAFE;
    }
  }
  if (this.player.isRiding()) {
    this.player.mountEntity((Entity)null);
  }
  Helper.Reflection.callMethod(this.player,Helper.Obfuscation.getPosNames("String_Node_Str"),new Class[]{Float.class,Float.class},new Object[]{0.2F,0.2F});
  this.player.yOffset=0.2F;
  if (this.player.worldObj.blockExists(p_71018_1_,p_71018_2_,p_71018_3_)) {
    int l=player.worldObj.getBlock(p_71018_1_,p_71018_2_,p_71018_3_).getBedDirection(player.worldObj,p_71018_1_,p_71018_2_,p_71018_3_);
    float f1=0.5F;
    float f=0.5F;
switch (l) {
case 0:
      f=0.9F;
    break;
case 1:
  f1=0.1F;
break;
case 2:
f=0.1F;
break;
case 3:
f1=0.9F;
}
this.func_71013_b(l);
this.player.setPosition((double)((float)p_71018_1_ + f1),(double)((float)p_71018_2_ + 0.9375F),(double)((float)p_71018_3_ + f));
}
 else {
this.player.setPosition((double)((float)p_71018_1_ + 0.5F),(double)((float)p_71018_2_ + 0.9375F),(double)((float)p_71018_3_ + 0.5F));
}
Helper.Reflection.setPrivateField(EntityPlayer.class,this.player,true,Helper.Obfuscation.getPosNames("String_Node_Str"));
Helper.Reflection.setPrivateField(EntityPlayer.class,this.player,0,Helper.Obfuscation.getPosNames("String_Node_Str"));
this.player.playerLocation=new ChunkCoordinates(p_71018_1_,p_71018_2_,p_71018_3_);
this.player.motionX=this.player.motionZ=this.player.motionY=0.0D;
if (!this.player.worldObj.isRemote) {
this.player.worldObj.updateAllPlayersSleepingFlag();
}
return EntityPlayer.EnumStatus.OK;
}

Fixed version (ground truth):
/** 
 * puts player to sleep on specified bed if possible
 */
public EntityPlayer.EnumStatus sleepInCoffinAt(int p_71018_1_,int p_71018_2_,int p_71018_3_){
  PlayerSleepInBedEvent event=new PlayerSleepInBedEvent(this.player,p_71018_1_,p_71018_2_,p_71018_3_);
  MinecraftForge.EVENT_BUS.post(event);
  if (event.result != null) {
    return event.result;
  }
  if (!this.player.worldObj.isRemote) {
    if (this.player.isPlayerSleeping() || !this.isEntityAlive()) {
      return EntityPlayer.EnumStatus.OTHER_PROBLEM;
    }
    if (!this.player.worldObj.provider.isSurfaceWorld()) {
      return EntityPlayer.EnumStatus.NOT_POSSIBLE_HERE;
    }
    if (!this.player.worldObj.isDaytime()) {
      return EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW;
    }
    if (Math.abs(this.player.posX - (double)p_71018_1_) > 3.0D || Math.abs(this.player.posY - (double)p_71018_2_) > 2.0D || Math.abs(this.player.posZ - (double)p_71018_3_) > 3.0D) {
      return EntityPlayer.EnumStatus.TOO_FAR_AWAY;
    }
    double d0=8.0D;
    double d1=5.0D;
    List list=this.player.worldObj.getEntitiesWithinAABB(EntityMob.class,AxisAlignedBB.getBoundingBox((double)p_71018_1_ - d0,(double)p_71018_2_ - d1,(double)p_71018_3_ - d0,(double)p_71018_1_ + d0,(double)p_71018_2_ + d1,(double)p_71018_3_ + d0));
    if (!list.isEmpty()) {
      return EntityPlayer.EnumStatus.NOT_SAFE;
    }
  }
  if (this.player.isRiding()) {
    this.player.mountEntity((Entity)null);
  }
  Helper.Reflection.callMethod(Entity.class,this.player,Helper.Obfuscation.getPosNames("String_Node_Str"),new Class[]{float.class,float.class},new Object[]{0.2F,0.2F});
  this.player.yOffset=0.2F;
  if (this.player.worldObj.blockExists(p_71018_1_,p_71018_2_,p_71018_3_)) {
    int l=player.worldObj.getBlock(p_71018_1_,p_71018_2_,p_71018_3_).getBedDirection(player.worldObj,p_71018_1_,p_71018_2_,p_71018_3_);
    float f1=0.5F;
    float f=0.5F;
switch (l) {
case 0:
      f=0.9F;
    break;
case 1:
  f1=0.1F;
break;
case 2:
f=0.1F;
break;
case 3:
f1=0.9F;
}
this.func_71013_b(l);
this.player.setPosition((double)((float)p_71018_1_ + f1),(double)((float)p_71018_2_ + 0.9375F),(double)((float)p_71018_3_ + f));
}
 else {
this.player.setPosition((double)((float)p_71018_1_ + 0.5F),(double)((float)p_71018_2_ + 0.9375F),(double)((float)p_71018_3_ + 0.5F));
}
Helper.Reflection.setPrivateField(EntityPlayer.class,this.player,true,Helper.Obfuscation.getPosNames("String_Node_Str"));
Helper.Reflection.setPrivateField(EntityPlayer.class,this.player,0,Helper.Obfuscation.getPosNames("String_Node_Str"));
this.player.playerLocation=new ChunkCoordinates(p_71018_1_,p_71018_2_,p_71018_3_);
this.player.motionX=this.player.motionZ=this.player.motionY=0.0D;
if (!this.player.worldObj.isRemote) {
this.player.worldObj.updateAllPlayersSleepingFlag();
}
return EntityPlayer.EnumStatus.OK;
}