Koulis2000 / MCScripts

1 stars 0 forks source link

Hang on crafting item with insufficient materials #9

Closed Bjonnfesk closed 11 months ago

Bjonnfesk commented 11 months ago

It seems that the craftCycle() hangs on attempting to craft an item that it can craft some, but not enough, of.

Say the system can craft Sticks from Oak Planks. 128 Sticks are requested, but only 4 Oak Planks are available. Only 8 Sticks can be crafted. In this case, the craftCycle() doesn't seem to do anything with that item until the materials for crafting absolutely all the 128 Sticks are available. Would it be better if it crafted the number it is able to craft every cycle?

This is caused by the wording of https://github.com/Koulis2000/MCScripts/blob/47e5a853ec69e249321d4958c100d66356174604/CCTweaked/janus-dossier.lua#L252, which doesn't check if sufficient materials are available before queueing a craft of the required number of items.

Koulis2000 commented 11 months ago

An isItemCrafting() check has been implemented right after issuing the craftOrder which lets us know if the item has indeed begun crafting. If it hasn't the order count is then reduced to 75% and attempts to craft again. This repeats for a set amount of times before giving up. We could probably skip the item without retrying. Maybe we could have some extra properties which tell the program if the craftOrder should repeat or not.

https://github.com/Koulis2000/MCScripts/blob/c830e9cf6bc1b3504c4312dab0953c498881e71a/CCTweaked/janus-dossier.lua#L194-L219