diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TectonicGirdleItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TectonicGirdleItem.java index fc8db490c7..15603f44a3 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TectonicGirdleItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TectonicGirdleItem.java @@ -29,6 +29,8 @@ import vazkii.botania.client.lib.ResourcesLib; import vazkii.botania.client.render.AccessoryRenderRegistry; import vazkii.botania.client.render.AccessoryRenderer; +import vazkii.botania.common.handler.EquipmentHandler; +import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.proxy.Proxy; public class TectonicGirdleItem extends BaubleItem { @@ -47,6 +49,11 @@ public Multimap getEquippedAttributeModifiers(Item return attributes; } + public static boolean negateExplosionKnockback(LivingEntity living) { + // TODO 1.21: replace with explosion knockback resistance attribute + return !EquipmentHandler.findOrEmpty(BotaniaItems.knockbackBelt, living).isEmpty(); + } + public static class Renderer implements AccessoryRenderer { private static HumanoidModel model = null; diff --git a/Xplat/src/main/java/vazkii/botania/mixin/ProtectionEnchantmentMixin.java b/Xplat/src/main/java/vazkii/botania/mixin/ProtectionEnchantmentMixin.java new file mode 100644 index 0000000000..de8f8b24e5 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/mixin/ProtectionEnchantmentMixin.java @@ -0,0 +1,21 @@ +package vazkii.botania.mixin; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.enchantment.ProtectionEnchantment; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import vazkii.botania.common.item.equipment.bauble.TectonicGirdleItem; + +@Mixin(ProtectionEnchantment.class) +public class ProtectionEnchantmentMixin { + @Inject(method = "getExplosionKnockbackAfterDampener", at = @At("HEAD"), cancellable = true) + private static void cancelExplosionKnockback(LivingEntity living, double knockback, CallbackInfoReturnable cir) { + if (TectonicGirdleItem.negateExplosionKnockback(living)) { + cir.setReturnValue(0.0); + } + } +} diff --git a/Xplat/src/main/resources/botania_xplat.mixins.json b/Xplat/src/main/resources/botania_xplat.mixins.json index b907fd636f..aa9c9d5e05 100644 --- a/Xplat/src/main/resources/botania_xplat.mixins.json +++ b/Xplat/src/main/resources/botania_xplat.mixins.json @@ -44,6 +44,7 @@ "PistonStructureResolverMixin", "PlayerMixin", "PollinateGoalMixin", + "ProtectionEnchantmentMixin", "RandomizableContainerBlockEntityAccessor", "RecipeManagerAccessor", "RecipeProviderAccessor",