Search in sources :

Example 6 with ItemKeychain

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeychain in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class DriveForm method update.

public void update(EntityPlayer player) {
    if (player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot() == -1) {
        player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setActiveSlot(player.inventory.currentItem);
    }
    if (player.world.isRemote) {
        GuiScreen currScreen = Minecraft.getMinecraft().currentScreen;
        if (currScreen instanceof GuiContainer) {
            Minecraft.getMinecraft().displayGuiScreen(null);
            player.sendMessage(new TextComponentTranslation("Cannot open containers while drive form is active"));
        }
    }
    if (player.inventory.currentItem != player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot())
        player.inventory.currentItem = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot();
    if (ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()))) {
        player.inventory.setItemStack(ItemStack.EMPTY);
        player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
    }
    if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(getKeychainSlot()).getItem()).getKeyblade()))) {
        player.inventory.setItemStack(ItemStack.EMPTY);
        player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
    }
    if (ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot()), ItemStack.EMPTY)) {
        player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
    }
    if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.offHandInventory.get(0), ItemStack.EMPTY)) {
        player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
    }
    if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
        if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() > 0) {
            player.getCapability(ModCapabilities.DRIVE_STATE, null).remFP(0.1);
            if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() < 0) {
                player.getCapability(ModCapabilities.DRIVE_STATE, null).setFP(0);
                endDrive(player);
                if (player.world.isRemote) {
                    PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
                }
            }
        } else {
            endDrive(player);
            if (player.world.isRemote) {
                PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
            }
        /*Utils.summonWeapon(player, EnumHand.MAIN_HAND, 0);
                if(hasOffHand())
                    Utils.summonWeapon(player, EnumHand.OFF_HAND, getKeychainSlot());
                player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
                player.inventory.offHandInventory.set(0, ItemStack.EMPTY);*/
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) DriveFormPacket(uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)5 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)5 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 ItemKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade)3 Map (java.util.Map)2 Item (net.minecraft.item.Item)2 IOrgWeapon (uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon)2 Iterator (java.util.Iterator)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1 RenderItem (net.minecraft.client.renderer.RenderItem)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IItemHandler (net.minecraftforge.items.IItemHandler)1 Material (uk.co.wehavecookies56.kk.api.materials.Material)1 Recipe (uk.co.wehavecookies56.kk.api.recipes.Recipe)1 OrganizationXIIICapability (uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability)1