Skip to content

Commit

Permalink
Update RuneDexterityItem.java
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Dec 9, 2024
1 parent 8d402d0 commit eed0a00
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Float, Float, AttributeModifier> MOVEMENT_SPEED = (health, maxHealth) -> {
public static final Function<LivingEntity, AttributeModifier> 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);
};
Expand All @@ -35,9 +39,7 @@ public void addExtraTooltipLines(Consumer<Component> consumer) {

@Override
public void addAttributeModifiers(Multimap<Holder<Attribute>, 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
Expand Down

0 comments on commit eed0a00

Please sign in to comment.