62 lines
1.6 KiB
Java
62 lines
1.6 KiB
Java
package com.thebrokenrail.sorcerycraft.spell;
|
|
|
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
|
import net.minecraft.block.AbstractFireBlock;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.util.Identifier;
|
|
import net.minecraft.util.hit.BlockHitResult;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
public class FlameSpell extends Spell {
|
|
public FlameSpell(Identifier id, int level) {
|
|
super(id, level);
|
|
}
|
|
|
|
@Override
|
|
public void execute(World world, Entity source, Entity attacker, Entity target) {
|
|
target.setFireTicks(400 + (getLevel() * 200));
|
|
}
|
|
|
|
@Override
|
|
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
|
BlockPos blockPos = hitResult.getBlockPos().offset(hitResult.getSide());
|
|
if (world.isAir(blockPos)) {
|
|
world.setBlockState(blockPos, AbstractFireBlock.getState(world, blockPos));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getXPCost() {
|
|
switch (getLevel()) {
|
|
case 0: {
|
|
return 8;
|
|
}
|
|
case 1: {
|
|
return 16;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
}
|