Class RandomChanceCondition
java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootCondition
com.github.darksoulq.abyssallib.world.data.loot.condition.RandomChanceCondition
A loot condition that evaluates to true based on a random probability check.
This is the standard condition used to create rare drops or optional loot by defining a success rate between 0.0 and 1.0.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<RandomChanceCondition> The codec used for serializing and deserializing the random chance condition.static final LootConditionType<RandomChanceCondition> The registered type definition for the random chance loot condition. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetType()Retrieves the specific type definition for this loot condition.booleantest(LootContext context) Performs a random check against the configured chance.
-
Field Details
-
CODEC
The codec used for serializing and deserializing the random chance condition.It requires a "chance" float field representing the probability of success.
-
TYPE
The registered type definition for the random chance loot condition.
-
-
Constructor Details
-
RandomChanceCondition
public RandomChanceCondition(float chance) Constructs a new RandomChanceCondition.- Parameters:
chance- The success probability, where 0.0 is never and 1.0 is always.
-
-
Method Details
-
test
Performs a random check against the configured chance.This uses the
Randominstance provided by theLootContextto ensure consistent behavior with the rest of the loot generation cycle.- Specified by:
testin classLootCondition- Parameters:
context- TheLootContextproviding the random source.- Returns:
trueif a random float [0, 1) is less than the chance;falseotherwise.
-
getType
Retrieves the specific type definition for this loot condition.- Specified by:
getTypein classLootCondition- Returns:
- The
LootConditionTypeassociated withRandomChanceCondition.
-