-
Notifications
You must be signed in to change notification settings - Fork 332
Recipe Fail Reason Display #4487
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
base: 1.20.1
Are you sure you want to change the base?
Recipe Fail Reason Display #4487
Conversation
fix AdjacentFluidCondition tooltip not display fluid info
551eabe to
cee5381
Compare
jurrejelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add docs to docs/content/modpack/changes/v7.5.0.md and the recipe modifiers page about this existing? the recipe modifiers page doesn't have java examples yet, up to you if you wanna add those too or just add it to the existing kjs examples
src/main/java/com/gregtechceu/gtceu/api/recipe/modifier/RecipeModifierList.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java
Outdated
Show resolved
Hide resolved
| @FunctionalInterface | ||
| public interface ModifierFunction { | ||
|
|
||
| // TODO: Add reasons for any NULL ModifierFunction (replace them with cancel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this finished within this codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet. There are still multiple usages of ModifierFunction.NULL in the codebase. Some of them were not replaced because I am not sure about reasons. I have only replaced the more common cases where the fail reason is explicit.
|
I hava added docs to v7.5.0.md. I am not familiar with KubeJS, so I did not touch that part. |
b1d184a to
1a4ab22
Compare
| You are supposed to replace `ModifierFunction.NULL` with `ModifierFunction.cancel(reason)` to tell the machine why the recipe fail to start. | ||
| ```patch | ||
| - return ModifierFunction.NULL; | ||
| + return ModifierFunction.cancel(Component.translate("gtceu.recipe_modifier.xxx")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it Component.translateable and not Component.translate?
| provider.add("gtceu.recipe_logic.insufficient_fuel", "Insufficient Fuel"); | ||
| provider.add("gtceu.recipe_logic.insufficient_in", "Insufficient Inputs"); | ||
| provider.add("gtceu.recipe_logic.insufficient_out", "Insufficient Outputs"); | ||
| provider.add("gtceu.recipe_logic.condition_fails", "Condition Fails"); | ||
| provider.add("gtceu.recipe_logic.no_contents", "Recipe has no Contents"); | ||
| provider.add("gtceu.recipe_logic.no_capabilities", "Machine has no Capabilities"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add failure_reason. to all of these keys:
| provider.add("gtceu.recipe_logic.insufficient_fuel", "Insufficient Fuel"); | |
| provider.add("gtceu.recipe_logic.insufficient_in", "Insufficient Inputs"); | |
| provider.add("gtceu.recipe_logic.insufficient_out", "Insufficient Outputs"); | |
| provider.add("gtceu.recipe_logic.condition_fails", "Condition Fails"); | |
| provider.add("gtceu.recipe_logic.no_contents", "Recipe has no Contents"); | |
| provider.add("gtceu.recipe_logic.no_capabilities", "Machine has no Capabilities"); | |
| provider.add("gtceu.recipe_logic.failure_reason.insufficient_fuel", "Insufficient fuel"); | |
| provider.add("gtceu.recipe_logic.failure_reason.insufficient_in", "Insufficient inputs"); | |
| provider.add("gtceu.recipe_logic.failure_reason.insufficient_out", "Insufficient outputs"); | |
| provider.add("gtceu.recipe_logic.failure_reason.condition_fails", "Condition fails"); | |
| provider.add("gtceu.recipe_logic.failure_reason.no_contents", "Recipe has no contents"); | |
| provider.add("gtceu.recipe_logic.failure_reason.no_capabilities", "Machine has no I/O"); |
Do also edit all the uses of these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, most of these don't seem to be used anywhere?
| provider.add("gtceu.recipe_modifier.default_fail", "Recipe Modifier Fail"); | ||
| provider.add("gtceu.recipe_modifier.insufficient_voltage", "Voltage Tier Too Low"); | ||
| provider.add("gtceu.recipe_modifier.insufficient_eu_to_start_fusion", | ||
| "Insufficient Energy to Initiate Fusion Reaction"); | ||
| provider.add("gtceu.recipe_modifier.coil_temperature_too_low", "Coil Temperature Too Low"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| provider.add("gtceu.recipe_modifier.default_fail", "Recipe Modifier Fail"); | |
| provider.add("gtceu.recipe_modifier.insufficient_voltage", "Voltage Tier Too Low"); | |
| provider.add("gtceu.recipe_modifier.insufficient_eu_to_start_fusion", | |
| "Insufficient Energy to Initiate Fusion Reaction"); | |
| provider.add("gtceu.recipe_modifier.coil_temperature_too_low", "Coil Temperature Too Low"); | |
| provider.add("gtceu.recipe_modifier.failure_reason.default_fail", "Recipe modifier failure"); | |
| provider.add("gtceu.recipe_modifier.failure_reason.insufficient_voltage", "Voltage too low"); | |
| provider.add("gtceu.recipe_modifier.failure_reason.insufficient_eu_to_start_fusion", | |
| "Insufficient energy to initiate fusion reaction"); | |
| provider.add("gtceu.recipe_modifier.failure_reason.coil_temperature_too_low", "Coil temperature too low"); |
| provider.add("gtceu.recipe_logic.insufficient_out", "Insufficient Outputs"); | ||
| provider.add("gtceu.recipe_logic.condition_fails", "Condition Fails"); | ||
| provider.add("gtceu.recipe_logic.no_contents", "Recipe has no Contents"); | ||
| provider.add("gtceu.recipe_logic.no_capabilities", "Machine has no Capabilities"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| provider.add("gtceu.recipe_logic.no_capabilities", "Machine has no Capabilities"); | |
| provider.add("gtceu.recipe_logic.failure_reason.no_capabilities", "Machine has no %s capabilities"); |
| Component.translatable("gtceu.recipe_logic.no_capabilities") | ||
| .append(Component.literal(": ")) | ||
| .append(Component.translatable(io.tooltip)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match my suggested change in RecipeLogicLang:
| Component.translatable("gtceu.recipe_logic.no_capabilities") | |
| .append(Component.literal(": ")) | |
| .append(Component.translatable(io.tooltip)), | |
| Component.translatable("gtceu.recipe_logic.failure_reason.no_capabilities", Component.translatable(io.tooltip)), |
| if (!reasons.isEmpty()) { | ||
| textList.add(Component.translatable("gtceu.recipe_logic.setup_fail").withStyle(ChatFormatting.RED)); | ||
| for (var reason : reasons) { | ||
| textList.add(Component.literal(" - " + reason.getString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't use getString and string concatenation to join components, as you'll lose all formatting information by doing that.
| textList.add(Component.literal(" - " + reason.getString())); | |
| textList.add(Component.literal(" - ").append(reason)); |
What
Add components to machines to show why recipes fail to setup, they are displayed in:
Implementation Details
Outcome
Players now can easily know why their machines do not work (in most cases).
Additional Information
Also add more info to AdjacentFluidCondition's tooltip to show specific fluid.
Add TODO about replacing ModifierFunction.NULL with cancel(reason).
Potential Compatibility Issues
This feature is all about info display, did not change the original logic or api. failReasonMap and failReasons are not persisted so
data errors will not occur.