All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magistuarmory.effects.LacerationEffect Maven / Gradle / Ivy

package com.magistuarmory.effects;

import com.magistuarmory.util.CombatHelper;
import net.minecraft.world.damagesource.CombatRules;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.*;
import net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class LacerationEffect extends MobEffect 
{
	public static LacerationEffect INSTANCE = new LacerationEffect();
	
	public LacerationEffect()
	{
		super(MobEffectCategory.HARMFUL, -10092544);
		m_19472_(Attributes.f_22276_, "81AEAA56-376B-4498-935B-2F7F68070635", -2.0f, Operation.ADDITION);
	}

	@Override
	public @NotNull String m_19481_()
	{
		return "effect.laceration";
	}

	@Override
	public boolean m_19486_()
	{
		return false;
	}

	public void m_6742_(LivingEntity victim, int i) 
	{
		if (victim.m_21223_() > victim.m_21233_())
			victim.m_21153_(victim.m_21233_());
	}

	public static void apply(DamageSource source, LivingEntity victim, float damage)
	{
		damage = CombatHelper.getDamageAfterAbsorb(source, victim, damage);
		
		if (victim instanceof Creeper)
			return;
		
		if (victim.m_21023_(LacerationEffect.INSTANCE))
		{
			MobEffectInstance effect = victim.m_21124_(LacerationEffect.INSTANCE);
			int amplifier = effect.m_19564_();
			int duration = effect.m_19557_();
			victim.m_21195_(LacerationEffect.INSTANCE);
			victim.m_7292_(new MobEffectInstance(LacerationEffect.INSTANCE, Math.max(duration, (int) (damage * 50)), Math.max(amplifier, (int) (0.4 * damage)), true, true, true));
		}
		else
		{
			victim.m_7292_(new MobEffectInstance(LacerationEffect.INSTANCE, (int) (damage * 50), (int) (0.4 * damage), true, true, true));
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy