Search in sources :

Example 6 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class ArmorHelper method decorate.

private static ItemStack decorate(ItemStack armor, ItemStack material, ArmorPartPosition pos) {
    if (StackHelper.isEmpty(armor))
        return StackHelper.empty();
    if (StackHelper.isEmpty(material))
        return armor;
    ToolPart part = ToolPartRegistry.fromDecoStack(material);
    if (part == null)
        return null;
    // Only main parts (like gems) work
    if (!(part instanceof ToolPartMain))
        return armor;
    ItemStack result = StackHelper.safeCopy(armor);
    setTagPart(result, pos.getDecoKey(), part, EnumMaterialGrade.fromStack(material));
    return result;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStack(net.minecraft.item.ItemStack)

Example 7 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class ToolHelper method decorate.

private static ItemStack decorate(ItemStack tool, ItemStack material, EnumDecoPos pos) {
    if (// Something went wrong
    StackHelper.isEmpty(tool))
        return StackHelper.empty();
    if (// No material in the slot is OK.
    StackHelper.isEmpty(material))
        return tool;
    // South - 'Bottom' (head right or 2)
    if (tool.getItem() instanceof ItemGemShield) {
        // @formatter:off
        if (pos == EnumDecoPos.NORTH)
            pos = EnumDecoPos.SOUTH;
        else if (pos == EnumDecoPos.EAST)
            pos = EnumDecoPos.NORTH;
        else if (pos == EnumDecoPos.SOUTH)
            pos = EnumDecoPos.EAST;
    }
    // No deco bit on certain (mostly non-super) rods.
    if (pos == EnumDecoPos.SOUTH && !(tool.getItem() instanceof ItemGemShield)) {
        ToolPartRod partRod = (ToolPartRod) getConstructionRod(tool);
        if (partRod == null || !partRod.supportsDecoration())
            return tool;
    }
    // Get the tool part, making sure it exists.
    ToolPart part = ToolPartRegistry.fromDecoStack(material);
    if (part == null)
        return null;
    // Only main parts (like gems) work
    if (!(part instanceof ToolPartMain))
        return tool;
    ItemStack result = StackHelper.safeCopy(tool);
    setTagPart(result, pos.nbtKey, part, EnumMaterialGrade.fromStack(material));
    return result;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) ItemStack(net.minecraft.item.ItemStack) ToolPartRod(net.silentchaos512.gems.api.tool.part.ToolPartRod)

Example 8 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class ToolHelper method getSubItems.

public static List<ItemStack> getSubItems(Item item, int materialLength) {
    if (toolSubItems.containsKey(item)) {
        // Return cached list.
        return toolSubItems.get(item);
    }
    List<ItemStack> list = Lists.newArrayList();
    // final boolean isSuperTool = item instanceof ITool && ((ITool) item).isSuperTool();
    final ItemStack rodWood = new ItemStack(Items.STICK);
    final ItemStack rodIron = ModItems.craftingMaterial.toolRodIron;
    final ItemStack rodGold = ModItems.craftingMaterial.toolRodGold;
    for (ToolPartMain part : ToolPartRegistry.getMains()) {
        // Check for parts with empty crafting stacks and scream at the user if any are found.
        if (StackHelper.isEmpty(part.getCraftingStack())) {
            if (!emptyPartSet.contains(part)) {
                emptyPartSet.add(part);
                SilentGems.logHelper.severe("Part with empty crafting stack: " + part);
                if (!foundEmptyPart) {
                    Greetings.addExtraMessage(TextFormatting.RED + "Errored tool part found! Please report this issue on the GitHub issue tracker.");
                    foundEmptyPart = true;
                }
                Greetings.addExtraMessage(TextFormatting.ITALIC + part.toString());
            }
        } else {
            if (!part.isBlacklisted(part.getCraftingStack())) {
                if (item instanceof ITool && !((ITool) item).getValidTiers().contains(part.getTier())) {
                    continue;
                }
                ItemStack rod = part.getTier() == EnumMaterialTier.SUPER ? rodGold : item instanceof ItemGemShield && part.getTier() == EnumMaterialTier.REGULAR ? rodIron : rodWood;
                ItemStack tool = constructTool(item, rod, part.getCraftingStack());
                tool.getTagCompound().setBoolean(NBT_EXAMPLE_TOOL, true);
                list.add(tool);
            }
        }
    }
    // Set maker name.
    String makerName = SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative");
    for (ItemStack stack : list) ToolHelper.setOriginalOwner(stack, makerName);
    // Save for later to prevent duplicates with different UUIDs.
    toolSubItems.put(item, list);
    return list;
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) ItemStack(net.minecraft.item.ItemStack) ITool(net.silentchaos512.gems.api.ITool)

Example 9 with ToolPartMain

use of net.silentchaos512.gems.api.tool.part.ToolPartMain in project SilentGems by SilentChaos512.

the class GemsClientEvents method onTooltip.

@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
    boolean ctrlDown = KeyTracker.isControlDown();
    boolean shiftDown = KeyTracker.isShiftDown();
    ItemStack stack = event.getItemStack();
    ToolPart part = StackHelper.isValid(stack) ? ToolPartRegistry.fromStack(stack) : null;
    if (part != null && !part.isBlacklisted(stack)) {
        if (part instanceof ToolPartRod) {
            onTooltipForToolRod(event, stack, part, ctrlDown, shiftDown);
        } else if (part instanceof ToolPartMain) {
            onTooltipForToolMaterial(event, stack, part, ctrlDown, shiftDown);
        } else if (part instanceof ArmorPartFrame) {
            // TODO: Localization
            event.getToolTip().add(TextFormatting.GOLD + "Armor Frame");
        }
    }
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStack(net.minecraft.item.ItemStack) ArmorPartFrame(net.silentchaos512.gems.api.tool.part.ArmorPartFrame) ToolPartRod(net.silentchaos512.gems.api.tool.part.ToolPartRod) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ToolPartMain (net.silentchaos512.gems.api.tool.part.ToolPartMain)9 ItemStack (net.minecraft.item.ItemStack)8 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)8 ToolPartRod (net.silentchaos512.gems.api.tool.part.ToolPartRod)3 ITool (net.silentchaos512.gems.api.ITool)2 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)2 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)2 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)2 IBlockState (net.minecraft.block.state.IBlockState)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IAmmoTool (net.silentchaos512.gems.api.IAmmoTool)1 IArmor (net.silentchaos512.gems.api.IArmor)1 ArmorPartFrame (net.silentchaos512.gems.api.tool.part.ArmorPartFrame)1 ToolPartTip (net.silentchaos512.gems.api.tool.part.ToolPartTip)1 ItemStackList (net.silentchaos512.lib.collection.ItemStackList)1