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/FlameSpell.java

62 lines
1.7 KiB
Java
Raw Normal View History

2020-03-01 18:19:59 +00:00
package com.thebrokenrail.sorcerycraft.spell;
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
2020-03-01 18:19:59 +00:00
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
2020-06-24 15:43:53 +00:00
import net.minecraft.item.AutomaticItemPlacementContext;
2020-03-01 18:19:59 +00:00
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
2020-03-01 18:19:59 +00:00
public class FlameSpell extends Spell {
public FlameSpell(Identifier id, int level) {
2020-03-01 18:19:59 +00:00
super(id, level);
}
@Override
2020-03-08 16:06:43 +00:00
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (attacker instanceof LivingEntity) {
((LivingEntity) attacker).onAttacking(target);
}
target.setOnFireFor(8 + (getLevel() * 4));
2020-03-01 18:19:59 +00:00
}
@Override
2020-03-08 16:06:43 +00:00
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
2020-06-24 15:43:53 +00:00
Items.FLINT_AND_STEEL.useOnBlock(new AutomaticItemPlacementContext(world, hitResult.getBlockPos(), hitResult.getSide().getOpposite(), new ItemStack(Items.FLINT_AND_STEEL), hitResult.getSide()));
}
2020-03-01 18:19:59 +00:00
@Override
public int getXPCost() {
switch (getLevel()) {
case 0: {
return 8;
}
case 1: {
return 12;
2020-03-01 18:19:59 +00:00
}
}
return -1;
}
@Override
public ItemStack getItemCost() {
switch (getLevel()) {
case 0: {
return new ItemStack(Items.FLINT_AND_STEEL);
}
case 1: {
return new ItemStack(Items.FIRE_CHARGE);
}
}
return ItemStack.EMPTY;
}
@Override
public int getMaxLevel() {
return 2;
}
}