Skip to content

Commit

Permalink
feat: add status effect version of Despoil for use by datapacks etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Jul 18, 2023
1 parent 20fb879 commit fe2ae46
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ private void addStatusEffectTranslations() {
addEffect(ModMobEffects.LIBIDO, "Fertility");
addEffect(ModMobEffects.BLEED, "Bleed");
addEffect(ModMobEffects.ESSENCE_ANEMIA, "[PH] Essence Anemia");
addEffect(ModMobEffects.DESPOIL, "Despoil");
}

private void addEnchantmentTranslations() {
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
"effect.biomancy.libido": "Fertility",
"effect.biomancy.bleed": "Bleed",
"effect.biomancy.essence_anemia": "[PH] Essence Anemia",
"effect.biomancy.despoil": "Despoil",
"serum.biomancy.empty": "ERROR: INVALID SERUM",
"death.attack.biomancy.chest_bite": "%1$s tried touching a chest but was eaten instead",
"death.attack.biomancy.primordial_spikes": "%1$s was impaled by primordial spikes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public final class ModMobEffects {
public static final RegistryObject<BleedEffect> BLEED = EFFECTS.register("bleed", () -> new BleedEffect(MobEffectCategory.HARMFUL, 0x8a0303, 2));

public static final RegistryObject<EssenceAnemiaEffect> ESSENCE_ANEMIA = EFFECTS.register("essence_anemia", () -> new EssenceAnemiaEffect(MobEffectCategory.HARMFUL, 0x986c76));
public static final RegistryObject<DespoilEffect> DESPOIL = EFFECTS.register("despoil", () -> new DespoilEffect(MobEffectCategory.BENEFICIAL, 0xdd77ff));
public static final RegistryObject<LibidoEffect> LIBIDO = EFFECTS.register("libido", () -> new LibidoEffect(MobEffectCategory.NEUTRAL, 0xe06a78));

public static final RegistryObject<AdrenalineEffect> ADRENALINE_RUSH = EFFECTS.register("adrenaline_rush", () -> new AdrenalineEffect(MobEffectCategory.BENEFICIAL, 0xff9532)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.elenterius.biomancy.init.ModEnchantments;
import com.github.elenterius.biomancy.init.ModItems;
import com.github.elenterius.biomancy.init.ModMobEffects;
import com.github.elenterius.biomancy.init.tags.ModEntityTags;
import com.github.elenterius.biomancy.util.random.DynamicLootTable;
import com.google.common.base.Suppliers;
Expand All @@ -10,6 +11,7 @@
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.advancements.critereon.EntityFlagsPredicate;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
Expand Down Expand Up @@ -84,10 +86,15 @@ public LootItemCondition[] getConditions() {
protected static int getDespoilLevel(LootContext lootContext) {
Entity killer = lootContext.getParamOrNull(LootContextParams.KILLER_ENTITY);
if (killer instanceof LivingEntity livingEntity) {
return ModEnchantments.DESPOIL.get().getSlotItems(livingEntity).values().stream()
int itemDespoilLevel = ModEnchantments.DESPOIL.get().getSlotItems(livingEntity).values().stream()
.mapToInt(DespoilLootModifier::getDespoilLevel)
.max()
.orElse(lootContext.getRandom().nextFloat() < 0.05f ? 1 : 0);

MobEffectInstance effectInstance = livingEntity.getEffect(ModMobEffects.DESPOIL.get());
int effectDespoilLevel = effectInstance != null ? effectInstance.getAmplifier() + 1 : 0;

return Math.max(itemDespoilLevel, effectDespoilLevel);
}

return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.elenterius.biomancy.statuseffect;

import net.minecraft.world.effect.MobEffectCategory;

public class DespoilEffect extends StatusEffect {

public DespoilEffect(MobEffectCategory category, int color) {
super(category, color, false);
}

}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe2ae46

Please sign in to comment.