private void SpreadBlockLightInternal(int x, int y, int z, int dist = 0) { if (dist > 0xf) { return; } Chunk chunk = Chunk.GetChunk(x >> 4, z >> 4, this); var currLight = chunk.GetBlockLight(x & 0xf, y, z & 0xf); if (currLight == 0) { return; } ForEveryAdjacentBlock(x, y, z, delegate(int xx, int yy, int zz) { var type = chunk.SGB(xx & 0xf, yy, zz & 0xf); var light = chunk.GetBlockLight(xx & 0xf, yy, zz & 0xf); if (Chunk.LightOpacity[type] == 0 && light < currLight - 1) { chunk.SetBlockLight(xx & 0xf, yy, zz & 0xf, (byte)(currLight - 1)); SpreadBlockLightInternal(xx, yy, zz, dist + 1); } }); }
private void UpdateShi(Player p) { p.SendTime(); if (Chunk.GetChunk((int)p.pos.x >> 4, (int)p.pos.z >> 4, p.level) == null) { p.level.LoadChunk((int)p.pos.x >> 4, (int)p.pos.z >> 4); } }
private void HandleLogin(byte[] message) { int version = util.EndianBitConverter.Big.ToInt32(message, 0); short length = util.EndianBitConverter.Big.ToInt16(message, 4); if (length > 32) { Kick("Username too long"); return; } username = Encoding.BigEndianUnicode.GetString(message, 6, (length * 2)); Logger.Log(ip + " Logged in as " + username); if (Server.VerifyNames) { bool verified = false; try { using (WebClient web = new WebClient()) { string response = web.DownloadString("http://session.minecraft.net/game/checkserver.jsp?user="******"&serverId=" + randomHash); verified = (response.Trim() == "YES"); } } catch { } if (!verified) { Kick("Failed to verify username!"); return; } } /*if (version > Server.protocolversion) //left commented during development * { * Kick("Outdated server!"); * return; * } * if (version < Server.protocolversion) * { * Kick("Outdated client!"); * return; * }*/ if (!IPInPrivateRange(ip)) { if (Player.players.Count >= Server.MaxPlayers) { if (Server.useviplist && Server.VIPList.Contains(username.ToLower())) { for (int i = players.Count - 1; i >= 0; i--) // kick the last joined non-vip { if (!Server.VIPList.Contains(players[i].username.ToLower())) { players[i].Kick("You have been kicked for a VIP."); break; } } } else if (Server.useviplist && !Server.VIPList.Contains(username.ToLower())) { Kick(Server.VIPListMessage); } else if (!Server.useviplist) { Kick("Server is full!"); } } if (Server.BanList.Contains(username.ToLower())) { Kick(Server.BanMessage); } if (Server.usewhitelist && !Server.WhiteList.Contains(username.ToLower())) { Kick(Server.WhiteListMessage); } } //TODO: load Player attributes like group, and other settings LoadAttributes(); LoggedIn = true; SendLoginPass(); Player.GlobalMessage(Color.Announce + username + " has joined the game!"); UpdateShi(this); int tries = 0; while (tries < 100 && Chunk.GetChunk((int)pos.x >> 4, (int)pos.z >> 4, level) == null) { tries++; System.Threading.Thread.Sleep(50); } if (Chunk.GetChunk((int)pos.x >> 4, (int)pos.z >> 4, level) == null) { Kick("Chunk missing: " + ((int)pos.x >> 4) + "," + ((int)pos.z >> 4)); } if (PlayerAuth != null) { PlayerAuth(this); } if (OnAuth != null) { OnAuth(this); } }
public void DoExplosionB(/*bool flag*/) { Player.players.ForEach(delegate(Player pl) { if (pl.MapLoaded && pl.level == worldObj && pl.VisibleChunks.Contains(Chunk.GetChunk((int)explosionX >> 4, (int)explosionZ >> 4, pl.level).point)) { pl.SendExplosion((int)explosionX, (int)explosionY, (int)explosionZ, explosionSize, destroyedBlockPositions.ToArray()); } }); List <Point3> arraylist = new List <Point3>(); arraylist.AddRange(destroyedBlockPositions); for (int i = arraylist.Count - 1; i >= 0; i--) { Point3 chunkposition = arraylist[i]; int j = (int)chunkposition.x; int k = (int)chunkposition.y; int l = (int)chunkposition.z; int i1 = worldObj.GetBlock(j, k, l); // This is particle code, and isn't needed here. /*if (flag) * { * double d = (float)j + worldObj.rand.nextFloat(); * double d1 = (float)k + worldObj.rand.nextFloat(); * double d2 = (float)l + worldObj.rand.nextFloat(); * double d3 = d - explosionX; * double d4 = d1 - explosionY; * double d5 = d2 - explosionZ; * double d6 = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); * d3 /= d6; * d4 /= d6; * d5 /= d6; * double d7 = 0.5D / (d6 / (double)explosionSize + 0.10000000000000001D); * d7 *= worldObj.rand.nextFloat() * worldObj.rand.nextFloat() + 0.3F; * d3 *= d7; * d4 *= d7; * d5 *= d7; * worldObj.spawnParticle("explode", (d + explosionX * 1.0D) / 2D, (d1 + explosionY * 1.0D) / 2D, (d2 + explosionZ * 1.0D) / 2D, d3, d4, d5); * worldObj.spawnParticle("smoke", d, d1, d2, d3, d4, d5); * }*/ if (i1 > 0) { if (ExplosionRNG.Next(10) < 3) { short block = Player.BlockDropSwitch((short)i1); if (block != 0) { worldObj.DropItem(j, k, l, block); } } worldObj.BlockChange(j, k, l, 0, 0); } } if (isFlaming) { for (int l2 = arraylist.Count - 1; l2 >= 0; l2--) { Point3 chunkposition = arraylist[l2]; int i3 = (int)chunkposition.x; int j3 = (int)chunkposition.y; int k3 = (int)chunkposition.z; int l3 = worldObj.GetBlock(i3, j3, k3); int i4 = worldObj.GetBlock(i3, j3 - 1, k3); if (l3 == 0 && i4 != 20 && BlockData.CanPlaceAgainst((byte)i4) && ExplosionRNG.Next(3) == 0) { worldObj.BlockChange(i3, j3, k3, (byte)Blocks.Fire, 0); } } } }