Record Class WeightedOutput
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.structure.processor.rule.WeightedOutput
- Record Components:
outputs- AWeightedListof candidateBlockStates and their integer weights.
- All Implemented Interfaces:
RuleOutput
public record WeightedOutput(net.minecraft.util.random.WeightedList<net.minecraft.world.level.block.state.BlockState> outputs)
extends Record
implements RuleOutput
A
RuleOutput implementation that randomly selects a BlockState from a weighted
list of candidates (WeightedList).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<WeightedOutput> TheMapCodecfor serializing and deserializing aWeightedOutputfrom JSON. -
Constructor Summary
ConstructorsConstructorDescriptionWeightedOutput(net.minecraft.util.random.WeightedList<net.minecraft.world.level.block.state.BlockState> outputs) Creates an instance of aWeightedOutputrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.net.minecraft.world.level.block.state.BlockStategetOutput(net.minecraft.util.RandomSource random, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings settings) Draws a randomBlockStatefromoutputsusing the per-blockRandomSource, falling back toBlocks.AIRif the weighted list is empty.Retrieves the unique string identifier for this output type.final inthashCode()Returns a hash code value for this object.net.minecraft.util.random.WeightedList<net.minecraft.world.level.block.state.BlockState> outputs()Returns the value of theoutputsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
TheMapCodecfor serializing and deserializing aWeightedOutputfrom JSON.
-
-
Constructor Details
-
WeightedOutput
public WeightedOutput(net.minecraft.util.random.WeightedList<net.minecraft.world.level.block.state.BlockState> outputs) Creates an instance of aWeightedOutputrecord class.- Parameters:
outputs- the value for theoutputsrecord component
-
-
Method Details
-
getTypeId
Retrieves the unique string identifier for this output type.- Specified by:
getTypeIdin interfaceRuleOutput- Returns:
- The type identifier
"weighted".
-
getOutput
public net.minecraft.world.level.block.state.BlockState getOutput(net.minecraft.util.RandomSource random, net.minecraft.core.BlockPos localPos, net.minecraft.core.BlockPos absolutePos, net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings settings) Draws a randomBlockStatefromoutputsusing the per-blockRandomSource, falling back toBlocks.AIRif the weighted list is empty.- Specified by:
getOutputin interfaceRuleOutput- Parameters:
random- The per-block deterministic random source.localPos- The unrotated template-local block position (unused).absolutePos- The transformed world-space block position (unused).settings- The structure placement settings (unused).- Returns:
- The randomly selected
BlockState.
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
outputs
public net.minecraft.util.random.WeightedList<net.minecraft.world.level.block.state.BlockState> outputs()Returns the value of theoutputsrecord component.- Returns:
- the value of the
outputsrecord component
-