Skip to content

Commit

Permalink
fix blast prot kb (MC-198809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf1nityy committed Aug 5, 2024
1 parent dbf2044 commit 077205c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nexia.core.mixin.misc;

import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(ProtectionEnchantment.class)
public class ProtectionEnchantmentMixin {
/**
* @author NotInfinityy
* @reason This fixes blast protection not reducing explosion knockback
* <a href="https://bugs.mojang.com/browse/MC-198809">MC-198809</a>
*/
@Overwrite
public static double getExplosionKnockbackAfterDampener(LivingEntity livingEntity, double d) {
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.BLAST_PROTECTION, livingEntity);
if (i > 0) {
d *= Mth.clamp(1.0 - (double)i * 0.15, 0.0, 1.0);
}

return d;
}
}
1 change: 1 addition & 0 deletions src/main/resources/core.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"misc.ExplosionMixin",
"misc.ItemCombinerMenuMixin",
"misc.MinecraftServerMixin",
"misc.ProtectionEnchantmentMixin",
"misc.ServerLevelMixin",
"misc.commands.BanCommandMixin",
"misc.commands.EmoteCommandMixin",
Expand Down

0 comments on commit 077205c

Please sign in to comment.