Skip to content

Refactor Multiblock Predicates to add XOR/AND predicate logic - #5131

Open
ghzdude wants to merge 109 commits into
GregTechCEu:1.20.1from
ghzdude:gh/predicate-refactor
Open

Refactor Multiblock Predicates to add XOR/AND predicate logic#5131
ghzdude wants to merge 109 commits into
GregTechCEu:1.20.1from
ghzdude:gh/predicate-refactor

Conversation

@ghzdude

@ghzdude ghzdude commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What

Refactors Multiblock predicates for two new logic types:

  • AND logic
    • all predicates must pass their min/max counts
    • any predicate may pass their internal checks
  • XOR logic
    • the first predicate to pass gets "selected" and only that predicate's internal
    • if one predicate passes, other predicates are checked if present in the multiblock

The data hatch predicate for the Assembly Line Multiblock now uses XOR logic, meaning you can have either a data access hatch or an optical data reception hatch, but not both at the same time. The min global count of this predicate has also been set to zero, to allow you to have no data hatches.

Implementation Details

The testing functions in PatternPredicate and BasePredicate returns a boolean for pass/fail
errors are added to a new class, PredicateContext
PatternState has a PredicateContext field, and the context also has a reference back to the state
Currently, the custom predicate tooltips through PatternPredicate#addTooltips() are commented out, as they ultimately appeared to be unused.
PatternPredicate is renamed to MultiPredicate
MultiPredicate is an abstract class, with the various logic implementations extending it
getPredicateName() -> getTypeName()
predicates and blockInfo have toString() implemented, making them easier to understand while debugging
many of BasePredicate's fields now have lombok getters/setters
BasePredicates are constructed through the new PredicateBuilder, and the concrete implementation is through TestablePredicate
new helper methods for constructing PatternStringErrors and SinglePredicateErrors

AI Usage

  • No AI driven tools were used for this pull request.

Outcome

The data access hatch and optical data reception hatch are now mutually exclusive in the assembly line multiblock
furthur implementations are also possible

How Was This Tested

Tested in-game on the all multiblocks world

Additional Information

2026-07-17_19 22 59 2026-07-17_19 23 15 2026-07-17_19 23 24 2026-07-17_19 23 42 image

@ghzdude ghzdude added Do Not Merge DO NOT MERGE THIS PR YET! type: refactor Suggestion to refactor a section of code labels Jul 18, 2026
@NotArgxment

Copy link
Copy Markdown
Contributor

this is similar to the issue i opened for laser hatches

ghzdude added 26 commits August 7, 2026 02:55
mass deletion

fix last few references

make MultiPredicate respect type

improve MultiPredicate debug name

implement MultiPredicate
rename testing methods
add helper methods to PatternState
clean up PredicateContext

implement rework

improve rework

merger predicate errors together

start work on rework
add useful methods to BlockInfo
merge debug names from BasePredicate for or/and
add contents method for between curly braces
use better constructor for MultiPredicate
fix rebase
spotless
replace custom with anonymous class
move methods around
improve MultiPredicate constructors
allow MultiPredicates with a single predicate to function
pre-calculate hasAir
use stream instead of stream supplier
comment out tooltips
spotless
make logic nonnull
make has air final
simplified indexed candidate list
use logic to simplify combining
add method to get inner predicate
add simplify method
add test global/slice min to BasePredicate
fix wrong method in xor
MultiPredicate no longer works with a single predicate
simplified predicate cannot be simplified further
ghzdude added 24 commits August 7, 2026 03:00
utilize predicate builder in Predicates.java and other classes
add predicate getter in BasePredicate
new MultiPredicate constructor
prefer using appendError() over error()
fix slice errors a bit
keep errors from previous check for flipped check
simplify retaining errors
make logic type a constructor field instead of method override
improve MultiPredicate constructors
fix typo
remove redundant predicate getter
simplify XorLogic slice/global min methods
update ExpandablePattern to match BlockPattern
improve MultiPredicate errors
remove global/layer count getters
replace layer "null" checks with boolean
replace slice record with int
delete logics and compacted predicate
store MultiPredicate children directly in a list
make MultiPredicate abstract to replace logics with subclasses
make BasePredicate implement comparable
spotless for good measure
replace anon class with TestablePredicate
dont iterate children in max count check
improve XorPredicate's passed predicate
add method to force skip flip check
handle xor in get predicate at pos + better error
move predicate for pos and on error up near other testing methods
javadocs
question todo
@ghzdude
ghzdude force-pushed the gh/predicate-refactor branch from a59f02d to 805b9d6 Compare August 7, 2026 10:03
@ghzdude
ghzdude marked this pull request as ready for review August 7, 2026 10:10
@ghzdude
ghzdude requested a review from a team as a code owner August 7, 2026 10:10
ghzdude added 2 commits August 7, 2026 03:38
fix check flipped
make pattern state nullable
simplify none valid
reset ctx in cm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.20.1 Do Not Merge DO NOT MERGE THIS PR YET! type: refactor Suggestion to refactor a section of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants