From 924a9d6f023ff366afb0e4196156e3bacc5b5256 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 8 Jun 2020 00:08:20 +1000 Subject: [PATCH] Fix fuse block not getting destroyed in nodestroy zones in TNT wars --- MCGalaxy/Blocks/Physics/TntPhysics.cs | 18 +++++++++++------- MCGalaxy/Commands/CPE/CustomBlockCommand.cs | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/MCGalaxy/Blocks/Physics/TntPhysics.cs b/MCGalaxy/Blocks/Physics/TntPhysics.cs index 97aa85311..93ae86769 100644 --- a/MCGalaxy/Blocks/Physics/TntPhysics.cs +++ b/MCGalaxy/Blocks/Physics/TntPhysics.cs @@ -92,6 +92,10 @@ namespace MCGalaxy.Blocks.Physics { Explode(lvl, x, y, z, size + 3, rand, 3, game); } + static bool IsFuse(BlockID b, int dx, int dy, int dz) { + return dx == 0 && dy == 1 && dz == 0 && b == Block.StillLava; + } + static void Explode(Level lvl, ushort x, ushort y, ushort z, int size, Random rand, int prob, TWGame game) { for (int xx = (x - size); xx <= (x + size ); ++xx) @@ -99,12 +103,12 @@ namespace MCGalaxy.Blocks.Physics { for (int zz = (z - size); zz <= (z + size); ++zz) { int index; - BlockID block = lvl.GetBlock((ushort)xx, (ushort)yy, (ushort)zz, out index); - if (block == Block.Invalid) continue; + BlockID b = lvl.GetBlock((ushort)xx, (ushort)yy, (ushort)zz, out index); + if (b == Block.Invalid) continue; bool doDestroy = prob < 0 || rand.Next(1, 10) < prob; - if (doDestroy && Block.Convert(block) != Block.TNT) { - if (game != null && block != Block.Air) { + if (doDestroy && Block.Convert(b) != Block.TNT) { + if (game != null && b != Block.Air && !IsFuse(b, xx - x, yy - y, zz - z)) { if (game.InZone((ushort)xx, (ushort)yy, (ushort)zz, game.tntImmuneZones)) continue; } @@ -116,13 +120,13 @@ namespace MCGalaxy.Blocks.Physics { lvl.AddUpdate(index, Block.Air, default(PhysicsArgs)); } else { PhysicsArgs args = default(PhysicsArgs); - args.Type1 = PhysicsArgs.Drop; args.Value1 = 50; + args.Type1 = PhysicsArgs.Drop; args.Value1 = 50; args.Type2 = PhysicsArgs.Dissipate; args.Value2 = 8; lvl.AddCheck(index, false, args); } - } else if (block == Block.TNT) { + } else if (b == Block.TNT) { lvl.AddUpdate(index, Block.TNT_Small, default(PhysicsArgs)); - } else if (block == Block.TNT_Small || block == Block.TNT_Big || block == Block.TNT_Nuke) { + } else if (b == Block.TNT_Small || b == Block.TNT_Big || b == Block.TNT_Nuke) { lvl.AddCheck(index); } } diff --git a/MCGalaxy/Commands/CPE/CustomBlockCommand.cs b/MCGalaxy/Commands/CPE/CustomBlockCommand.cs index ef9c57f9f..3f54cc656 100644 --- a/MCGalaxy/Commands/CPE/CustomBlockCommand.cs +++ b/MCGalaxy/Commands/CPE/CustomBlockCommand.cs @@ -652,6 +652,7 @@ namespace MCGalaxy.Commands.CPE { if (!CommandParser.CheckRange(p, P.Y, "Y", -127, 127)) return false; if (!CommandParser.CheckRange(p, P.Z, "Z", -127, 127)) return false; + // TODO: Improve output message with relative coords (currently shows "Set max for Stone to ~ ~8 ~") x = (byte)P.X; z = (byte)P.Y; y = (byte)P.Z; // blockdef files have z being height, we use y being height return true; }