Class ProbableValue<T>

java.lang.Object
net.glowstone.util.loot.ProbableValue<T>

public class ProbableValue<T> extends Object
Probability distribution with a list of possible values.
  • Constructor Details

    • ProbableValue

      public ProbableValue(org.json.simple.JSONObject json, @NonNls @NonNls String type)
      Reads a distribution from a JSON object.
      Parameters:
      json - a JSON object
      type - the JSON property of json to read, which is either an instance of T or an array of objects of the form {'chance': 0.123, 'value': T}
  • Method Details

    • generate

      public T generate(Random random)
      Samples a value from this distribution.
      Parameters:
      random - the PRNG to use
      Returns:
      a random value
    • getPossibilities

      public Map<T,Double> getPossibilities()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object