Give players an inventory and send it to clients
This also gives the player a stack of stone to play with on login, but that's a temporary change.
This commit is contained in:
parent
f02dcd9004
commit
c7a11b320d
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using TrueCraft.API.World;
|
using TrueCraft.API.World;
|
||||||
using TrueCraft.API.Entities;
|
using TrueCraft.API.Entities;
|
||||||
|
using TrueCraft.API.Windows;
|
||||||
|
|
||||||
namespace TrueCraft.API.Networking
|
namespace TrueCraft.API.Networking
|
||||||
{
|
{
|
||||||
@ -10,6 +11,7 @@ namespace TrueCraft.API.Networking
|
|||||||
bool DataAvailable { get; }
|
bool DataAvailable { get; }
|
||||||
IWorld World { get; }
|
IWorld World { get; }
|
||||||
IEntity Entity { get; }
|
IEntity Entity { get; }
|
||||||
|
IWindow Inventory { get; }
|
||||||
|
|
||||||
void QueuePacket(IPacket packet);
|
void QueuePacket(IPacket packet);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,12 @@ namespace TrueCraft.Core.Networking.Packets
|
|||||||
{
|
{
|
||||||
public byte ID { get { return 0x68; } }
|
public byte ID { get { return 0x68; } }
|
||||||
|
|
||||||
|
public WindowItemsPacket(sbyte windowID, ItemStack[] items)
|
||||||
|
{
|
||||||
|
WindowID = windowID;
|
||||||
|
Items = items;
|
||||||
|
}
|
||||||
|
|
||||||
public sbyte WindowID;
|
public sbyte WindowID;
|
||||||
public ItemStack[] Items;
|
public ItemStack[] Items;
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ namespace TrueCraft.Handlers
|
|||||||
client.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));
|
client.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));
|
||||||
client.ChunkRadius = 2;
|
client.ChunkRadius = 2;
|
||||||
client.UpdateChunks();
|
client.UpdateChunks();
|
||||||
|
client.QueuePacket(new WindowItemsPacket(0, client.Inventory.GetSlots()));
|
||||||
client.QueuePacket(new SpawnPositionPacket(0, 16, 0));
|
client.QueuePacket(new SpawnPositionPacket(0, 16, 0));
|
||||||
client.QueuePacket(new SetPlayerPositionPacket(0, 16, 17, 0, 0, 0, true));
|
client.QueuePacket(new SetPlayerPositionPacket(0, 16, 17, 0, 0, 0, true));
|
||||||
server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(10), client.SendKeepAlive);
|
server.Scheduler.ScheduleEvent(DateTime.Now.AddSeconds(10), client.SendKeepAlive);
|
||||||
|
@ -12,6 +12,8 @@ using System.Linq;
|
|||||||
using TrueCraft.Core.Networking.Packets;
|
using TrueCraft.Core.Networking.Packets;
|
||||||
using TrueCraft.Core.World;
|
using TrueCraft.Core.World;
|
||||||
using Ionic.Zlib;
|
using Ionic.Zlib;
|
||||||
|
using TrueCraft.API.Windows;
|
||||||
|
using TrueCraft.Core.Windows;
|
||||||
|
|
||||||
namespace TrueCraft
|
namespace TrueCraft
|
||||||
{
|
{
|
||||||
@ -24,6 +26,8 @@ namespace TrueCraft
|
|||||||
PacketQueue = new ConcurrentQueue<IPacket>();
|
PacketQueue = new ConcurrentQueue<IPacket>();
|
||||||
LoadedChunks = new List<Coordinates2D>();
|
LoadedChunks = new List<Coordinates2D>();
|
||||||
Server = server;
|
Server = server;
|
||||||
|
Inventory = new InventoryWindow();
|
||||||
|
InventoryWindow.Hotbar[0] = new ItemStack(1, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkStream NetworkStream { get; set; }
|
public NetworkStream NetworkStream { get; set; }
|
||||||
@ -34,6 +38,15 @@ namespace TrueCraft
|
|||||||
public IMultiplayerServer Server { get; set; }
|
public IMultiplayerServer Server { get; set; }
|
||||||
public IWorld World { get; internal set; }
|
public IWorld World { get; internal set; }
|
||||||
public IEntity Entity { get; internal set; }
|
public IEntity Entity { get; internal set; }
|
||||||
|
public IWindow Inventory { get; private set; }
|
||||||
|
|
||||||
|
public InventoryWindow InventoryWindow
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Inventory as InventoryWindow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal int ChunkRadius { get; set; }
|
internal int ChunkRadius { get; set; }
|
||||||
internal IList<Coordinates2D> LoadedChunks { get; set; }
|
internal IList<Coordinates2D> LoadedChunks { get; set; }
|
||||||
|
Reference in New Issue
Block a user