Search in sources :

Example 11 with ItemKeyblade

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

the class Utils method summonWeapon.

/**
 * Summon a weapon in a player's hand
 * @param player
 * @param hand
 * @param keychainSlot
 * @return
 */
public static boolean summonWeapon(EntityPlayer player, EnumHand hand, int keychainSlot) {
    SummonKeybladeCapability.ISummonKeyblade summonCap = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
    OrganizationXIIICapability.IOrganizationXIII organizationXIIICap = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
    if (organizationXIIICap.getMember() == Utils.OrgMember.NONE) {
        if (ItemStack.areItemStacksEqual(summonCap.getInventoryKeychain().getStackInSlot(keychainSlot), ItemStack.EMPTY)) {
            player.sendMessage(new TextComponentTranslation(TextFormatting.RED + "Missing keychain to summon"));
            return false;
        }
        if (!summonCap.getIsKeybladeSummoned(hand) && ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && summonCap.getInventoryKeychain().getStackInSlot(0).getItem() instanceof ItemKeychain) {
            summonCap.setActiveSlot(player.inventory.currentItem);
            ItemStack keychain = summonCap.getInventoryKeychain().getStackInSlot(keychainSlot);
            ItemStack keyblade = new ItemStack(((ItemKeychain) (keychain.getItem())).getKeyblade());
            if (hand == EnumHand.MAIN_HAND) {
                player.inventory.setInventorySlotContents(player.inventory.currentItem, keyblade);
            } else {
                player.inventory.offHandInventory.set(0, keyblade);
            }
            if (player.world.isRemote)
                PacketDispatcher.sendToServer(new SummonKeyblade(hand, keychainSlot));
            return true;
        } else if (!ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof ItemRealKeyblade && summonCap.getIsKeybladeSummoned(hand)) {
            if (player.world.isRemote)
                PacketDispatcher.sendToServer(new DeSummonKeyblade(hand));
            player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
            player.inventory.offHandInventory.set(0, ItemStack.EMPTY);
            return true;
        } else {
            return false;
        }
    } else {
        if (!organizationXIIICap.summonedWeapon(hand) && ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY)) {
            if (player.world.isRemote)
                PacketDispatcher.sendToServer(new SummonOrgWeapon(hand, organizationXIIICap.currentWeapon()));
            if (hand == EnumHand.MAIN_HAND)
                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(organizationXIIICap.currentWeapon()));
            else
                player.inventory.offHandInventory.set(0, new ItemStack(organizationXIIICap.currentWeapon()));
            organizationXIIICap.setWeaponSummoned(hand, true);
            return true;
        } else if (!ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof IOrgWeapon || (organizationXIIICap.getMember() == Utils.OrgMember.ROXAS && !ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof ItemKeyblade)) {
            if (player.world.isRemote) {
                PacketDispatcher.sendToServer(new DeSummonOrgWeapon(hand));
            }
            organizationXIIICap.setWeaponSummoned(hand, false);
            if (hand == EnumHand.MAIN_HAND)
                player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
            else
                player.inventory.offHandInventory.set(0, ItemStack.EMPTY);
            return true;
        } else {
            return false;
        }
    }
}
Also used : DeSummonOrgWeapon(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonOrgWeapon) SummonOrgWeapon(uk.co.wehavecookies56.kk.common.network.packet.server.SummonOrgWeapon) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) DeSummonKeyblade(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonKeyblade) ItemRealKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) SummonKeybladeCapability(uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability) DeSummonOrgWeapon(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonOrgWeapon) SummonKeyblade(uk.co.wehavecookies56.kk.common.network.packet.server.SummonKeyblade) DeSummonKeyblade(uk.co.wehavecookies56.kk.common.network.packet.server.DeSummonKeyblade) ItemStack(net.minecraft.item.ItemStack) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) OrganizationXIIICapability(uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability)

Example 12 with ItemKeyblade

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

the class GuiRecipeList method drawStats.

public void drawStats(ItemKeyblade item, int var1, int var3, int colour) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(RECIPES.getKnownRecipes().get(var1).toString() + ".name"), listWidth - 1), this.left + 3, var3 + 2, colour);
    this.ir.renderItemAndEffectIntoGUI(new ItemStack(item), this.left + 3, var3 + 12);
    String plus = item.getStrength() < 0 ? "" : "+";
    this.f.drawString("Str: " + plus + item.getStrength(), this.left + 25, var3 + 12, 0xFF0000);
    plus = item.getMagic() < 0 ? "" : "+";
    this.f.drawString("Mag: " + plus + item.getMagic(), this.left + 25, var3 + 20, 0x4444FF);
}
Also used : ItemStack(net.minecraft.item.ItemStack) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 13 with ItemKeyblade

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

the class GuiSynthesis method drawSelectedFreeDev.

public void drawSelectedFreeDev(int mouseX, int mouseY) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int posX = 220;
    if (freeDevSelected != -1) {
        Minecraft.getMinecraft().renderEngine.bindTexture(optionsBackground);
        drawGradientRect(posX - 10, 60, 700, height - ((height / 8) + 70 / 16), -1072689136, -804253680);
    }
    GL11.glPushMatrix();
    {
        for (int i = 0; i < RECIPES.getFreeDevRecipes().size(); i++) if (freeDevSelected == i) {
            float scale = 1.0f;
            if (mc.gameSettings.guiScale == Constants.SCALE_LARGE) {
                scale = 0.5f;
            }
            GL11.glPushMatrix();
            {
                GL11.glTranslatef(posX, 70, 0);
                GL11.glScalef(2 * scale, 2 * scale, 2 * scale);
                drawString(fontRenderer, Utils.translateToLocal(RECIPES.getFreeDevRecipes().get(i).toString() + ".name"), 0, 0, 0xFFF700);
            // drawString(fontRendererObj, "Strength: +"+((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
            // drawString(fontRendererObj, "Magic: +"+ ((ItemKeyblade)ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getMagic(), 0, 20, 0x4444FF);
            }
            GL11.glPopMatrix();
            drawString(fontRenderer, Utils.translateToLocal(Strings.Gui_Synthesis_Main_Recipes_ReqMaterials) + TextFormatting.ITALIC, posX, 100, 0x00C3FF);
            int row = 0;
            int column = 0;
            int materialLength = 0;
            Iterator it = FreeDevRecipeRegistry.get(RECIPES.getFreeDevRecipes().get(i)).getRequirements().entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
                int distY = (int) (24 * scale);
                int distX = (int) (100 * scale);
                GL11.glPushMatrix();
                {
                    GL11.glColor4f(1, 1, 1, 1);
                    ResourceLocation synthMaterial = pair.getKey().getTexture();
                    if (synthMaterial == null) {
                        GL11.glTranslatef((int) (posX + (materialLength * 1.05f)), 110 + (distY * row), 0);
                        GL11.glScalef(scale, scale, 0);
                        Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(pair.getKey().getItem(), 0, 0);
                    } else {
                        mc.renderEngine.bindTexture(synthMaterial);
                        GL11.glTranslatef(posX + (materialLength * 1.05f * scale), 110 + (distY * row), 0);
                        GL11.glScalef(0.0625f * scale, 0.0625f * scale, 0);
                        drawTexturedModalRect(0, 0, 0, 0, 256, 256);
                    }
                }
                GL11.glPopMatrix();
                String name = pair.getKey().getName();
                String info = "";
                int colour = 0xFFFFFF;
                SynthesisMaterialCapability.ISynthesisMaterial MATS = mc.player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
                if (MATS.getKnownMaterialsMap().containsKey(pair.getKey().getName())) {
                    info = " - You have " + MATS.getKnownMaterialsMap().get(pair.getKey().getName());
                    if (MATS.getKnownMaterialsMap().get(pair.getKey().getName()) >= pair.getValue())
                        colour = 0x00CF18;
                    else
                        colour = 0xB50000;
                } else {
                    info = " - You have 0";
                    colour = 0xB50000;
                }
                String material = Utils.translateToLocal(name + ".name") + " x" + pair.getValue();
                GL11.glPushMatrix();
                {
                    GL11.glTranslatef((int) (posX + 18 + (materialLength * 1.05f * scale)), 114 + (distY * row), 0);
                    GL11.glScalef(scale, scale, 0);
                    drawString(fontRenderer, material, 0, 0, 0xFFFFFF);
                }
                GL11.glPopMatrix();
                GL11.glPushMatrix();
                {
                    GL11.glTranslatef((int) (posX + 18 + (fontRenderer.getStringWidth(material) * scale) + (materialLength * 1.05f * scale)), 114 + (distY * row), 0);
                    GL11.glScalef(scale, scale, 0);
                    drawString(fontRenderer, info, 0, 0, colour);
                }
                GL11.glPopMatrix();
                if (column == 1) {
                    row++;
                    column = 0;
                    materialLength = 0;
                } else {
                    materialLength = (fontRenderer.getStringWidth(Utils.translateToLocal(ModItems.Chain_IncompleteKiblade.getUnlocalizedName() + ".name") + " - You have XXXX")) + 20;
                    column = 1;
                }
            }
        }
    }
    GL11.glPopMatrix();
}
Also used : SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) Material(uk.co.wehavecookies56.kk.api.materials.Material) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability) ResourceLocation(net.minecraft.util.ResourceLocation) Iterator(java.util.Iterator) Map(java.util.Map)

Aggregations

ItemKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade)9 ItemStack (net.minecraft.item.ItemStack)8 SynthesisRecipeCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)5 IOrgWeapon (uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon)5 Item (net.minecraft.item.Item)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Map (java.util.Map)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemKeychain (uk.co.wehavecookies56.kk.common.item.base.ItemKeychain)3 Iterator (java.util.Iterator)2 RenderItem (net.minecraft.client.renderer.RenderItem)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Material (uk.co.wehavecookies56.kk.api.materials.Material)2 SynthesisMaterialCapability (uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability)2 IKHMob (uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob)2 ItemRealKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade)2 Entity (net.minecraft.entity.Entity)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1