Skip to content

Commit

Permalink
fix 10455
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Nov 17, 2024
1 parent bb50bbf commit f0deefb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class BuildingModules
(buildingView) -> IColonyManager.getInstance().getCompatibilityManager().getCompostInputs()));

public static final BuildingEntry.ModuleProducer<RestaurantMenuModule, RestaurantMenuModuleView> RESTAURANT_MENU =
new BuildingEntry.ModuleProducer<>("restaurant_menu", () -> new RestaurantMenuModule(true, building -> 2 * building.getBuildingLevel()), () -> RestaurantMenuModuleView::new);
new BuildingEntry.ModuleProducer<>("restaurant_menu", () -> new RestaurantMenuModule(true, ISchematicProvider::getBuildingLevel), () -> RestaurantMenuModuleView::new);

public static final BuildingEntry.ModuleProducer<RestaurantMenuModule, RestaurantMenuModuleView> NETHERMINER_MENU =
new BuildingEntry.ModuleProducer<>("netherminer_menu", () -> new RestaurantMenuModule(false, building -> 16), () -> RestaurantMenuModuleView::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.minecolonies.api.crafting.RecipeStorage;
import com.minecolonies.api.util.InventoryUtils;
import com.minecolonies.api.util.ItemStackUtils;
import com.minecolonies.api.util.MathUtils;
import com.minecolonies.api.util.WorldUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -119,29 +120,29 @@ public void onColonyTick(@NotNull final IColony colony)

for (final ItemStorage menuItem : menu)
{
ItemStack itemStack = menuItem.getItemStack().copy();
if (itemStack.isEmpty())
final ItemStack originalStack = menuItem.getItemStack().copy();
if (originalStack.isEmpty())
{
continue;
}
ItemStack requestStack = originalStack;

if (canCook && MinecoloniesAPIProxy.getInstance().getFurnaceRecipes().getFirstSmeltingRecipeByResult(menuItem) instanceof RecipeStorage recipeStorage)
if (canCook && MinecoloniesAPIProxy.getInstance().getFurnaceRecipes().getFirstSmeltingRecipeByResult(menuItem) instanceof RecipeStorage recipeStorage && MathUtils.RANDOM.nextBoolean())
{
// Smelting Recipes only got 1 input. Request the input if this is a smeltable.

itemStack = recipeStorage.getInput().get(0).getItemStack();
// Smelting Recipes only got 1 input. Request sometimes the input if this is a smeltable.
requestStack = recipeStorage.getInput().get(0).getItemStack().copy();
}

final int target = itemStack.getMaxStackSize() * getExpectedStock();
final int count = InventoryUtils.hasBuildingEnoughElseCount(this.building, new ItemStorage(itemStack, true), target);
final int target = originalStack.getMaxStackSize() * getExpectedStock();
final int count = InventoryUtils.hasBuildingEnoughElseCount(this.building, new ItemStorage(originalStack, true), target);
final int delta = target - count;
final IToken<?> request = getMatchingRequest(itemStack, list);
final IToken<?> request = getMatchingRequest(requestStack, list);
if (delta > (building.getColony().getResearchManager().getResearchEffects().getEffectStrength(MIN_ORDER) > 0 ? target / 4 : 0))
{
if (request == null)
{
itemStack.setCount(Math.min(16, Math.min(itemStack.getMaxStackSize(), delta)));
final MinimumStack stack = new MinimumStack(itemStack, false);
requestStack.setCount(Math.min(16, Math.min(requestStack.getMaxStackSize(), delta)));
final MinimumStack stack = new MinimumStack(requestStack, false);
stack.setCanBeResolvedByBuilding(false);
building.createRequest(stack, false);
}
Expand Down

0 comments on commit f0deefb

Please sign in to comment.