From d2243b4c8e3bb252a356cacfc2a339e634959265 Mon Sep 17 00:00:00 2001 From: Dakota Date: Sat, 5 Oct 2024 12:54:00 -0500 Subject: [PATCH] v2.0 - other bug fixes --- .../garnished/mixin/LivingEntityMixin.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/dakotapride/garnished/mixin/LivingEntityMixin.java b/src/main/java/net/dakotapride/garnished/mixin/LivingEntityMixin.java index ba9fe29c..01f58aa8 100644 --- a/src/main/java/net/dakotapride/garnished/mixin/LivingEntityMixin.java +++ b/src/main/java/net/dakotapride/garnished/mixin/LivingEntityMixin.java @@ -86,13 +86,30 @@ public LivingEntityMixin(EntityType entityType, Level level) { @Inject(method = "getDamageAfterMagicAbsorb", at = @At("HEAD")) private void applyThornsDamage$getDamageAfterMagicAbsorb(DamageSource source, float amount, CallbackInfoReturnable cir) { + if (source.getEntity() instanceof LivingEntity attacker) { + float j = amount / 2; + boolean f = j <= 3; + //boolean k = j < (attacker.getMaxHealth() / 2.25F); + MobEffect e = GarnishedEffects.THORNS; - if (source.getDirectEntity() instanceof LivingEntity attacker) { - if (entity.hasEffect(GarnishedEffects.THORNS) && entity.getEffect(GarnishedEffects.THORNS) != null) { - attacker.hurt(entity.damageSources().thorns(entity), 3.0F * Objects.requireNonNull(entity.getEffect(GarnishedEffects.THORNS)).getAmplifier()); + if (f) { + j = 4; } - } + if (entity.hasEffect(e) && !attacker.hasEffect(e)) { + attacker.hurt(source, j); + + //CreateGarnished.LOGGER.info("Applied standard {} to {} from {}", j, attacker, entity); + } else if (j > (attacker.getMaxHealth() * 0.80F) && entity.hasEffect(e) && !attacker.hasEffect(e)) { + attacker.hurt(source, (attacker.getMaxHealth() * 0.80F)); + + //CreateGarnished.LOGGER.info("Applied maximum {} to {} from {}", (attacker.getMaxHealth() / 1.25F), attacker, entity); + } + +// if (entity.hasEffect(GarnishedEffects.THORNS.get())) { +// attacker.hurt(entity.damageSources().thorns(entity), (amount / 3)); +// } + } } @Inject(method = "hurt", at = @At("HEAD"), cancellable = true)