aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-18 20:10:16 +0200
committerLinnea Gräf <nea@nea.moe>2024-04-18 20:23:44 +0200
commitc264ca9e8f9f2b0aed457753c43bb4e25edb0ef1 (patch)
treef0eac8c4902bca00f9e44bc4d0e9b6eb73e7144d /src/main/java/moe/nea/firmament/mixins
parentfbe94315a45082bdf50d0a95583725352e3f20ec (diff)
downloadFirmament-c264ca9e8f9f2b0aed457753c43bb4e25edb0ef1.tar.gz
Firmament-c264ca9e8f9f2b0aed457753c43bb4e25edb0ef1.tar.bz2
Firmament-c264ca9e8f9f2b0aed457753c43bb4e25edb0ef1.zip
Add pickaxe ability timer
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java b/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java
new file mode 100644
index 0000000..4e6d766
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/SlotClickEventPatch.java
@@ -0,0 +1,34 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.mixins;
+
+import com.llamalad7.mixinextras.sugar.Local;
+import moe.nea.firmament.events.SlotClickEvent;
+import net.minecraft.client.network.ClientPlayerInteractionManager;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.screen.ScreenHandler;
+import net.minecraft.screen.slot.SlotActionType;
+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(ClientPlayerInteractionManager.class)
+public class SlotClickEventPatch {
+
+ @Inject(method = "clickSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"))
+ private void onSlotClick(int syncId, int slotId, int button, SlotActionType actionType, PlayerEntity player, CallbackInfo ci, @Local ScreenHandler handler) {
+ if (0 <= slotId && slotId < handler.slots.size()) {
+ SlotClickEvent.Companion.publish(new SlotClickEvent(
+ handler.getSlot(slotId),
+ handler.getSlot(slotId).getStack(),
+ button,
+ actionType
+ ));
+ }
+ }
+}