Skip to content

Commit 12fa021

Browse files
committed
Merge branch 'master' into release
2 parents d224ab1 + dd524f7 commit 12fa021

File tree

12 files changed

+90
-72
lines changed

12 files changed

+90
-72
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ jobs:
3838
file: src/MiNET/MiNET.Console/minet.zip
3939
asset_name: MiNET.zip
4040
tag: ${{ github.ref }}
41-
release_name: MiNET-CobwebSMP 1.13.0.12 (1.21.0)
41+
release_name: MiNET-CobwebSMP 1.13.0.13 (1.21.2)
4242
body: ${{ github.event.head_commit.message }}

src/MiNET/MiNET.Client/BedrockTraceHandler.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,25 @@ public override void HandleMcpeInventoryContent(McpeInventoryContent message)
206206
public override void HandleMcpeCreativeContent(McpeCreativeContent message)
207207
{
208208
Log.Warn($"[McpeCreativeContent] Received {message.input.Count} creative items");
209+
FileStream file = File.OpenWrite("newResources/creativeInventory.txt");
210+
var writer = new IndentedTextWriter(new StreamWriter(file), "\t");
211+
writer.WriteLine($"//Minecraft Bedrock Edition {McpeProtocolInfo.GameVersion} Creative Inventory");
209212
foreach (var item in message.input)
210213
{
211214
//Log.Warn($"Got item: {item.Name} ({item.Id} : {item.Metadata})");
215+
if (item.ExtraData == null)
216+
{
217+
writer.WriteLine($"new Item({item.Id}, {item.Metadata}),");
218+
}
219+
else
220+
{
221+
writer.WriteLine($"new Item({item.Id}, {item.Metadata}){{ ExtraData = {item.ExtraData}}},");
222+
}
212223
}
213224
Log.Warn($"[McpeCreativeContent] Done reading {message.input.Count} creative items\n");
225+
writer.Flush();
226+
file.Close();
227+
Log.Warn("Received creative items exported to newResources/creativeInventory.txt\n");
214228
}
215229

216230
public override void HandleMcpeAddItemEntity(McpeAddItemEntity message)
@@ -458,7 +472,7 @@ public override void HandleMcpeCraftingData(McpeCraftingData message)
458472
{
459473
if (Client.IsEmulator) return;
460474

461-
string fileName = Path.GetTempPath() + "Recipes_" + Guid.NewGuid() + ".txt";
475+
string fileName = "newResources/recipes.txt";
462476
Log.Info("Writing recipes to filename: " + fileName);
463477
FileStream file = File.OpenWrite(fileName);
464478

@@ -569,6 +583,7 @@ public override void HandleMcpeCraftingData(McpeCraftingData message)
569583

570584
writer.Flush();
571585
file.Close();
586+
Log.Warn("Received recipes exported to newResources/recipes.txt\n");
572587
//Environment.Exit(0);
573588
}
574589

@@ -723,7 +738,8 @@ public override void HandleMcpeBiomeDefinitionList(McpeBiomeDefinitionList messa
723738

724739
var root = message.namedtag.NbtFile.RootTag;
725740
//Log.Debug($"\n{root}");
726-
File.WriteAllText(Path.Combine(Path.GetTempPath(), "Biomes_" + Guid.NewGuid() + ".txt"), root.ToString());
741+
File.WriteAllText("newResources/biomes.txt", root.ToString());
742+
Log.Warn("Received biome definitions exported to newResources/biomes.txt\n");
727743
}
728744

729745
public override void HandleMcpeNetworkChunkPublisherUpdate(McpeNetworkChunkPublisherUpdate message)

src/MiNET/MiNET.Console/a.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/MiNET/MiNET.Console/minet.zip

600 KB
Binary file not shown.

src/MiNET/MiNET.Console/runtimeconfig.template.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"configProperties": {
44
"System.GC.Server": true,
55
"System.GC.Concurrent": true,
6-
"System.Drawing.EnableUnixSupport": true
76
}
87
}
98
}

src/MiNET/MiNET/Entities/ImageProviders/TextMapImageProvider.cs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,33 @@
2323

2424
#endregion
2525

26-
using System.Drawing;
27-
using System.Drawing.Imaging;
2826
using MiNET.Net;
2927
using MiNET.Utils;
28+
using SixLabors.Fonts;
29+
using SixLabors.ImageSharp;
30+
using SixLabors.ImageSharp.Drawing.Processing;
31+
using SixLabors.ImageSharp.PixelFormats;
32+
using SixLabors.ImageSharp.Processing;
33+
using RectangleF = System.Drawing.RectangleF;
3034

3135
namespace MiNET.Entities.ImageProviders
3236
{
3337
public class TextMapImageProvider : IMapImageProvider
3438
{
39+
private static FontCollection _fontCollection;
3540
private static Font _font = null;
36-
41+
3742
static TextMapImageProvider()
3843
{
39-
_font = new Font("Arial", 9);
44+
_fontCollection = new FontCollection();
45+
_fontCollection.AddSystemFonts();
46+
47+
if (_fontCollection.TryGet("Arial", out var family))
48+
{
49+
_font = family.CreateFont(9);
50+
}
4051
}
41-
52+
4253
public string Text { get; set; }
4354

4455
public TextMapImageProvider(string text = "")
@@ -78,39 +89,30 @@ public virtual McpeWrapper GetBatch(MapInfo mapInfo, bool forced)
7889

7990
private static byte[] DrawText(MapInfo map, string text)
8091
{
81-
using (var bitmap = new Bitmap(map.Col, map.Row))
82-
{
83-
using (Graphics graphics = Graphics.FromImage(bitmap))
84-
{
85-
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
86-
graphics.DrawString(text, _font, Brushes.AntiqueWhite, new PointF(0, 0));
87-
}
88-
89-
Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
90-
BitmapData bmpData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat);
91-
92-
int bytesPerPixel = Bitmap.GetPixelFormatSize(bitmap.PixelFormat) / 8;
93-
int byteCount = bmpData.Stride * bitmap.Height;
94-
byte[] bytes = new byte[byteCount];
92+
var bitmap = new Image<Rgba32>(map.Col, map.Row);
93+
var rectf = new RectangleF(0, 0, map.Col, map.Row);
9594

96-
System.Runtime.InteropServices.Marshal.Copy(bmpData.Scan0, bytes, 0, byteCount);
95+
bitmap.Mutate(
96+
x =>
97+
{
98+
x.DrawText(text, _font, SixLabors.ImageSharp.Color.AntiqueWhite, new PointF(0, 0));
99+
});
97100

98-
bitmap.UnlockBits(bmpData);
101+
byte[] bytes = new byte[bitmap.Height * bitmap.Width * 4];
99102

100-
for (int i = 0; i < bytes.Length; i += bytesPerPixel)
103+
int i = 0;
104+
for (int y = 0; y < bitmap.Height; y++)
105+
{
106+
for (int x = 0; x < bitmap.Width; x++)
101107
{
102-
byte b = bytes[i];
103-
byte g = bytes[i + 1];
104-
byte r = bytes[i + 2];
105-
byte a = bytes[i + 3];
106-
bytes[i] = r;
107-
bytes[i + 1] = g;
108-
bytes[i + 2] = b;
109-
bytes[i + 3] = a;
108+
var color = bitmap[x, y];
109+
bytes[i++] = color.R;
110+
bytes[i++] = color.G;
111+
bytes[i++] = color.B;
112+
bytes[i++] = 0xff;
110113
}
111-
112-
return bytes;
113114
}
115+
return bytes;
114116
}
115117
}
116118
}

src/MiNET/MiNET/LoginMessageHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public void HandleMcpeClientToServerHandshake(McpeClientToServerHandshake messag
530530
IMcpeMessageHandler messageHandler = server.CreatePlayer(_session, _playerInfo);
531531
_bedrockHandler.Handler = messageHandler; // Replace current message handler with real one.
532532

533-
if (_playerInfo.ProtocolVersion != McpeProtocolInfo.ProtocolVersion)
533+
if (_playerInfo.ProtocolVersion != McpeProtocolInfo.ProtocolVersion && _playerInfo.ProtocolVersion != McpeProtocolInfo.v1_21_2)
534534
{
535535
Log.Warn($"Wrong version ({_playerInfo.ProtocolVersion}) of Minecraft. Upgrade to join this server.");
536536
_session.Disconnect($"Wrong version ({_playerInfo.ProtocolVersion}) of Minecraft. This server requires {McpeProtocolInfo.ProtocolVersion}");

src/MiNET/MiNET/MiNET.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
44
<PackageId>MiNET-CobwebSMP</PackageId>
5-
<Version>1.13.0.12</Version>
5+
<Version>1.13.0.13</Version>
66
<Authors>gurun</Authors>
77
<Company>Niclas Olofsson</Company>
88
<Description>MiNET - a Minecraft PocketEdition Server</Description>
@@ -35,13 +35,14 @@
3535
<PackageReference Include="jose-jwt" Version="5.0.0" />
3636
<PackageReference Include="LibNoise.NetStandart" Version="0.2.0" />
3737
<PackageReference Include="log4net" Version="2.0.14" />
38-
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
38+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
3939
<PackageReference Include="MiNET.astar" Version="1.0.14" />
4040
<PackageReference Include="MiNET.fnbt" Version="1.0.22" />
4141
<PackageReference Include="MiNET.LevelDB" Version="1.0.49" />
4242
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4343
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
44-
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
44+
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
45+
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="2.1.3" />
4546
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
4647
</ItemGroup>
4748
<ItemGroup>

src/MiNET/MiNET/Net/MCPE Protocol.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace MiNET.Net
4444
public class McpeProtocolInfo
4545
{
4646
public const int ProtocolVersion = 685;
47+
public const int v1_21_2 = 686;
4748
public const string GameVersion = "1.21.0";
4849
}
4950

src/MiNET/MiNET/Player.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ public virtual void HandleMcpeText(McpeText message)
21772177

21782178
if (string.IsNullOrEmpty(text)) return;
21792179

2180-
Level.BroadcastMessage(text, sender: this);
2180+
Level.BroadcastMessage($"<{Username}> {text}", sender: this);
21812181
}
21822182

21832183
private int _lastOrderingIndex;

0 commit comments

Comments
 (0)