diff --git a/TrueCraft.API/World/IWorld.cs b/TrueCraft.API/World/IWorld.cs index fc71832..f6b74eb 100644 --- a/TrueCraft.API/World/IWorld.cs +++ b/TrueCraft.API/World/IWorld.cs @@ -10,6 +10,7 @@ namespace TrueCraft.API.World { string Name { get; set; } IChunkProvider ChunkProvider { get; set; } + long Time { get; set; } event EventHandler BlockChanged; diff --git a/TrueCraft.Core/Logic/Items/FlintAndSteelItem.cs b/TrueCraft.Core/Logic/Items/FlintAndSteelItem.cs new file mode 100644 index 0000000..ec5554e --- /dev/null +++ b/TrueCraft.Core/Logic/Items/FlintAndSteelItem.cs @@ -0,0 +1,18 @@ +using System; +using TrueCraft.API.Logic; + +namespace TrueCraft.Core.Logic.Items +{ + public class FlintAndSteelItem : ToolItem + { + public static readonly short ItemID = 0x103; + + public override short ID { get { return 0x103; } } + + public override sbyte MaximumStack { get { return 1; } } + + public override short BaseDurability { get { return 65; } } + + public override string DisplayName { get { return "Flint and Steel"; } } + } +} \ No newline at end of file diff --git a/TrueCraft.Core/World/World.cs b/TrueCraft.Core/World/World.cs index 79b66d9..bcb66f6 100644 --- a/TrueCraft.Core/World/World.cs +++ b/TrueCraft.Core/World/World.cs @@ -16,6 +16,18 @@ namespace TrueCraft.Core.World public string BaseDirectory { get; internal set; } public IDictionary Regions { get; set; } public IChunkProvider ChunkProvider { get; set; } + public DateTime BaseTime { get; set; } + public long Time + { + get + { + return (long)((DateTime.Now - BaseTime).TotalSeconds * 20) % 24000; + } + set + { + // TODO + } + } public event EventHandler BlockChanged; @@ -23,6 +35,7 @@ namespace TrueCraft.Core.World { Name = name; Regions = new Dictionary(); + BaseTime = DateTime.Now; } public World(string name, IChunkProvider chunkProvider) : this(name) diff --git a/TrueCraft/Commands/CommandManager.cs b/TrueCraft/Commands/CommandManager.cs index 3754c6f..3c81677 100644 --- a/TrueCraft/Commands/CommandManager.cs +++ b/TrueCraft/Commands/CommandManager.cs @@ -23,6 +23,8 @@ namespace TrueCraft.Commands Commands.Add(new GiveCommand()); Commands.Add(new HelpCommand()); Commands.Add(new ResendInvCommand()); + Commands.Add(new PositionCommand()); + Commands.Add(new TimeCommand()); } /// diff --git a/TrueCraft/Commands/DebugCommands.cs b/TrueCraft/Commands/DebugCommands.cs index 473c5de..b928de0 100644 --- a/TrueCraft/Commands/DebugCommands.cs +++ b/TrueCraft/Commands/DebugCommands.cs @@ -9,6 +9,72 @@ using TrueCraft.Core.Networking.Packets; namespace TrueCraft.Commands { + public class PositionCommand : Command + { + public override string Name + { + get { return "pos"; } + } + + public override string Description + { + get { return "Shows your position."; } + } + + public override string[] Aliases + { + get { return new string[0]; } + } + + public override void Handle(IRemoteClient Client, string Alias, string[] Arguments) + { + if (Arguments.Length != 0) + { + Help(Client, Alias, Arguments); + return; + } + Client.SendMessage(Client.Entity.Position.ToString()); + } + + public override void Help(IRemoteClient Client, string Alias, string[] Arguments) + { + Client.SendMessage("/pos: Shows your position."); + } + } + + public class TimeCommand : Command + { + public override string Name + { + get { return "time"; } + } + + public override string Description + { + get { return "Shows the current time."; } + } + + public override string[] Aliases + { + get { return new string[0]; } + } + + public override void Handle(IRemoteClient Client, string Alias, string[] Arguments) + { + if (Arguments.Length != 0) + { + Help(Client, Alias, Arguments); + return; + } + Client.SendMessage(Client.World.Time.ToString()); + } + + public override void Help(IRemoteClient Client, string Alias, string[] Arguments) + { + Client.SendMessage("/time: Shows the current time."); + } + } + public class ResendInvCommand : Command { public override string Name diff --git a/TrueCraft/Handlers/LoginHandlers.cs b/TrueCraft/Handlers/LoginHandlers.cs index fc46bd3..7dfcda2 100644 --- a/TrueCraft/Handlers/LoginHandlers.cs +++ b/TrueCraft/Handlers/LoginHandlers.cs @@ -44,6 +44,7 @@ namespace TrueCraft.Handlers (int)client.Entity.Position.Y, (int)client.Entity.Position.Z)); client.QueuePacket(new SetPlayerPositionPacket(client.Entity.Position.X, client.Entity.Position.Y, client.Entity.Position.Y + client.Entity.Size.Height, client.Entity.Position.Z, 0, 0, true)); + client.QueuePacket(new TimeUpdatePacket(client.World.Time)); // Start housekeeping for this client server.GetEntityManagerForWorld(client.World).SpawnEntity(client.Entity);