Skip to content

Commit

Permalink
feat(ench): ice aspect slowness effect
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Feb 21, 2024
1 parent 0b31a8b commit 3cbabfa
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
package org.auioc.mcmod.harmonicench.enchantment.impl;

import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -68,9 +70,16 @@ public int getMaxCost(int lvl) {
public float onLivingHurt(int lvl, boolean isSource, EquipmentSlot slot, LivingEntity target, DamageSource source, float amount) {
if (isSource && target.canFreeze()) {
int ticksFrozen = target.getTicksFrozen();

double f = (ticksFrozen == 0) ? 200.0D : 100.0D;
double r = MathUtil.sigma(lvl, 1, (double i) -> f / i);
target.setTicksFrozen(ticksFrozen + ((int) r));

double t = (ticksFrozen == 0)
? MathUtil.sigma(lvl, 1, (double i) -> 5.0D / i) - 3.5D
: MathUtil.sigma(lvl, 1, (double i) -> 2.5D / i);
var effect = new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, (int) (t * 20.0D), Math.max(lvl, 2) - 1);
target.addEffect(effect, source.getEntity());
}
return amount;
}
Expand Down

0 comments on commit 3cbabfa

Please sign in to comment.