/** puts player to sleep on specified bed if possible */ public EnumStatus sleepInBedAt(int par1, int par2, int par3) { EnumStatus customSleep = ForgeHooks.sleepInBedAt(this, par1, par2, par3); if (customSleep != null) { return customSleep; } if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) { return EnumStatus.OTHER_PROBLEM; } if (!this.worldObj.worldProvider.func_48567_d()) { return EnumStatus.NOT_POSSIBLE_HERE; } if (this.worldObj.isDaytime()) { return EnumStatus.NOT_POSSIBLE_NOW; } if (Math.abs(this.posX - (double) par1) > 3.0D || Math.abs(this.posY - (double) par2) > 2.0D || Math.abs(this.posZ - (double) par3) > 3.0D) { return EnumStatus.TOO_FAR_AWAY; } double var4 = 8.0D; double var6 = 5.0D; List var8 = this.worldObj.getEntitiesWithinAABB( EntityMob.class, AxisAlignedBB.getBoundingBoxFromPool( (double) par1 - var4, (double) par2 - var6, (double) par3 - var4, (double) par1 + var4, (double) par2 + var6, (double) par3 + var4)); if (!var8.isEmpty()) { return EnumStatus.NOT_SAFE; } } this.setSize(0.2F, 0.2F); this.yOffset = 0.2F; if (this.worldObj.blockExists(par1, par2, par3)) { int var9 = this.worldObj.getBlockMetadata(par1, par2, par3); int var5 = BlockBed.getDirection(var9); Block block = Block.blocksList[worldObj.getBlockId(par1, par2, par3)]; if (block != null) { var5 = block.getBedDirection(worldObj, par1, par2, par3); } float var10 = 0.5F; float var7 = 0.5F; switch (var5) { case 0: var7 = 0.9F; break; case 1: var10 = 0.1F; break; case 2: var7 = 0.1F; break; case 3: var10 = 0.9F; } this.func_22059_e(var5); this.setPosition( (double) ((float) par1 + var10), (double) ((float) par2 + 0.9375F), (double) ((float) par3 + var7)); } else { this.setPosition( (double) ((float) par1 + 0.5F), (double) ((float) par2 + 0.9375F), (double) ((float) par3 + 0.5F)); } this.sleeping = true; this.sleepTimer = 0; this.playerLocation = new ChunkCoordinates(par1, par2, par3); this.motionX = this.motionZ = this.motionY = 0.0D; if (!this.worldObj.isRemote) { this.worldObj.updateAllPlayersSleepingFlag(); } return EnumStatus.OK; }