Program: 12685
Project: 12685
Buggy source:
@Override public EntityPlayer.SleepResult trySleep(BlockPos bedLocation){
  if (!player.worldObj.isRemote) {
    if (player.isPlayerSleeping() || !player.isEntityAlive()) {
      return EntityPlayer.SleepResult.OTHER_PROBLEM;
    }
    if (!player.worldObj.provider.isSurfaceWorld()) {
      return EntityPlayer.SleepResult.NOT_POSSIBLE_HERE;
    }
    if (!player.worldObj.isDaytime()) {
      return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
    }
    if (Math.abs(player.posX - (double)bedLocation.getX()) > 3.0D || Math.abs(player.posY - (double)bedLocation.getY()) > 2.0D || Math.abs(player.posZ - (double)bedLocation.getZ()) > 3.0D) {
      return EntityPlayer.SleepResult.TOO_FAR_AWAY;
    }
    double d0=8.0D;
    double d1=5.0D;
    List<EntityMob> list=player.worldObj.getEntitiesWithinAABB(EntityMob.class,new AxisAlignedBB((double)bedLocation.getX() - d0,(double)bedLocation.getY() - d1,(double)bedLocation.getZ() - d0,(double)bedLocation.getX() + d0,(double)bedLocation.getY() + d1,(double)bedLocation.getZ() + d0));
    if (!list.isEmpty()) {
      return EntityPlayer.SleepResult.NOT_SAFE;
    }
  }
  if (player.isRiding()) {
    player.dismountRidingEntity();
  }
  if (!setEntitySize(0.2F,0.2F))   return EntityPlayer.SleepResult.OTHER_PROBLEM;
  IBlockState state=null;
  if (player.worldObj.isBlockLoaded(bedLocation))   state=player.worldObj.getBlockState(bedLocation);
  if (state != null && state.getBlock().isBed(state,player.worldObj,bedLocation,player)) {
    EnumFacing enumfacing=state.getBlock().getBedDirection(state,player.worldObj,bedLocation);
    float f=0.5F;
    float f1=0.5F;
switch (enumfacing) {
case SOUTH:
      f1=0.9F;
    break;
case NORTH:
  f1=0.1F;
break;
case WEST:
f=0.1F;
break;
case EAST:
f=0.9F;
}
try {
Method mSetSize=ReflectionHelper.findMethod(EntityPlayer.class,player,new String[]{"String_Node_Str",SRGNAMES.EntityPlayer_setRenderOffsetForSleep},EnumFacing.class);
mSetSize.invoke(player,enumfacing);
}
 catch (Exception e) {
VampirismMod.log.e(TAG,e,"String_Node_Str");
return EntityPlayer.SleepResult.OTHER_PROBLEM;
}
player.setPosition((double)((float)bedLocation.getX() + f),(double)((float)bedLocation.getY() + 0.6875F),(double)((float)bedLocation.getZ() + f1));
}
 else {
player.setPosition((double)((float)bedLocation.getX() + 0.5F),(double)((float)bedLocation.getY() + 0.6875F),(double)((float)bedLocation.getZ() + 0.5F));
}
sleepTimer=0;
sleepingInCoffin=true;
player.noClip=true;
player.playerLocation=bedLocation;
player.motionX=player.motionZ=player.motionY=0.0D;
if (!player.worldObj.isRemote) {
DaySleepHelper.updateAllPlayersSleeping(player.worldObj);
}
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP=(EntityPlayerMP)player;
Packet<?> packet=new SPacketUseBed(player,bedLocation);
playerMP.getServerWorld().getEntityTracker().sendToAllTrackingEntity(playerMP,packet);
playerMP.connection.setPlayerLocation(player.posX,player.posY,player.posZ,player.rotationYaw,player.rotationPitch);
playerMP.connection.sendPacket(packet);
}
return EntityPlayer.SleepResult.OK;
}

Fixed version (ground truth):
@Override public EntityPlayer.SleepResult trySleep(BlockPos bedLocation){
  if (!player.worldObj.isRemote) {
    if (player.isPlayerSleeping() || !player.isEntityAlive()) {
      return EntityPlayer.SleepResult.OTHER_PROBLEM;
    }
    if (!player.worldObj.provider.isSurfaceWorld()) {
      return EntityPlayer.SleepResult.NOT_POSSIBLE_HERE;
    }
    if (!player.worldObj.isDaytime()) {
      return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
    }
    if (Math.abs(player.posX - (double)bedLocation.getX()) > 3.0D || Math.abs(player.posY - (double)bedLocation.getY()) > 2.0D || Math.abs(player.posZ - (double)bedLocation.getZ()) > 3.0D) {
      return EntityPlayer.SleepResult.TOO_FAR_AWAY;
    }
    double d0=8.0D;
    double d1=5.0D;
    List<EntityMob> list=player.worldObj.getEntitiesWithinAABB(EntityMob.class,new AxisAlignedBB((double)bedLocation.getX() - d0,(double)bedLocation.getY() - d1,(double)bedLocation.getZ() - d0,(double)bedLocation.getX() + d0,(double)bedLocation.getY() + d1,(double)bedLocation.getZ() + d0));
    if (!list.isEmpty()) {
      return EntityPlayer.SleepResult.NOT_SAFE;
    }
  }
  if (player.isRiding()) {
    player.dismountRidingEntity();
  }
  if (!setEntitySize(0.2F,0.2F))   return EntityPlayer.SleepResult.OTHER_PROBLEM;
  IBlockState state=null;
  if (player.worldObj.isBlockLoaded(bedLocation))   state=player.worldObj.getBlockState(bedLocation);
  if (state != null && state.getBlock().isBed(state,player.worldObj,bedLocation,player)) {
    EnumFacing enumfacing=state.getBlock().getBedDirection(state,player.worldObj,bedLocation);
    float f=0.5F;
    float f1=0.5F;
switch (enumfacing) {
case SOUTH:
      f1=0.9F;
    break;
case NORTH:
  f1=0.1F;
break;
case WEST:
f=0.1F;
break;
case EAST:
f=0.9F;
break;
default :
}
try {
Method mSetSize=ReflectionHelper.findMethod(EntityPlayer.class,player,new String[]{"String_Node_Str",SRGNAMES.EntityPlayer_setRenderOffsetForSleep},EnumFacing.class);
mSetSize.invoke(player,enumfacing);
}
 catch (Exception e) {
VampirismMod.log.e(TAG,e,"String_Node_Str");
return EntityPlayer.SleepResult.OTHER_PROBLEM;
}
player.setPosition((double)((float)bedLocation.getX() + f),(double)((float)bedLocation.getY() + 0.6875F),(double)((float)bedLocation.getZ() + f1));
}
 else {
player.setPosition((double)((float)bedLocation.getX() + 0.5F),(double)((float)bedLocation.getY() + 0.6875F),(double)((float)bedLocation.getZ() + 0.5F));
}
sleepTimer=0;
sleepingInCoffin=true;
player.noClip=true;
player.playerLocation=bedLocation;
player.motionX=player.motionZ=player.motionY=0.0D;
if (!player.worldObj.isRemote) {
DaySleepHelper.updateAllPlayersSleeping(player.worldObj);
}
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP=(EntityPlayerMP)player;
Packet<?> packet=new SPacketUseBed(player,bedLocation);
playerMP.getServerWorld().getEntityTracker().sendToAllTrackingEntity(playerMP,packet);
playerMP.connection.setPlayerLocation(player.posX,player.posY,player.posZ,player.rotationYaw,player.rotationPitch);
playerMP.connection.sendPacket(packet);
}
return EntityPlayer.SleepResult.OK;
}