Search in sources :

Example 1 with ArmorPartFrame

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

the class RecipeMixedMaterialItem method partTiersMatch.

protected boolean partTiersMatch(InventoryCrafting inv) {
    EnumMaterialTier tier = null;
    // Check mains
    for (ItemStack stack : getMaterials(inv)) {
        ToolPart part = ToolPartRegistry.fromStack(stack);
        if (tier == null) {
            tier = part.getTier();
        } else if (tier != part.getTier()) {
            return false;
        }
    }
    // No mains found?
    if (tier == null) {
        return false;
    }
    // Tier restrictions?
    if (tierRestriction != null && tier != tierRestriction) {
        return false;
    }
    // Check rod
    ItemStack rod = getRod(inv);
    if (StackHelper.isValid(rod))
        return ToolPartRegistry.fromStack(rod).validForToolOfTier(tier);
    // Check frame
    ItemStack frame = getFrame(inv);
    if (StackHelper.isValid(frame)) {
        ToolPart partFrame = ToolPartRegistry.fromStack(frame);
        if (partFrame instanceof ArmorPartFrame) {
            return partFrame.validForToolOfTier(tier) && doesFrameMatchItem((ArmorPartFrame) partFrame);
        }
    }
    return true;
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemStack(net.minecraft.item.ItemStack) ArmorPartFrame(net.silentchaos512.gems.api.tool.part.ArmorPartFrame)

Example 2 with ArmorPartFrame

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

the class ToolHelper method addExampleRecipe.

public static void addExampleRecipe(Item item, EnumMaterialTier[] tiers, String[] lines, Object... extraParams) {
    // New ingredient-based recipes
    ConfigOptionToolClass config = item instanceof ITool ? ((ITool) item).getConfig() : null;
    for (EnumMaterialTier tier : tiers) {
        // Only add recipes for valid tiers
        if (config != null && !config.validTiers.contains(tier))
            continue;
        // Head parts for tier
        List<ItemStack> heads = new ArrayList<>();
        for (ToolPart part : ToolPartRegistry.getMains()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getTier() == tier && StackHelper.isValid(part.getCraftingStack()))
            heads.add(part.getCraftingStack());
        IngredientSL headIngredient = IngredientSL.from(heads.toArray(new ItemStack[0]));
        // Rods for tier
        List<ItemStack> rods = new ArrayList<>();
        for (ToolPart part : ToolPartRegistry.getRods()) if (!part.isBlacklisted(part.getCraftingStack()) && part.getCompatibleTiers().contains(tier))
            rods.add(part.getCraftingStack());
        IngredientSL rodIngredient = IngredientSL.from(rods.toArray(new ItemStack[0]));
        // Armor frames
        List<ItemStack> frames = new ArrayList<>();
        if (item instanceof ItemGemArmor) {
            EntityEquipmentSlot slot = ((ItemGemArmor) item).armorType;
            for (ToolPart part : ToolPartRegistry.getValues()) if (part instanceof ArmorPartFrame && ((ArmorPartFrame) part).getSlot() == slot && part.getTier() == tier && !part.isBlacklisted(part.getCraftingStack()))
                frames.add(part.getCraftingStack());
        }
        IngredientSL frameIngredient = IngredientSL.from(frames.toArray(new ItemStack[0]));
        ResourceLocation recipeName = new ResourceLocation(item.getRegistryName().toString() + "_" + tier.name().toLowerCase() + "_example");
        ItemStack result = new ItemStack(item);
        NBTTagCompound tags = new NBTTagCompound();
        tags.setInteger(NBT_EXAMPLE_TOOL_TIER, tier.ordinal());
        result.setTagCompound(tags);
        // Super ugly, but I've got never better at the moment.
        List<Object> params = new ArrayList<>();
        for (String line : lines) params.add(line);
        if (recipeContainsKey(lines, "h")) {
            params.add('h');
            params.add(headIngredient);
        }
        if (recipeContainsKey(lines, "r")) {
            params.add('r');
            params.add(rodIngredient);
        }
        if (recipeContainsKey(lines, "a")) {
            params.add('a');
            params.add(frameIngredient);
        }
        for (Object obj : extraParams) params.add(obj);
        EXAMPLE_RECIPES.add(SilentGems.registry.recipes.makeShaped(recipeName.getResourcePath(), result, params.toArray()));
    }
}
Also used : IngredientSL(net.silentchaos512.lib.recipe.IngredientSL) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ITool(net.silentchaos512.gems.api.ITool) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ResourceLocation(net.minecraft.util.ResourceLocation) ConfigOptionToolClass(net.silentchaos512.gems.config.ConfigOptionToolClass) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) IRegistryObject(net.silentchaos512.lib.registry.IRegistryObject) ItemGemArmor(net.silentchaos512.gems.item.armor.ItemGemArmor) ItemStack(net.minecraft.item.ItemStack) ArmorPartFrame(net.silentchaos512.gems.api.tool.part.ArmorPartFrame)

Example 3 with ArmorPartFrame

use of net.silentchaos512.gems.api.tool.part.ArmorPartFrame 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

ItemStack (net.minecraft.item.ItemStack)3 ArmorPartFrame (net.silentchaos512.gems.api.tool.part.ArmorPartFrame)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)2 ArrayList (java.util.ArrayList)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 ITool (net.silentchaos512.gems.api.ITool)1 ToolPartMain (net.silentchaos512.gems.api.tool.part.ToolPartMain)1 ToolPartRod (net.silentchaos512.gems.api.tool.part.ToolPartRod)1 ConfigOptionToolClass (net.silentchaos512.gems.config.ConfigOptionToolClass)1 ItemGemArmor (net.silentchaos512.gems.item.armor.ItemGemArmor)1 IngredientSL (net.silentchaos512.lib.recipe.IngredientSL)1 IRegistryObject (net.silentchaos512.lib.registry.IRegistryObject)1