From 0a808165743548e4dd03a6b872772755d0760b84 Mon Sep 17 00:00:00 2001 From: Thelnfamous1 Date: Tue, 13 Feb 2024 21:37:56 -0600 Subject: [PATCH] Fix #258 --- .../minionmaster/FollowerEvents.java | 2 ++ .../mixin/LivingEntityMixin.java | 29 +++++++++++++++++++ .../resources/dungeons_libraries.mixins.json | 1 + 3 files changed, 32 insertions(+) create mode 100644 src/main/java/com/infamous/dungeons_libraries/mixin/LivingEntityMixin.java diff --git a/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerEvents.java b/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerEvents.java index e63b5d3..24ba12e 100644 --- a/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerEvents.java +++ b/src/main/java/com/infamous/dungeons_libraries/capabilities/minionmaster/FollowerEvents.java @@ -54,6 +54,7 @@ private static void createDummyTarget(Level level) { } } + /* @SubscribeEvent public static void onLivingDropsEvent(LivingDropsEvent event) { Follower cap = getFollowerCapability(event.getEntity()); @@ -61,6 +62,7 @@ public static void onLivingDropsEvent(LivingDropsEvent event) { event.setCanceled(true); } } + */ @SubscribeEvent public static void onLivingEntityTick(LivingEvent.LivingTickEvent event) { diff --git a/src/main/java/com/infamous/dungeons_libraries/mixin/LivingEntityMixin.java b/src/main/java/com/infamous/dungeons_libraries/mixin/LivingEntityMixin.java new file mode 100644 index 0000000..2590bfb --- /dev/null +++ b/src/main/java/com/infamous/dungeons_libraries/mixin/LivingEntityMixin.java @@ -0,0 +1,29 @@ +package com.infamous.dungeons_libraries.mixin; + +import com.infamous.dungeons_libraries.capabilities.minionmaster.Follower; +import com.infamous.dungeons_libraries.capabilities.minionmaster.FollowerLeaderHelper; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +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(LivingEntity.class) +public abstract class LivingEntityMixin extends Entity { + + public LivingEntityMixin(EntityType p_19870_, Level p_19871_) { + super(p_19870_, p_19871_); + } + + @Inject(method = "dropFromLootTable", at = @At("HEAD"), cancellable = true) + private void cancelDropFromLootTableIfSummoned(DamageSource source, boolean hurtByPlayer, CallbackInfo ci){ + Follower cap = FollowerLeaderHelper.getFollowerCapability(this); + if (cap.isSummon()) { + ci.cancel(); + } + } +} diff --git a/src/main/resources/dungeons_libraries.mixins.json b/src/main/resources/dungeons_libraries.mixins.json index 287918b..4e6a647 100644 --- a/src/main/resources/dungeons_libraries.mixins.json +++ b/src/main/resources/dungeons_libraries.mixins.json @@ -17,6 +17,7 @@ "CrossbowItemMixin", "EnchantmentHelperMixin", "ItemAccessor", + "LivingEntityMixin", "MobInvoker", "MobMixin", "NearestAttackableTargetGoalAccessor",