Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crafting large numbers of items at once freezes the game #6

Closed
James103 opened this issue Jul 24, 2020 · 11 comments
Closed

Crafting large numbers of items at once freezes the game #6

James103 opened this issue Jul 24, 2020 · 11 comments
Labels
wontfix This will not be worked on

Comments

@James103
Copy link

James103 commented Jul 24, 2020

Minecraft 1.16.1
Stacc 1.16.1 4

In 1.15.2, I tried crafting 100,000 Stone Pickaxes and it caused the server to freeze for about 30 seconds. Then I tried crafting 1,000,000 Iron Blocks and it caused the server to freeze for a few minutes.
In 1.16.1, I tried crafting 100,000 Oak Logs and it caused the server to freeze for about 25 seconds (24544ms from the log).

These freezes are most likely because the game rescans the entire recipe registry for each and every item to be crafted, instead of caching and first checking the most recently used recipe (similar to how FastWorkbench and FastFurnace does it).

By similar logic, the following also holds true:

  • Repairing a diamond helmet with a very large negative durability with a maxed-out stack of diamonds freezes the game for a few minutes. To reproduce: /give @p diamond_helmet{Damage:1000000000) and /give @p diamond 1000000000

  • Large numbers of trades at once may freeze the game for a few seconds to minutes. To reproduce: summon villager ~ ~ ~ {VillagerData:{level:99,profession:"minecraft:armorer",type:"minecraft:desert"},Offers:{Recipes:[{maxUses:2147483647,priceMultiplier:0f,buy:{id:"minecraft:stone",Count:1b},sell:{id:"minecraft:dirt",Count:1b}}]}} and /give @p stone 1000000000

@Devan-Kerman
Copy link
Owner

Does fastworkbench fix the problem, ain't there a fabric version

@Devan-Kerman
Copy link
Owner

ye there is

@Devan-Kerman Devan-Kerman pinned this issue Jul 29, 2020
@Devan-Kerman
Copy link
Owner

if the game continues to lag even with that mod, tell me

@James103
Copy link
Author

With FastBench for Fabric on a vanilla crafting table, I get the following results:

  • Crafting 100,000 Iron Blocks causes the client to freeze for less than a second.
  • Crafting 1,000,000 Iron Blocks causes the client to freeze for a few seconds.
  • Crafting 10,000,000 Iron Blocks causes the client to freeze for a few more seconds. The server also outputs a log entry saying that it was running about 5 seconds behind.
  • Crafting 100,000,000 Iron Blocks causes the client to freeze for a couple minutes. The server also outputs a log entry saying that it was running about 50 seconds behind.
  • Crafting 1 billion Iron Blocks will most likely crash the server due to the watchdog, if enabled.

@Devan-Kerman
Copy link
Owner

iitemstack bad iritat

@Tfarcenim
Copy link

no u

@Devan-Kerman Devan-Kerman added the wontfix This will not be worked on label Aug 1, 2020
@Devan-Kerman
Copy link
Owner

not sure how to practically fix this without breaking a bunch of mods, either iitemstack will do it or a fapi addition is gonna need to be added

@Tfarcenim
Copy link

The problem is that fixing this would require rewriting a good portion of the crafting system and would be extremely likely to break mods.

@Nathan22211
Copy link

yeah what I would do is prevent items from stacking over a certain number in the crafting table

@Devan-Kerman
Copy link
Owner

fixed via setting max stack size in crafting inventory to 64

@Devan-Kerman
Copy link
Owner

small amendment

@Mixin(CraftingInventory.class)
public abstract class CraftingInventoryMixin_LimitStackSize implements Inventory {
	private static final int STACC_SIZE_LIMIT;
	static {
		if(FabricLoader.getInstance().isModLoaded("fastbench")) {
			STACC_SIZE_LIMIT = 1_000_000;
		} else {
			STACC_SIZE_LIMIT = 1_000;
		}
	}
	@Override
	public int getMaxCountPerStack() {
		return STACC_SIZE_LIMIT;
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants