Search in sources :

Example 1 with ConfigOptionToolClass

use of net.silentchaos512.gems.config.ConfigOptionToolClass 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)

Aggregations

ArrayList (java.util.ArrayList)1 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ITool (net.silentchaos512.gems.api.ITool)1 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)1 ArmorPartFrame (net.silentchaos512.gems.api.tool.part.ArmorPartFrame)1 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)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