Skip to content

Commit

Permalink
Fix #258
Browse files Browse the repository at this point in the history
  • Loading branch information
Thelnfamous1 committed Feb 14, 2024
1 parent ab16477 commit 0a80816
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ private static void createDummyTarget(Level level) {
}
}

/*
@SubscribeEvent
public static void onLivingDropsEvent(LivingDropsEvent event) {
Follower cap = getFollowerCapability(event.getEntity());
if (cap.isFollower()) {
event.setCanceled(true);
}
}
*/

@SubscribeEvent
public static void onLivingEntityTick(LivingEvent.LivingTickEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/dungeons_libraries.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"CrossbowItemMixin",
"EnchantmentHelperMixin",
"ItemAccessor",
"LivingEntityMixin",
"MobInvoker",
"MobMixin",
"NearestAttackableTargetGoalAccessor",
Expand Down

0 comments on commit 0a80816

Please sign in to comment.