Search in sources :

Example 6 with ItemSpellBook

use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.

the class SpellScrollRenderer method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (mc.thePlayer.isPotionActive(Potion.invisibility.id))
        return;
    ItemStack scrollStack = null;
    if (item.getItem() instanceof ItemSpellBase) {
        scrollStack = item;
    } else if (item.getItem() instanceof ItemSpellBook) {
        scrollStack = ((ItemSpellBook) item.getItem()).getActiveScrollInventory(item)[((ItemSpellBook) item.getItem()).GetActiveSlot(item)];
    }
    if (scrollStack == null)
        return;
    Affinity affinity = SpellUtils.instance.mainAffinityFor(scrollStack);
    renderEffect(affinity, true, data);
}
Also used : ItemSpellBase(am2.api.spell.ItemSpellBase) Affinity(am2.api.spell.enums.Affinity) ItemStack(net.minecraft.item.ItemStack) ItemSpellBook(am2.items.ItemSpellBook)

Example 7 with ItemSpellBook

use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.

the class AMKeyBindings method onKeyInput.

@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
    EntityPlayer clientPlayer = FMLClientHandler.instance().getClient().thePlayer;
    if (Minecraft.getMinecraft().currentScreen != null) {
        if (Minecraft.getMinecraft().currentScreen instanceof GuiInventory) {
            if (ManaToggleKey.isPressed()) {
                boolean curDisplayFlag = AMCore.config.displayManaInInventory();
                AMCore.config.setDisplayManaInInventory(!curDisplayFlag);
            }
        }
        return;
    }
    if (ShapeGroupKey.isPressed()) {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        ItemStack curItem = player.inventory.getStackInSlot(player.inventory.currentItem);
        if (curItem == null || (curItem.getItem() != ItemsCommonProxy.spell && curItem.getItem() != ItemsCommonProxy.spellBook && curItem.getItem() != ItemsCommonProxy.arcaneSpellbook)) {
            return;
        }
        int shapeGroup;
        if (curItem.getItem() == ItemsCommonProxy.spell) {
            shapeGroup = SpellUtils.instance.cycleShapeGroup(curItem);
        } else {
            ItemStack spellStack = ((ItemSpellBook) curItem.getItem()).GetActiveItemStack(curItem);
            if (spellStack == null) {
                return;
            }
            shapeGroup = SpellUtils.instance.cycleShapeGroup(spellStack);
            ((ItemSpellBook) curItem.getItem()).replaceAciveItemStack(curItem, spellStack);
        }
        AMNetHandler.INSTANCE.sendShapeGroupChangePacket(shapeGroup, clientPlayer.getEntityId());
    } else if (this.SpellBookNextSpellKey.isPressed()) {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        ItemStack curItem = player.inventory.getStackInSlot(player.inventory.currentItem);
        if (curItem == null) {
            return;
        }
        if (curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook) {
            // send packet to server
            AMNetHandler.INSTANCE.sendSpellbookSlotChange(player, player.inventory.currentItem, ItemSpellBook.ID_NEXT_SPELL);
        }
    } else if (this.SpellBookPrevSpellKey.isPressed()) {
        EntityPlayer player = Minecraft.getMinecraft().thePlayer;
        ItemStack curItem = player.inventory.getStackInSlot(player.inventory.currentItem);
        if (curItem == null) {
            return;
        }
        if (curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook) {
            // send packet to server
            AMNetHandler.INSTANCE.sendSpellbookSlotChange(player, player.inventory.currentItem, ItemSpellBook.ID_PREV_SPELL);
        }
    } else if (AuraCustomizationKey.isPressed()) {
        if (AMCore.proxy.playerTracker.hasAA(clientPlayer)) {
            Minecraft.getMinecraft().displayGuiScreen(new AuraCustomizationMenu());
        }
    } else if (AffinityActivationKey.isPressed()) {
        if (AffinityData.For(clientPlayer).isAbilityReady()) {
            // send packet to the server to process the ability
            AMNetHandler.INSTANCE.sendAffinityActivate();
            // activate the ability on the client
            AffinityData.For(clientPlayer).onAffinityAbility();
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) AuraCustomizationMenu(am2.guis.AuraCustomizationMenu) ItemStack(net.minecraft.item.ItemStack) GuiInventory(net.minecraft.client.gui.inventory.GuiInventory) ItemSpellBook(am2.items.ItemSpellBook) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 8 with ItemSpellBook

use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderSpellBookUI.

private void RenderSpellBookUI(int i, int j, FontRenderer fontrenderer, ItemStack bookStack) {
    mc.renderEngine.bindTexture(spellbook_ui);
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    AMVector2 spellbookVec = getShiftedVector(AMCore.config.getSpellBookPosition(), i, j);
    int spellUI_x = spellbookVec.iX;
    int spellUI_y = spellbookVec.iY;
    int spellUI_width = 148;
    int spellUI_height = 22;
    float activeSpellSize = 15f;
    int bookActiveSlot = ((ItemSpellBook) bookStack.getItem()).GetActiveSlot(bookStack);
    float x = spellUI_x + bookActiveSlot * 12.9f;
    float y = spellUI_y;
    this.zLevel = -5;
    drawTexturedModalRect_Classic(spellUI_x, spellUI_y, 0, 0, 106, 15, spellUI_width, spellUI_height);
    ItemStack[] activeScrolls = ((ItemSpellBook) bookStack.getItem()).getActiveScrollInventory(bookStack);
    mc.renderEngine.bindTexture(items);
    this.zLevel = 0;
    for (int n = 0; n < 8; ++n) {
        float IIconX = spellUI_x + 1.5f + n * 12.9f;
        ItemStack stackItem = activeScrolls[n];
        if (stackItem == null) {
            continue;
        }
        int d = 12;
        DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 0), "items", IIconX, spellUI_y + 1.5f, d, d, false);
        DrawIconAtXY(((ItemSpellBase) stackItem.getItem()).getIconFromDamageForRenderPass(stackItem.getItemDamage(), 1), "items", IIconX, spellUI_y + 1.5f, d, d, false);
    }
    mc.renderEngine.bindTexture(spellbook_ui);
    this.zLevel = 1000;
    drawTexturedModalRect_Classic(x, y, 148, 0, activeSpellSize, activeSpellSize, 20, 20);
    this.zLevel = 0;
    mc.renderEngine.bindTexture(mc_gui);
}
Also used : AMVector2(am2.api.math.AMVector2) ItemStack(net.minecraft.item.ItemStack) ItemSpellBook(am2.items.ItemSpellBook)

Example 9 with ItemSpellBook

use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.

the class ContainerSpellBook method onContainerClosed.

@Override
public void onContainerClosed(EntityPlayer entityplayer) {
    World world = entityplayer.worldObj;
    if (!world.isRemote) {
        ItemStack spellBookItemStack = bookStack;
        ItemSpellBook spellBook = (ItemSpellBook) spellBookItemStack.getItem();
        ItemStack[] items = GetFullInventory();
        spellBook.UpdateStackTagCompound(spellBookItemStack, items);
        entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, spellBookItemStack);
    }
    super.onContainerClosed(entityplayer);
}
Also used : World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ItemSpellBook(am2.items.ItemSpellBook)

Example 10 with ItemSpellBook

use of am2.items.ItemSpellBook in project ArsMagica2 by Mithion.

the class ServerGuiManager method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te == null && ID != ArsMagicaGuiIdList.GUI_SPELL_BOOK && ID != ArsMagicaGuiIdList.GUI_KEYSTONE && ID != ArsMagicaGuiIdList.GUI_ESSENCE_BAG && ID != ArsMagicaGuiIdList.GUI_RUNE_BAG && ID != ArsMagicaGuiIdList.GUI_RIFT && ID != ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION) {
        return null;
    }
    switch(ID) {
        case ArsMagicaGuiIdList.GUI_ESSENCE_REFINER:
            if (!(te instanceof TileEntityEssenceRefiner)) {
                return null;
            }
            return new ContainerEssenceRefiner(player.inventory, (TileEntityEssenceRefiner) te);
        case ArsMagicaGuiIdList.GUI_SPELL_BOOK:
            ItemStack bookStack = player.getCurrentEquippedItem();
            if (bookStack.getItem() == null || !(bookStack.getItem() instanceof ItemSpellBook)) {
                return null;
            }
            ItemSpellBook item = (ItemSpellBook) bookStack.getItem();
            return new ContainerSpellBook(player.inventory, player.getCurrentEquippedItem(), item.ConvertToInventory(bookStack));
        case ArsMagicaGuiIdList.GUI_CALEFACTOR:
            if (!(te instanceof TileEntityCalefactor)) {
                return null;
            }
            return new ContainerCalefactor(player, (TileEntityCalefactor) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE_LOCKABLE:
            if (!(te instanceof IKeystoneLockable)) {
                return null;
            }
            return new ContainerKeystoneLockable(player.inventory, (IKeystoneLockable) te);
        case ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER:
            if (!(te instanceof TileEntityAstralBarrier)) {
                return null;
            }
            return new ContainerAstralBarrier(player.inventory, (TileEntityAstralBarrier) te);
        case ArsMagicaGuiIdList.GUI_SEER_STONE:
            if (!(te instanceof TileEntitySeerStone)) {
                return null;
            }
            return new ContainerSeerStone(player.inventory, (TileEntitySeerStone) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE_CHEST:
            if (!(te instanceof TileEntityKeystoneChest)) {
                return null;
            }
            return new ContainerKeystoneChest(player.inventory, (TileEntityKeystoneChest) te);
        case ArsMagicaGuiIdList.GUI_KEYSTONE:
            ItemStack keystoneStack = player.getCurrentEquippedItem();
            if (keystoneStack.getItem() == null || !(keystoneStack.getItem() instanceof ItemKeystone)) {
                return null;
            }
            ItemKeystone keystone = (ItemKeystone) keystoneStack.getItem();
            int runeBagSlot = InventoryUtilities.getInventorySlotIndexFor(player.inventory, ItemsCommonProxy.runeBag);
            ItemStack runeBag = null;
            if (runeBagSlot > -1)
                runeBag = player.inventory.getStackInSlot(runeBagSlot);
            return new ContainerKeystone(player.inventory, player.getCurrentEquippedItem(), runeBag, keystone.ConvertToInventory(keystoneStack), runeBag == null ? null : ItemsCommonProxy.runeBag.ConvertToInventory(runeBag), runeBagSlot);
        case ArsMagicaGuiIdList.GUI_ESSENCE_BAG:
            ItemStack bagStack = player.getCurrentEquippedItem();
            if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemEssenceBag)) {
                return null;
            }
            ItemEssenceBag bag = (ItemEssenceBag) bagStack.getItem();
            return new ContainerEssenceBag(player.inventory, player.getCurrentEquippedItem(), bag.ConvertToInventory(bagStack));
        case ArsMagicaGuiIdList.GUI_RUNE_BAG:
            bagStack = player.getCurrentEquippedItem();
            if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemRuneBag)) {
                return null;
            }
            ItemRuneBag runebag = (ItemRuneBag) bagStack.getItem();
            return new ContainerRuneBag(player.inventory, player.getCurrentEquippedItem(), runebag.ConvertToInventory(bagStack));
        case ArsMagicaGuiIdList.GUI_ARCANE_RECONSTRUCTOR:
            if (!(te instanceof TileEntityArcaneReconstructor)) {
                return null;
            }
            return new ContainerArcaneReconstructor(player.inventory, (TileEntityArcaneReconstructor) te);
        case ArsMagicaGuiIdList.GUI_INSCRIPTION_TABLE:
            if (!(te instanceof TileEntityInscriptionTable)) {
                return null;
            }
            return new ContainerInscriptionTable((TileEntityInscriptionTable) te, player.inventory);
        case ArsMagicaGuiIdList.GUI_SUMMONER:
            if (!(te instanceof TileEntitySummoner)) {
                return null;
            }
            return new ContainerSummoner(player.inventory, (TileEntitySummoner) te);
        case ArsMagicaGuiIdList.GUI_MAGICIANS_WORKBENCH:
            if (!(te instanceof TileEntityMagiciansWorkbench)) {
                return null;
            }
            return new ContainerMagiciansWorkbench(player.inventory, (TileEntityMagiciansWorkbench) te);
        case ArsMagicaGuiIdList.GUI_RIFT:
            return new ContainerRiftStorage(player.inventory, RiftStorage.For(player));
        case ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION:
            return new ContainerSpellCustomization(player);
        case ArsMagicaGuiIdList.GUI_CRYSTAL_MARKER:
            if (!(te instanceof TileEntityCrystalMarker)) {
                return null;
            }
            return new ContainerCrystalMarker(player, (TileEntityCrystalMarker) te);
        case ArsMagicaGuiIdList.GUI_OBELISK:
            if (!(te instanceof TileEntityObelisk)) {
                return null;
            }
            return new ContainerObelisk((TileEntityObelisk) te, player);
        case ArsMagicaGuiIdList.GUI_FLICKER_HABITAT:
            if (!(te instanceof TileEntityFlickerHabitat)) {
                return null;
            }
            return new ContainerFlickerHabitat(player, (TileEntityFlickerHabitat) te);
        case ArsMagicaGuiIdList.GUI_ARMOR_INFUSION:
            if (!(te instanceof TileEntityArmorImbuer)) {
                return null;
            }
            return new ContainerArmorInfuser(player, (TileEntityArmorImbuer) te);
        case ArsMagicaGuiIdList.GUI_ARCANE_DECONSTRUCTOR:
            if (!(te instanceof TileEntityArcaneDeconstructor)) {
                return null;
            }
            return new ContainerArcaneDeconstructor(player.inventory, (TileEntityArcaneDeconstructor) te);
        case ArsMagicaGuiIdList.GUI_INERT_SPAWNER:
            if (!(te instanceof TileEntityInertSpawner)) {
                return null;
            }
            return new ContainerInertSpawner(player, (TileEntityInertSpawner) te);
        case ArsMagicaGuiIdList.GUI_SPELL_SEALED_DOOR:
            if (!(te instanceof TileEntitySpellSealedDoor)) {
                return null;
            }
            return new ContainerSpellSealedDoor(player.inventory, (TileEntitySpellSealedDoor) te);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IKeystoneLockable(am2.api.blocks.IKeystoneLockable) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)11 ItemSpellBook (am2.items.ItemSpellBook)8 IKeystoneLockable (am2.api.blocks.IKeystoneLockable)2 AMVector2 (am2.api.math.AMVector2)2 ExtendedProperties (am2.playerextensions.ExtendedProperties)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ItemSpellBase (am2.api.spell.ItemSpellBase)1 Affinity (am2.api.spell.enums.Affinity)1 AuraCustomizationMenu (am2.guis.AuraCustomizationMenu)1 IBoundItem (am2.items.IBoundItem)1 AMDataWriter (am2.network.AMDataWriter)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 GuiInventory (net.minecraft.client.gui.inventory.GuiInventory)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 IIcon (net.minecraft.util.IIcon)1 World (net.minecraft.world.World)1