Search in sources :

Example 1 with ItemKeychain

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

the class CreateFromSynthesisRecipe method process.

@Override
public void process(EntityPlayer player, Side side) {
    boolean freeDev = false;
    if (FreeDevRecipeRegistry.isFreeDevRecipeRegistered(name)) {
        freeDev = true;
    }
    if (!freeDev) {
        if (RecipeRegistry.get(name).getResult().getItem() instanceof ItemKeychain)
            player.inventory.addItemStackToInventory(RecipeRegistry.get(name).getResult());
        Recipe r = RecipeRegistry.get(name);
        SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
        Iterator it = r.getRequirements().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
            MATS.removeMaterial(pair.getKey(), pair.getValue());
        }
    } else {
        player.inventory.addItemStackToInventory(FreeDevRecipeRegistry.get(name).getResult());
        Recipe r = FreeDevRecipeRegistry.get(name);
        SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
        Iterator it = r.getRequirements().entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
            MATS.removeMaterial(pair.getKey(), pair.getValue());
        }
    }
    PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
Also used : SynthesisMaterialCapability(uk.co.wehavecookies56.kk.common.capability.SynthesisMaterialCapability) ItemKeychain(uk.co.wehavecookies56.kk.common.item.base.ItemKeychain) Recipe(uk.co.wehavecookies56.kk.api.recipes.Recipe) Iterator(java.util.Iterator) Material(uk.co.wehavecookies56.kk.api.materials.Material) Map(java.util.Map) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 2 with ItemKeychain

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeychain 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 3 with ItemKeychain

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

the class SummonKeyblade method process.

@Override
public void process(EntityPlayer player, Side side) {
    ItemStack keychain = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(offHandSlot);
    ItemStack keyblade = new ItemStack(((ItemKeychain) (keychain.getItem())).getKeyblade());
    if (keychain.hasTagCompound()) {
        keyblade.setTagCompound(keychain.getTagCompound());
    }
    if (hand == EnumHand.MAIN_HAND) {
        player.inventory.setInventorySlotContents(player.inventory.currentItem, keyblade);
    } else {
        player.inventory.offHandInventory.set(0, keyblade);
    }
    player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.summon, SoundCategory.MASTER, 1.0f, 1.0f);
    player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(hand, true);
    player.sendMessage(new TextComponentTranslation(TextFormatting.DARK_GREEN + "Summoned " + player.getHeldItem(hand).getDisplayName()));
    PacketDispatcher.sendToAllAround(new SpawnKeybladeParticles(player), player, 64.0D);
    PacketDispatcher.sendTo(new SyncKeybladeData(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) player);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) SyncKeybladeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData) SpawnKeybladeParticles(uk.co.wehavecookies56.kk.common.network.packet.client.SpawnKeybladeParticles) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemKeychain

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeychain 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)

Example 5 with ItemKeychain

use of uk.co.wehavecookies56.kk.common.item.base.ItemKeychain 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)

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