Skip to content

Commit

Permalink
yeet
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash (Bagel) committed Dec 28, 2024
1 parent e3a887a commit e318a62
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
package dev.shadowsoffire.attributeslib.mixin;

import dev.shadowsoffire.attributeslib.AttributesLib;
import dev.shadowsoffire.attributeslib.api.ALCombatRules;
import net.minecraft.world.damagesource.CombatRules;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
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;

@Mixin(value = CombatRules.class, priority = 1500)
public class CombatRulesMixin {
//TODO This is bad! Do not do this!
/**
* @see ALCombatRules#getDamageAfterProtection(net.minecraft.world.entity.LivingEntity, net.minecraft.world.damagesource.DamageSource, float, float)
*/
@Inject(method ="getDamageAfterMagicAbsorb", at = @At("HEAD"), cancellable = true)
private static void zenith_attributes$getDamageAfterMagicAbsorb(float damage, float protPoints, CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(damage * ALCombatRules.getProtDamageReduction(protPoints));
}

/**
* @see ALCombatRules#getDamageAfterArmor(LivingEntity, DamageSource, float, float, float)
*/
@Inject(method ="getDamageAfterAbsorb", at = @At("HEAD"), cancellable = true)
private static void zenith_attributes$getDamageAfterAbsorb(float damage, float totalArmor, float toughnessAttribute, CallbackInfoReturnable<Float> cir) {
AttributesLib.LOGGER.trace("Invocation of CombatRules#getDamageAfterAbsorb is bypassing armor pen.");
cir.setReturnValue(damage * ALCombatRules.getArmorDamageReduction(damage, totalArmor, toughnessAttribute));
}
//TODO Update/redo combat changes
// /**
// * @see ALCombatRules#getDamageAfterProtection(net.minecraft.world.entity.LivingEntity, net.minecraft.world.damagesource.DamageSource, float, float)
// */
// @Inject(method ="getDamageAfterMagicAbsorb", at = @At("HEAD"), cancellable = true)
// private static void zenith_attributes$getDamageAfterMagicAbsorb(float damage, float protPoints, CallbackInfoReturnable<Float> cir) {
// cir.setReturnValue(damage * ALCombatRules.getProtDamageReduction(protPoints));
// }
//
// /**
// * @see ALCombatRules#getDamageAfterArmor(LivingEntity, DamageSource, float, float, float)
// */
// @Inject(method ="getDamageAfterAbsorb", at = @At("HEAD"), cancellable = true)
// private static void zenith_attributes$getDamageAfterAbsorb(float damage, float totalArmor, float toughnessAttribute, CallbackInfoReturnable<Float> cir) {
// AttributesLib.LOGGER.trace("Invocation of CombatRules#getDamageAfterAbsorb is bypassing armor pen.");
// cir.setReturnValue(damage * ALCombatRules.getArmorDamageReduction(damage, totalArmor, toughnessAttribute));
// }
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dev.shadowsoffire.attributeslib.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import de.dafuqs.additionalentityattributes.AdditionalEntityAttributes;
import dev.shadowsoffire.attributeslib.api.ALCombatRules;
import dev.shadowsoffire.attributeslib.api.ALObjects;
import dev.shadowsoffire.attributeslib.api.events.LivingHealEvent;
import dev.shadowsoffire.attributeslib.api.events.LivingHurtEvent;
Expand All @@ -17,9 +15,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -81,16 +77,16 @@ public LivingEntityMixin(EntityType<?> pEntityType, Level pLevel) {
public int zenith_attributes$sunderingGetAmplifier(@Nullable MobEffectInstance inst, Operation<Integer> original) {
return inst == null ? -1 : original.call(inst);
}

@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterAbsorb(FFF)F"), method = "getDamageAfterArmorAbsorb", require = 1)
public float zenith_attributes$applyArmorPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterArmor(ths(), src, amount, ths().getArmorValue(), (float) (ths()).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_attributes$applyProtPen(float amount, DamageSource src) {
return ALCombatRules.getDamageAfterProtection(ths(), src, amount, EnchantmentHelper.getDamageProtection((ths()).getArmorSlots(), src));
}
//Todo figure out armor modification...
// @ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/damagesource/CombatRules;getDamageAfterAbsorb(FFF)F"), method = "getDamageAfterArmorAbsorb", require = 1)
// public float zenith_attributes$applyArmorPen(float amount, DamageSource src) {
// return ALCombatRules.getDamageAfterArmor(ths(), src, amount, ths().getArmorValue(), (float) (ths()).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_attributes$applyProtPen(float amount, DamageSource src) {
// return ALCombatRules.getDamageAfterProtection(ths(), src, amount, EnchantmentHelper.getDamageProtection((ths()).getArmorSlots(), src));
// }

@ModifyVariable(method = "heal", at = @At(value = "HEAD"), argsOnly = true)
private float zenith_attributes$onHealEvent(float value){
Expand Down

0 comments on commit e318a62

Please sign in to comment.