diff --git a/Blocks/Behaviour/Block.Behaviour.cs b/Blocks/Behaviour/Block.Behaviour.cs index 3a554e814..2cfdbaef6 100644 --- a/Blocks/Behaviour/Block.Behaviour.cs +++ b/Blocks/Behaviour/Block.Behaviour.cs @@ -59,6 +59,7 @@ namespace MCGalaxy { walkthroughHandlers[Block.air_switch] = WalkthroughBehaviour.Door; walkthroughHandlers[Block.water_door] = WalkthroughBehaviour.Door; walkthroughHandlers[Block.lava_door] = WalkthroughBehaviour.Door; + walkthroughHandlers[Block.train] = WalkthroughBehaviour.Train; for (int i = 0; i < 256; i++) { if (Props[i].IsMessageBlock) { diff --git a/Blocks/Behaviour/WalkthroughBehaviour.cs b/Blocks/Behaviour/WalkthroughBehaviour.cs index 2cc29190e..7306b260f 100644 --- a/Blocks/Behaviour/WalkthroughBehaviour.cs +++ b/Blocks/Behaviour/WalkthroughBehaviour.cs @@ -20,10 +20,19 @@ using System.Collections.Generic; using System.Data; using MCGalaxy.SQL; -namespace MCGalaxy.BlockBehaviour { - +namespace MCGalaxy.BlockBehaviour { internal static class WalkthroughBehaviour { + internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) { + p.level.Blockchange(x, y, z, Block.DoorAirs(block)); + return true; + } + + internal static bool Train(Player p, byte block, ushort x, ushort y, ushort z) { + if (!p.onTrain) p.HandleDeath(Block.train); + return true; + } + internal static bool Portal(Player p, byte block, ushort x, ushort y, ushort z, bool checkPos) { if (checkPos && p.level.PosToInt(x, y, z) == p.lastWalkthrough) return true; p.RevertBlock(x, y, z); @@ -107,11 +116,6 @@ namespace MCGalaxy.BlockBehaviour { return true; } - internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) { - p.level.Blockchange(x, y, z, Block.DoorAirs(block)); - return true; - } - static string[] sep = { " |/" }; const StringSplitOptions opts = StringSplitOptions.RemoveEmptyEntries; static List empty = new List(); diff --git a/Commands/other/CmdRide.cs b/Commands/other/CmdRide.cs index edb7ebdfd..cb3c5096b 100644 --- a/Commands/other/CmdRide.cs +++ b/Commands/other/CmdRide.cs @@ -16,10 +16,8 @@ permissions and limitations under the Licenses. */ using System.Threading; -namespace MCGalaxy.Commands -{ - public sealed class CmdRide : Command - { +namespace MCGalaxy.Commands { + public sealed class CmdRide : Command { public override string name { get { return "ride"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Other; } } @@ -48,7 +46,7 @@ namespace MCGalaxy.Commands for (ushort zz = (ushort)(z - 1); zz <= z + 1; zz++) { if (p.level.GetTile(xx, yy, zz) != Block.train) continue; - p.invincible = true; p.trainGrab = true; + p.trainGrab = true; byte yaw = 0, pitch = 0; if (y - yy == -1) pitch = 240; @@ -76,7 +74,6 @@ namespace MCGalaxy.Commands } Thread.Sleep(3); - p.invincible = false; p.trainGrab = false; skip: ; @@ -84,8 +81,8 @@ namespace MCGalaxy.Commands Player.Message(p, "Dismounted"); Thread.Sleep(1000); - p.invincible = false; p.trainGrab = false; + p.onTrain = false; } public override void Help(Player p) { diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index 87d0d3026..a24301cdc 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -830,6 +830,7 @@ return; if (!immediate && lastDeath.AddSeconds(2) > DateTime.UtcNow) return; if (!level.Killer || invincible || hidden) return; + onTrain = false; trainGrab = false; ushort x = (ushort)(pos[0] / 32), y = (ushort)(pos[1] / 32), z = (ushort)(pos[2] / 32); string deathMsg = Block.Props[b].DeathMessage; if (deathMsg != null) Chat.GlobalChatLevel(this, String.Format(deathMsg, ColoredName), false);