Record Class OverhauledRule
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.structure.processor.rule.OverhauledRule
- Record Components:
inputPredicates- List ofRuleTestpredicates tested against the template's original input block state (any match passes).locationPredicates- List ofRuleTestpredicates tested against the current block state at the target location (any match passes).positionPredicate- APosRuleTestevaluated against the local, absolute, and pivot positions.probability- The probability (0.0to1.0) that this rule applies when all predicates match.copyProperties- Whether shared block state properties should be copied from the existing state onto the output state.output- TheRuleOutputprovider that produces the replacementBlockState.
public record OverhauledRule(List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> inputPredicates, List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> locationPredicates, net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTest positionPredicate, float probability, boolean copyProperties, RuleOutput output)
extends Record
A data-driven rule evaluated by
RuleProcessor.
Supports either single or array-based input_predicate and location_predicate definitions
(evaluated via logical OR within each list), an optional PosRuleTest, a rule-level trigger
probability, a copyProperties flag for preserving block state properties (such as
stair orientation or slab half), and a polymorphic RuleOutput.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<OverhauledRule> The codec responsible for serializing and deserializingOverhauledRuleinstances from JSON. -
Constructor Summary
ConstructorsConstructorDescriptionOverhauledRule(List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> inputPredicates, List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> locationPredicates, net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTest positionPredicate, float probability, boolean copyProperties, RuleOutput output) Creates an instance of aOverhauledRulerecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of thecopyPropertiesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> Returns the value of theinputPredicatesrecord component.List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> Returns the value of thelocationPredicatesrecord component.output()Returns the value of theoutputrecord component.net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTestReturns the value of thepositionPredicaterecord component.floatReturns the value of theprobabilityrecord component.booleantest(net.minecraft.world.level.block.state.BlockState inputState, net.minecraft.world.level.block.state.BlockState locationState, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.core.BlockPos pivot, net.minecraft.util.RandomSource random) Evaluates whether the input state, location state, and block positions satisfy this rule's predicates.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
The codec responsible for serializing and deserializingOverhauledRuleinstances from JSON.
-
-
Constructor Details
-
OverhauledRule
public OverhauledRule(List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> inputPredicates, List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> locationPredicates, net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTest positionPredicate, float probability, boolean copyProperties, RuleOutput output) Creates an instance of aOverhauledRulerecord class.- Parameters:
inputPredicates- the value for theinputPredicatesrecord componentlocationPredicates- the value for thelocationPredicatesrecord componentpositionPredicate- the value for thepositionPredicaterecord componentprobability- the value for theprobabilityrecord componentcopyProperties- the value for thecopyPropertiesrecord componentoutput- the value for theoutputrecord component
-
-
Method Details
-
test
public boolean test(net.minecraft.world.level.block.state.BlockState inputState, net.minecraft.world.level.block.state.BlockState locationState, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.core.BlockPos pivot, net.minecraft.util.RandomSource random) Evaluates whether the input state, location state, and block positions satisfy this rule's predicates.- Parameters:
inputState- The original block state from the template.locationState- The current block state at the target placement position.localPos- The unrotated template-local block position.absolutePos- The transformed world-space block position.pivot- The structure pivot position.random- The per-block deterministic random source.- Returns:
trueif at least one input predicate, at least one location predicate, and the position predicate all match;falseotherwise.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
inputPredicates
Returns the value of theinputPredicatesrecord component.- Returns:
- the value of the
inputPredicatesrecord component
-
locationPredicates
public List<net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest> locationPredicates()Returns the value of thelocationPredicatesrecord component.- Returns:
- the value of the
locationPredicatesrecord component
-
positionPredicate
public net.minecraft.world.level.levelgen.structure.templatesystem.PosRuleTest positionPredicate()Returns the value of thepositionPredicaterecord component.- Returns:
- the value of the
positionPredicaterecord component
-
probability
public float probability()Returns the value of theprobabilityrecord component.- Returns:
- the value of the
probabilityrecord component
-
copyProperties
public boolean copyProperties()Returns the value of thecopyPropertiesrecord component.- Returns:
- the value of the
copyPropertiesrecord component
-
output
Returns the value of theoutputrecord component.- Returns:
- the value of the
outputrecord component
-