Skip to content

Commit

Permalink
Tectonic Girdle nullifies explosion knockback
Browse files Browse the repository at this point in the history
(closes #4581)
  • Loading branch information
TheRealWormbo committed Jun 16, 2024
1 parent 08ff8dd commit 9190ce5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -47,6 +49,11 @@ public Multimap<Attribute, AttributeModifier> 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<LivingEntity> model = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Double> cir) {
if (TectonicGirdleItem.negateExplosionKnockback(living)) {
cir.setReturnValue(0.0);
}
}
}
1 change: 1 addition & 0 deletions Xplat/src/main/resources/botania_xplat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"PistonStructureResolverMixin",
"PlayerMixin",
"PollinateGoalMixin",
"ProtectionEnchantmentMixin",
"RandomizableContainerBlockEntityAccessor",
"RecipeManagerAccessor",
"RecipeProviderAccessor",
Expand Down

0 comments on commit 9190ce5

Please sign in to comment.