diff --git a/Blocks/Behaviour/Block.Behaviour.cs b/Blocks/Behaviour/Block.Behaviour.cs index 995e7d844..ab873a209 100644 --- a/Blocks/Behaviour/Block.Behaviour.cs +++ b/Blocks/Behaviour/Block.Behaviour.cs @@ -107,9 +107,9 @@ namespace MCGalaxy { physicsHandlers[Block.WaterDown] = ExtLiquidPhysics.DoWaterfall; physicsHandlers[Block.LavaDown] = ExtLiquidPhysics.DoLavafall; physicsHandlers[Block.WaterFaucet] = (lvl, C) => - ExtLiquidPhysics.DoFaucet(lvl, C, Block.WaterDown); + ExtLiquidPhysics.DoFaucet(lvl, C, Block.WaterDown); physicsHandlers[Block.LavaFaucet] = (lvl, C) => - ExtLiquidPhysics.DoFaucet(lvl, C, Block.LavaDown); + ExtLiquidPhysics.DoFaucet(lvl, C, Block.LavaDown); physicsHandlers[Block.finiteWater] = FinitePhysics.DoWaterOrLava; physicsHandlers[Block.finiteLava] = FinitePhysics.DoWaterOrLava; physicsHandlers[Block.finiteFaucet] = FinitePhysics.DoFaucet; @@ -149,18 +149,28 @@ namespace MCGalaxy { physicsHandlers[Block.train] = TrainPhysics.Do; for (int i = 0; i < 256; i++) { - //Adv physics updating anything placed next to water or lava - if ((i >= Block.red && i <= Block.redmushroom) || i == Block.wood || - i == Block.trunk || i == Block.bookcase) { - physicsHandlers[i] = OtherPhysics.DoOther; - continue; - } - - byte odoor = Block.odoor((byte)i); - if (odoor != Block.Zero) { - physicsHandlers[i] = DoorPhysics.odoorPhysics; - physicsDoorsHandlers[i] = DoorPhysics.odoorPhysics; - } + //Adv physics updating anything placed next to water or lava + if ((i >= Block.red && i <= Block.redmushroom) || i == Block.wood || + i == Block.trunk || i == Block.bookcase) { + physicsHandlers[i] = OtherPhysics.DoOther; + continue; + } + + byte odoor = Block.odoor((byte)i); + byte door = Block.DoorAirs((byte)i); + if (odoor != Block.Zero) { + physicsHandlers[i] = DoorPhysics.odoorPhysics; + physicsDoorsHandlers[i] = DoorPhysics.odoorPhysics; + } else if (door == Block.door_tnt_air) { + physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4); + physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4); + } else if (door == Block.air_switch_air || door == Block.air_door_air) { + physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4, true); + physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4, true); + } else if (door != Block.air) { + physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 16); + physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 16); + } } } } diff --git a/Levels/Level.Physics.cs b/Levels/Level.Physics.cs index 4fc566435..99b1a3bdd 100644 --- a/Levels/Level.Physics.cs +++ b/Levels/Level.Physics.cs @@ -132,12 +132,17 @@ namespace MCGalaxy { IntToPos(C.b, out x, out y, out z); try { string info = C.data as string; - if (info == null) info = ""; - + if (info == null) info = ""; if (PhysicsUpdate != null) PhysicsUpdate(x, y, z, C.time, info, this); - if (info.Length == 0 || ExtraInfoPhysics.DoDoorsOnly(this, C, null)) - DoorPhysics.Do(this, C, true); + + if (info.Length == 0 || ExtraInfoPhysics.DoDoorsOnly(this, C, null)) { + Block.HandlePhysics handler = Block.physicsDoorsHandlers[blocks[C.b]]; + if (handler != null) + handler(this, C); + else if (info.Length == 0 || !info.Contains("wait")) + C.time = 255; + } } catch { listCheckExists.Set(x, y, z, false); ListCheck.Remove(C); @@ -149,14 +154,19 @@ namespace MCGalaxy { IntToPos(C.b, out x, out y, out z); try { string info = C.data as string; - if (info == null) info = ""; - + if (info == null) info = ""; if (PhysicsUpdate != null) PhysicsUpdate(x, y, z, C.time, info, this); if (OnPhysicsUpdateEvent.events.Count > 0) OnPhysicsUpdateEvent.Call(x, y, z, C.time, info, this); - if (info.Length == 0 || ExtraInfoPhysics.DoComplex(this, C)) - DoorPhysics.Do(this, C, false); + + if (info.Length == 0 || ExtraInfoPhysics.DoComplex(this, C)) { + Block.HandlePhysics handler = Block.physicsHandlers[blocks[C.b]]; + if (handler != null) + handler(this, C); + else if (info.Length == 0 || !info.Contains("wait")) + C.time = 255; + } } catch { listCheckExists.Set(x, y, z, false); ListCheck.Remove(C); diff --git a/Levels/Physics/DoorPhysics.cs b/Levels/Physics/DoorPhysics.cs index 80f767790..8cfadb882 100644 --- a/Levels/Physics/DoorPhysics.cs +++ b/Levels/Physics/DoorPhysics.cs @@ -21,51 +21,6 @@ namespace MCGalaxy.BlockPhysics { public static class DoorPhysics { - public static void Do(Level lvl, Check C, bool doorsOnly) { - switch (lvl.blocks[C.b]) { - - //Change any door blocks nearby into door_air - case Block.door_tree_air: - case Block.door_obsidian_air: - case Block.door_glass_air: - case Block.door_stone_air: - case Block.door_leaves_air: - case Block.door_sand_air: - case Block.door_wood_air: - case Block.door_green_air: - case Block.door_stair_air: - case Block.water_door_air: - case Block.lava_door_air: - case Block.door_iron_air: - case Block.door_gold_air: - case Block.door_cobblestone_air: - case Block.door_red_air: - case Block.door_darkpink_air: - case Block.door_darkgrey_air: - case Block.door_lightgrey_air: - case Block.door_white_air: - - case Block.door_dirt_air: - case Block.door_grass_air: - case Block.door_blue_air: - case Block.door_book_air: - AnyDoor(lvl, C, 16); break; - case Block.air_switch_air: - case Block.air_door_air: - AnyDoor(lvl, C, 4, true); break; - case Block.door_tnt_air: - AnyDoor(lvl, C, 4); break; - default: - // TODO: door only selector - Block.HandlePhysics handler = Block.physicsHandlers[lvl.blocks[C.b]]; - if (!doorsOnly && handler != null) { handler(lvl, C); return; } - //non special blocks are then ignored, maybe it would be better to avoid getting here and cutting down the list - if (!(C.data is string) || !((string)C.data).Contains("wait")) - C.time = 255; - break; - } - } - public static void odoorPhysics(Level lvl, Check C) { if (C.time != 0) { C.time = 0; return; } @@ -86,7 +41,8 @@ namespace MCGalaxy.BlockPhysics { lvl.AddUpdate(index, block, true); } - static void AnyDoor(Level lvl, Check C, int timer, bool instaUpdate = false) { + //Change any door blocks nearby into door_air + public static void AnyDoor(Level lvl, Check C, int timer, bool instaUpdate = false) { ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (C.time != 0) {