Skip to content

Commit

Permalink
fix: serverside issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Nov 23, 2024
1 parent 382df80 commit 134efbb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 <B extends PacketByteBuf> void onCustomPayloadDecode(B packetByteBuf, CallbackInfoReturnable<CustomPayload> 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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/bbor.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"server.MixinMinecraftServer",
"server.MixinServerChunkLoadingManager",
"server.management.MixinPlayerList",
"server.network.MixinServerCommonNetworkHandler",
"server.network.MixinServerPlayNetworkHandler",
"world.chunk.MixinPalettedContainer"
],
"client": [
Expand Down

0 comments on commit 134efbb

Please sign in to comment.