Running on the WorldTickEvent and using the world.playerEntities ArrayList to cycle through players.
When I have a player that is in a bed who is FullyAsleep(entityplayer.isPlayerFullyAsleep()), I get their coordinates using x = posX etc..
I wake up the player, then put them back to bed with sleepinBedAt(x,y,z). Although this works on servers, in SinglePlayer or Multiplayer via "Open To LAN", the x coordinate is 1 integer larger. This causes players to be shifted off of their bed when they are fullyAsleep. Assuming it was a bug with forge or Minecraft, I decided to work around it by using Minecraft.getMinecraft().isSingleplayer() to alter the x coordinate based on the type of server that was running the mod, however this causes a crash on servers when that line is run.
for(int i = 0; i < players.size(); i++){
entityplayer = (EntityPlayer) players.get(i);
if(entityplayer.isPlayerFullyAsleep()){
int x;
if(Minecraft.getMinecraft().isSingleplayer()) x = (int) entityplayer.posX - 1;
else x = (int) entityplayer.posX;
int y = (int) entityplayer.posY;
int z = (int) entityplayer.posZ;
entityplayer.wakeUpPlayer(true, false, true);
entityplayer.sleepInBedAt(x, y, z);
Any help with this issue would be appreciated.