Search in sources :

Example 1 with GuiInventory

use of net.minecraft.client.gui.inventory.GuiInventory 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)

Aggregations

AuraCustomizationMenu (am2.guis.AuraCustomizationMenu)1 ItemSpellBook (am2.items.ItemSpellBook)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 GuiInventory (net.minecraft.client.gui.inventory.GuiInventory)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1