public void a(boolean flag, boolean flag1, boolean flag2) { this.b(0.6F, 1.8F); this.A(); ChunkCoordinates chunkcoordinates = this.F; ChunkCoordinates chunkcoordinates1 = this.F; if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) { BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false); chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); if (chunkcoordinates1 == null) { chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z); } this.setPosition( (double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F)); } this.sleeping = false; if (!this.world.isStatic && flag1) { this.world.everyoneSleeping(); } if (flag) { this.sleepTicks = 0; } else { this.sleepTicks = 100; } if (flag2) { this.setRespawnPosition(this.F); } }
public void wakeUpPlayer(boolean flag, boolean flag1, boolean flag2) { setSize(0.6F, 1.8F); resetHeight(); ChunkCoordinates chunkcoordinates = bedChunkCoordinates; ChunkCoordinates chunkcoordinates1 = bedChunkCoordinates; if (chunkcoordinates != null && worldObj.getBlockId(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ) == Block.bed.blockID) { BlockBed.setBedOccupied( worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, false); ChunkCoordinates chunkcoordinates2 = BlockBed.getNearestEmptyChunkCoordinates( worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, 0); if (chunkcoordinates2 == null) { chunkcoordinates2 = new ChunkCoordinates( chunkcoordinates.posX, chunkcoordinates.posY + 1, chunkcoordinates.posZ); } setPosition( (float) chunkcoordinates2.posX + 0.5F, (float) chunkcoordinates2.posY + yOffset + 0.1F, (float) chunkcoordinates2.posZ + 0.5F); } sleeping = false; if (!worldObj.multiplayerWorld && flag1) { worldObj.updateAllPlayersSleepingFlag(); } if (flag) { sleepTimer = 0; } else { sleepTimer = 100; } if (flag2) { setPlayerSpawnCoordinate(bedChunkCoordinates); } }
public static ChunkCoordinates verifyRespawnCoordinates( World world, ChunkCoordinates chunkcoordinates) { IChunkProvider ichunkprovider = world.getIChunkProvider(); ichunkprovider.loadChunk(chunkcoordinates.posX - 3 >> 4, chunkcoordinates.posZ - 3 >> 4); ichunkprovider.loadChunk(chunkcoordinates.posX + 3 >> 4, chunkcoordinates.posZ - 3 >> 4); ichunkprovider.loadChunk(chunkcoordinates.posX - 3 >> 4, chunkcoordinates.posZ + 3 >> 4); ichunkprovider.loadChunk(chunkcoordinates.posX + 3 >> 4, chunkcoordinates.posZ + 3 >> 4); if (world.getBlockId(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ) != Block.bed.blockID) { return null; } else { ChunkCoordinates chunkcoordinates1 = BlockBed.getNearestEmptyChunkCoordinates( world, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, 0); return chunkcoordinates1; } }
public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) { IChunkProvider ichunkprovider = world.q(); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4); if (world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) != Block.BED.id) { return null; } else { ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); return chunkcoordinates1; } }
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; }
private boolean func_50011_a(World par1World, int par2, int par3, int par4) { int var5 = par1World.getBlockId(par2, par3, par4); int var6 = par1World.getBlockMetadata(par2, par3, par4); if (var5 == Block.chest.blockID) { TileEntityChest var7 = (TileEntityChest) par1World.getBlockTileEntity(par2, par3, par4); if (var7.numUsingPlayers < 1) { return true; } } else { if (var5 == Block.stoneOvenActive.blockID) { return true; } if (var5 == Block.bed.blockID && !BlockBed.isBlockFootOfBed(var6)) { return true; } } return false; }
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; }
/** 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; }
public EnumBedResult a(int i, int j, int k) { if (!this.world.isStatic) { if (this.isSleeping() || !this.isAlive()) { return EnumBedResult.OTHER_PROBLEM; } if (!this.world.worldProvider.d()) { return EnumBedResult.NOT_POSSIBLE_HERE; } if (this.world.e()) { return EnumBedResult.NOT_POSSIBLE_NOW; } if (Math.abs(this.locX - (double) i) > 3.0D || Math.abs(this.locY - (double) j) > 2.0D || Math.abs(this.locZ - (double) k) > 3.0D) { return EnumBedResult.TOO_FAR_AWAY; } double d0 = 8.0D; double d1 = 5.0D; List list = this.world.a( EntityMonster.class, AxisAlignedBB.b( (double) i - d0, (double) j - d1, (double) k - d0, (double) i + d0, (double) j + d1, (double) k + d0)); if (!list.isEmpty()) { return EnumBedResult.NOT_SAFE; } } this.b(0.2F, 0.2F); this.height = 0.2F; if (this.world.isLoaded(i, j, k)) { int l = this.world.getData(i, j, k); int i1 = BlockBed.b(l); float f = 0.5F; float f1 = 0.5F; switch (i1) { case 0: f1 = 0.9F; break; case 1: f = 0.1F; break; case 2: f1 = 0.1F; break; case 3: f = 0.9F; } this.c(i1); this.setPosition( (double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); } else { this.setPosition( (double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); } this.sleeping = true; this.sleepTicks = 0; this.F = new ChunkCoordinates(i, j, k); this.motX = this.motZ = this.motY = 0.0D; if (!this.world.isStatic) { this.world.everyoneSleeping(); } return EnumBedResult.OK; }