Record Class LootContext

java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.world.data.loot.LootContext
Record Components:
location - The Location where loot is being generated.
looter - The Entity (usually a Player) receiving the loot.
killer - The Entity that caused a death (if applicable).
victim - The Entity that died (if applicable).
tool - The ItemStack used to obtain the loot.
luck - The calculated luck value used for bonus rolls and quality.
random - The Random instance used for selections.

public record LootContext(org.bukkit.Location location, @Nullable org.bukkit.entity.Entity looter, @Nullable org.bukkit.entity.Entity killer, @Nullable org.bukkit.entity.Entity victim, @Nullable org.bukkit.inventory.ItemStack tool, float luck, Random random) extends Record
Immutable record containing the environment and entity data for loot generation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder class for constructing LootContext instances.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LootContext(org.bukkit.Location location, org.bukkit.entity.Entity looter, org.bukkit.entity.Entity killer, org.bukkit.entity.Entity victim, org.bukkit.inventory.ItemStack tool, float luck, Random random)
    Creates an instance of a LootContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(org.bukkit.Location loc)
    Initializes a builder for a LootContext.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    org.bukkit.entity.Entity
    Returns the value of the killer record component.
    org.bukkit.Location
    Returns the value of the location record component.
    org.bukkit.entity.Entity
    Returns the value of the looter record component.
    float
    Returns the value of the luck record component.
    Returns the value of the random record component.
    org.bukkit.inventory.ItemStack
    Returns the value of the tool record component.
    final String
    Returns a string representation of this record class.
    org.bukkit.entity.Entity
    Returns the value of the victim record component.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LootContext

      public LootContext(org.bukkit.Location location, @Nullable org.bukkit.entity.Entity looter, @Nullable org.bukkit.entity.Entity killer, @Nullable org.bukkit.entity.Entity victim, @Nullable org.bukkit.inventory.ItemStack tool, float luck, Random random)
      Creates an instance of a LootContext record class.
      Parameters:
      location - the value for the location record component
      looter - the value for the looter record component
      killer - the value for the killer record component
      victim - the value for the victim record component
      tool - the value for the tool record component
      luck - the value for the luck record component
      random - the value for the random record component
  • Method Details

    • builder

      public static LootContext.Builder builder(org.bukkit.Location loc)
      Initializes a builder for a LootContext.
      Parameters:
      loc - The world location.
      Returns:
      A new LootContext.Builder instance.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • location

      public org.bukkit.Location location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component
    • looter

      @Nullable public org.bukkit.entity.Entity looter()
      Returns the value of the looter record component.
      Returns:
      the value of the looter record component
    • killer

      @Nullable public org.bukkit.entity.Entity killer()
      Returns the value of the killer record component.
      Returns:
      the value of the killer record component
    • victim

      @Nullable public org.bukkit.entity.Entity victim()
      Returns the value of the victim record component.
      Returns:
      the value of the victim record component
    • tool

      @Nullable public org.bukkit.inventory.ItemStack tool()
      Returns the value of the tool record component.
      Returns:
      the value of the tool record component
    • luck

      public float luck()
      Returns the value of the luck record component.
      Returns:
      the value of the luck record component
    • random

      public Random random()
      Returns the value of the random record component.
      Returns:
      the value of the random record component