Skip to content

Commit

Permalink
v2.0 - other bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DakotaPride committed Oct 1, 2024
1 parent 7b387bb commit c56c300
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.dakotapride.garnished.item.hatchet.tier.integrated.mythicupgrades.MythicUpgradesHatchetToolItem;
import net.dakotapride.garnished.registry.GarnishedAdvancementUtils;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;

import net.minecraft.world.entity.EquipmentSlot;
Expand Down Expand Up @@ -35,6 +36,8 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

import java.util.Objects;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity {
@Shadow
Expand Down Expand Up @@ -85,18 +88,19 @@ public LivingEntityMixin(EntityType<?> entityType, Level level) {
private void applyThornsDamage$getDamageAfterMagicAbsorb(DamageSource source, float amount, CallbackInfoReturnable<Float> cir) {

if (source.getDirectEntity() instanceof LivingEntity attacker) {
if (entity.hasEffect(GarnishedEffects.THORNS)) {
attacker.hurt(entity.damageSources().thorns(entity), 3.0F * entity.getEffect(GarnishedEffects.THORNS).getAmplifier());
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());
}
}

}

@Inject(method = "hurt", at = @At("HEAD"), cancellable = true)
private void negateArrowDamage$hurt(DamageSource pSource, float pAmount, CallbackInfoReturnable<Boolean> cir) {
if (entity.hasEffect(GarnishedEffects.TRUTH_SEEKER) && pSource.getDirectEntity() instanceof AbstractArrow) {
MobEffectInstance truthSeekerMobEffect = entity.getEffect(GarnishedEffects.TRUTH_SEEKER);
int effectAmplifier = truthSeekerMobEffect.getAmplifier();
if (entity.hasEffect(GarnishedEffects.TRUTH_SEEKER) && pSource.getDirectEntity() instanceof AbstractArrow && entity.getEffect(GarnishedEffects.TRUTH_SEEKER) != null) {
MobEffect truthSeekerMobEffect = GarnishedEffects.TRUTH_SEEKER;
//assert truthSeekerMobEffect != null;
int effectAmplifier = Objects.requireNonNull(entity.getEffect(truthSeekerMobEffect)).getAmplifier();
int boundInt = 20 - effectAmplifier;
int j = entity.getRandom().nextInt(10);
int k = j + 10;
Expand Down

0 comments on commit c56c300

Please sign in to comment.