the enchantment level of the book matches with the effect
All checks were successful
Build Mod / build (push) Successful in 48s

This commit is contained in:
2026-01-17 15:32:23 -06:00
parent f9608ed604
commit 71e6c854be
3 changed files with 5 additions and 9 deletions

View File

@@ -24,20 +24,18 @@ public record CripplingEnchantmentEffect(LevelBasedValue duration) implements En
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity target, Vec3 pos) {
if (target instanceof LivingEntity victim) {
if (context.owner() != null && context.owner() instanceof Player player) {
int Duration = (int) (this.duration.calculate(level) * 50); // Convert to ticks
int slownessAmplifier = level - 1; // Level 1 = Slowness 0, Level 2 = Slowness I, Level 3 = Slowness II
int weaknessAmplifier = level - 1; // Level 1 = Weakness 0, Level 2 = Weakness I, Level 3 = Weakness II
int Duration = (int) (this.duration.calculate(level) * 40); // Convert to ticks
victim.addEffect(new MobEffectInstance(
MobEffects.SLOWNESS,
Duration,
slownessAmplifier,
level,
false,
true
));
victim.addEffect(new MobEffectInstance(
MobEffects.WEAKNESS,
Duration,
weaknessAmplifier,
level,
false,
true
));

View File

@@ -25,12 +25,11 @@ public record PoisonEnchantmentEffect(LevelBasedValue duration) implements Encha
if (target instanceof LivingEntity victim) {
if (context.owner() != null && context.owner() instanceof Player player) {
int poisonDuration = (int) (this.duration.calculate(level) * 40); // Convert to ticks
int poisonAmplifier = level - 2; // Level 1 = Poison 0, Level 2 = Poison I, Level 3 = Poison II
victim.addEffect(new MobEffectInstance(
MobEffects.POISON,
poisonDuration,
poisonAmplifier,
level,
false,
true
));

View File

@@ -25,12 +25,11 @@ public record WitheringEnchantmentEffect(LevelBasedValue duration) implements En
if (target instanceof LivingEntity victim) {
if (context.owner() != null && context.owner() instanceof Player player) {
int witherDuration = (int) (this.duration.calculate(level) * 40); // Convert to ticks
int witherAmplifier = level - 2; // Level 1 = Wither 0, Level 2 = Wither I, Level 3 = Wither II
victim.addEffect(new MobEffectInstance(
MobEffects.WITHER,
witherDuration,
witherAmplifier,
level,
false,
true
));