blob: 5320a1367e10507bfd2485064a48c557423373d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package moe.nea.firmament.mixins.custompayload;
import moe.nea.firmament.apis.ingame.JoinedCustomPayload;
import net.minecraft.network.listener.ClientCommonPacketListener;
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.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(CustomPayloadS2CPacket.class)
public abstract class SplitJoinedCustomPayload {
@Shadow
public abstract CustomPayload payload();
@Inject(method = "apply(Lnet/minecraft/network/listener/ClientCommonPacketListener;)V", at = @At("HEAD"), cancellable = true)
private void onApply(ClientCommonPacketListener clientCommonPacketListener, CallbackInfo ci) {
if (payload() instanceof JoinedCustomPayload joinedCustomPayload) {
new CustomPayloadS2CPacket(joinedCustomPayload.getOriginal()).apply(clientCommonPacketListener);
new CustomPayloadS2CPacket(joinedCustomPayload.getSmuggled()).apply(clientCommonPacketListener);
ci.cancel();
}
}
}
|