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

CyclopsMC / IntegratedDynamics / 20456074232

23 Dec 2025 08:51AM UTC coverage: 53.11% (+0.03%) from 53.083%
20456074232

push

github

rubensworks
Merge remote-tracking branch 'origin/master-1.21-lts' into master-1.21

2858 of 8742 branches covered (32.69%)

Branch coverage included in aggregate %.

17431 of 29460 relevant lines covered (59.17%)

3.07 hits per line

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

82.05
/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.*;
8
import net.minecraft.world.item.crafting.display.RecipeDisplay;
9
import net.minecraft.world.item.crafting.display.SlotDisplay;
10
import net.minecraft.world.level.Level;
11
import net.neoforged.neoforge.fluids.FluidStack;
12
import org.apache.commons.lang3.tuple.Pair;
13
import org.cyclops.cyclopscore.recipe.ItemStackFromIngredient;
14
import org.cyclops.integrateddynamics.RegistryEntries;
15
import org.cyclops.integrateddynamics.core.recipe.display.RecipeDisplaySqueezer;
16

17
import java.util.List;
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
    private PlacementInfo placementInfo;
32

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

41
    public Ingredient getInputIngredient() {
42
        return inputIngredient;
3✔
43
    }
44

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

49
    public List<Pair<? extends SlotDisplay, Float>> getOutputItemsAsSlots() {
50
        return this.getOutputItems().stream().map(i -> i.ingredient.map(
13✔
51
                left -> Pair.of(new SlotDisplay.ItemSlotDisplay(left.getLeft().getItem()), left.getRight()),
12✔
52
                right -> Pair.of(right.getLeft().getIngredient().display(), right.getRight())
10✔
53
        )).toList();
1✔
54
    }
55

56
    public Optional<FluidStack> getOutputFluid() {
57
        return outputFluid;
3✔
58
    }
59

60
    @Override
61
    public boolean matches(CraftingInput inv, Level worldIn) {
62
        return inputIngredient.test(inv.getItem(0));
7✔
63
    }
64

65
    @Override
66
    public ItemStack assemble(CraftingInput inv, HolderLookup.Provider registryAccess) {
67
        // Should not be called, but let's provide a good fallback
68
        if (this.outputItems.isEmpty()) {
×
69
            return ItemStack.EMPTY;
×
70
        }
71
        return this.outputItems.get(0).getIngredientFirst().copy();
×
72
    }
73

74
    public NonNullList<IngredientChance> assemble(ItemStack inputItem) {
75
        return getOutputItems();
3✔
76
    }
77

78
    @Override
79
    public RecipeSerializer<? extends Recipe<CraftingInput>> getSerializer() {
80
        return RegistryEntries.RECIPESERIALIZER_SQUEEZER.get();
×
81
    }
82

83
    @Override
84
    public RecipeType<? extends Recipe<CraftingInput>> getType() {
85
        return RegistryEntries.RECIPETYPE_SQUEEZER.get();
4✔
86
    }
87

88
    @Override
89
    public PlacementInfo placementInfo() {
90
        if (this.placementInfo == null) {
3✔
91
            this.placementInfo = PlacementInfo.create(this.inputIngredient);
5✔
92
        }
93
        return this.placementInfo;
3✔
94
    }
95

96
    @Override
97
    public RecipeBookCategory recipeBookCategory() {
98
        return RegistryEntries.RECIPEBOOKCATEGORY_SQUEEZER.get();
4✔
99
    }
100

101
    @Override
102
    public List<RecipeDisplay> display() {
103
        return List.of(new RecipeDisplaySqueezer(
5✔
104
                this.getInputIngredient().display(),
3✔
105
                this.getOutputItemsAsSlots(),
2✔
106
                this.getOutputFluid().orElse(FluidStack.EMPTY),
7✔
107
                new SlotDisplay.ItemSlotDisplay(RegistryEntries.BLOCK_SQUEEZER.get().asItem()),
6✔
108
                0
109
        ));
110
    }
111

112
    public static class IngredientChance {
113
        private final Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> ingredient;
114

115
        public IngredientChance(Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> ingredient) {
2✔
116
            this.ingredient = Objects.requireNonNull(ingredient);
5✔
117
        }
1✔
118

119
        public Either<ItemStack, ItemStackFromIngredient> getIngredient() {
120
            return ingredient.mapBoth(Pair::getLeft, Pair::getLeft);
6✔
121
        }
122

123
        public Either<Pair<ItemStack, Float>, Pair<ItemStackFromIngredient, Float>> getIngredientChance() {
124
            return ingredient;
×
125
        }
126

127
        public ItemStack getIngredientFirst() {
128
            return getIngredient().map(l -> l, ItemStackFromIngredient::getFirstItemStack);
9✔
129
        }
130

131
        public float getChance() {
132
            return ingredient.map(Pair::getRight, Pair::getRight);
8✔
133
        }
134

135
    }
136

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