Record Class ProbabilityDistribution
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.effect.ProbabilityDistribution
- Record Components:
samplingAttempts- The maximum number of Monte Carlo rejection-sampling iterations attempted before falling back to a uniform random point inside the volume bounds.
Rejection-sampling utility for selecting random 3D coordinates within a list of
GlobalVolumes
weighted by their internal Topology falloff multipliers.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ProbabilityDistribution> Codec for serializing and deserializingProbabilityDistributioninstances from JSON.static final StringJSON field key for the maximum number of rejection-sampling attempts. -
Constructor Summary
ConstructorsConstructorDescriptionProbabilityDistribution(int samplingAttempts) Creates an instance of aProbabilityDistributionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static net.minecraft.world.phys.Vec3getUniformPoint(List<GlobalVolume> volumes, net.minecraft.util.RandomSource random) Selects a uniformly distributed random point inside the bounding box of a randomly chosenGlobalVolume.final inthashCode()Returns a hash code value for this object.net.minecraft.world.phys.Vec3samplePoint(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, List<GlobalVolume> volumes) Samples a random world-space coordinate fromvolumesweighted by each volume's topological multiplier.intReturns the value of thesamplingAttemptsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
SAMPLING_ATTEMPTS
JSON field key for the maximum number of rejection-sampling attempts.- See Also:
-
CODEC
Codec for serializing and deserializingProbabilityDistributioninstances from JSON.
-
-
Constructor Details
-
ProbabilityDistribution
public ProbabilityDistribution(int samplingAttempts) Creates an instance of aProbabilityDistributionrecord class.- Parameters:
samplingAttempts- the value for thesamplingAttemptsrecord component
-
-
Method Details
-
samplePoint
public net.minecraft.world.phys.Vec3 samplePoint(net.minecraft.server.level.ServerLevel level, int enchantmentLevel, net.minecraft.world.entity.Entity spatialReference, net.minecraft.world.phys.Vec3 epicenter, List<GlobalVolume> volumes) Samples a random world-space coordinate fromvolumesweighted by each volume's topological multiplier.- Parameters:
level- The active server level providing the random source.enchantmentLevel- The active level of the enchantment.spatialReference- The reference entity anchoring the spell field.epicenter- The fallback epicenter returned ifvolumesis empty.volumes- The list of evaluatedGlobalVolumes to sample from.- Returns:
- A sampled world-space
Vec3coordinate.
-
getUniformPoint
public static net.minecraft.world.phys.Vec3 getUniformPoint(List<GlobalVolume> volumes, net.minecraft.util.RandomSource random) Selects a uniformly distributed random point inside the bounding box of a randomly chosenGlobalVolume.- Parameters:
volumes- The list of candidateGlobalVolumes.random- The random number generator.- Returns:
- A uniformly sampled world-space
Vec3, orVec3.ZEROifvolumesis empty.
-
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 with '=='. -
samplingAttempts
public int samplingAttempts()Returns the value of thesamplingAttemptsrecord component.- Returns:
- the value of the
samplingAttemptsrecord component
-