Search in sources :

Example 1 with ISpell

use of com.bewitchment.api.spell.ISpell 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)

Example 2 with ISpell

use of com.bewitchment.api.spell.ISpell in project Bewitchment by Um-Mitternacht.

the class EntitySpellCarrier method onImpact.

@Override
protected void onImpact(RayTraceResult result) {
    if (!world.isRemote) {
        ISpell spell = getSpell();
        EntityLivingBase caster = getCaster();
        if (spell != null) {
            if (result.typeOfHit != Type.ENTITY || result.entityHit != caster)
                spell.performEffect(result, caster, world);
            if (result.typeOfHit == Type.BLOCK && (spell.getType() == EnumSpellType.PROJECTILE_BLOCK || spell.getType() == EnumSpellType.PROJECTILE_ALL))
                this.setDead();
            if (result.typeOfHit == Type.ENTITY && (spell.getType() == EnumSpellType.PROJECTILE_ENTITY || spell.getType() == EnumSpellType.PROJECTILE_ALL) && result.entityHit != caster)
                this.setDead();
        } else
            Bewitchment.logger.warn("Spell is null for " + this + " with spell reg name of " + getSpellName());
    }
}
Also used : ISpell(com.bewitchment.api.spell.ISpell) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 3 with ISpell

use of com.bewitchment.api.spell.ISpell in project Bewitchment by Um-Mitternacht.

the class ClientProxy method init.

@Override
public void init(FMLInitializationEvent event) {
    Keybinds.registerKeys();
    BlockColors blocks = Minecraft.getMinecraft().getBlockColors();
    // Block Colors
    blocks.registerBlockColorHandler(new BlockCandleColorHandler(), ModBlocks.candle_medium, ModBlocks.candle_small, ModBlocks.candle_medium_lit, ModBlocks.candle_small_lit);
    blocks.registerBlockColorHandler(new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
            EnumGlyphType type = state.getValue(BlockCircleGlyph.TYPE);
            switch(type) {
                case ENDER:
                    return 0x770077;
                case GOLDEN:
                    return 0xe3dc3c;
                case NETHER:
                    return 0xbb0000;
                default:
                case NORMAL:
                    return 0xFFFFFF;
                case ANY:
                    // A green one should never happen!
                    return 0x00FF00;
            }
        }
    }, ModBlocks.ritual_glyphs);
    blocks.registerBlockColorHandler(new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
            if (tintIndex == 1) {
                return Color.HSBtoRGB((pos.getX() + pos.getY() + pos.getZ()) % 50 / 50f, 0.4f, 1f);
            }
            return -1;
        }
    }, ModBlocks.crystal_ball);
    ItemColors items = Minecraft.getMinecraft().getItemColors();
    // Item Colors
    items.registerItemColorHandler(new ItemCandleColorHandler(), Item.getItemFromBlock(ModBlocks.candle_medium), Item.getItemFromBlock(ModBlocks.candle_small));
    items.registerItemColorHandler(new BrewItemColorHandler(), ModItems.brew_phial_drink, ModItems.brew_phial_splash, ModItems.brew_phial_linger);
    items.registerItemColorHandler(new IItemColor() {

        @Override
        public int colorMultiplier(ItemStack stack, int tintIndex) {
            if (tintIndex == 0) {
                ISpell s = ItemSpellPage.getSpellFromItemStack(stack);
                if (s != null)
                    return s.getColor();
            }
            return -1;
        }
    }, ModItems.spell_page);
    NetworkRegistry.INSTANCE.registerGuiHandler(Bewitchment.instance, new GuiHandler());
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ISpell(com.bewitchment.api.spell.ISpell) IBlockAccess(net.minecraft.world.IBlockAccess) GuiHandler(com.bewitchment.common.core.net.GuiHandler) BlockColors(net.minecraft.client.renderer.color.BlockColors) IItemColor(net.minecraft.client.renderer.color.IItemColor) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ItemColors(net.minecraft.client.renderer.color.ItemColors) EnumGlyphType(com.bewitchment.api.ritual.EnumGlyphType) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ISpell (com.bewitchment.api.spell.ISpell)3 EnumGlyphType (com.bewitchment.api.ritual.EnumGlyphType)1 GuiHandler (com.bewitchment.common.core.net.GuiHandler)1 EntitySpellCarrier (com.bewitchment.common.entity.EntitySpellCarrier)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockColors (net.minecraft.client.renderer.color.BlockColors)1 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)1 IItemColor (net.minecraft.client.renderer.color.IItemColor)1 ItemColors (net.minecraft.client.renderer.color.ItemColors)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 IBlockAccess (net.minecraft.world.IBlockAccess)1