-
Notifications
You must be signed in to change notification settings - Fork 212
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
Refactor RecipeModifier and OC system #2499
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screret
requested changes
Dec 15, 2024
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.
this is SO MUCH BETTER than what we had tysm
src/main/java/com/gregtechceu/gtceu/api/machine/steam/SimpleSteamMachine.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gregtechceu/gtceu/api/machine/steam/SteamBoilerMachine.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gregtechceu/gtceu/api/machine/SimpleGeneratorMachine.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gregtechceu/gtceu/api/recipe/content/ContentModifier.java
Show resolved
Hide resolved
src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/steam/LargeBoilerMachine.java
Outdated
Show resolved
Hide resolved
...va/com/gregtechceu/gtceu/common/machine/multiblock/steam/SteamParallelMultiblockMachine.java
Outdated
Show resolved
Hide resolved
...main/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/FusionReactorMachine.java
Show resolved
Hide resolved
.../com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeCombustionEngineMachine.java
Outdated
Show resolved
Hide resolved
...main/java/com/gregtechceu/gtceu/common/machine/multiblock/generator/LargeTurbineMachine.java
Outdated
Show resolved
Hide resolved
screret
approved these changes
Dec 16, 2024
screret
pushed a commit
that referenced
this pull request
Dec 28, 2024
Co-authored-by: YoungOnion <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR aims to more clearly define how the RecipeModifier system is meant to function.
One key element of this is that recipes should not be mutated by a Recipe Modifier.
Instead, each recipe modifier should describe how the recipe should be changed given the current state of the recipe and machine. This replaces the old system of
OCParams
andOCResult
, which, to be frank, was confusing and often led to inconsistencies due to modifications being overwritten by recipe modifiers.The scope of
OCParams
andOCResult
have been narrowed to simply be used forOverclockingLogic
.Modifier Details
A new functional interface
ModifierFunction
has been introduced which will take aGTRecipe
as an input to itsapply
method and return a modified copy of the recipe. The original recipe should not be mutated. TheModifierFunction
is allowed to returnnull
if the recipe should be cancelled.The
RecipeModifier
functional interface now only takes the current state ofMetaMachine, GTRecipe
and returns aModifierFunction
describing how the recipe modifier thinks the recipe should be changed. Again, the original recipe should not be mutated. The returned function should not be null; if a modifier wishes to cancel a recipe, it should instead return a modifier function that nulls the recipe. This can be done via a lambda or the staticModifierFunction.NULL
. The identity can also be referenced using the staticModifierFunction.IDENTITY
.All existing recipe modifiers have been updated to match these desired behaviors.
For convenience, the
ModifierFunction
class includes the nestedFunctionBuilder
class, accessible viaModifierFunction#builder
, which provides a variety of parameters to build the function of your choosing withContentModifier
s.ModifierFunction
s can also be composed or chained via thecompose
orandThen
methods.The
RecipeModifierList
class still exists as a way to collect and apply multiple recipe modifiers. It no longer has any special behavior and instead simply composes its list of modifiers. It keeps track of a running recipe so that each consecutive modifier is being calculated in order based on what would be applied by previous modifiers.The
RecipeModifier#nullWrongType
method is a utility method that simply returnsModifierFunction.NULL
while logging the incorrect use of a recipe modifier.Parallel and Overclocking Logic Changes
The parallel methods no longer do anything to a recipe. Instead, they simply calculate and return the amount of parallels that can be achieved with the given parameters. It is up to the caller to use this number as they wish.
The
OverclockingLogic
class has had its structure changed to that of the previously nested interfaceLogic
, as there is no need for outer class definition. The functional interface, assisted by a helper factory methodcreate
taking the place of the constructor, is sufficient. Default interface methods are now used instead of static helper methods.The Overclocking methods have been modified to account for the maximum parallels that a recipe can be run at. This fixes rare cases where, if already previously modified, a recipe may parallel overclock too much and would be unable to run due to missing inputs or output space.
Additional Details
The Large Turbine Machine modifier has been changed. Like other generators, large turbines will now parallelize a recipe (via fastParallel) until they produce their desired power. Then, the efficiency stat of the rotor holder will multiply the burntime of the fuel.
Outcome
Happi life