Skip to content

Commit

Permalink
fix mixin method names
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash (Bagel) committed May 14, 2024
1 parent bf52e3d commit ffdee46
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public LivingEntityMixin(EntityType<?> pEntityType, Level pLevel) {
* @param damage The initial damage amount
*/
@Redirect(at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(FF)F"), method = "getDamageAfterMagicAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F")
public float zenith$sunderingApplyEffect(float value, float max, DamageSource source, float damage) {
public float zenith_attributes$sunderingApplyEffect(float value, float max, DamageSource source, float damage) {
if (this.hasEffect(ALObjects.MobEffects.SUNDERING) && !source.is(DamageTypeTags.BYPASSES_RESISTANCE)) {
int level = this.getEffect(ALObjects.MobEffects.SUNDERING).getAmplifier() + 1;
value += damage * level * 0.2F;
Expand All @@ -67,7 +67,7 @@ public LivingEntityMixin(EntityType<?> pEntityType, Level pLevel) {
* @reason Used to enter an if-condition so the above mixin always triggers.
*/
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasEffect(Lnet/minecraft/world/effect/MobEffect;)Z"), method = "getDamageAfterMagicAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F")
public boolean zenith$sunderingHasEffect(LivingEntity ths, MobEffect effect) {
public boolean zenith_attributes$sunderingHasEffect(LivingEntity ths, MobEffect effect) {
return true;
}

Expand All @@ -76,17 +76,17 @@ public LivingEntityMixin(EntityType<?> pEntityType, Level pLevel) {
* @reason Used to prevent an NPE since we're faking true on hasEffect
*/
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/effect/MobEffectInstance;getAmplifier()I"), method = "getDamageAfterMagicAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F")
public int zenith$sunderingGetAmplifier(@Nullable MobEffectInstance inst) {
public int zenith_attributes$sunderingGetAmplifier(@Nullable MobEffectInstance inst) {
return inst == null ? -1 : inst.getAmplifier();
}

@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterAbsorb(FFF)F"), method = "getDamageAfterArmorAbsorb", require = 1)
public float zenith_applyArmorPen(float amount, DamageSource src) {
public float zenith_attributes$applyArmorPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterArmor((LivingEntity) (Object) this, src, amount,((LivingEntity)(Object) this).getArmorValue(), (float) ((LivingEntity)(Object) this).getAttributeValue(Attributes.ARMOR_TOUGHNESS));
}

@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterMagicAbsorb(FF)F"), method = "getDamageAfterMagicAbsorb", require = 1)
public float zenith_applyProtPen(float amount, DamageSource src) {
public float zenith_attributes$applyProtPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterProtection((LivingEntity) (Object) this, src, amount, EnchantmentHelper.getDamageProtection(((LivingEntity)(Object) this).getArmorSlots(), src));
}

Expand All @@ -97,7 +97,7 @@ public float zenith_applyProtPen(float amount, DamageSource src) {
}

@Inject(method = "updateUsingItem", at = @At("HEAD"))
private void useItemEvent(ItemStack usingItem, CallbackInfo ci) {
private void zenith_attributes$useItemEvent(ItemStack usingItem, CallbackInfo ci) {
if (!usingItem.isEmpty())
this.useItemRemaining = AttributeEvents.drawSpeed((LivingEntity) (Object) this, usingItem, this.useItemRemaining);
}
Expand All @@ -108,7 +108,7 @@ private void useItemEvent(ItemStack usingItem, CallbackInfo ci) {
}

@Inject(method = "createLivingAttributes", at = @At("RETURN"))
private static void zenith_attributes(CallbackInfoReturnable<AttributeSupplier.Builder> cir) {
private static void zenith_attributes$customAttributes(CallbackInfoReturnable<AttributeSupplier.Builder> cir) {
cir.getReturnValue().add(ALObjects.Attributes.DRAW_SPEED)
.add(ALObjects.Attributes.CRIT_CHANCE)
.add(ALObjects.Attributes.COLD_DAMAGE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package dev.shadowsoffire.attributeslib.mixin;

import java.util.function.Predicate;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.goal.target.TargetGoal;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.ai.goal.target.TargetGoal;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import java.util.function.Predicate;

@Mixin(NearestAttackableTargetGoal.class)
public abstract class NearestAttackableTargetGoalMixin extends TargetGoal {
Expand All @@ -29,7 +28,7 @@ public NearestAttackableTargetGoalMixin(Mob pMob, boolean pMustSee) {
TargetingConditions targetConditions;

@Inject(method = "<init>(Lnet/minecraft/world/entity/Mob;Ljava/lang/Class;IZZLjava/util/function/Predicate;)V", at = @At("TAIL"))
private void apoth_cachePredicate(Mob pMob, Class<?> pTargetType, int pRandomInterval, boolean pMustSee, boolean pMustReach, @Nullable Predicate<LivingEntity> pTargetPredicate, CallbackInfo ci) {
private void zenith_attributes$cachePredicate(Mob pMob, Class<?> pTargetType, int pRandomInterval, boolean pMustSee, boolean pMustReach, @Nullable Predicate<LivingEntity> pTargetPredicate, CallbackInfo ci) {
this.ctorTargetPredicate = pTargetPredicate;
}

Expand All @@ -41,7 +40,7 @@ private void apoth_cachePredicate(Mob pMob, Class<?> pTargetType, int pRandomInt
* Technically {@link TargetGoal#canContinueToUse()} uses the real value, which should kick it back after a delay.
*/
@Inject(method = "findTarget()V", at = @At("HEAD"))
private void apoth_updateFollowRange(CallbackInfo ci) {
private void zenith_attributes$updateFollowRange(CallbackInfo ci) {
this.targetConditions.range(this.getFollowDistance());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class PotionUtilsMixin {
* @see PotionUtils#addPotionTooltip(List, List, float)
*/
@Redirect(method = "addPotionTooltip(Ljava/util/List;Ljava/util/List;F)V", at = @At(value = "INVOKE", target = "Ljava/util/List;isEmpty()Z", ordinal = 1), require = 1)
private static boolean attributeslib_potionTooltips(List<Pair<Attribute, AttributeModifier>> list, List<MobEffectInstance> effects, List<Component> tooltips, float durationFactor) {
private static boolean zenith_attributes$potionTooltips(List<Pair<Attribute, AttributeModifier>> list, List<MobEffectInstance> effects, List<Component> tooltips, float durationFactor) {
if (!list.isEmpty()) {
tooltips.add(CommonComponents.EMPTY);
tooltips.add(Component.translatable("potion.whenDrank").withStyle(ChatFormatting.DARK_PURPLE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class ProjectileMixin {

@ModifyArgs(method = "shootFromRotation", at = @At(value = "INVOKE", target = "net/minecraft/world/entity/projectile/Projectile.shoot (DDDFF)V"))
private void zenith_attributes$gatherComponents(Args args, Entity shooter, float x, float y, float z, float velocity, float inaccuracy) {
private void zenith_attributes$modifyArrowVelocity(Args args, Entity shooter, float x, float y, float z, float velocity, float inaccuracy) {
if (((Projectile) (Object) this) instanceof AbstractArrow arrow) {
AttributeEvents.modifyArrowVelocity(args, arrow, velocity);
}
Expand Down

0 comments on commit ffdee46

Please sign in to comment.