public static bool ButtonRelease(Physics P, Check C) { if (C.time < 4) { C.time++; return false; } if ((P.w.GetMeta(C.x, C.y, C.z) & 0x8) != 0) P.AddUpdate(C.x, C.y, C.z, (byte)Blocks.ButtonStone, (byte)(P.w.GetMeta(C.x, C.y, C.z) ^ 0x8)); return true; }
public static bool LavaFlow(Physics P, Check C) { if (C.time < 6) { C.time++; return false; } byte meta = P.w.GetMeta(C.x, C.y, C.z); if (!P.HigherLiquidCheck(C.x, C.y, C.z, 10, meta) && !P.HigherLiquidCheck(C.x, C.y, C.z, 11, meta)) { if ((meta & 0x7) >= 0x6) P.AddUpdate(C.x, C.y, C.z, 0, 0); else { P.AddUpdate(C.x, C.y, C.z, 10, (byte)Math.Min(meta + 2, 0x6)); if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 10) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 11)) { C.time = 0; return false; } } } else if ((meta & 0x8) != 0) { if (!P.LavaFlowCheck(C.x, C.y - 1, C.z)) { meta = 0; goto flowOut; } P.LavaFlow(C.x, C.y - 1, C.z, 0x8); } else if ((meta & 0x7) < 0x6) { goto flowOut; } else { P.LavaFlow(C.x, C.y - 1, C.z, 0x8); } return true; flowOut: if (P.LavaFlowCheck(C.x, C.y - 1, C.z)) { P.LavaFlow(C.x, C.y - 1, C.z, 0x8); if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 10) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 11)) { P.LavaFlow(C.x + 1, C.y, C.z, 0x6); P.LavaFlow(C.x - 1, C.y, C.z, 0x6); P.LavaFlow(C.x, C.y, C.z + 1, 0x6); P.LavaFlow(C.x, C.y, C.z - 1, 0x6); } } else { if (P.AdjacentLiquidCheck(C.x, C.y, C.z, 8) || P.AdjacentLiquidCheck(C.x, C.y, C.z, 9)) { if ((meta & 0x7) == 0) P.AddUpdate(C.x, C.y, C.z, 49, 0); else P.AddUpdate(C.x, C.y, C.z, 4, 0); Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 1004, P.w); //Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 2000, 4, w); } else { meta += 2; P.LavaFlow(C.x + 1, C.y, C.z, meta); P.LavaFlow(C.x - 1, C.y, C.z, meta); P.LavaFlow(C.x, C.y, C.z + 1, meta); P.LavaFlow(C.x, C.y, C.z - 1, meta); if (P.w.GetBlock(C.x, C.y - 1, C.z) == 8 || P.w.GetBlock(C.x, C.y - 1, C.z) == 9) { P.AddUpdate(C.x, C.y - 1, C.z, 4, 0); Player.GlobalSoundEffect(C.x, (byte)C.y, C.z, 1004, P.w); } } } return true; }
public static bool WaterFlow(Physics P, Check C) { //if (C.time < 5) { C.time++; return false; } byte meta = P.w.GetMeta(C.x, C.y, C.z); if (!P.HigherLiquidCheck(C.x, C.y, C.z, 8, meta) && !P.HigherLiquidCheck(C.x, C.y, C.z, 9, meta)) { if ((meta & 0x7) >= 0x7) P.AddUpdate(C.x, C.y, C.z, 0, 0); else { P.AddUpdate(C.x, C.y, C.z, 8, (byte)Math.Min(meta + 2, 0x7)); if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 8) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 9)) { C.time = 0; return false; } } } else if ((meta & 0x8) != 0) { if (!P.WaterFlowCheck(C.x, C.y - 1, C.z)) { meta = 0; goto flowOut; } P.WaterFlow(C.x, C.y - 1, C.z, 0x8); } else if ((meta & 0x7) < 0x7) { goto flowOut; } else { P.WaterFlow(C.x, C.y - 1, C.z, 0x8); } return true; flowOut: if (P.WaterFlowCheck(C.x, C.y - 1, C.z)) { P.WaterFlow(C.x, C.y - 1, C.z, 0x8); if (!P.AdjacentLiquidCheck(C.x, C.y, C.z, 8) && !P.AdjacentLiquidCheck(C.x, C.y, C.z, 9)) { P.WaterFlow(C.x + 1, C.y, C.z, 0x7); P.WaterFlow(C.x - 1, C.y, C.z, 0x7); P.WaterFlow(C.x, C.y, C.z + 1, 0x7); P.WaterFlow(C.x, C.y, C.z - 1, 0x7); } } else { meta++; P.WaterFlow(C.x + 1, C.y, C.z, meta); P.WaterFlow(C.x - 1, C.y, C.z, meta); P.WaterFlow(C.x, C.y, C.z + 1, meta); P.WaterFlow(C.x, C.y, C.z - 1, meta); } return true; }
public static bool SpongeSoak(Physics P, Check C) { P.SpongePlaced(C.x, C.y, C.z); return true; }
/// <summary> /// Initializes a new instance of the <see cref="SMP.World"/> class and generates 49 chunks. /// </summary> /// <param name='spawnx'> /// Spawnx. The x spawn pos. /// </param> /// <param name='spawny'> /// Spawny. The y spawn pos. /// </param> /// <param name='spawnz'> /// Spawnz. The z spawn pos. /// </param> public World(double spawnx, double spawny, double spawnz, string name, long seed) : this() { this.name = name; this.seed = seed; this.SpawnX = spawnx; this.SpawnY = spawny; this.SpawnZ = spawnz; chunkData = new Dictionary<Point, Chunk>(); physics = new Physics(this); generator = new GenStandard(this, true); chunkManager = new WorldChunkManager(this); Logger.Log("Generating " + this.name + "..."); int cursorH = 25 + this.name.Length; float count = 0, total = (Server.ViewDistance * 2 + 1) * (Server.ViewDistance * 2 + 1); Console.SetCursorPosition(cursorH, Console.CursorTop - 1); Console.Write("0%"); object derpLock = new object(); try // Mono 2.10.2 has Parallel.For(int) and Parallel.ForEach implemented, not sure about 2.8 though. Any version less does not support .NET 4.0 { Parallel.For(((int)SpawnX >> 4) - Server.ViewDistance, ((int)SpawnX >> 4) + Server.ViewDistance + 1, delegate(int x) { Parallel.For(((int)SpawnZ >> 4) - Server.ViewDistance, ((int)SpawnZ >> 4) + Server.ViewDistance + 1, delegate(int z) { LoadChunk(x, z, false, false); lock (derpLock) { Console.SetCursorPosition(cursorH, Console.CursorTop); count++; Console.Write((int)((count / total) * 100) + "%"); } }); //Logger.Log(x + " Row Generated."); }); } catch (NotImplementedException) { for (int x = ((int)SpawnX >> 4) - Server.ViewDistance; x < ((int)SpawnX >> 4) + Server.ViewDistance + 1; x++) { for (int z = ((int)SpawnZ >> 4) - Server.ViewDistance; z < ((int)SpawnZ >> 4) + Server.ViewDistance + 1; z++) { LoadChunk(x, z, false, false); Console.SetCursorPosition(cursorH, Console.CursorTop); count++; Console.Write((int)((count / total) * 100) + "%"); } //Logger.Log(x + " Row Generated."); } } Console.Write("\r"); Logger.Log("Look distance = " + Server.ViewDistance); Init(); physics.Start(); if (World.WorldLoad != null) World.WorldLoad(this); }
/// <summary> /// Initializes a new instance of the <see cref="SMP.World"/> class and generates 49 chunks. /// </summary> /// <param name='spawnx'> /// Spawnx. The x spawn pos. /// </param> /// <param name='spawny'> /// Spawny. The y spawn pos. /// </param> /// <param name='spawnz'> /// Spawnz. The z spawn pos. /// </param> public World(double spawnx, double spawny, double spawnz, string name, long seed) { this.seed = seed; chunkData = new Dictionary<Point, Chunk>(); generator = new GenStandard(this, true); this.name = name; Server.Log("Generating..."); try // Mono 2.10.2 has Parallel.For(int) and Parallel.ForEach implemented, not sure about 2.8 though. Any version less does not support .NET 4.0 { Parallel.For(-3, 4, delegate(int x) { Parallel.For(-3, 4, delegate(int z) { LoadChunk(x, z, false); }); Server.Log(x + " Row Generated."); }); } catch(NotImplementedException) { for (int x = -3; x < 4; x++) { for (int z = -3; z < 4; z++) { LoadChunk(x, z, false); } Server.Log(x + " Row Generated."); } } Server.Log("Look distance = 3"); this.SpawnX = spawnx; this.SpawnY = spawny; this.SpawnZ = spawnz; timeupdate.Elapsed += delegate { time += 20; if (time > 24000) time = 0; Player.players.ForEach(delegate(Player p) { if (p.MapLoaded && p.level == this) p.SendTime(); }); }; timeupdate.Start(); blockflush.Elapsed += delegate { FlushBlockChanges(); }; blockflush.Start(); this.physics = new Physics(this); this.physics.Start(); if (World.WorldLoad != null) World.WorldLoad(this); }