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

CyclopsMC / IntegratedDynamics / 20455923509

23 Dec 2025 08:44AM UTC coverage: 45.076% (-0.03%) from 45.108%
20455923509

push

github

rubensworks
Bump mod version

2607 of 8568 branches covered (30.43%)

Branch coverage included in aggregate %.

11872 of 23553 relevant lines covered (50.41%)

2.39 hits per line

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

50.0
/src/main/java/org/cyclops/integrateddynamics/core/recipe/type/RecipeSqueezer.java
1
package org.cyclops.integrateddynamics.core.recipe.type;
2

3
import com.mojang.datafixers.util.Either;
4
import net.minecraft.core.HolderLookup;
5
import net.minecraft.core.NonNullList;
6
import net.minecraft.world.item.ItemStack;
7
import net.minecraft.world.item.crafting.CraftingInput;
8
import net.minecraft.world.item.crafting.Ingredient;
9
import net.minecraft.world.item.crafting.Recipe;
10
import net.minecraft.world.item.crafting.RecipeSerializer;
11
import net.minecraft.world.item.crafting.RecipeType;
12
import net.minecraft.world.level.Level;
13
import net.neoforged.neoforge.fluids.FluidStack;
14
import org.apache.commons.lang3.tuple.Pair;
15
import org.cyclops.cyclopscore.recipe.ItemStackFromIngredient;
16
import org.cyclops.integrateddynamics.RegistryEntries;
17

18
import java.util.Objects;
19
import java.util.Optional;
20

21
/**
22
 * Squeezer recipe
23
 * @author rubensworks
24
 */
25
public class RecipeSqueezer implements Recipe<CraftingInput> {
26

27
    private final Ingredient inputIngredient;
28
    private final NonNullList<IngredientChance> outputItems;
29
    private final Optional<FluidStack> outputFluid;
30

31
    public RecipeSqueezer(Ingredient inputIngredient,
32
                          NonNullList<IngredientChance> outputItems,
33
                          Optional<FluidStack> outputFluid) {
2✔
34
        this.inputIngredient = inputIngredient;
3✔
35
        this.outputItems = outputItems;
3✔
36
        this.outputFluid = outputFluid;
3✔
37
    }
1✔
38

39
    public Ingredient getInputIngredient() {
40
        return inputIngredient;
×
41
    }
42

43
    public NonNullList<IngredientChance> getOutputItems() {
44
        return outputItems;
3✔
45
    }
46

47
    public Optional<FluidStack> getOutputFluid() {
48
        return outputFluid;
3✔
49
    }
50

51
    @Override
52
    public boolean matches(CraftingInput inv, Level worldIn) {
53
        return inputIngredient.test(inv.getItem(0));
7✔
54
    }
55

56
    @Override
57
    public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registryAccess) {
58
        // Should not be called, but let's provide a good fallback
59
        if (this.outputItems.isEmpty()) {
×
60
            return ItemStack.EMPTY;
×
61
        }
62
        return this.outputItems.get(0).getIngredientFirst().copy();
×
63
    }
64

65
    public NonNullList<IngredientChance> assemble(ItemStack inputItem) {
66
        return getOutputItems();
3✔
67
    }
68

69
    @Override
70
    public boolean canCraftInDimensions(int width, int height) {
71
        return width * height <= 1;
×
72
    }
73

74
    @Override
75
    public ItemStack getResultItem(HolderLookup.Provider registryAccess) {
76
        // Should not be called, but lets provide a good fallback
77
        if (this.outputItems.isEmpty()) {
×
78
            return ItemStack.EMPTY;
×
79
        }
80
        return this.outputItems.get(0).getIngredientFirst().copy();
×
81
    }
82

83
    @Override
84
    public RecipeSerializer<?> getSerializer() {
85
        return RegistryEntries.RECIPESERIALIZER_SQUEEZER.get();
×
86
    }
87

88
    @Override
89
    public RecipeType<?> getType() {
90
        return RegistryEntries.RECIPETYPE_SQUEEZER.get();
4✔
91
    }
92

93
    public static class IngredientChance {
94
        private final Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> ingredient;
95

96
        public IngredientChance(Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> ingredient) {
2✔
97
            this.ingredient = Objects.requireNonNull(ingredient);
5✔
98
        }
1✔
99

100
        public Either<ItemStack, ItemStackFromIngredient> getIngredient() {
101
            return ingredient.mapBoth(Pair::getLeft, Pair::getLeft);
6✔
102
        }
103

104
        public Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> getIngredientChance() {
105
            return ingredient;
×
106
        }
107

108
        public ItemStack getIngredientFirst() {
109
            return getIngredient().map(l -> l, ItemStackFromIngredient::getFirstItemStack);
9✔
110
        }
111

112
        public float getChance() {
113
            return ingredient.map(Pair::getRight, Pair::getRight);
8✔
114
        }
115

116
    }
117

118
}
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