diff --git a/TrueCraft.Core/Logic/Blocks/AirBlock.cs b/TrueCraft.Core/Logic/Blocks/AirBlock.cs index 73aee09..649b204 100644 --- a/TrueCraft.Core/Logic/Blocks/AirBlock.cs +++ b/TrueCraft.Core/Logic/Blocks/AirBlock.cs @@ -20,6 +20,8 @@ namespace TrueCraft.Core.Logic.Blocks public override string DisplayName { get { return "Air"; } } + public override BoundingBox? BoundingBox { get { return null; } } + public override Tuple GetTextureMap(byte metadata) { return new Tuple(0, 0); diff --git a/TrueCraft/Handlers/LoginHandlers.cs b/TrueCraft/Handlers/LoginHandlers.cs index 27b2a66..bbf503e 100644 --- a/TrueCraft/Handlers/LoginHandlers.cs +++ b/TrueCraft/Handlers/LoginHandlers.cs @@ -5,6 +5,7 @@ using TrueCraft.API.Networking; using TrueCraft.Core.Networking.Packets; using TrueCraft.API; using TrueCraft.Core.Entities; +using TrueCraft.API.World; namespace TrueCraft.Handlers { @@ -41,6 +42,17 @@ namespace TrueCraft.Handlers if (!remoteClient.Load()) remoteClient.Entity.Position = remoteClient.World.SpawnPoint; + // Make sure they don't spawn in the ground + var collision = new Func(() => + { + var feet = client.World.GetBlockID((Coordinates3D)client.Entity.Position); + var head = client.World.GetBlockID((Coordinates3D)(client.Entity.Position + Vector3.Up)); + var feetBox = server.BlockRepository.GetBlockProvider(feet).BoundingBox; + var headBox = server.BlockRepository.GetBlockProvider(head).BoundingBox; + return feetBox != null || headBox != null; + }); + while (collision()) + client.Entity.Position += Vector3.Up; // Send setup packets remoteClient.QueuePacket(new LoginResponsePacket(0, 0, Dimension.Overworld));