From 5b1b8f22b0d1cbd7fe3a6195e9e2186ac21ce9e4 Mon Sep 17 00:00:00 2001 From: attackeight Date: Wed, 17 Apr 2024 19:15:47 -0400 Subject: [PATCH] Respect Manual Only Recipes The following recipes will now respect the "_manual_only" recipe suffix - Sandpaper Polishing (Deploying) - Item Application (Deploying) - Smelting (Fan Blasting) - Smoking (Fan Smoking) - Blasting (Fan Blasting) fixes Creators-Of-Create#5164 --- .../simibubi/create/compat/jei/CreateJEI.java | 8 ++++++++ .../deployer/DeployerBlockEntity.java | 20 +++++++++++++++---- .../fan/processing/AllFanProcessingTypes.java | 14 +++++++------ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index fc41d0205..fcdc719e7 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -143,6 +143,7 @@ public class CreateJEI implements IModPlugin { smoking = builder(SmokingRecipe.class) .addTypedRecipes(() -> RecipeType.SMOKING) + .removeNonAutomation() .catalystStack(ProcessingViaFanCategory.getFan("fan_smoking")) .doubleItemIcon(AllItems.PROPELLER.get(), Items.CAMPFIRE) .emptyBackground(178, 72) @@ -152,6 +153,7 @@ public class CreateJEI implements IModPlugin { .addTypedRecipesExcluding(() -> RecipeType.SMELTING, () -> RecipeType.BLASTING) .addTypedRecipes(() -> RecipeType.BLASTING) .removeRecipes(() -> RecipeType.SMOKING) + .removeNonAutomation() .catalystStack(ProcessingViaFanCategory.getFan("fan_blasting")) .doubleItemIcon(AllItems.PROPELLER.get(), Items.LAVA_BUCKET) .emptyBackground(178, 72) @@ -257,6 +259,7 @@ public class CreateJEI implements IModPlugin { .addTypedRecipes(AllRecipeTypes.DEPLOYING) .addTypedRecipes(AllRecipeTypes.SANDPAPER_POLISHING::getType, DeployerApplicationRecipe::convert) .addTypedRecipes(AllRecipeTypes.ITEM_APPLICATION::getType, ManualApplicationRecipe::asDeploying) + .removeNonAutomation() .catalyst(AllBlocks.DEPLOYER::get) .catalyst(AllBlocks.DEPOT::get) .catalyst(AllItems.BELT_CONNECTOR::get) @@ -464,6 +467,11 @@ public class CreateJEI implements IModPlugin { }); } + public CategoryBuilder removeNonAutomation() { + return addRecipeListConsumer(recipes -> recipes.removeIf(recipe -> + recipe.getId().getPath().contains("_manual_only"))); + } + public CategoryBuilder catalystStack(Supplier supplier) { catalysts.add(supplier); return this; diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java index 26363adb3..d706c73f1 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java @@ -5,6 +5,7 @@ import static com.simibubi.create.content.kinetics.base.DirectionalKineticBlock. import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.UUID; import javax.annotation.Nullable; @@ -46,9 +47,11 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ClipContext.Block; import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -547,8 +550,10 @@ public class DeployerBlockEntity extends KineticBlockEntity { ItemStack heldItemMainhand = player.getMainHandItem(); if (heldItemMainhand.getItem() instanceof SandPaperItem) { sandpaperInv.setItem(0, stack); - return AllRecipeTypes.SANDPAPER_POLISHING.find(sandpaperInv, level) - .orElse(null); + Optional> sandPaperRecipe = AllRecipeTypes.SANDPAPER_POLISHING.find(sandpaperInv, level); + if (sandPaperRecipe.isPresent() && !sandPaperRecipe.get().getId().getPath().endsWith("_manual_only")) + return sandPaperRecipe.get(); + return null; } recipeInv.setItem(0, stack); @@ -558,13 +563,20 @@ public class DeployerBlockEntity extends KineticBlockEntity { event.addRecipe(() -> SequencedAssemblyRecipe.getRecipe(level, event.getInventory(), AllRecipeTypes.DEPLOYING.getType(), DeployerApplicationRecipe.class), 100); - event.addRecipe(() -> AllRecipeTypes.DEPLOYING.find(event.getInventory(), level), 50); - event.addRecipe(() -> AllRecipeTypes.ITEM_APPLICATION.find(event.getInventory(), level), 50); + event.addRecipe(() -> checkRecipe(AllRecipeTypes.DEPLOYING, event.getInventory(), level), 50); + event.addRecipe(() -> checkRecipe(AllRecipeTypes.ITEM_APPLICATION, event.getInventory(), level), 50); MinecraftForge.EVENT_BUS.post(event); return event.getRecipe(); } + private Optional> checkRecipe(AllRecipeTypes type, RecipeWrapper inv, Level level) { + Optional> opt = type.find(inv, level); + if (opt.isPresent() && !opt.get().getId().getPath().contains("_manual_only")) + return opt; + return Optional.empty(); + } + public DeployerFakePlayer getPlayer() { return player; } diff --git a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java index bfddea4c0..c4c8e8b38 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java +++ b/src/main/java/com/simibubi/create/content/kinetics/fan/processing/AllFanProcessingTypes.java @@ -116,7 +116,7 @@ public class AllFanProcessingTypes { public List process(ItemStack stack, Level level) { return null; } - + @Override public void spawnProcessingParticles(Level level, Vec3 pos) { } @@ -162,15 +162,17 @@ public class AllFanProcessingTypes { Optional smeltingRecipe = level.getRecipeManager() .getRecipeFor(RecipeType.SMELTING, RECIPE_WRAPPER, level); - if (smeltingRecipe.isPresent()) - return true; + if (smeltingRecipe.isPresent()) { + return !smeltingRecipe.get().getId().getPath().endsWith("_manual_only"); + } RECIPE_WRAPPER.setItem(0, stack); Optional blastingRecipe = level.getRecipeManager() .getRecipeFor(RecipeType.BLASTING, RECIPE_WRAPPER, level); - if (blastingRecipe.isPresent()) - return true; + if (blastingRecipe.isPresent()) { + return !blastingRecipe.get().getId().getPath().endsWith("_manual_only"); + } return !stack.getItem() .isFireResistant(); @@ -390,7 +392,7 @@ public class AllFanProcessingTypes { RECIPE_WRAPPER.setItem(0, stack); Optional recipe = level.getRecipeManager() .getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level); - return recipe.isPresent(); + return recipe.isPresent() && !recipe.get().getId().getPath().endsWith("_manual_only"); } @Override