From 52c7d290623ce6975fee7115b0af668a2dcd53ad Mon Sep 17 00:00:00 2001 From: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com> Date: Mon, 17 Aug 2020 18:37:05 +0800 Subject: [PATCH] Handle 1.16 new entity properties name Convert new naming style to old style --- .../Protocol/Handlers/Protocol18.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index df141ac0..8385a580 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -901,6 +901,25 @@ namespace MinecraftClient.Protocol.Handlers if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x); keys.Add(_key, _value); } + if (protocolversion >= MC116Version) + { + Dictionary newKeys = new Dictionary(); + foreach(var pair in keys) + { + var firstPart = pair.Key.Replace("minecraft:", "").Split('.').ToList(); // Remove "minecraft:" and split out the "generic." + var secondPart = firstPart[1].Split('_').ToList(); + string first = secondPart[0]; // "namingStyle" firts is lower case + secondPart.RemoveAt(0); + List converted = new List(); + foreach(var s in secondPart) + { + converted.Add(char.ToUpper(s[0]) + s.Substring(1)); + } + string final = firstPart[0] + "." + first + string.Join("", converted); + newKeys.Add(final, pair.Value); + } + keys = newKeys; + } handler.OnEntityProperties(EntityID, keys); } break;