Search in sources :

Example 6 with ItemKeyblade

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

the class GuiRecipeList method drawSlot.

@Override
protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int colour = 0xFFFFFF;
    if (parent.isRecipeUsable(RECIPES.getKnownRecipes().get(var1))) {
        colour = 0x55FF55;
    }
    Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(var1).substring(5)));
    if (item instanceof ItemKeyblade) {
        drawStats((ItemKeyblade) item, var1, var3, colour);
    } else if (item instanceof IOrgWeapon) {
        drawStats((IOrgWeapon) item, var1, var3, colour);
    } else {
        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);
    }
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) ItemStack(net.minecraft.item.ItemStack) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability)

Example 7 with ItemKeyblade

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

the class GuiSynthesis method drawSelected.

public void drawSelected(int mouseX, int mouseY) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = mc.player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);
    int posX = 220;
    if (selected != -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.getKnownRecipes().size(); i++) if (selected == 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.getKnownRecipes().get(i).toString() + ".name"), 0, 0, 0xFFF700);
                Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)));
                if (item instanceof ItemKeyblade) {
                    drawString(fontRenderer, "Strength: +" + ((ItemKeyblade) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
                    drawString(fontRenderer, "Magic: +" + ((ItemKeyblade) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getMagic(), 0, 20, 0x4444FF);
                } else if (item instanceof IOrgWeapon) {
                    drawString(fontRenderer, "Strength: +" + ((IOrgWeapon) ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(i).substring(5)))).getStrength(), 0, 10, 0xFF0000);
                    drawString(fontRenderer, "Magic: +" + ((IOrgWeapon) 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, 130, 0x00C3FF);
            int row = 0;
            int column = 0;
            int materialLength = 0;
            Iterator it = RecipeRegistry.get(RECIPES.getKnownRecipes().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)), 140 + (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), 140 + (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)), 144 + (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)), 144 + (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) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) Material(uk.co.wehavecookies56.kk.api.materials.Material) SynthesisRecipeCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisRecipeCapability) Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Iterator(java.util.Iterator) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) Map(java.util.Map)

Example 8 with ItemKeyblade

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

the class TESRPedestal method render.

@Override
public void render(TileEntityPedestal te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH)) {
        IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH);
        GlStateManager.pushAttrib();
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        GlStateManager.disableRescaleNormal();
        this.renderItem = Minecraft.getMinecraft().getRenderItem();
        GlStateManager.pushMatrix();
        {
            int rot = te.getRotation();
            GlStateManager.translate(0.5, 1.3, 0.5);
            GlStateManager.rotate(90 * rot, 0, 1, 0);
            GlStateManager.scale(0.02, 0.02, 0.02);
            te.setKeyblade(itemHandler.getStackInSlot(0));
            Item itemToRender = te.keyblade.getItem();
            GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 128.0F, 128.0F);
            if (itemToRender instanceof ItemKeyblade)
                renderItem.renderItem(new ItemStack(itemToRender), ItemCameraTransforms.TransformType.NONE);
            else if (itemToRender instanceof ItemKeychain)
                renderItem.renderItem(new ItemStack(((ItemKeychain) itemToRender).getKeyblade()), ItemCameraTransforms.TransformType.NONE);
            else if (itemToRender instanceof ItemOrgShield)
                renderItem.renderItem(new ItemStack((itemToRender)), ItemCameraTransforms.TransformType.NONE);
            GL11.glPopAttrib();
        }
        GlStateManager.popMatrix();
        GlStateManager.popMatrix();
        GlStateManager.popAttrib();
    }
    super.render(te, x, y, z, partialTicks, destroyStage, alpha);
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) IItemHandler(net.minecraftforge.items.IItemHandler) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) ItemOrgShield(uk.co.wehavecookies56.kk.common.item.org.ItemOrgShield) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) ItemStack(net.minecraft.item.ItemStack)

Example 9 with ItemKeyblade

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

the class EntityEvents method onHurt.

/* @SubscribeEvent
    public void onLivingUpdate (LivingEvent.LivingUpdateEvent event) {
        if (event.getEntityLiving() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getEntityLiving();

            if(player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() == 0 && player.isAirBorne){
                player.motionX=0;
                player.motionY=0;
                player.motionZ=0;
            }
        }
    }*/
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        PlayerStatsCapability.IPlayerStats STATS = event.getEntity().getCapability(ModCapabilities.PLAYER_STATS, null);
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if (event.getAmount() - STATS.getDefense() <= 0)
            event.setAmount(1);
        else
            event.setAmount((float) (event.getAmount() - (STATS.getDefense() * 0.25)));
        if (event.getSource().getDamageType().equals("lightningBolt"))
            if (EntityThunder.summonLightning)
                event.setCanceled(true);
    }
    if (event.getSource().getTrueSource() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        player.getCapability(ModCapabilities.DRIVE_STATE, null).addDP(1);
        PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
    }
    if (event.getEntityLiving() instanceof IKHMob) {
        EntityPlayer player = null;
        IKHMob khMob = (IKHMob) event.getEntityLiving();
        if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
            player = (EntityPlayer) event.getSource().getImmediateSource();
        }
        if (player != null) {
            if (khMob.getType() == MobType.HEARTLESS_EMBLEM || khMob.getType() == MobType.HEARTLESS_PUREBLOOD || khMob.getType() == MobType.NOBODY) {
                // If the player has a real weapon in any slot
                if (!(player.getHeldItemMainhand().getItem() instanceof ItemKeyblade || player.getHeldItemMainhand().getItem() instanceof IOrgWeapon || player.getHeldItemOffhand().getItem() instanceof ItemKeyblade || player.getHeldItemOffhand().getItem() instanceof IOrgWeapon)) {
                    event.setCanceled(true);
                }
            // }
            }
        }
    }
    if (event.getSource().getImmediateSource() instanceof EntityPlayer && !event.getSource().damageType.equals(EnumHand.OFF_HAND.name())) {
        EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
        if (event.getSource().getDamageType().equals("thorns"))
            return;
        if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
            if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade || player.getHeldItem(player.getActiveHand()).getItem() instanceof IOrgWeapon) {
                event.setAmount(event.getAmount() - 4 + DamageCalculation.getStrengthDamage(player));
            }
        }
    }
}
Also used : IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) SyncDriveData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData) PlayerStatsCapability(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 10 with ItemKeyblade

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

the class ItemEvents method addTooltip.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addTooltip(ItemTooltipEvent event) {
    List<String> tooltip = event.getToolTip();
    for (ItemStack stack : MunnyRegistry.munnyValues.keySet()) {
        if (areItemStacksEqual(stack, event.getItemStack())) {
            event.getToolTip().add(TextFormatting.YELLOW + "Munny: " + MunnyRegistry.munnyValues.get(stack) * event.getItemStack().getCount());
        }
    }
    // TODO Localize all this
    if (event.getItemStack().getItem() instanceof ItemKeyblade && event.getEntityPlayer() != null) {
        // List<String> tooltip = event.getToolTip();
        ItemKeyblade keyblade = (ItemKeyblade) event.getItemStack().getItem();
        (tooltip.subList(1, tooltip.size())).clear();
        NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
        double sharpnessDamage = 0;
        for (int i = 0; i < nbttaglist.tagCount(); i++) {
            int id = nbttaglist.getCompoundTagAt(i).getShort("id");
            int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
            // System.out.println(Enchantment.getEnchantmentByID(id).getName());
            if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
                sharpnessDamage = getSharpnessDamage(lvl);
            }
        }
        double keyStrength = keyblade.getStrength() + sharpnessDamage;
        String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "-";
        tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
        tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
        if (keyblade.getDescription() != null) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
                tooltip.add(keyblade.description);
                tooltip.add("");
            } else {
                tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
            }
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
            if (event.getItemStack().hasTagCompound()) {
                tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
                for (int i = 0; i < nbttaglist.tagCount(); i++) {
                    int id = nbttaglist.getCompoundTagAt(i).getShort("id");
                    int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
                    if (Enchantment.getEnchantmentByID(id) != null) {
                        tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
                    }
                }
            }
            for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
                Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
                if (!multimap.isEmpty()) {
                    tooltip.add("");
                    for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
                        AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
                        double d0 = attributemodifier.getAmount();
                        boolean flag = false;
                        if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
                            d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
                            d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
                            flag = true;
                        }
                        double d1;
                        if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
                            d1 = d0;
                        } else {
                            d1 = d0 * 100.0D;
                        }
                        if (entry.getKey() == "generic.attackDamage") {
                            d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
                        }
                        if (flag) {
                            tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        } else if (d0 > 0.0D) {
                            tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        } else if (d0 < 0.0D) {
                            d1 = d1 * -1.0D;
                            tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        }
                    }
                }
            }
        } else {
            tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
        }
    }
    if (event.getItemStack().getItem() instanceof ItemKeychain && event.getEntityPlayer() != null) {
        // List<String> tooltip = event.getToolTip();
        ItemKeyblade keyblade = ((ItemKeychain) event.getItemStack().getItem()).getKeyblade();
        if (keyblade != null) {
            (tooltip.subList(1, tooltip.size())).clear();
            NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
            double sharpnessDamage = 0;
            for (int i = 0; i < nbttaglist.tagCount(); i++) {
                int id = nbttaglist.getCompoundTagAt(i).getShort("id");
                int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
                if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
                    sharpnessDamage = getSharpnessDamage(lvl);
                }
            }
            double keyStrength = keyblade.getStrength() + sharpnessDamage;
            String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "";
            tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
            tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
            if (keyblade.getDescription() != null) {
                if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                    tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
                    tooltip.add(keyblade.description);
                    tooltip.add("");
                } else {
                    tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
                }
            }
            if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
                if (event.getItemStack().hasTagCompound()) {
                    tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
                    for (int i = 0; i < nbttaglist.tagCount(); i++) {
                        int id = nbttaglist.getCompoundTagAt(i).getShort("id");
                        int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
                        if (Enchantment.getEnchantmentByID(id) != null) {
                            tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
                        }
                    }
                }
            } else {
                tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
            }
        }
    }
    if (event.getItemStack().getItem() instanceof IOrgWeapon) {
        IOrgWeapon weapon = (IOrgWeapon) event.getItemStack().getItem();
        (tooltip.subList(1, tooltip.size())).clear();
        NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
        double sharpnessDamage = 0;
        for (int i = 0; i < nbttaglist.tagCount(); i++) {
            int id = nbttaglist.getCompoundTagAt(i).getShort("id");
            int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
            // System.out.println(Enchantment.getEnchantmentByID(id).getName());
            if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
                sharpnessDamage = getSharpnessDamage(lvl);
            }
        }
        double keyStrength = weapon.getStrength() + sharpnessDamage;
        String magicSymbol = (weapon.getMagic() > 0) ? "+" : "";
        tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength + " (" + (DamageCalculation.getOrgStrengthDamage(event.getEntityPlayer(), event.getItemStack()) + sharpnessDamage) + ")");
        tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + weapon.getMagic() + " (" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, weapon) + ")");
        if (weapon.getDescription() != null) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
                tooltip.add(weapon.getDescription());
                tooltip.add("");
            } else {
                tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
            }
        }
        if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
            if (event.getItemStack().hasTagCompound()) {
                tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
                for (int i = 0; i < nbttaglist.tagCount(); i++) {
                    int id = nbttaglist.getCompoundTagAt(i).getShort("id");
                    int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
                    if (Enchantment.getEnchantmentByID(id) != null) {
                        tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
                    }
                }
            }
            for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
                Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
                if (!multimap.isEmpty()) {
                    tooltip.add("");
                    for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
                        AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
                        double d0 = attributemodifier.getAmount();
                        boolean flag = false;
                        if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
                            d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
                            d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
                            flag = true;
                        }
                        double d1;
                        if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
                            d1 = d0;
                        } else {
                            d1 = d0 * 100.0D;
                        }
                        if (entry.getKey() == "generic.attackDamage") {
                            d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
                        }
                        if (flag) {
                            tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        } else if (d0 > 0.0D) {
                            tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        } else if (d0 < 0.0D) {
                            d1 = d1 * -1.0D;
                            tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
                        }
                    }
                }
            }
        } else {
            tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
        }
    }
    if (event.getItemStack().getItem() instanceof IOrgWeapon && event.getItemStack().getItem() != ModItems.DreamShield) {
        String member = ((IOrgWeapon) event.getItemStack().getItem()).getMember().toString();
        tooltip.add(member.substring(0, 1) + member.substring(1, member.length()).toLowerCase());
    }
    Item ghostBlox = Item.getItemFromBlock(ModBlocks.GhostBlox);
    if (event.getItemStack().getItem() == ghostBlox) {
        if (!KeyboardHelper.isShiftDown()) {
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        } else {
            int x = 30;
            String s = Utils.translateToLocal(Strings.GhostBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.GhostBlox.getUnlocalizedName() + ".name"));
            s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
            String[] splitS = s.split("\n");
            for (String element : splitS) event.getToolTip().add(element);
        }
    }
    Item dangerBlox = Item.getItemFromBlock(ModBlocks.DangerBlox);
    if (event.getItemStack().getItem() == dangerBlox) {
        if (!KeyboardHelper.isShiftDown()) {
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        } else {
            int x = 30;
            String s = Utils.translateToLocal(Strings.DangerBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.DangerBlox.getUnlocalizedName() + ".name"));
            s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
            String[] splitS = s.split("\n");
            for (String element : splitS) event.getToolTip().add(element);
        }
    }
    Item bounceBlox = Item.getItemFromBlock(ModBlocks.BounceBlox);
    if (event.getItemStack().getItem() == bounceBlox) {
        if (!KeyboardHelper.isShiftDown()) {
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        } else {
            int x = 30;
            String s = Utils.translateToLocal(Strings.BounceBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.BounceBlox.getUnlocalizedName() + ".name"));
            s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
            String[] splitS = s.split("\n");
            for (String element : splitS) event.getToolTip().add(element);
        }
    }
    Item magnetBlox = Item.getItemFromBlock(ModBlocks.MagnetBlox);
    if (event.getItemStack().getItem() == magnetBlox) {
        if (!KeyboardHelper.isShiftDown()) {
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        } else {
            event.getToolTip().add("This Block is WIP and doesn't work at all.");
            event.getToolTip().add("It won't crash your game though.");
        }
    }
    Item kkchest = Item.getItemFromBlock(ModBlocks.KKChest);
    if (event.getItemStack().getItem() == kkchest) {
        // event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_1));
        if (!KeyboardHelper.isShiftDown())
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        else
            event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_2));
    }
    Item savepoint = Item.getItemFromBlock(ModBlocks.SavePoint);
    if (event.getItemStack().getItem() == savepoint)
        if (!KeyboardHelper.isShiftDown())
            event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
        else
            event.getToolTip().add(Utils.translateToLocal(Strings.SavePointDesc));
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) NBTTagList(net.minecraft.nbt.NBTTagList) Item(net.minecraft.item.Item) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) IOrgWeapon(uk.co.wehavecookies56.kk.common.item.org.IOrgWeapon) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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