Program: 12777
Project: 12777
Buggy source:
/** 
 * puts player to sleep on specified coffin if possible
 */
public EntityPlayer.EnumStatus sleepInCoffinAt(int x,int y,int z){
  PlayerSleepInBedEvent event=new PlayerSleepInBedEvent(this.player,x,y,z);
  MinecraftForge.EVENT_BUS.post(event);
  if (event.result != null) {
    return event.result;
  }
  if (!this.player.worldObj.isRemote) {
    if (this.sleepingCoffin || !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)x) > 3.0D || Math.abs(this.player.posY - (double)y) > 2.0D || Math.abs(this.player.posZ - (double)z) > 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)x - d0,(double)y - d1,(double)z - d0,(double)x + d0,(double)y + d1,(double)z + 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(x,y,z)) {
    int direction=((BlockCoffin)player.worldObj.getBlock(x,y,z)).getDirection(player.worldObj,x,y,z);
    float f1=0.5F;
    float f=0.5F;
switch (direction) {
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(direction);
this.player.setPosition((double)((float)x + f1),(double)((float)y + 0.9375F),(double)((float)z + f));
}
 else {
this.player.setPosition((double)((float)x + 0.5F),(double)((float)y + 0.9375F),(double)((float)z + 0.5F));
}
this.sleepingCoffin=true;
this.sleeptimerCoffin=0;
this.player.playerLocation=new ChunkCoordinates(x,y,z);
this.player.motionX=this.player.motionZ=this.player.motionY=0.0D;
if (!this.player.worldObj.isRemote) {
}
return EntityPlayer.EnumStatus.OK;
}

Fixed version (ground truth):
/** 
 * puts player to sleep on specified coffin if possible
 */
public EntityPlayer.EnumStatus sleepInCoffinAt(int x,int y,int z){
  PlayerSleepInBedEvent event=new PlayerSleepInBedEvent(this.player,x,y,z);
  MinecraftForge.EVENT_BUS.post(event);
  if (event.result != null) {
    return event.result;
  }
  if (!this.player.worldObj.isRemote) {
    if (this.sleepingCoffin || !this.isTheEntityAlive()) {
      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)x) > 3.0D || Math.abs(this.player.posY - (double)y) > 2.0D || Math.abs(this.player.posZ - (double)z) > 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)x - d0,(double)y - d1,(double)z - d0,(double)x + d0,(double)y + d1,(double)z + 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(x,y,z)) {
    int direction=((BlockCoffin)player.worldObj.getBlock(x,y,z)).getDirection(player.worldObj,x,y,z);
    float f1=0.5F;
    float f=0.5F;
switch (direction) {
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(direction);
this.player.setPosition((double)((float)x + f1),(double)((float)y + 0.9375F),(double)((float)z + f));
}
 else {
this.player.setPosition((double)((float)x + 0.5F),(double)((float)y + 0.9375F),(double)((float)z + 0.5F));
}
this.sleepingCoffin=true;
this.sleeptimerCoffin=0;
this.player.playerLocation=new ChunkCoordinates(x,y,z);
this.player.motionX=this.player.motionZ=this.player.motionY=0.0D;
if (!this.player.worldObj.isRemote) {
}
return EntityPlayer.EnumStatus.OK;
}