blob: 2084821d9f2a8a0d9d890b4abf3ae4f4a9ba2b2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package moe.nea.firmament.mixins.custompayload;
import moe.nea.firmament.apis.ingame.FirmamentCustomPayload;
import moe.nea.firmament.events.FirmamentCustomPayloadEvent;
import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
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(value = ClientCommonNetworkHandler.class, priority = 500)
public class CustomPayloadEventDispatcher {
@Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true)
private void handleFirmamentParsedPayload(CustomPayloadS2CPacket packet, CallbackInfo ci) {
if (packet.payload() instanceof FirmamentCustomPayload customPayload) {
FirmamentCustomPayloadEvent.Companion.publishSync(new FirmamentCustomPayloadEvent(customPayload));
ci.cancel();
}
}
}
|