aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-06-14 18:34:40 +0200
committerLinnea Gräf <nea@nea.moe>2024-06-14 18:34:40 +0200
commite4bd69a0569b4ccc49b9e4b89998220bf4bfe25a (patch)
tree2cb89c55c9c63cbb115cfeaff1848f301c9a461c /src/main/java/moe/nea/firmament/mixins
parentcd1826a49822e7be0fb583e7b540270560fb657d (diff)
downloadfirmament-e4bd69a0569b4ccc49b9e4b89998220bf4bfe25a.tar.gz
firmament-e4bd69a0569b4ccc49b9e4b89998220bf4bfe25a.tar.bz2
firmament-e4bd69a0569b4ccc49b9e4b89998220bf4bfe25a.zip
Add shiny pig tracker
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java25
-rw-r--r--src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java39
-rw-r--r--src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java (renamed from src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java)4
3 files changed, 66 insertions, 2 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java b/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java
new file mode 100644
index 0000000..1c095da
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java
@@ -0,0 +1,25 @@
+/*
+ * 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.EntityDespawnEvent;
+import net.minecraft.client.world.ClientWorld;
+import net.minecraft.entity.Entity;
+import org.jetbrains.annotations.Nullable;
+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(ClientWorld.class)
+public class EntityDespawnPatch {
+ @Inject(method = "removeEntity", at = @At(value = "TAIL"))
+ private void onRemoved(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci, @Local @Nullable Entity entity) {
+ EntityDespawnEvent.Companion.publish(new EntityDespawnEvent(entity, entityId, removalReason));
+ }
+}
diff --git a/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java b/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java
new file mode 100644
index 0000000..4c2e92f
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/EntityInteractEventPatch.java
@@ -0,0 +1,39 @@
+/*
+ * 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.events.EntityInteractionEvent;
+import net.minecraft.client.network.ClientPlayerInteractionManager;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.util.ActionResult;
+import net.minecraft.util.Hand;
+import net.minecraft.util.hit.EntityHitResult;
+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;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(ClientPlayerInteractionManager.class)
+public class EntityInteractEventPatch {
+ @Inject(method = "attackEntity", at = @At("HEAD"))
+ private void onAttack(PlayerEntity player, Entity target, CallbackInfo ci) {
+ EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.ATTACK, target, Hand.MAIN_HAND));
+ }
+
+ @Inject(method = "interactEntity", at = @At("HEAD"))
+ private void onInteract(PlayerEntity player, Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
+ EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.INTERACT, entity, hand));
+ }
+
+ @Inject(method = "interactEntityAtLocation", at = @At("HEAD"))
+ private void onInteractAtLocation(PlayerEntity player, Entity entity, EntityHitResult hitResult, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
+ EntityInteractionEvent.Companion.publish(new EntityInteractionEvent(EntityInteractionEvent.InteractionKind.INTERACT_AT_LOCATION, entity, hand));
+ }
+
+}
diff --git a/src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
index 111ab33..6618e95 100644
--- a/src/main/java/moe/nea/firmament/mixins/HudRenderEvents.java
+++ b/src/main/java/moe/nea/firmament/mixins/HudRenderEventsPatch.java
@@ -19,8 +19,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(InGameHud.class)
-public class HudRenderEvents {
- @Inject(method = "renderSleepOverlay", at = @At(value = "TAIL"))
+public class HudRenderEventsPatch {
+ @Inject(method = "renderSleepOverlay", at = @At(value = "HEAD"))
public void renderCallBack(DrawContext context, float tickDelta, CallbackInfo ci) {
HudRenderEvent.Companion.publish(new HudRenderEvent(context, tickDelta));
}