Record Class LootItemRandomChanceWithEnchantedBonusCondition
java.lang.Object
java.lang.Record
net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceWithEnchantedBonusCondition
- All Implemented Interfaces:
Predicate<LootContext>, LootContextUser, LootItemCondition, Validatable
public record LootItemRandomChanceWithEnchantedBonusCondition(float unenchantedChance, LevelBasedValue enchantedChance, Holder<Enchantment> enchantment)
extends Record
implements LootItemCondition
-
Nested Class Summary
Nested classes/interfaces inherited from interface LootItemCondition
LootItemCondition.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LevelBasedValueThe field for theenchantedChancerecord component.private final Holder<Enchantment> The field for theenchantmentrecord component.static final com.mojang.serialization.MapCodec<LootItemRandomChanceWithEnchantedBonusCondition> private final floatThe field for theunenchantedChancerecord component.Fields inherited from interface LootItemCondition
CODEC, DIRECT_CODEC, TYPED_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionLootItemRandomChanceWithEnchantedBonusCondition(float unenchantedChance, LevelBasedValue enchantedChance, Holder<Enchantment> enchantment) Creates an instance of aLootItemRandomChanceWithEnchantedBonusConditionrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<LootItemRandomChanceWithEnchantedBonusCondition> codec()Returns the value of theenchantedChancerecord component.Returns the value of theenchantmentrecord component.final booleanIndicates whether some other object is "equal to" this one.Set<ContextKey<?>> final inthashCode()Returns a hash code value for this object.static LootItemCondition.BuilderrandomChanceAndLootingBoost(HolderLookup.Provider registries, float chance, float perEnchantmentLevel) booleantest(LootContext context) final StringtoString()Returns a string representation of this record class.floatReturns the value of theunenchantedChancerecord component.Methods inherited from interface LootContextUser
validate
-
Field Details
-
unenchantedChance
private final float unenchantedChanceThe field for theunenchantedChancerecord component. -
enchantedChance
The field for theenchantedChancerecord component. -
enchantment
The field for theenchantmentrecord component. -
MAP_CODEC
public static final com.mojang.serialization.MapCodec<LootItemRandomChanceWithEnchantedBonusCondition> MAP_CODEC
-
-
Constructor Details
-
LootItemRandomChanceWithEnchantedBonusCondition
public LootItemRandomChanceWithEnchantedBonusCondition(float unenchantedChance, LevelBasedValue enchantedChance, Holder<Enchantment> enchantment) Creates an instance of aLootItemRandomChanceWithEnchantedBonusConditionrecord class.- Parameters:
unenchantedChance- the value for theunenchantedChancerecord componentenchantedChance- the value for theenchantedChancerecord componentenchantment- the value for theenchantmentrecord component
-
-
Method Details
-
codec
- Specified by:
codecin interfaceLootItemCondition
-
getReferencedContextParams
- Specified by:
getReferencedContextParamsin interfaceLootContextUser
-
test
- Specified by:
testin interfacePredicate<LootContext>
-
randomChanceAndLootingBoost
public static LootItemCondition.Builder randomChanceAndLootingBoost(HolderLookup.Provider registries, float chance, float perEnchantmentLevel) -
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
unenchantedChance
public float unenchantedChance()Returns the value of theunenchantedChancerecord component.- Returns:
- the value of the
unenchantedChancerecord component
-
enchantedChance
Returns the value of theenchantedChancerecord component.- Returns:
- the value of the
enchantedChancerecord component
-
enchantment
Returns the value of theenchantmentrecord component.- Returns:
- the value of the
enchantmentrecord component
-