Skip to content

Commit 3ed5f1a

Browse files
committed
add Animate Entity packet
1 parent b47fdc3 commit 3ed5f1a

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/MiNET/MiNET.Client/McpeClientMessageHandlerBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,11 @@ public void HandleMcpePlayerFog(McpePlayerFog message)
782782
{
783783

784784
}
785+
786+
public virtual void HandleMcpeAnimateEntity(McpeAnimateEntity message)
787+
{
788+
Log.Warn($"Got entity animation {message.animationName}");
789+
}
785790
}
786791

787792
public class DefaultMessageHandler : McpeClientMessageHandlerBase

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
using MiNET.Utils.Metadata;
3939
using MiNET.Utils.Vectors;
4040
using MiNET.Utils.Nbt;
41+
using System.Linq;
4142

4243
namespace MiNET.Net
4344
{
@@ -250,6 +251,7 @@ public interface IMcpeClientMessageHandler
250251
void HandleMcpeEmoteList(McpeEmoteList message);
251252
void HandleMcpePermissionRequest(McpePermissionRequest message);
252253
void HandleMcpePlayerFog(McpePlayerFog message);
254+
void HandleMcpeAnimateEntity(McpeAnimateEntity message);
253255
}
254256

255257
public class McpeClientMessageDispatcher
@@ -661,6 +663,9 @@ public bool HandlePacket(Packet message)
661663
case McpePlayerFog msg:
662664
_messageHandler.HandleMcpePlayerFog(msg);
663665
break;
666+
case McpeAnimateEntity msg:
667+
_messageHandler.HandleMcpeAnimateEntity(msg);
668+
break;
664669
default:
665670
return false;
666671
}
@@ -10927,5 +10932,81 @@ protected override void ResetPacket()
1092710932

1092810933
}
1092910934
}
10935+
public partial class McpeAnimateEntity : Packet<McpeAnimateEntity>
10936+
{
10937+
10938+
public string animationName; // = null;
10939+
public string nextState; // = null;
10940+
public string stopExpression; // = null;
10941+
public int molangVersion; // = null;
10942+
public string controllerName; // = null;
10943+
public float blendOutTime; // = null;
10944+
public long[] entities; // = null;
10945+
10946+
public McpeAnimateEntity()
10947+
{
10948+
Id = 0x9e;
10949+
IsMcpe = true;
10950+
}
10951+
10952+
protected override void EncodePacket()
10953+
{
10954+
base.EncodePacket();
10955+
10956+
BeforeEncode();
10957+
10958+
Write(animationName);
10959+
Write(nextState);
10960+
Write(stopExpression);
10961+
Write(molangVersion);
10962+
Write(controllerName);
10963+
Write(blendOutTime);
10964+
WriteUnsignedVarInt((uint)entities.Count());
10965+
for (int i = 0; i < entities.Count(); i++)
10966+
{
10967+
WriteUnsignedVarLong(entities[i]);
10968+
}
10969+
10970+
AfterEncode();
10971+
}
10972+
10973+
partial void BeforeEncode();
10974+
partial void AfterEncode();
1093010975

10976+
protected override void DecodePacket()
10977+
{
10978+
base.DecodePacket();
10979+
10980+
BeforeDecode();
10981+
10982+
animationName = ReadString();
10983+
nextState = ReadString();
10984+
stopExpression = ReadString();
10985+
molangVersion = ReadInt();
10986+
controllerName = ReadString();
10987+
blendOutTime = ReadFloat();
10988+
for (int i = 0; i < ReadUnsignedVarInt(); i++)
10989+
{
10990+
entities[i] = ReadUnsignedVarLong();
10991+
}
10992+
10993+
AfterDecode();
10994+
}
10995+
10996+
partial void BeforeDecode();
10997+
partial void AfterDecode();
10998+
10999+
protected override void ResetPacket()
11000+
{
11001+
base.ResetPacket();
11002+
11003+
animationName = default(string);
11004+
nextState = default(string);
11005+
stopExpression = default(string);
11006+
molangVersion = default(int);
11007+
controllerName = default(string);
11008+
blendOutTime = default(float);
11009+
entities = default(long[]);
11010+
}
11011+
}
1093111012
}

0 commit comments

Comments
 (0)