DoubleDoorDevelopment / CrayCrafting

Crafting recipe randomizer
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Exponential Recipe Growth #4

Closed mellamokb closed 9 years ago

mellamokb commented 9 years ago

Every time there is an amnesia event, the recipes seem to double and grow exponentially. I only noticed after playing "Dude Where's My Blocks" for a couple of hours, then closed and re-opened the game and it takes a long time, like >10 minutes to open the world after MC has started (related: http://minecraft.curseforge.com/modpacks/229877-dude-wheres-my-blocks/issues/1495). First off the craycrafting.dat has grown from the original size of 800 KB to 60 MB! Also I notice the number of recipes being loaded in the log file is much larger.

I did a little testing to verify. I set the amnesia timer to just one minute, then started a new world. Waited for first amnesia event, then closed and re-opened the world, and repeated a couple times. Here are the results showing the parts of the log related to loading the world and amnesia events (I set debug to True on the d3core.cfg).

First Load:

[00:02:22] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedRecipes Removed 1492 & added 2984 recipes from SERVER [00:02:22] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessRecipes Removed 408 & added 816 recipes from SERVER [00:02:22] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedOreRecipe Removed 1412 & added 2828 recipes from SERVER [00:02:22] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessOreRecipe Removed 184 & added 368 recipes from SERVER

First Amnesia Event:

[00:03:22] [CrayCrafting-Timer/WARN] [CrayCrafting/CrayCrafting]: Recipe timer! Resetting all the recipes! [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapedRecipes Removed 1492 & added 2984 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapelessRecipes Removed 408 & added 816 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapedOreRecipe Removed 1412 & added 2828 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapelessOreRecipe Removed 184 & added 368 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/WARN] [CrayCrafting/CrayCrafting]: randomizeRecipes CLIENT CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedRecipes Removed 1494 & added 2988 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessRecipes Removed 409 & added 818 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedOreRecipe Removed 1418 & added 2836 recipes from CLIENT [00:03:22] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessOreRecipe Removed 194 & added 388 recipes from CLIENT

Second Load:

[00:04:05] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedRecipes Removed 2986 & added 5972 recipes from SERVER [00:04:05] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessRecipes Removed 817 & added 1634 recipes from SERVER [00:04:05] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedOreRecipe Removed 2829 & added 5664 recipes from SERVER [00:04:06] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessOreRecipe Removed 378 & added 756 recipes from SERVER

Second Amnesia Event:

[00:04:24] [CrayCrafting-Timer/WARN] [CrayCrafting/CrayCrafting]: Recipe timer! Resetting all the recipes! [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapedRecipes Removed 2986 & added 5972 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapelessRecipes Removed 817 & added 1634 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapedOreRecipe Removed 2829 & added 5664 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: UNDO ShapelessOreRecipe Removed 378 & added 756 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/WARN] [CrayCrafting/CrayCrafting]: randomizeRecipes CLIENT CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedRecipes Removed 2994 & added 5988 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessRecipes Removed 821 & added 1642 recipes from CLIENT [00:04:24] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedOreRecipe Removed 2850 & added 5700 recipes from CLIENT [00:04:25] [CrayCrafting-Timer/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessOreRecipe Removed 418 & added 836 recipes from CLIENT

Third Load:

[00:04:47] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedRecipes Removed 5980 & added 11960 recipes from SERVER [00:04:47] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessRecipes Removed 1638 & added 3276 recipes from SERVER [00:04:47] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapedOreRecipe Removed 5678 & added 11364 recipes from SERVER [00:04:49] [Server thread/INFO] [CrayCrafting/CrayCrafting]: APPLY ShapelessOreRecipe Removed 796 & added 1592 recipes from SERVER

You can see after 2 amnesia events and restarts, it has grown from 1492 to 5980 ShapedRecipes! It is doubled in size each time. After many amnesia events this grows into the 100,000+ recipes and now it takes over 10 minutes to load the world. Also, when I view recipes in NEI, I see lots of different recipes for a single item, instead of just the two I expect (normal + CrayCrafting randomized recipe). I am searching the code to find a solution -- it obviously appears to do with removing half as many recipes as it is adding in the numbers above.

mellamokb commented 9 years ago

Note that the "UNDO ShapedRecipes Removed 1492 & added 2984" that sounds like it is adding twice as many as it is removing, is actually just a messaging bug. It is displaying the wrong counts in the output. Only place I can find an issue must be in RecipeRegistry.randomizeRecipes, because that is the only place that modifies the craycrafting.dat file.

mellamokb commented 9 years ago

Yes, I think the problem comes down to BaseType.applyRandomization. Recipes are added to nbtList with nbtList.appendTag(nbtRecipe), but the old recipes are never removed. The nbtList accumulates items as recipes are randomized and stored into the file. nbtList needs to be reset at the beginning of each randomization, or it needs to have the old recipes manually removed. Working on a fix and testing...

dries007 commented 9 years ago

Fixed by #5, correct?