From 134efbb28b2646ef655de017c7ba65acdb7fff55 Mon Sep 17 00:00:00 2001 From: ishland Date: Sat, 23 Nov 2024 15:24:58 +0800 Subject: [PATCH] fix: serverside issue --- .../bbor/mixin/network/common/MixinCustomPayload$1.java | 5 +++-- ...tworkHandler.java => MixinServerPlayNetworkHandler.java} | 6 ++---- src/main/resources/bbor.mixins.json | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) rename src/main/java/com/irtimaled/bbor/mixin/server/network/{MixinServerCommonNetworkHandler.java => MixinServerPlayNetworkHandler.java} (84%) diff --git a/src/main/java/com/irtimaled/bbor/mixin/network/common/MixinCustomPayload$1.java b/src/main/java/com/irtimaled/bbor/mixin/network/common/MixinCustomPayload$1.java index 897ec324..c3bc0430 100644 --- a/src/main/java/com/irtimaled/bbor/mixin/network/common/MixinCustomPayload$1.java +++ b/src/main/java/com/irtimaled/bbor/mixin/network/common/MixinCustomPayload$1.java @@ -1,7 +1,6 @@ package com.irtimaled.bbor.mixin.network.common; import com.irtimaled.bbor.common.BBORCustomPayload; -import com.irtimaled.bbor.common.messages.servux.ServuxStructurePackets; import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.CustomPayload; @@ -16,13 +15,15 @@ @Mixin(targets = "net.minecraft.network.packet.CustomPayload$1") public class MixinCustomPayload$1 { + private static final Identifier BBOR_SERVUX_CHANNEL = Identifier.tryParse("servux:structures"); + @Inject( method = "decode(Lnet/minecraft/network/PacketByteBuf;)Lnet/minecraft/network/packet/CustomPayload;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/CustomPayload$1;getCodec(Lnet/minecraft/util/Identifier;)Lnet/minecraft/network/codec/PacketCodec;"), cancellable = true ) private void onCustomPayloadDecode(B packetByteBuf, CallbackInfoReturnable cir, @Local @NotNull Identifier identifier) { - if (identifier.getNamespace().equals("bbor") || identifier.equals(ServuxStructurePackets.CHANNEL)) { + if (identifier.getNamespace().equals("bbor") || identifier.equals(BBOR_SERVUX_CHANNEL)) { cir.setReturnValue(new BBORCustomPayload(identifier, packetByteBuf)); } } diff --git a/src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerCommonNetworkHandler.java b/src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerPlayNetworkHandler.java similarity index 84% rename from src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerCommonNetworkHandler.java rename to src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerPlayNetworkHandler.java index 500c9ce8..b26a0d5a 100644 --- a/src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerCommonNetworkHandler.java +++ b/src/main/java/com/irtimaled/bbor/mixin/server/network/MixinServerPlayNetworkHandler.java @@ -2,18 +2,16 @@ import com.irtimaled.bbor.common.BBORCustomPayload; import com.irtimaled.bbor.common.interop.CommonInterop; -import com.irtimaled.bbor.common.messages.PayloadReader; import com.irtimaled.bbor.common.messages.SubscribeToServer; import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket; -import net.minecraft.server.network.ServerCommonNetworkHandler; import net.minecraft.server.network.ServerPlayNetworkHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ServerCommonNetworkHandler.class) -public class MixinServerCommonNetworkHandler { +@Mixin(ServerPlayNetworkHandler.class) +public class MixinServerPlayNetworkHandler { @Inject(method = "onCustomPayload", at = @At(value = "HEAD"), cancellable = true) private void onCustomPayload(CustomPayloadC2SPacket packet, CallbackInfo ci) { diff --git a/src/main/resources/bbor.mixins.json b/src/main/resources/bbor.mixins.json index a795ee7d..731b3f35 100644 --- a/src/main/resources/bbor.mixins.json +++ b/src/main/resources/bbor.mixins.json @@ -14,7 +14,7 @@ "server.MixinMinecraftServer", "server.MixinServerChunkLoadingManager", "server.management.MixinPlayerList", - "server.network.MixinServerCommonNetworkHandler", + "server.network.MixinServerPlayNetworkHandler", "world.chunk.MixinPalettedContainer" ], "client": [