/// <summary> /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the /// block. /// </summary> public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (par1World.IsRemote) { return(true); } int i = par1World.GetBlockMetadata(par2, par3, par4); if (!IsBlockFootOfBed(i)) { int j = GetDirection(i); par2 += HeadBlockToFootBlockMap[j][0]; par4 += HeadBlockToFootBlockMap[j][1]; if (par1World.GetBlockId(par2, par3, par4) != BlockID) { return(true); } i = par1World.GetBlockMetadata(par2, par3, par4); } if (!par1World.WorldProvider.CanRespawnHere()) { double d = (double)par2 + 0.5D; double d1 = (double)par3 + 0.5D; double d2 = (double)par4 + 0.5D; par1World.SetBlockWithNotify(par2, par3, par4, 0); int k = GetDirection(i); par2 += HeadBlockToFootBlockMap[k][0]; par4 += HeadBlockToFootBlockMap[k][1]; if (par1World.GetBlockId(par2, par3, par4) == BlockID) { par1World.SetBlockWithNotify(par2, par3, par4, 0); d = (d + (double)par2 + 0.5D) / 2D; d1 = (d1 + (double)par3 + 0.5D) / 2D; d2 = (d2 + (double)par4 + 0.5D) / 2D; } par1World.NewExplosion(null, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F, 5F, true); return(true); } if (IsBedOccupied(i)) { EntityPlayer entityplayer = null; IEnumerator <EntityPlayer> iterator = par1World.PlayerEntities.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } EntityPlayer entityplayer1 = iterator.Current; if (entityplayer1.IsPlayerSleeping()) { ChunkCoordinates chunkcoordinates = entityplayer1.PlayerLocation; if (chunkcoordinates.PosX == par2 && chunkcoordinates.PosY == par3 && chunkcoordinates.PosZ == par4) { entityplayer = entityplayer1; } } }while (true); if (entityplayer == null) { SetBedOccupied(par1World, par2, par3, par4, false); } else { par5EntityPlayer.AddChatMessage("tile.bed.occupied"); return(true); } } EnumStatus enumstatus = par5EntityPlayer.SleepInBedAt(par2, par3, par4); if (enumstatus == EnumStatus.OK) { SetBedOccupied(par1World, par2, par3, par4, true); return(true); } if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW) { par5EntityPlayer.AddChatMessage("tile.bed.noSleep"); } else if (enumstatus == EnumStatus.NOT_SAFE) { par5EntityPlayer.AddChatMessage("tile.bed.notSafe"); } return(true); }