diff --git a/changelog.md b/changelog.md index 18ba55a3d..6021ba2d6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## Forestry 1.0.8 +- Remove bottler recipes from JEI + ## Forestry 1.0.7 - Sort products displayed in JEI by their chances - Fix mating behaviour of unmated queens (ex. from Creative Menu) diff --git a/src/main/java/forestry/core/recipes/jei/ForestryRecipeType.java b/src/main/java/forestry/core/recipes/jei/ForestryRecipeType.java index 245b22e97..bd130d85d 100644 --- a/src/main/java/forestry/core/recipes/jei/ForestryRecipeType.java +++ b/src/main/java/forestry/core/recipes/jei/ForestryRecipeType.java @@ -10,11 +10,9 @@ import forestry.api.recipes.ISqueezerRecipe; import forestry.api.recipes.IStillRecipe; import forestry.factory.MachineUIDs; -import forestry.factory.recipes.jei.bottler.BottlerRecipe; import mezz.jei.api.recipe.RecipeType; public class ForestryRecipeType { - public static final RecipeType BOTTLER = create(MachineUIDs.BOTTLER, BottlerRecipe.class); public static final RecipeType CARPENTER = create(MachineUIDs.CARPENTER, ICarpenterRecipe.class); public static final RecipeType CENTRIFUGE = create(MachineUIDs.CENTRIFUGE, ICentrifugeRecipe.class); public static final RecipeType FABRICATOR = create(MachineUIDs.FABRICATOR, IFabricatorRecipe.class); diff --git a/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java b/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java index e0287d928..9fe782ccf 100644 --- a/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java +++ b/src/main/java/forestry/factory/recipes/jei/FactoryJeiPlugin.java @@ -1,7 +1,6 @@ package forestry.factory.recipes.jei; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -30,7 +29,6 @@ import forestry.factory.blocks.BlockTypeFactoryTesr; import forestry.factory.features.FactoryBlocks; import forestry.factory.features.FactoryRecipeTypes; -import forestry.factory.gui.GuiBottler; import forestry.factory.gui.GuiCarpenter; import forestry.factory.gui.GuiCentrifuge; import forestry.factory.gui.GuiFabricator; @@ -38,8 +36,6 @@ import forestry.factory.gui.GuiMoistener; import forestry.factory.gui.GuiSqueezer; import forestry.factory.gui.GuiStill; -import forestry.factory.recipes.jei.bottler.BottlerRecipeCategory; -import forestry.factory.recipes.jei.bottler.BottlerRecipeMaker; import forestry.factory.recipes.jei.carpenter.CarpenterRecipeCategory; import forestry.factory.recipes.jei.carpenter.CarpenterRecipeTransferHandler; import forestry.factory.recipes.jei.centrifuge.CentrifugeRecipeCategory; @@ -58,7 +54,6 @@ import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; -import mezz.jei.api.recipe.category.IRecipeCategory; import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.IRecipeCatalystRegistration; import mezz.jei.api.registration.IRecipeCategoryRegistration; @@ -78,52 +73,22 @@ public void registerCategories(IRecipeCategoryRegistration registry) { IJeiHelpers jeiHelpers = registry.getJeiHelpers(); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); - List> categories = new ArrayList<>(); - - if (true) { - categories.add(new BottlerRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new CarpenterRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new CentrifugeRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new FabricatorRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new FermenterRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new MoistenerRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new RainmakerRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new SqueezerRecipeCategory(guiHelper)); - } - - if (true) { - categories.add(new StillRecipeCategory(guiHelper)); - } - - registry.addRecipeCategories(categories.toArray(new IRecipeCategory[0])); + registry.addRecipeCategories( + new CarpenterRecipeCategory(guiHelper), + new CentrifugeRecipeCategory(guiHelper), + new FabricatorRecipeCategory(guiHelper), + new FermenterRecipeCategory(guiHelper), + new MoistenerRecipeCategory(guiHelper), + new RainmakerRecipeCategory(guiHelper), + new SqueezerRecipeCategory(guiHelper), + new StillRecipeCategory(guiHelper) + ); } @Override public void registerRecipes(IRecipeRegistration registry) { RecipeManager manager = ClientsideCode.getRecipeManager(); - registry.addRecipes(ForestryRecipeType.BOTTLER, BottlerRecipeMaker.getBottlerRecipes(registry.getIngredientManager())); registry.addRecipes(ForestryRecipeType.CARPENTER, RecipeUtils.getRecipes(manager, FactoryRecipeTypes.CARPENTER).toList()); registry.addRecipes(ForestryRecipeType.CENTRIFUGE, RecipeUtils.getRecipes(manager, FactoryRecipeTypes.CENTRIFUGE).toList()); registry.addRecipes(ForestryRecipeType.FABRICATOR, RecipeUtils.getRecipes(manager, FactoryRecipeTypes.FABRICATOR).toList()); @@ -137,6 +102,7 @@ public void registerRecipes(IRecipeRegistration registry) { BlockFactoryPlain rainTank = FactoryBlocks.PLAIN.get(BlockTypeFactoryPlain.RAINTANK).block(); JeiUtil.addDescription(registry, rainTank); + JeiUtil.addDescription(registry, FactoryBlocks.TESR.get(BlockTypeFactoryTesr.BOTTLER).block()); } @Override @@ -147,7 +113,6 @@ public void registerRecipeTransferHandlers(IRecipeTransferRegistration registry) @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) { - registry.addRecipeCatalyst(new ItemStack(FactoryBlocks.TESR.get(BlockTypeFactoryTesr.BOTTLER).block()), ForestryRecipeType.BOTTLER); registry.addRecipeCatalyst(new ItemStack(FactoryBlocks.TESR.get(BlockTypeFactoryTesr.CARPENTER).block()), ForestryRecipeType.CARPENTER); registry.addRecipeCatalyst(new ItemStack(FactoryBlocks.TESR.get(BlockTypeFactoryTesr.CENTRIFUGE).block()), ForestryRecipeType.CENTRIFUGE); registry.addRecipeCatalyst(new ItemStack(FactoryBlocks.PLAIN.get(BlockTypeFactoryPlain.FABRICATOR).block()), ForestryRecipeType.FABRICATOR); @@ -162,9 +127,6 @@ public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) { public void registerGuiHandlers(IGuiHandlerRegistration registry) { registry.addGenericGuiContainerHandler(GuiForestry.class, new ForestryAdvancedGuiHandler()); - registry.addRecipeClickArea(GuiBottler.class, 107, 33, 26, 22, ForestryRecipeType.BOTTLER); - registry.addRecipeClickArea(GuiBottler.class, 45, 33, 26, 22, ForestryRecipeType.BOTTLER); - registry.addRecipeClickArea(GuiCarpenter.class, 98, 48, 21, 26, ForestryRecipeType.CARPENTER); registry.addRecipeClickArea(GuiCentrifuge.class, 38, 22, 38, 14, ForestryRecipeType.CENTRIFUGE); diff --git a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipe.java b/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipe.java deleted file mode 100644 index 6d7c0938c..000000000 --- a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipe.java +++ /dev/null @@ -1,13 +0,0 @@ -package forestry.factory.recipes.jei.bottler; - -import javax.annotation.Nullable; - -import net.minecraft.world.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -public record BottlerRecipe( - ItemStack inputStack, - FluidStack fluid, - @Nullable ItemStack outputStack, - boolean fillRecipe) {} diff --git a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeCategory.java b/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeCategory.java deleted file mode 100644 index ba91e6021..000000000 --- a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeCategory.java +++ /dev/null @@ -1,96 +0,0 @@ -package forestry.factory.recipes.jei.bottler; - -import com.mojang.blaze3d.vertex.PoseStack; - -import forestry.api.ForestryConstants; -import forestry.core.config.Constants; -import forestry.core.recipes.jei.ForestryRecipeCategory; -import forestry.core.recipes.jei.ForestryRecipeType; -import forestry.factory.blocks.BlockTypeFactoryTesr; -import forestry.factory.features.FactoryBlocks; -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.forge.ForgeTypes; -import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; -import mezz.jei.api.gui.builder.IRecipeSlotBuilder; -import mezz.jei.api.gui.drawable.IDrawable; -import mezz.jei.api.gui.ingredient.IRecipeSlotsView; -import mezz.jei.api.helpers.IGuiHelper; -import mezz.jei.api.recipe.IFocusGroup; -import mezz.jei.api.recipe.RecipeIngredientRole; -import mezz.jei.api.recipe.RecipeType; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; - -public class BottlerRecipeCategory extends ForestryRecipeCategory { - private final static ResourceLocation guiTexture = ForestryConstants.forestry(Constants.TEXTURE_PATH_GUI + "/bottler.png"); - - private final IDrawable icon; - private final IDrawable slot; - private final IDrawable tank; - private final IDrawable arrowDown; - private final IDrawable tankOverlay; - - public BottlerRecipeCategory(IGuiHelper guiHelper) { - super(guiHelper.createBlankDrawable(62, 60), "block.forestry.bottler"); - - this.slot = guiHelper.getSlotDrawable(); - this.tank = guiHelper.createDrawable(guiTexture, 79, 13, 18, 60); - this.arrowDown = guiHelper.createDrawable(guiTexture, 20, 25, 12, 8); - this.tankOverlay = guiHelper.createDrawable(guiTexture, 176, 0, 16, 58); - ItemStack bottler = new ItemStack(FactoryBlocks.TESR.get(BlockTypeFactoryTesr.BOTTLER).block()); - this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, bottler); - } - - @Override - public RecipeType getRecipeType() { - return ForestryRecipeType.BOTTLER; - } - - @Override - public IDrawable getIcon() { - return this.icon; - } - - @Override - public void setRecipe(IRecipeLayoutBuilder builder, BottlerRecipe recipe, IFocusGroup focuses) { - IRecipeSlotBuilder fillInputSlot = builder.addSlot(RecipeIngredientRole.INPUT, 45, 1) - .setBackground(slot, -1, -1); - - IRecipeSlotBuilder fillOutputSlot = builder.addSlot(RecipeIngredientRole.OUTPUT, 45, 43) - .setBackground(slot, -1, -1); - - IRecipeSlotBuilder drainInputSlot = builder.addSlot(RecipeIngredientRole.INPUT, 1, 1) - .setBackground(slot, -1, -1); - - IRecipeSlotBuilder drainOutputSlot = builder.addSlot(RecipeIngredientRole.OUTPUT, 1, 43) - .setBackground(slot, -1, -1); - - RecipeIngredientRole tankSlotRole; - - if (recipe.fillRecipe()) { - fillInputSlot.addItemStack(recipe.inputStack()); - if (recipe.outputStack() != null) { - fillOutputSlot.addItemStack(recipe.outputStack()); - } - tankSlotRole = RecipeIngredientRole.INPUT; - } else { - drainInputSlot.addItemStack(recipe.inputStack()); - if (recipe.outputStack() != null) { - drainOutputSlot.addItemStack(recipe.outputStack()); - } - tankSlotRole = RecipeIngredientRole.OUTPUT; - } - - builder.addSlot(tankSlotRole, 23, 1) - .setFluidRenderer(10000, false, 16, 58) - .setBackground(tank, -1, -1) - .setOverlay(tankOverlay, 0, 0) - .addIngredient(ForgeTypes.FLUID_STACK, recipe.fluid()); - } - - @Override - public void draw(BottlerRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStack stack, double mouseX, double mouseY) { - arrowDown.draw(stack, 3, 26); - arrowDown.draw(stack, 47, 26); - } -} diff --git a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeMaker.java b/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeMaker.java deleted file mode 100644 index c3c2e6d1a..000000000 --- a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeMaker.java +++ /dev/null @@ -1,93 +0,0 @@ -package forestry.factory.recipes.jei.bottler; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; - -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandlerItem; -import net.minecraftforge.registries.ForgeRegistries; - -import mezz.jei.api.constants.VanillaTypes; -import mezz.jei.api.runtime.IIngredientManager; - -public class BottlerRecipeMaker { - public static List getBottlerRecipes(IIngredientManager ingredientManager) { - List recipes = new ArrayList<>(); - for (ItemStack stack : ingredientManager.getAllIngredients(VanillaTypes.ITEM_STACK)) { - Optional drainFluidHandler = stack.copy() - .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null) - .resolve(); - if (drainFluidHandler.isPresent()) { - addDrainRecipes(recipes, drainFluidHandler.get(), stack); - addFillRecipes(recipes, stack); - } - } - - return recipes; - } - - private static void addDrainRecipes(List recipes, IFluidHandlerItem fluidHandler, ItemStack stack) { - if (Items.BUCKET.equals(stack.getItem())) { - return; - } - - FluidStack drainedFluid = fluidHandler.drain(Integer.MAX_VALUE, IFluidHandler.FluidAction.SIMULATE); - if (drainedFluid.isEmpty()) { - for (Fluid fluid : ForgeRegistries.FLUIDS.getValues()) { - IFluidHandlerItem currentFluidHandler = stack.copy() - .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null) - .resolve() - .orElseThrow(); - - int simulateFill = currentFluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), IFluidHandler.FluidAction.SIMULATE); - if (simulateFill > 0) { - currentFluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), IFluidHandler.FluidAction.EXECUTE); - addDrainRecipe(recipes, currentFluidHandler, currentFluidHandler.getContainer().copy()); - } - } - } else { - addDrainRecipe(recipes, fluidHandler, stack); - } - } - - private static void addDrainRecipe(List recipes, IFluidHandlerItem fluidHandler, ItemStack stack) { - FluidStack drainedFluid = fluidHandler.drain(Integer.MAX_VALUE, IFluidHandler.FluidAction.EXECUTE); - if (!drainedFluid.isEmpty() && drainedFluid.getAmount() > 0) { - ItemStack drained = fluidHandler.getContainer(); - if (drained.getItem() == Items.AIR) { - drained = null; - } - - recipes.add(new BottlerRecipe(stack, drainedFluid, drained, false)); - } - } - - private static void addFillRecipes(List recipes, ItemStack stack) { - for (Fluid fluid : ForgeRegistries.FLUIDS.getValues()) { - IFluidHandlerItem currentFluidHandler = stack.copy() - .getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM, null) - .resolve() - .orElseThrow(); - - //try to reduce itemstack copies - int simulateFill = currentFluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), IFluidHandler.FluidAction.SIMULATE); - if (simulateFill > 0) { - FluidStack filledFluid = new FluidStack(fluid, simulateFill); - currentFluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), IFluidHandler.FluidAction.EXECUTE); - ItemStack filled = currentFluidHandler.getContainer(); - if (filled.getItem() == Items.AIR) { - filled = null; - } - - recipes.add(new BottlerRecipe(stack, filledFluid, filled, true)); - } - } - } -} diff --git a/src/main/java/forestry/factory/recipes/jei/bottler/package-info.java b/src/main/java/forestry/factory/recipes/jei/bottler/package-info.java deleted file mode 100644 index ef094d0b8..000000000 --- a/src/main/java/forestry/factory/recipes/jei/bottler/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -package forestry.factory.recipes.jei.bottler; - -import javax.annotation.ParametersAreNonnullByDefault; - -import forestry.core.utils.FieldsAreNonnullByDefault; - -import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/resources/assets/forestry/lang/en_us.json b/src/main/resources/assets/forestry/lang/en_us.json index 42622351b..38193aa82 100644 --- a/src/main/resources/assets/forestry/lang/en_us.json +++ b/src/main/resources/assets/forestry/lang/en_us.json @@ -2168,6 +2168,7 @@ "for.jei.description.miner_bag": "Extra inventory that automatically picks up ores and valuable mining-related item.", "for.jei.description.apiarist_bag": "Extra inventory that automatically picks up bees.", "for.jei.description.lepidopterist_bag": "Extra inventory that automatically picks up butterflies.", + "for.jei.description.bottler": "Used to empty and fill containers with fluids.", "_comment": "###################", "_comment": "JEI Recipes", "_comment": "###################",