/* * SPDX-FileCopyrightText: 2024 Linnea Gräf * * SPDX-License-Identifier: GPL-3.0-or-later */ package moe.nea.firmament.mixins.custompayload; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import moe.nea.firmament.apis.ingame.InGameCodecWrapper; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.packet.CustomPayload; import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import java.util.List; @Mixin(priority = 1001, value = CustomPayloadS2CPacket.class) public abstract class InjectCustomCodecIntoS2CCustomPayloadPacket { @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/CustomPayload;createCodec(Lnet/minecraft/network/packet/CustomPayload$CodecFactory;Ljava/util/List;)Lnet/minecraft/network/codec/PacketCodec;")) private static PacketCodec wrapFactory( CustomPayload.CodecFactory unknownCodecFactory, List> types, Operation> original) { var originalCodec = original.call(unknownCodecFactory, types); return new InGameCodecWrapper(originalCodec, InGameCodecWrapper.Direction.S2C); } }