Class RandomChanceWithLootingCondition
java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootCondition
com.github.darksoulq.abyssallib.world.data.loot.condition.RandomChanceWithLootingCondition
A loot condition that evaluates to true based on a probability that increases with the Looting enchantment level.
This condition calculates success using the formula: chance + (looting_level * multiplier).
It is primarily used for rare mob drops where the probability of the drop is intended to scale
with the player's equipment.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Codec<RandomChanceWithLootingCondition> The codec used for serializing and deserializing the random chance with looting condition.static final LootConditionType<RandomChanceWithLootingCondition> The registered type definition for the random chance with looting loot condition. -
Constructor Summary
ConstructorsConstructorDescriptionRandomChanceWithLootingCondition(float chance, float multiplier) Constructs a new RandomChanceWithLootingCondition. -
Method Summary
Modifier and TypeMethodDescriptiongetType()Retrieves the specific type definition for this loot condition.booleantest(LootContext context) Performs a random check against the base chance plus the looting bonus.
-
Field Details
-
CODEC
The codec used for serializing and deserializing the random chance with looting condition.It maps the "chance" base probability and the "looting_multiplier" float which is added per level of the Looting enchantment.
-
TYPE
The registered type definition for the random chance with looting loot condition.
-
-
Constructor Details
-
RandomChanceWithLootingCondition
public RandomChanceWithLootingCondition(float chance, float multiplier) Constructs a new RandomChanceWithLootingCondition.- Parameters:
chance- The base success probability.multiplier- The probability increase per level of the Looting enchantment.
-
-
Method Details
-
test
Performs a random check against the base chance plus the looting bonus.The level of the
Enchantment.LOOTINGis retrieved from the tool present in theLootContext. If no tool is present, the level defaults to 0.- Specified by:
testin classLootCondition- Parameters:
context- TheLootContextproviding the tool and random source.- Returns:
trueif a random float [0, 1) is less than the calculated threshold;falseotherwise.
-
getType
Retrieves the specific type definition for this loot condition.- Specified by:
getTypein classLootCondition- Returns:
- The
LootConditionTypeassociated withRandomChanceWithLootingCondition.
-