当前位置: 首页>>代码示例>>C#>>正文


C# MinecraftServer.GetClientWorld方法代码示例

本文整理汇总了C#中MinecraftServer.GetClientWorld方法的典型用法代码示例。如果您正苦于以下问题:C# MinecraftServer.GetClientWorld方法的具体用法?C# MinecraftServer.GetClientWorld怎么用?C# MinecraftServer.GetClientWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MinecraftServer的用法示例。


在下文中一共展示了MinecraftServer.GetClientWorld方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlePacket

        public override void HandlePacket(MinecraftServer server, MinecraftClient client)
        {
            switch (ClientStatus)
            {
                case ClientStatus.InitialSpawn:
                    // Create a hash for session verification
                    SHA1 sha1 = SHA1.Create();
                    AsnKeyBuilder.AsnMessage encodedKey = AsnKeyBuilder.PublicKeyToX509(server.ServerKey);
                    byte[] shaData = Encoding.UTF8.GetBytes(client.AuthenticationHash)
                        .Concat(client.SharedKey)
                        .Concat(encodedKey.GetBytes()).ToArray();
                    string hash = Cryptography.JavaHexDigest(shaData);

                    // Talk to session.minecraft.net
                    if (server.OnlineMode)
                    {
                        var webClient = new WebClient();
                        var webReader = new StreamReader(webClient.OpenRead(
                            new Uri(string.Format(sessionCheckUri, client.Username, hash))));
                        string response = webReader.ReadToEnd();
                        webReader.Close();
                        if (response != "YES")
                        {
                            client.SendPacket(new DisconnectPacket("Failed to verify username!"));
                            return;
                        }
                    }

                    server.LogInPlayer(client);
                    break;
                case ClientStatus.Respawn:
                    var world = server.GetClientWorld(client);
                    client.Entity.Position = new Vector3(
                        client.Entity.SpawnPoint.X,
                        client.Entity.SpawnPoint.Y + PlayerEntity.Height,
                        client.Entity.SpawnPoint.Z);
                    client.Entity.Health = client.Entity.MaxHealth;
                    client.Entity.Food = 20;
                    client.Entity.FoodSaturation = 20;
                    server.EntityManager.SpawnEntity(server.GetClientWorld(client), client.Entity);
                    //client.SendPacket(new UpdateHealthPacket(client.Entity.Health, client.Entity.Food, client.Entity.FoodSaturation));
                    client.SendPacket(new RespawnPacket(Dimension.Overworld, server.Difficulty,
                        client.Entity.GameMode, world.LevelType));
                    client.SendPacket(new PlayerPositionAndLookPacket(
                                  client.Entity.Position, client.Entity.Yaw, client.Entity.Pitch, true));
                    server.ProcessSendQueue();
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:51,代码来源:ClientStatusPacket.cs

示例2: HandlePacket

 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     if (client.Entity.Position.DistanceTo(Position) <= MaxDigDistance)
     {
         switch (Action)
         {
             case PlayerAction.StartedDigging:
                 if (client.Entity.GameMode == GameMode.Creative)
                     server.GetClientWorld(client).SetBlock(Position, new AirBlock());
                 break;
             case PlayerAction.FinishedDigging:
                 server.GetClientWorld(client).SetBlock(Position, new AirBlock());
                 break;
         }
     }
 }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:16,代码来源:PlayerDiggingPacket.cs

示例3: HandlePacket

 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     if (Client.Entity.Position.DistanceTo(Position) <= MaxDigDistance)
     {
         switch (Action)
         {
             case PlayerAction.StartedDigging:
                 // if (creative)
                 Server.GetClientWorld(Client).SetBlock(Position, new AirBlock());
                 break;
             case PlayerAction.FinishedDigging:
                 Server.GetClientWorld(Client).SetBlock(Position, new AirBlock());
                 break;
         }
     }
 }
开发者ID:keneo,项目名称:Craft.Net,代码行数:16,代码来源:PlayerDiggingPacket.cs

示例4: HandlePacket

 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     switch (Action)
     {
         case EntityAction.Crouch:
             Client.IsCrouching = true;
             break;
         case EntityAction.Uncrouch:
             Client.IsCrouching = false;
             break;
         case EntityAction.StartSprinting:
             Client.IsSprinting = true;
             break;
         case EntityAction.StopSprinting:
             Client.IsSprinting = false;
             break;
     }
     if (Action != EntityAction.LeaveBed) // NOTE: Does this matter?
     {
         this.EntityId = Client.Entity.Id;
         for (int i = 0; i < 
              Server.GetClientsInWorld(Server.GetClientWorld(Client)).Count(); i++)
         {
             if (Server.Clients [i] != Client)
                 Server.Clients [i].SendPacket(this);
         }
         Server.ProcessSendQueue();
     }
 }
开发者ID:keneo,项目名称:Craft.Net,代码行数:29,代码来源:EntityActionPacket.cs

示例5: HandlePacket

 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     EntityId = client.Entity.Id;
     var clients = server.GetClientsInWorld(server.GetClientWorld(client)).Where(c => c.Entity.Id != EntityId);
     foreach (var _client in clients)
         _client.SendPacket(this);
     server.ProcessSendQueue();
 }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:8,代码来源:AnimationPacket.cs

示例6: SendPacket

 public override void SendPacket(MinecraftServer server, MinecraftClient client)
 {
     byte[] payload = new byte[] { PacketId }
         .Concat(DataUtility.CreateInt32((int)Dimension))
         .Concat(new byte[] { (byte)Difficulty, (byte)GameMode })
         .Concat(DataUtility.CreateInt16(WorldHeight))
         .Concat(DataUtility.CreateString(server.GetClientWorld(client).LevelType))
         .ToArray();
     client.SendData(payload);
 }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:10,代码来源:RespawnPacket.cs

示例7: HandlePacket

 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     if (!Client.ReadyToSpawn)
         return;
     Client.Entity.Position = new Vector3(X, Y, Z);
     if (Client.Entity.Position.DistanceTo(Client.Entity.OldPosition) > 
         Client.MaxMoveDistance)
     {
         Client.SendPacket(new DisconnectPacket("Hacking: You moved too fast!"));
         Server.ProcessSendQueue();
         return;
     }
     Client.UpdateChunksAsync();
     Server.GetClientWorld(Client).EntityManager.UpdateEntity(Client.Entity);
     Server.ProcessSendQueue();
 }
开发者ID:keneo,项目名称:Craft.Net,代码行数:16,代码来源:PlayerPositionPacket.cs

示例8: HandlePacket

 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     if (Client.Entity.Position.DistanceTo(Position) > 6)
         return;
     if (HeldItem.Id < 0x80 && HeldItem.Id >= 0)
     {
         Block block = (Block)HeldItem.Id;
         Vector3 clickedBlock = Position;
         Vector3 placedBlock = Position;
         placedBlock += AdjustByDirection(Direction);
         if (block != null)
         {
             // TODO: More stuff here
             Server.GetClientWorld(Client).SetBlock(placedBlock, block);
         }
     }
 }
开发者ID:keneo,项目名称:Craft.Net,代码行数:17,代码来源:BlockPlacementPacket.cs

示例9: HandlePacket

 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     if (client.Entity.Position.DistanceTo(Position) > 6) // TODO: Use client.Reach
         return;
     var item = client.Entity.Inventory[client.Entity.SelectedSlot];
     if (item != null && item.Id == 0xFFFF)
         item.Id = 0;
     if (item != null)
     {
         item.Item.OnItemUsed(server.GetClientWorld(client), Position, AdjustByDirection(Direction), CursorPosition, client.Entity);
         if (client.Entity.GameMode != GameMode.Creative)
             client.Entity.Inventory[client.Entity.SelectedSlot].Count--;
     }
     else
     {
         client.SendPacket(new DisconnectPacket("Unrecognized item!"));
         server.ProcessSendQueue();
     }
 }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:19,代码来源:BlockPlacementPacket.cs


注:本文中的MinecraftServer.GetClientWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。