• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/cyclops/integrateddynamics/client/render/valuetype/RecipeValueTypeWorldRenderer.java
1
package org.cyclops.integrateddynamics.client.render.valuetype;
2

3
import com.google.common.collect.Lists;
4
import com.mojang.blaze3d.vertex.PoseStack;
5
import net.minecraft.client.Minecraft;
6
import net.minecraft.client.gui.Font;
7
import net.minecraft.client.renderer.SubmitNodeCollector;
8
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
9
import net.minecraft.core.Direction;
10
import net.minecraft.network.chat.Component;
11
import net.minecraft.world.item.ItemStack;
12
import org.cyclops.commoncapabilities.api.capability.recipehandler.IPrototypedIngredientAlternatives;
13
import org.cyclops.commoncapabilities.api.capability.recipehandler.IRecipeDefinition;
14
import org.cyclops.commoncapabilities.api.ingredient.IIngredientMatcher;
15
import org.cyclops.commoncapabilities.api.ingredient.IPrototypedIngredient;
16
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
17
import org.cyclops.commoncapabilities.api.ingredient.PrototypedIngredient;
18
import org.cyclops.cyclopscore.helper.IModHelpers;
19
import org.cyclops.integrateddynamics.api.client.render.valuetype.IValueTypeWorldRenderer;
20
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
21
import org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentHandler;
22
import org.cyclops.integrateddynamics.api.part.IPartContainer;
23
import org.cyclops.integrateddynamics.api.part.IPartType;
24
import org.cyclops.integrateddynamics.client.render.part.DisplayPartOverlayRenderer;
25
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueObjectTypeIngredients;
26
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueObjectTypeRecipe;
27
import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes;
28
import org.cyclops.integrateddynamics.core.ingredient.IngredientComponentHandlers;
29

30
import java.util.Collections;
31
import java.util.List;
32
import java.util.Optional;
33
import java.util.stream.Collectors;
34
import java.util.stream.Stream;
35

36
/**
37
 * A value type world renderer for blocks.
38
 * @author rubensworks
39
 */
40
public class RecipeValueTypeWorldRenderer implements IValueTypeWorldRenderer {
×
41

42
    private static final IValueTypeWorldRenderer INGREDIENTS_RENDERER = ValueTypeWorldRenderers.REGISTRY
×
43
            .getRenderer(ValueTypes.OBJECT_INGREDIENTS);
×
44

45
    @Override
46
    public void submitValue(BlockEntityRendererProvider.Context context, IPartContainer partContainer,
47
                            Direction direction, IPartType partType, IValue value, float partialTicks,
48
                            PoseStack matrixStack, SubmitNodeCollector nodeCollector,
49
                            int combinedLight, int combinedOverlay, float alpha) {
50
        Optional<IRecipeDefinition> recipeOptional = ((ValueObjectTypeRecipe.ValueRecipe) value).getRawValue();
×
51
        if(recipeOptional.isPresent()) {
×
52
            IRecipeDefinition recipe = recipeOptional.get();
×
53

54
            matrixStack.pushPose();
×
55
            matrixStack.scale(0.5F, 0.5F, 1F);
×
56

57
            matrixStack.pushPose();
×
58
            matrixStack.scale(0.3F, 0.3F, 1F);
×
59
            nodeCollector.submitText(matrixStack, 8, 15, Component.translatable("gui.integrateddynamics.input_short").getVisualOrderText(), false, Font.DisplayMode.NORMAL, combinedLight, IModHelpers.get().getBaseHelpers().RGBToInt(255, 255, 255), 0, 0);
×
60
            nodeCollector.submitText(matrixStack, 8, 15, Component.translatable("gui.integrateddynamics.input_short").getVisualOrderText(), false, Font.DisplayMode.NORMAL, combinedLight, IModHelpers.get().getBaseHelpers().RGBToInt(255, 255, 255), 0, 0);
×
61
            nodeCollector.submitText(matrixStack, 46, 15, Component.translatable("gui.integrateddynamics.output_short").getVisualOrderText(), false, Font.DisplayMode.NORMAL, combinedLight, IModHelpers.get().getBaseHelpers().RGBToInt(255, 255, 255), 0, 0);
×
62
            matrixStack.popPose();
×
63

64
            matrixStack.translate(0, 2 * DisplayPartOverlayRenderer.MAX / 3, 0);
×
65
            renderInput(context, partContainer, direction, partType, recipe, partialTicks,
×
66
                    matrixStack, nodeCollector, combinedLight, combinedOverlay, alpha);
67
            matrixStack.translate(DisplayPartOverlayRenderer.MAX, 0, 0);
×
68
            INGREDIENTS_RENDERER.submitValue(context, partContainer, direction, partType,
×
69
                    ValueObjectTypeIngredients.ValueIngredients.of(recipe.getOutput()), partialTicks,
×
70
                    matrixStack, nodeCollector, combinedLight, combinedOverlay, alpha);
71

72
            matrixStack.popPose();
×
73
        }
74
    }
×
75

76
    protected void renderInput(BlockEntityRendererProvider.Context context, IPartContainer partContainer,
77
                               Direction direction, IPartType partType, IRecipeDefinition recipe, float partialTicks,
78
                               PoseStack matrixStack, SubmitNodeCollector nodeCollector,
79
                               int combinedLight, int combinedOverlay, float alpha) {
80
        // Get a list of all values
81
        int ingredientCount = recipe.getInputComponents().stream().mapToInt((c) -> recipe.getInputs(c).size()).sum();
×
82
        List<IValue> values = Lists.newArrayListWithExpectedSize(ingredientCount);
×
83

84
        // For ingredients with multiple possibilities, vary them based on the current tick
85
        int tick = ((int) Minecraft.getInstance().level.getGameTime()) / 30;
×
86
        for (IngredientComponent<?, ?> component : recipe.getInputComponents()) {
×
87
            IIngredientMatcher<?, ?> matcher = component.getMatcher();
×
88
            IIngredientComponentHandler componentHandler = IngredientComponentHandlers.REGISTRY.getComponentHandler(component);
×
89
            Stream<List<IPrototypedIngredient>> inputs = enhanceRecipeInputs(component, recipe);
×
90
            inputs.forEach(element ->
×
91
                    values.add(componentHandler.toValue(IngredientsValueTypeWorldRenderer.prepareElementForTick(
×
92
                            element, tick, () -> new PrototypedIngredient(component, matcher.getEmptyInstance(), matcher.getAnyMatchCondition())).getPrototype())));
×
93
        }
×
94

95
        // Render ingredients in a square matrix
96
        IngredientsValueTypeWorldRenderer.renderGrid(context, partContainer, direction, partType, values,
×
97
                partialTicks, matrixStack, nodeCollector, combinedLight, combinedOverlay, alpha);
98
    }
×
99

100
    protected <T, M> Stream<List<IPrototypedIngredient>> enhanceRecipeInputs(IngredientComponent<T, M> ingredientComponent,
101
                                                                             IRecipeDefinition recipe) {
102
        Stream<IPrototypedIngredientAlternatives<T, M>> inputs = recipe.getInputs(ingredientComponent).stream();
×
103
        if (ingredientComponent == IngredientComponent.ITEMSTACK) {
×
104
            IIngredientMatcher<ItemStack, Integer> matcher = (IIngredientMatcher<ItemStack, Integer>) ingredientComponent.getMatcher();
×
105
            return ((Stream<IPrototypedIngredientAlternatives<ItemStack, Integer>>) (Stream) inputs).map(input -> input
×
106
                    .getAlternatives().stream()
×
107
                    .map(prototypedIngredient -> Collections.singletonList(prototypedIngredient))
×
108
                    .flatMap(List::stream)
×
109
                    .collect(Collectors.toList())
×
110
            );
111
        } else {
112
            return ((Stream<IPrototypedIngredientAlternatives<?, ?>>) (Stream) inputs)
×
113
                    .map(p -> Lists.newArrayList(p.getAlternatives()));
×
114
        }
115
    }
116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc