diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-29 21:09:07 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-06-01 01:34:34 +0200 |
commit | e630426656b713ec67bfe7ede2f2081751e349db (patch) | |
tree | 63eff82e16d400a42b5a48bfcb6c89ec81c6763e /src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java | |
parent | fac6103658b2c8d6bab3598606d57041cfe16e0c (diff) | |
download | firmament-e630426656b713ec67bfe7ede2f2081751e349db.tar.gz firmament-e630426656b713ec67bfe7ede2f2081751e349db.tar.bz2 firmament-e630426656b713ec67bfe7ede2f2081751e349db.zip |
[WIP] Add mod api
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java b/src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java new file mode 100644 index 0000000..66710eb --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/CustomPayloadEventDispatcher.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import moe.nea.firmament.apis.ingame.FirmamentCustomPayload; +import moe.nea.firmament.events.FirmamentCustomPayloadEvent; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.packet.CustomPayload; +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(ClientPlayNetworkHandler.class) +public class CustomPayloadEventDispatcher { + @Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) + private void handleFirmamentParsedPayload(CustomPayload payload, CallbackInfo ci) { + if (payload instanceof FirmamentCustomPayload customPayload) { + FirmamentCustomPayloadEvent.Companion.publish(new FirmamentCustomPayloadEvent(customPayload)); + ci.cancel(); + } + } +} |