CivMC / FactoryMod

Configurable factories for automating item production - Built for Paper 1.16.5
Other
0 stars 11 forks source link

Update recipe auto-select logic to consider disrepair status #32

Closed dquist closed 1 year ago

dquist commented 1 year ago

Summary of changes

This PR updates the auto-selection logic to support automatic selection of the repair recipe, but if and only if the factory is in disrepair.

Effectively this means that the repair recipe will never be chosen as long as the factory has health, however once it goes into disrepair, the repair recipe is the only one that will be eligible for auto-selection.

Fixes #1

Testing

In a local dev branch, I was able to reproduce this bug in a unit test by importing a bunch of test utility files I had originally written for ExilePearl. I kept that test code out of this PR, however you can view the specific test that was failing in my personal dev branch.

I will also load this into my local dev sever, but wanted to get πŸ‘€ on it in the meantime.

Update - loaded and verified in my local dev server. I manually selected a production recipe (Bake Bread), and when I tried to activate it auto-selected to repair recipe, but then did not run because the repair materials are not present.

There's room for improving the message handling here, but this fixes the bug and I'd like to do some additional cleanup in a follow-up PR.

image