diff --git a/src/main/java/com/minecolonies/api/inventory/container/ContainerCraftingBrewingstand.java b/src/main/java/com/minecolonies/api/inventory/container/ContainerCraftingBrewingstand.java index f98ee540b96..f90884f2e20 100644 --- a/src/main/java/com/minecolonies/api/inventory/container/ContainerCraftingBrewingstand.java +++ b/src/main/java/com/minecolonies/api/inventory/container/ContainerCraftingBrewingstand.java @@ -171,12 +171,12 @@ else if (slot >= 0 && slot < 3) this.playerInventory = inv; this.buildingPos = pos; - this.addSlot(new SlotItemHandler(brewingStandInventory, 3, 79, 17)); - this.addSlot(new InputItemHandler(brewingStandInventory, 0, 56, 51)); this.addSlot(new InputItemHandler(brewingStandInventory, 1, 79, 58)); this.addSlot(new InputItemHandler(brewingStandInventory, 2, 102, 51)); + this.addSlot(new SlotItemHandler(brewingStandInventory, 3, 79, 17)); + // Player inventory slots // Note: The slot numbers are within the player inventory and may be the same as the field inventory. int i; @@ -273,7 +273,7 @@ public void clicked(final int slotId, final int clickedButton, final ClickType m */ public void setInput(final ItemStack stack) { - handleSlotClick(getSlot(0), stack); + handleSlotClick(getSlot(3), stack); } /** @@ -283,9 +283,9 @@ public void setInput(final ItemStack stack) */ public void setContainer(final ItemStack stack) { + handleSlotClick(getSlot(0), stack); handleSlotClick(getSlot(1), stack); handleSlotClick(getSlot(2), stack); - handleSlotClick(getSlot(3), stack); } /** diff --git a/src/main/java/com/minecolonies/core/client/gui/containers/WindowBrewingstandCrafting.java b/src/main/java/com/minecolonies/core/client/gui/containers/WindowBrewingstandCrafting.java index c3dbb38baba..209bc54cde1 100644 --- a/src/main/java/com/minecolonies/core/client/gui/containers/WindowBrewingstandCrafting.java +++ b/src/main/java/com/minecolonies/core/client/gui/containers/WindowBrewingstandCrafting.java @@ -8,6 +8,7 @@ import com.minecolonies.core.colony.buildings.moduleviews.CraftingModuleView; import com.minecolonies.core.colony.buildings.views.AbstractBuildingView; import com.minecolonies.core.network.messages.server.colony.building.worker.AddRemoveRecipeMessage; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -16,7 +17,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.alchemy.PotionBrewing; import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; @@ -112,19 +112,18 @@ public void onPress(@NotNull final Button button) { if (module.canLearn(ModCraftingTypes.BREWING.get())) { + final ItemStack potion = container.getSlot(0).getItem(); + final ItemStack ingredient = container.getSlot(3).getItem(); + final List input = new ArrayList<>(); - input.add(new ItemStorage(container.slots.get(0).getItem())); - input.add(new ItemStorage(container.slots.get(1).getItem())); - input.add(new ItemStorage(container.slots.get(2).getItem())); - input.add(new ItemStorage(container.slots.get(3).getItem())); + input.add(new ItemStorage(potion, 3, false)); + input.add(new ItemStorage(ingredient)); - final ItemStack - primaryOutput = PotionBrewing.EMPTY.mix(container.slots.get(3).getItem(), container.slots.get(0).getItem()).copy(); - primaryOutput.setCount(3); + final ItemStack primaryOutput = Minecraft.getInstance().level.potionBrewing().mix(ingredient, potion); - if (!ItemStackUtils.isEmpty(primaryOutput)) + if (!ItemStackUtils.isEmpty(primaryOutput) && primaryOutput != potion) { - new AddRemoveRecipeMessage(building, input, 1, primaryOutput, false, Blocks.BREWING_STAND, module.getProducer().getRuntimeID()).sendToServer(); + new AddRemoveRecipeMessage(building, input, 1, primaryOutput.copyWithCount(3), false, Blocks.BREWING_STAND, module.getProducer().getRuntimeID()).sendToServer(); } } } diff --git a/src/main/java/com/minecolonies/core/recipes/BrewingCraftingType.java b/src/main/java/com/minecolonies/core/recipes/BrewingCraftingType.java index 769e86af1a9..10e95d29989 100644 --- a/src/main/java/com/minecolonies/core/recipes/BrewingCraftingType.java +++ b/src/main/java/com/minecolonies/core/recipes/BrewingCraftingType.java @@ -8,19 +8,14 @@ import com.minecolonies.api.crafting.registry.CraftingType; import com.minecolonies.api.equipment.ModEquipmentTypes; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.alchemy.PotionBrewing; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.neoforged.neoforge.common.brewing.IBrewingRecipe; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; /** * A crafting type for brewing recipes @@ -39,31 +34,23 @@ public List findRecipes(@NotNull RecipeManager recipeManager, @N final List recipes = new ArrayList<>(); final ICompatibilityManager compatibilityManager = MinecoloniesAPIProxy.getInstance().getColonyManager().getCompatibilityManager(); - for (final IBrewingRecipe recipe : PotionBrewing.EMPTY.getRecipes()) - { - final List inputs = compatibilityManager.getListOfAllItems().stream() - .filter(recipe::isInput) - .collect(Collectors.toList()); - final List ingredients = compatibilityManager.getListOfAllItems().stream() - .filter(recipe::isIngredient) - .collect(Collectors.toList()); + final List containers = compatibilityManager.getListOfAllItems().stream() + .filter(world.potionBrewing()::isInput) + .toList(); + final List ingredients = compatibilityManager.getListOfAllItems().stream() + .filter(world.potionBrewing()::isIngredient) + .toList(); - for (final ItemStack input : inputs) + for (final ItemStack container : containers) + { + for (final ItemStack ingredient : ingredients) { - for (final ItemStack ingredient : ingredients) + final ItemStack output = world.potionBrewing().mix(ingredient, container); + if (!output.isEmpty() && output != container) { - final ItemStack output = recipe.getOutput(input, ingredient); - if (!output.isEmpty()) - { - final ItemStack actualInput = input.copy(); - actualInput.setCount(3); - final ItemStack actualOutput = output.copy(); - actualOutput.setCount(3); - - recipes.add(new GenericRecipe(null, actualOutput, Collections.emptyList(), - Arrays.asList(Collections.singletonList(ingredient), Collections.singletonList(actualInput)), - 1, Blocks.BREWING_STAND, null, ModEquipmentTypes.none.get(), Collections.emptyList(), -1)); - } + recipes.add(new GenericRecipe(null, output.copyWithCount(3), List.of(), + List.of(List.of(ingredient), List.of(container.copyWithCount(3))), + 1, Blocks.BREWING_STAND, null, ModEquipmentTypes.none.get(), List.of(), -1)); } } }