Skip to content

Commit

Permalink
Merge branch 'mc1.19/fabric/dev' into mc1.20.1/fabric/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Mar 18, 2024
2 parents 10a63e4 + 3481318 commit 229d73c
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/main/java/com/simibubi/create/compat/emi/CreateEmiPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllFluids;
Expand Down Expand Up @@ -288,7 +289,7 @@ public void register(EmiRegistry registry) {
// In World Interaction recipes
addFluidInteractionRecipe(registry, "create/limestone", AllFluids.HONEY.get(),
Fluids.LAVA, AllPaletteStoneTypes.LIMESTONE.getBaseBlock().get());
addFluidInteractionRecipe(registry, "create/chocolate", AllFluids.CHOCOLATE.get(),
addFluidInteractionRecipe(registry, "create/scoria", AllFluids.CHOCOLATE.get(),
Fluids.LAVA, AllPaletteStoneTypes.SCORIA.getBaseBlock().get());

// Introspective recipes based on present stacks need to make sure
Expand Down Expand Up @@ -321,22 +322,34 @@ private <T extends Recipe<?>> void addAll(EmiRegistry registry, AllRecipeTypes t
* @param output The stack that will be outputted from this interaction recipe
*/
private void addFluidInteractionRecipe(@NotNull EmiRegistry registry, String outputId, Fluid left, Fluid right, Block output) {
// EmiStack doesnt accept flowing fluids, must always be a source
// EmiStack doesn't accept flowing fluids, must always be a source
if (left instanceof SimpleFlowableFluid.Flowing flowing)
left = flowing.getSource();
if (right instanceof SimpleFlowableFluid.Flowing flowing)
right = flowing.getSource();

EmiStack leftInput = EmiStack.of(left, 81000);
EmiStack rightInput = EmiStack.of(right, 81000);

// fabric: 81000 droplets = 1000 mb
registry.addRecipe(EmiWorldInteractionRecipe.builder()
.id(Create.asResource("/world/fluid_interaction/" + outputId))
.leftInput(EmiStack.of(left, 81000))
.rightInput(EmiStack.of(right, 81000), false)
addRecipeSafe(registry, () -> EmiWorldInteractionRecipe.builder()
.id(new ResourceLocation("emi", "/world/fluid_interaction/" + outputId))
.leftInput(leftInput.copy().setRemainder(leftInput))
.rightInput(rightInput.copy().setRemainder(rightInput), false)
.output(EmiStack.of(output))
.build()
);
}

private static void addRecipeSafe(EmiRegistry registry, Supplier<EmiRecipe> supplier) {
try {
registry.addRecipe(supplier.get());
} catch (Throwable e) {
Create.LOGGER.warn("[Create] Exception thrown when parsing EMI recipe (no ID available)");
Create.LOGGER.error(e.toString());
}
}

private void addDeferredRecipes(Consumer<EmiRecipe> consumer) {
List<Fluid> fluids = EmiApi.getIndexStacks().stream()
.filter(s -> s.getKey() instanceof Fluid)
Expand Down

0 comments on commit 229d73c

Please sign in to comment.