Search in sources :

Example 1 with EntitySpellCarrier

use of com.bewitchment.common.entity.EntitySpellCarrier in project Bewitchment by Um-Mitternacht.

the class ItemSpellPage method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
    ISpell spell = getSpellFromItemStack(stack);
    if (spell != null && !worldIn.isRemote) {
        // }
        if (spell.getType() == EnumSpellType.INSTANT)
            spell.performEffect(new RayTraceResult(Type.MISS, entityLiving.getLookVec(), EnumFacing.UP, entityLiving.getPosition()), entityLiving, worldIn);
        else {
            EntitySpellCarrier car = new EntitySpellCarrier(worldIn, entityLiving.posX + entityLiving.getLookVec().x, entityLiving.posY + entityLiving.getEyeHeight() + entityLiving.getLookVec().y, entityLiving.posZ + entityLiving.getLookVec().z);
            car.setSpell(spell);
            car.setCaster(entityLiving);
            car.shoot(entityLiving, entityLiving.rotationPitch, entityLiving.rotationYaw, 0, 2f, 0);
            worldIn.spawnEntity(car);
        }
    }
    if (entityLiving instanceof EntityPlayer && ((EntityPlayer) entityLiving).isCreative())
        return stack;
    return ItemStack.EMPTY;
}
Also used : EntitySpellCarrier(com.bewitchment.common.entity.EntitySpellCarrier) ISpell(com.bewitchment.api.spell.ISpell) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ISpell (com.bewitchment.api.spell.ISpell)1 EntitySpellCarrier (com.bewitchment.common.entity.EntitySpellCarrier)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1