Record Class LootContext
java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.world.data.loot.LootContext
- Record Components:
location- TheLocationwhere loot is being generated.looter- TheEntity(usually a Player) receiving the loot.killer- TheEntitythat caused a death (if applicable).victim- TheEntitythat died (if applicable).tool- TheItemStackused to obtain the loot.luck- The calculated luck value used for bonus rolls and quality.random- TheRandominstance 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 ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingLootContextinstances. -
Constructor Summary
ConstructorsConstructorDescriptionLootContext(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 aLootContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic LootContext.Builderbuilder(org.bukkit.Location loc) Initializes a builder for a LootContext.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.org.bukkit.entity.Entitykiller()Returns the value of thekillerrecord component.org.bukkit.Locationlocation()Returns the value of thelocationrecord component.org.bukkit.entity.Entitylooter()Returns the value of thelooterrecord component.floatluck()Returns the value of theluckrecord component.random()Returns the value of therandomrecord component.org.bukkit.inventory.ItemStacktool()Returns the value of thetoolrecord component.final StringtoString()Returns a string representation of this record class.org.bukkit.entity.Entityvictim()Returns the value of thevictimrecord component.
-
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 aLootContextrecord class.- Parameters:
location- the value for thelocationrecord componentlooter- the value for thelooterrecord componentkiller- the value for thekillerrecord componentvictim- the value for thevictimrecord componenttool- the value for thetoolrecord componentluck- the value for theluckrecord componentrandom- the value for therandomrecord component
-
-
Method Details
-
builder
Initializes a builder for a LootContext.- Parameters:
loc- The world location.- Returns:
- A new
LootContext.Builderinstance.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
location
public org.bukkit.Location location()Returns the value of thelocationrecord component.- Returns:
- the value of the
locationrecord component
-
looter
@Nullable public org.bukkit.entity.Entity looter()Returns the value of thelooterrecord component.- Returns:
- the value of the
looterrecord component
-
killer
@Nullable public org.bukkit.entity.Entity killer()Returns the value of thekillerrecord component.- Returns:
- the value of the
killerrecord component
-
victim
@Nullable public org.bukkit.entity.Entity victim()Returns the value of thevictimrecord component.- Returns:
- the value of the
victimrecord component
-
tool
@Nullable public org.bukkit.inventory.ItemStack tool()Returns the value of thetoolrecord component.- Returns:
- the value of the
toolrecord component
-
luck
public float luck()Returns the value of theluckrecord component.- Returns:
- the value of the
luckrecord component
-
random
Returns the value of therandomrecord component.- Returns:
- the value of the
randomrecord component
-