public float getBedOrientationInDegrees() { if (bedChunkCoordinates != null) { int i = worldObj.getBlockMetadata( bedChunkCoordinates.posX, bedChunkCoordinates.posY, bedChunkCoordinates.posZ); int j = BlockBed.getDirectionFromMetadata(i); switch (j) { case 0: return 90F; case 1: return 0.0F; case 2: return 270F; case 3: return 180F; } } return 0.0F; }
public EnumStatus sleepInBedAt(int i, int j, int k) { if (!worldObj.multiplayerWorld) { if (isPlayerSleeping() || !isEntityAlive()) { return EnumStatus.OTHER_PROBLEM; } if (worldObj.worldProvider.isAlternateDimension) { return EnumStatus.NOT_POSSIBLE_HERE; } if (worldObj.isDaytime()) { return EnumStatus.NOT_POSSIBLE_NOW; } if (Math.abs(posX - (double) i) > 3D || Math.abs(posY - (double) j) > 2D || Math.abs(posZ - (double) k) > 3D) { return EnumStatus.TOO_FAR_AWAY; } double d = 8D; double d1 = 5D; List list = worldObj.getEntitiesWithinAABB( net.minecraft.src.EntityMob.class, AxisAlignedBB.getBoundingBoxFromPool( (double) i - d, (double) j - d1, (double) k - d, (double) i + d, (double) j + d1, (double) k + d)); if (!list.isEmpty()) { return EnumStatus.NOT_SAFE; } } setSize(0.2F, 0.2F); yOffset = 0.2F; if (worldObj.blockExists(i, j, k)) { int l = worldObj.getBlockMetadata(i, j, k); int i1 = BlockBed.getDirectionFromMetadata(l); float f = 0.5F; float f1 = 0.5F; switch (i1) { case 0: f1 = 0.9F; break; case 2: f1 = 0.1F; break; case 1: f = 0.1F; break; case 3: f = 0.9F; break; } func_22052_e(i1); setPosition((float) i + f, (float) j + 0.9375F, (float) k + f1); } else { setPosition((float) i + 0.5F, (float) j + 0.9375F, (float) k + 0.5F); } sleeping = true; sleepTimer = 0; bedChunkCoordinates = new ChunkCoordinates(i, j, k); motionX = motionZ = motionY = 0.0D; if (!worldObj.multiplayerWorld) { worldObj.updateAllPlayersSleepingFlag(); } return EnumStatus.OK; }