diff options
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/EntityDespawnPatch.java | 25 |
1 files changed, 25 insertions, 0 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)); + } +} |