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.

public record ProbabilityDistribution(int samplingAttempts) extends Record
Rejection-sampling utility for selecting random 3D coordinates within a list of GlobalVolumes weighted by their internal Topology falloff multipliers.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<ProbabilityDistribution>
    Codec for serializing and deserializing ProbabilityDistribution instances from JSON.
    static final String
    JSON field key for the maximum number of rejection-sampling attempts.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProbabilityDistribution(int samplingAttempts)
    Creates an instance of a ProbabilityDistribution record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    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 chosen GlobalVolume.
    final int
    Returns a hash code value for this object.
    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 from volumes weighted by each volume's topological multiplier.
    int
    Returns the value of the samplingAttempts record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ProbabilityDistribution

      public ProbabilityDistribution(int samplingAttempts)
      Creates an instance of a ProbabilityDistribution record class.
      Parameters:
      samplingAttempts - the value for the samplingAttempts record 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 from volumes weighted 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 if volumes is empty.
      volumes - The list of evaluated GlobalVolumes to sample from.
      Returns:
      A sampled world-space Vec3 coordinate.
    • 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 chosen GlobalVolume.
      Parameters:
      volumes - The list of candidate GlobalVolumes.
      random - The random number generator.
      Returns:
      A uniformly sampled world-space Vec3, or Vec3.ZERO if volumes is empty.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • samplingAttempts

      public int samplingAttempts()
      Returns the value of the samplingAttempts record component.
      Returns:
      the value of the samplingAttempts record component