Record Class LootPool
java.lang.Object
java.lang.Record
com.github.darksoulq.abyssallib.world.data.loot.LootPool
- Record Components:
rolls- The base number of times to roll this pool.bonusRolls- Additional rolls scaled by theLootContext.luck()value.entries- The list ofLootEntryobjects to choose from.conditions- A list ofLootConditions that must pass for the pool to execute.
public record LootPool(int rolls, int bonusRolls, List<LootEntry> entries, List<LootCondition> conditions)
extends Record
A pool of potential loot entries within a table.
A pool determines how many "rolls" it performs. During each roll, weights are calculated for valid entries to determine which item is selected.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLootPool(int rolls, int bonusRolls, List<LootEntry> entries, List<LootCondition> conditions) Creates an instance of aLootPoolrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thebonusRollsrecord component.Returns the value of theconditionsrecord component.entries()Returns the value of theentriesrecord component.final booleanIndicates whether some other object is "equal to" this one.voidgenerate(LootContext context, Consumer<org.bukkit.inventory.ItemStack> sink) Executes the logic to generate loot from this pool.final inthashCode()Returns a hash code value for this object.introlls()Returns the value of therollsrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
Codec for serializing and deserializingLootPoolinstances.
-
-
Constructor Details
-
LootPool
Creates an instance of aLootPoolrecord class.- Parameters:
rolls- the value for therollsrecord componentbonusRolls- the value for thebonusRollsrecord componententries- the value for theentriesrecord componentconditions- the value for theconditionsrecord component
-
-
Method Details
-
generate
Executes the logic to generate loot from this pool.- Parameters:
context- TheLootContextused for conditions and random selection.sink- AConsumerthat accepts the generatedItemStacks.
-
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 '=='. -
rolls
public int rolls()Returns the value of therollsrecord component.- Returns:
- the value of the
rollsrecord component
-
bonusRolls
public int bonusRolls()Returns the value of thebonusRollsrecord component.- Returns:
- the value of the
bonusRollsrecord component
-
entries
Returns the value of theentriesrecord component.- Returns:
- the value of the
entriesrecord component
-
conditions
Returns the value of theconditionsrecord component.- Returns:
- the value of the
conditionsrecord component
-