Add shiny pig tracker

This commit is contained in:
Linnea Gräf
2024-06-14 18:34:40 +02:00
parent cd1826a498
commit e4bd69a056
17 changed files with 548 additions and 6 deletions

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}