Search in sources :

Example 1 with IGearIngredient

use of net.silentchaos512.gear.crafting.ingredient.IGearIngredient in project Silent-Gear by SilentChaos512.

the class GearHelper method getExamplePartsFromRecipe.

public static Collection<IPartData> getExamplePartsFromRecipe(GearType gearType, Iterable<Ingredient> ingredients) {
    Map<PartType, IPartData> map = new LinkedHashMap<>();
    PartType.MAIN.makeCompoundPart(gearType, Const.Materials.EXAMPLE).ifPresent(p -> map.put(PartType.MAIN, p));
    for (Ingredient ingredient : ingredients) {
        if (ingredient instanceof IGearIngredient) {
            PartType type = ((IGearIngredient) ingredient).getPartType();
            type.makeCompoundPart(gearType, Const.Materials.EXAMPLE).ifPresent(p -> map.put(type, p));
        }
    }
    return map.values();
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) IGearIngredient(net.silentchaos512.gear.crafting.ingredient.IGearIngredient) Ingredient(net.minecraft.world.item.crafting.Ingredient) IGearIngredient(net.silentchaos512.gear.crafting.ingredient.IGearIngredient) IPartData(net.silentchaos512.gear.api.part.IPartData)

Example 2 with IGearIngredient

use of net.silentchaos512.gear.crafting.ingredient.IGearIngredient in project Silent-Gear by SilentChaos512.

the class GearCraftingRecipeCategoryJei method draw.

@Override
public void draw(CraftingRecipe recipe, PoseStack matrixStack, double mouseX, double mouseY) {
    Collection<Component> lines = new ArrayList<>();
    NonNullList<Ingredient> ingredients = recipe.getIngredients();
    for (int i = 0; i < ingredients.size(); i++) {
        Ingredient ingredient = ingredients.get(i);
        if (ingredient instanceof IGearIngredient) {
            Component text = ((IGearIngredient) ingredient).getJeiHint().orElse(null);
            if (text != null) {
                String prefix = (i + 1) + ": ";
                lines.add(new TextComponent(prefix).append(text));
            }
        }
    }
    matrixStack.pushPose();
    float scale = lines.size() > 5 ? 0.75f : 1f;
    matrixStack.scale(scale, scale, 1f);
    Font font = Minecraft.getInstance().font;
    int y = (int) (56 / scale);
    for (Component line : lines) {
        font.drawShadow(matrixStack, line.getVisualOrderText(), 0, y, -1);
        y += 10;
    }
    matrixStack.popPose();
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) Ingredient(net.minecraft.world.item.crafting.Ingredient) IGearIngredient(net.silentchaos512.gear.crafting.ingredient.IGearIngredient) ArrayList(java.util.ArrayList) IGearIngredient(net.silentchaos512.gear.crafting.ingredient.IGearIngredient) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) Font(net.minecraft.client.gui.Font)

Aggregations

Ingredient (net.minecraft.world.item.crafting.Ingredient)2 IGearIngredient (net.silentchaos512.gear.crafting.ingredient.IGearIngredient)2 ArrayList (java.util.ArrayList)1 Font (net.minecraft.client.gui.Font)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 IPartData (net.silentchaos512.gear.api.part.IPartData)1 PartType (net.silentchaos512.gear.api.part.PartType)1