mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Tidy up #6385
This commit is contained in:
parent
0f3c2a6167
commit
e32239299a
4 changed files with 28 additions and 24 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -38,6 +39,7 @@ import net.minecraft.world.item.crafting.ShapedRecipe;
|
|||
import net.minecraft.world.item.crafting.SimpleRecipeSerializer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
@ -65,6 +67,10 @@ public enum AllRecipeTypes implements IRecipeTypeInfo {
|
|||
|
||||
TOOLBOX_DYEING(() -> new SimpleRecipeSerializer<>(ToolboxDyeingRecipe::new), () -> RecipeType.CRAFTING, false);
|
||||
|
||||
public static final Predicate<? super Recipe<?>> CAN_BE_AUTOMATED = r -> !r.getId()
|
||||
.getPath()
|
||||
.endsWith("_manual_only");
|
||||
|
||||
private final ResourceLocation id;
|
||||
private final RegistryObject<RecipeSerializer<?>> serializerObject;
|
||||
@Nullable
|
||||
|
|
|
@ -468,8 +468,7 @@ public class CreateJEI implements IModPlugin {
|
|||
}
|
||||
|
||||
public CategoryBuilder<T> removeNonAutomation() {
|
||||
return addRecipeListConsumer(recipes -> recipes.removeIf(recipe ->
|
||||
recipe.getId().getPath().contains("_manual_only")));
|
||||
return addRecipeListConsumer(recipes -> recipes.removeIf(AllRecipeTypes.CAN_BE_AUTOMATED.negate()));
|
||||
}
|
||||
|
||||
public CategoryBuilder<T> catalystStack(Supplier<ItemStack> supplier) {
|
||||
|
|
|
@ -47,7 +47,6 @@ 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;
|
||||
|
@ -550,10 +549,7 @@ public class DeployerBlockEntity extends KineticBlockEntity {
|
|||
ItemStack heldItemMainhand = player.getMainHandItem();
|
||||
if (heldItemMainhand.getItem() instanceof SandPaperItem) {
|
||||
sandpaperInv.setItem(0, stack);
|
||||
Optional<Recipe<SandPaperInv>> sandPaperRecipe = AllRecipeTypes.SANDPAPER_POLISHING.find(sandpaperInv, level);
|
||||
if (sandPaperRecipe.isPresent() && !sandPaperRecipe.get().getId().getPath().endsWith("_manual_only"))
|
||||
return sandPaperRecipe.get();
|
||||
return null;
|
||||
return checkRecipe(AllRecipeTypes.SANDPAPER_POLISHING, sandpaperInv, level).orElse(null);
|
||||
}
|
||||
|
||||
recipeInv.setItem(0, stack);
|
||||
|
@ -571,10 +567,7 @@ public class DeployerBlockEntity extends KineticBlockEntity {
|
|||
}
|
||||
|
||||
private Optional<? extends Recipe<? extends Container>> checkRecipe(AllRecipeTypes type, RecipeWrapper inv, Level level) {
|
||||
Optional<? extends Recipe<? extends Container>> opt = type.find(inv, level);
|
||||
if (opt.isPresent() && !opt.get().getId().getPath().contains("_manual_only"))
|
||||
return opt;
|
||||
return Optional.empty();
|
||||
return type.find(inv, level).filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
}
|
||||
|
||||
public DeployerFakePlayer getPlayer() {
|
||||
|
|
|
@ -160,19 +160,19 @@ public class AllFanProcessingTypes {
|
|||
public boolean canProcess(ItemStack stack, Level level) {
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<SmeltingRecipe> smeltingRecipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.SMELTING, RECIPE_WRAPPER, level);
|
||||
.getRecipeFor(RecipeType.SMELTING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
if (smeltingRecipe.isPresent()) {
|
||||
return !smeltingRecipe.get().getId().getPath().endsWith("_manual_only");
|
||||
}
|
||||
if (smeltingRecipe.isPresent())
|
||||
return true;
|
||||
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<BlastingRecipe> blastingRecipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.BLASTING, RECIPE_WRAPPER, level);
|
||||
.getRecipeFor(RecipeType.BLASTING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
if (blastingRecipe.isPresent()) {
|
||||
return !blastingRecipe.get().getId().getPath().endsWith("_manual_only");
|
||||
}
|
||||
if (blastingRecipe.isPresent())
|
||||
return true;
|
||||
|
||||
return !stack.getItem()
|
||||
.isFireResistant();
|
||||
|
@ -183,11 +183,14 @@ public class AllFanProcessingTypes {
|
|||
public List<ItemStack> process(ItemStack stack, Level level) {
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<SmokingRecipe> smokingRecipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level);
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<? extends AbstractCookingRecipe> smeltingRecipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.SMELTING, RECIPE_WRAPPER, level);
|
||||
.getRecipeFor(RecipeType.SMELTING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
if (!smeltingRecipe.isPresent()) {
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
smeltingRecipe = level.getRecipeManager()
|
||||
|
@ -391,8 +394,10 @@ public class AllFanProcessingTypes {
|
|||
public boolean canProcess(ItemStack stack, Level level) {
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<SmokingRecipe> recipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level);
|
||||
return recipe.isPresent() && !recipe.get().getId().getPath().endsWith("_manual_only");
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
return recipe.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -400,7 +405,8 @@ public class AllFanProcessingTypes {
|
|||
public List<ItemStack> process(ItemStack stack, Level level) {
|
||||
RECIPE_WRAPPER.setItem(0, stack);
|
||||
Optional<SmokingRecipe> smokingRecipe = level.getRecipeManager()
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level);
|
||||
.getRecipeFor(RecipeType.SMOKING, RECIPE_WRAPPER, level)
|
||||
.filter(AllRecipeTypes.CAN_BE_AUTOMATED);
|
||||
|
||||
if (smokingRecipe.isPresent())
|
||||
return RecipeApplier.applyRecipeOn(stack, smokingRecipe.get());
|
||||
|
|
Loading…
Reference in a new issue