Search in sources :

Example 1 with ItemToolSoul

use of net.silentchaos512.gems.item.ItemToolSoul in project SilentGems by SilentChaos512.

the class RecipeApplyToolSoul method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack tool = StackHelper.empty();
    ItemStack soul = StackHelper.empty();
    for (int i = 0; i < inv.getSizeInventory(); ++i) {
        ItemStack stack = inv.getStackInSlot(i);
        // Found a tool or armor piece?
        if (stack.getItem() instanceof ITool || stack.getItem() instanceof IArmor) {
            if (StackHelper.isValid(tool)) {
                return StackHelper.empty();
            }
            tool = stack;
        } else // Found a soul?
        if (stack.getItem() instanceof ItemToolSoul) {
            if (StackHelper.isValid(soul)) {
                return StackHelper.empty();
            }
            soul = stack;
        }
    }
    if (StackHelper.isEmpty(tool) || StackHelper.isEmpty(soul)) {
        return StackHelper.empty();
    }
    // Does tool already have a soul?
    if (SoulManager.getSoul(tool) != null) {
        return StackHelper.empty();
    }
    // Is the soul valid?
    ToolSoul toolSoul = ModItems.toolSoul.getSoul(soul);
    if (toolSoul == null) {
        return StackHelper.empty();
    }
    ItemStack result = StackHelper.safeCopy(tool);
    // Have to change UUID to prevent soul duping.
    // result.getTagCompound().removeTag(ToolHelper.NBT_UUID);
    SoulManager.setSoul(result, toolSoul, true);
    // Apply name, if applicable.
    if (soul.hasDisplayName()) {
        String name = soul.getDisplayName();
        toolSoul.setName(name);
        result.setStackDisplayName(name);
    }
    // Recalculate stats and return.
    ToolHelper.recalculateStats(result);
    return result;
}
Also used : ItemToolSoul(net.silentchaos512.gems.item.ItemToolSoul) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) ItemToolSoul(net.silentchaos512.gems.item.ItemToolSoul) ItemStack(net.minecraft.item.ItemStack) ITool(net.silentchaos512.gems.api.ITool) IArmor(net.silentchaos512.gems.api.IArmor)

Example 2 with ItemToolSoul

use of net.silentchaos512.gems.item.ItemToolSoul in project SilentGems by SilentChaos512.

the class ToolSoul method addInformation.

public void addInformation(ItemStack stack, World world, List<String> list, boolean advanced) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    String color;
    // Level, XP, AP
    color = "" + TextFormatting.GREEN;
    list.add(color + loc.getMiscText("ToolSoul.level", level, xp, getXpToNextLevel()));
    list.add(color + loc.getMiscText("ToolSoul.actionPoints", actionPoints, getMaxActionPoints()));
    boolean skillsKeyDown = Keyboard.isKeyDown(Keyboard.KEY_S);
    if (skillsKeyDown || stack.getItem() instanceof ItemToolSoul) {
        // Display elements.
        String e1 = element1 == null ? "None" : element1.getDisplayName();
        String e2 = element2 == null ? "None" : element2.getDisplayName();
        String elements = e1 + (e2.equalsIgnoreCase("none") ? "" : ", " + e2);
        list.add(loc.getMiscText("ToolSoul.elements", elements));
    }
    if (skillsKeyDown) {
        // Display stat modifiers.
        color = "  " + TextFormatting.YELLOW;
        float durability = getDurabilityModifierForDisplay(this);
        float harvestSpeed = getHarvestSpeedModifierForDisplay(this);
        float meleeDamage = getMeleeDamageModifierForDisplay(this);
        float magicDamage = getMagicDamageModifierForDisplay(this);
        float protection = getProtectionModifierForDisplay(this);
        if (durability != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("Durability", durability, 0, true));
        if (harvestSpeed != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("HarvestSpeed", harvestSpeed, 0, true));
        if (meleeDamage != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("MeleeDamage", meleeDamage, 0, true));
        if (magicDamage != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("MagicDamage", magicDamage, 0, true));
        if (protection != 0f)
            list.add(color + TooltipHelper.getAsColoredPercentage("Protection", protection, 0, true));
        // Display skills.
        for (Entry<SoulSkill, Integer> entry : skills.entrySet()) {
            SoulSkill skill = entry.getKey();
            int level = entry.getValue();
            list.add("  " + skill.getLocalizedName(stack, level));
        }
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.keyForSkills"));
    }
}
Also used : ItemToolSoul(net.silentchaos512.gems.item.ItemToolSoul) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Aggregations

ItemToolSoul (net.silentchaos512.gems.item.ItemToolSoul)2 ItemStack (net.minecraft.item.ItemStack)1 IArmor (net.silentchaos512.gems.api.IArmor)1 ITool (net.silentchaos512.gems.api.ITool)1 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)1 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)1