Просмотр исходного кода

update projects dot netcore version

JasonWang 6 лет назад
Родитель
Сommit
d932bc7e95

+ 1 - 1
README-zh.md

@@ -13,7 +13,7 @@ MineCase
 
 不同的区块由不同的服务器管理,所有的玩家都可以在同一个世界进行游戏,这位minecraft服务器带来了更多的拓展性。
 
-目前仅支持 `Minecraft`  [1.14.4](https://www.minecraft.net/en-us/article/minecraft-java-1-14-4-released)的版本。
+目前仅支持 `Minecraft`  [1.15.2](https://www.minecraft.net/en-us/article/minecraft-java-edition-1-15-2)的版本。
 
 ![Screenshots](screenshots/1.jpg)
 

+ 1 - 1
README.md

@@ -11,7 +11,7 @@ MineCase
 The project is designed to create a high-performance, distributed `Minecraft` server with virtual actor provided by Orleans distributed framework. 
 Different chunks are managed on different servers so that more players can join in and play in the same world. This makes minecraft servers more scalable.
 Servers like Anarchy servers can allow more players to join in without waiting in queue by using distributed server.
-It written in `C#` with `.NET Core 2.0` env and based on `orleans` framework to work with released [1.14.4 protocol](https://www.minecraft.net/en-us/article/minecraft-java-1-14-4-released). The [website](https://wiki.vg/) describes the Minecraft protocol clearly.
+It written in `C#` with `.NET Core 3.1` env and based on `orleans` framework to work with released [1.15.2 protocol](https://www.minecraft.net/en-us/article/minecraft-java-edition-1-15-2). The [website](https://wiki.vg/) describes the Minecraft protocol clearly.
 
 **MineCase is under refactoring, so branch refactor may not work.**
 

+ 1 - 1
src/MineCase.Core/MineCase.Core.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>
 
   <ItemGroup>

+ 1 - 1
src/MineCase.Gateway/MineCase.Gateway.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <LangVersion>7.2</LangVersion>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>

+ 1 - 1
src/MineCase.Nbt/MineCase.Nbt.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFrameworks>netstandard2.0</TargetFrameworks>
+    <TargetFrameworks>netcoreapp3.1</TargetFrameworks>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
     <Configurations>Debug;Release;Appveyor;TravisCI</Configurations>

+ 2 - 2
src/MineCase.Protocol/MineCase.Protocol.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <LangVersion>7.2</LangVersion>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
@@ -26,11 +26,11 @@
 
   <ItemGroup>
     <ProjectReference Include="..\MineCase.Core\MineCase.Core.csproj" />
+    <ProjectReference Include="..\MineCase.Nbt\MineCase.Nbt.csproj" />
   </ItemGroup>
 
   <ItemGroup>
     <Folder Include="Protocol\Play\Server\" />
-    <Folder Include="Protocol\Play\Client\" />
   </ItemGroup>
 
 </Project>

+ 78 - 0
src/MineCase.Protocol/Protocol/Play/Client/ChunkData.cs

@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using MineCase.Serialization;
+
+namespace MineCase.Protocol.Protocol.Play.Client
+{
+    [Packet(0x22, ProtocolType.Play, PacketDirection.ClientBound)]
+    public sealed class ChunkData : ISerializablePacket
+    {
+        [SerializeAs(DataType.Int)]
+        public int ChunkX;
+
+        [SerializeAs(DataType.Int)]
+        public int ChunkZ;
+
+        [SerializeAs(DataType.Boolean)]
+        public bool FullChunk;
+
+        [SerializeAs(DataType.VarInt)]
+        public int PrimaryBitMask;
+
+        [SerializeAs(DataType.ByteArray)]
+        public Nbt.Tags.NbtCompound Heightmaps;
+
+        [SerializeAs(DataType.Array)]
+        public byte[] Data;
+
+        [SerializeAs(DataType.VarInt)]
+        public uint NumberOfBlockEntities;
+
+        [SerializeAs(DataType.Array)]
+        public List<Nbt.Tags.NbtCompound> BlockEntities;
+
+        public void Deserialize(BinaryReader br)
+        {
+            ChunkX = br.ReadAsInt();
+            ChunkZ = br.ReadAsInt();
+            FullChunk = br.ReadAsBoolean();
+            PrimaryBitMask = br.ReadAsVarInt(out _);
+            Heightmaps = br.ReadAsCompoundTag();
+            if (FullChunk)
+            {
+                // TODO: read biome
+            }
+
+            int size = br.ReadAsVarInt(out _);
+            if (size > 2 * 1024 * 1024)
+                throw new InvalidDataException("Chunk Packet trying to allocate too much memory on read.");
+            Data = br.ReadAsByteArray(size);
+            int blockEntitiesNum = br.ReadAsVarInt(out _);
+            BlockEntities = new List<Nbt.Tags.NbtCompound>();
+
+            for (int i = 0; i < blockEntitiesNum; ++i)
+            {
+                BlockEntities.Add(br.ReadAsCompoundTag());
+            }
+        }
+
+        public void Serialize(BinaryWriter bw)
+        {
+            bw.WriteAsInt(ChunkX);
+            bw.WriteAsInt(ChunkZ);
+            bw.WriteAsBoolean(FullChunk);
+            bw.WriteAsVarInt(PrimaryBitMask, out _);
+            bw.WriteAsCompoundTag(Heightmaps);
+            bw.WriteAsVarInt(Data.Length, out _);
+            bw.WriteAsByteArray(Data);
+            bw.WriteAsVarInt(BlockEntities.Count, out _);
+
+            foreach (Nbt.Tags.NbtCompound compoundnbt in BlockEntities)
+            {
+                bw.WriteAsCompoundTag(compoundnbt);
+            }
+        }
+    }
+}

+ 5 - 0
src/MineCase.Protocol/Serialization/BinaryReaderExtensions.cs

@@ -74,6 +74,11 @@ namespace MineCase.Serialization
         {
             return br.ReadBytes(length);
         }
+
+        public static Nbt.Tags.NbtCompound ReadAsCompoundTag(this BinaryReader br)
+        {
+            return (Nbt.Tags.NbtCompound)Nbt.Serialization.NbtTagSerializer.DeserializeTag(br);
+        }
     }
 
     internal static class StreamExtensions

+ 12 - 0
src/MineCase.Protocol/Serialization/BinaryWriterExtensions.cs

@@ -70,5 +70,17 @@ namespace MineCase.Serialization
             bw.WriteAsVarInt(bytes.Length, out _);
             bw.Write(bytes);
         }
+
+        public static void WriteAsCompoundTag(this BinaryWriter bw, Nbt.Tags.NbtCompound nbt)
+        {
+            if (nbt == null)
+            {
+                bw.WriteAsByte(0);
+            }
+            else
+            {
+                Nbt.Serialization.NbtTagSerializer.SerializeTag(nbt, bw);
+            }
+        }
     }
 }

+ 1 - 1
src/MineCase.Server.Grains/MineCase.Server.Grains.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <LangVersion>7.2</LangVersion>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>

+ 1 - 1
src/MineCase.Server.Interfaces/MineCase.Server.Interfaces.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <LangVersion>7.2</LangVersion>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>

+ 1 - 1
src/MineCase.Server/MineCase.Server.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <LangVersion>7.2</LangVersion>
     <CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>