From eed0a007438e60883fad8aa62ab3476bca2ab7f5 Mon Sep 17 00:00:00 2001 From: SammySemicolon <69329424+SammySemicolon@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:00:37 +0100 Subject: [PATCH] Update RuneDexterityItem.java --- .../curios/runes/miracle/RuneDexterityItem.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sammy/malum/common/item/curiosities/curios/runes/miracle/RuneDexterityItem.java b/src/main/java/com/sammy/malum/common/item/curiosities/curios/runes/miracle/RuneDexterityItem.java index 197b9de1f..875294c14 100644 --- a/src/main/java/com/sammy/malum/common/item/curiosities/curios/runes/miracle/RuneDexterityItem.java +++ b/src/main/java/com/sammy/malum/common/item/curiosities/curios/runes/miracle/RuneDexterityItem.java @@ -14,12 +14,16 @@ import net.minecraft.world.item.ItemStack; import top.theillusivec4.curios.api.SlotContext; -import java.util.function.BiFunction; -import java.util.function.Consumer; +import java.util.function.*; public class RuneDexterityItem extends AbstractRuneCurioItem { - public static final BiFunction MOVEMENT_SPEED = (health, maxHealth) -> { + public static final Function MOVEMENT_SPEED = (living) -> { + if (living == null) { + return 0.2f; + } + final float health = living.getHealth(); + final float maxHealth = living.getMaxHealth(); float value = 0.2f * (2 - (health / maxHealth)); return new AttributeModifier(MalumMod.malumPath("curio_movement_speed"), value, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL); }; @@ -35,9 +39,7 @@ public void addExtraTooltipLines(Consumer consumer) { @Override public void addAttributeModifiers(Multimap, AttributeModifier> map, SlotContext slotContext, ItemStack stack) { - addAttributeModifier(map, Attributes.MOVEMENT_SPEED, MOVEMENT_SPEED.apply( - slotContext.entity().getHealth(), slotContext.entity().getMaxHealth() - )); + addAttributeModifier(map, Attributes.MOVEMENT_SPEED, MOVEMENT_SPEED.apply(slotContext.entity())); } @Override