This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
SorceryCraft/src/main/java/com/thebrokenrail/sorcerycraft/spell/DamageSpell.java

55 lines
1.4 KiB
Java

package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class DamageSpell extends Spell {
public DamageSpell(Identifier id, int level) {
super(id, level);
}
@Override
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (target instanceof LivingEntity) {
StatusEffects.INSTANT_DAMAGE.applyInstantEffect(source, attacker, (LivingEntity) target, getLevel(), 1.0d);
}
}
@Override
public int getXPCost() {
switch (getLevel()) {
case 0: {
return 4;
}
case 1: {
return 8;
}
}
return -1;
}
@Override
public ItemStack getItemCost() {
switch (getLevel()) {
case 0: {
return ItemStack.EMPTY;
}
case 1: {
return new ItemStack(Items.WITHER_ROSE);
}
}
return ItemStack.EMPTY;
}
@Override
public int getMaxLevel() {
return 2;
}
}