From 1c0a649a0cd3923aad6bf83f43a492dcea9ba4ec Mon Sep 17 00:00:00 2001 From: Chris <2648373+QuiCM@users.noreply.github.com> Date: Tue, 2 Jun 2020 13:34:26 +0930 Subject: [PATCH] Add handling for liquid net module --- .../Handlers/NetModules/LiquidHandler.cs | 29 +++++++++++++++++++ .../NetModules/NetModulePacketHandler.cs | 8 +++-- TShockAPI/TShockAPI.csproj | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 TShockAPI/Handlers/NetModules/LiquidHandler.cs diff --git a/TShockAPI/Handlers/NetModules/LiquidHandler.cs b/TShockAPI/Handlers/NetModules/LiquidHandler.cs new file mode 100644 index 00000000..e7fe647f --- /dev/null +++ b/TShockAPI/Handlers/NetModules/LiquidHandler.cs @@ -0,0 +1,29 @@ +using System.IO; + +namespace TShockAPI.Handlers.NetModules +{ + /// + /// Handles the NetLiquidModule. Rejects all incoming net liquid requests, as clients should never send them + /// + public class LiquidHandler : INetModuleHandler + { + /// + /// Does nothing. We should not deserialize this data + /// + /// + public void Deserialize(MemoryStream data) + { + // No need to deserialize + } + + /// + /// Rejects the packet. Clients should not send this to us + /// + /// + /// + public void HandlePacket(TSPlayer player, out bool rejectPacket) + { + rejectPacket = true; + } + } +} diff --git a/TShockAPI/Handlers/NetModules/NetModulePacketHandler.cs b/TShockAPI/Handlers/NetModules/NetModulePacketHandler.cs index f4d20bb4..820d2fe2 100644 --- a/TShockAPI/Handlers/NetModules/NetModulePacketHandler.cs +++ b/TShockAPI/Handlers/NetModules/NetModulePacketHandler.cs @@ -1,5 +1,4 @@ -using System; -using Terraria; +using Terraria; using static TShockAPI.GetDataHandlers; namespace TShockAPI.Handlers.NetModules @@ -48,6 +47,11 @@ namespace TShockAPI.Handlers.NetModules handler = new PylonHandler(); break; } + case NetModulesTypes.Liquid: + { + handler = new LiquidHandler(); + break; + } default: { // As of 1.4.x.x, this is now used for more things: diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index b129837f..2f4a406c 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -92,6 +92,7 @@ +