Skip to content

Commit

Permalink
Fix liquid death drops and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed May 22, 2024
1 parent e44eed2 commit dbf2b7b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CRMixinLoader implements ILateMixinLoader {

private static final Map<String, Supplier<Boolean>> commonMixinConfigs = ImmutableMap.copyOf(new HashMap<String, Supplier<Boolean>>() {
{
put("mixins.crimsonrevelations.json", () -> true);
put("mixins.crimsonrevelations.json", () -> true);
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package com.mobiusflip.crimsonrevelations.mixin;

import com.mobiusflip.crimsonrevelations.entity.boss.EntityOvergrownTaintacle;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
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 thaumcraft.api.ThaumcraftApiHelper;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectHelper;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.damagesource.DamageSourceThaumcraft;
import thaumcraft.common.lib.events.EntityEvents;

@Mixin(value = EntityEvents.class, remap = false)
Expand All @@ -15,5 +25,20 @@ private static void crLivingDrops(LivingDropsEvent event, CallbackInfo ci) {
// No hardcoded treasure bag drop
if (!event.getEntity().world.isRemote && event.isRecentlyHit() && event.getEntity() instanceof EntityOvergrownTaintacle)
ci.cancel();

// We will need this to make sure liquid death can properly work on our affected mobs again
if (event.getSource() == DamageSourceThaumcraft.dissolve && event.getEntity() instanceof EntityOvergrownTaintacle) {
AspectList aspects = AspectHelper.getEntityAspects(event.getEntityLiving());

if (aspects != null && aspects.size() > 0) {
Aspect[] list = aspects.getAspects();

for (int f = MathHelper.getInt(event.getEntity().getEntityWorld().rand, 1, 1 + aspects.visSize() / 10), a = 0; a < f; ++a) {
Aspect aspect = list[event.getEntity().getEntityWorld().rand.nextInt(list.length)];
ItemStack stack = ThaumcraftApiHelper.makeCrystal(aspect);
event.getDrops().add(new EntityItem(event.getEntity().world, event.getEntityLiving().posX, event.getEntityLiving().posY + event.getEntityLiving().getEyeHeight(), event.getEntityLiving().posZ, stack));
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.crimsonrevelations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"TCEntityEventsMixin"
"TCEntityEventsMixin"
],
"client": [],
"server": []
Expand Down

0 comments on commit dbf2b7b

Please sign in to comment.