Record Class PotionContents
java.lang.Object
java.lang.Record
net.minecraft.world.item.alchemy.PotionContents
- All Implemented Interfaces:
ConsumableListener, TooltipProvider
public record PotionContents(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName)
extends Record
implements ConsumableListener, TooltipProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final com.mojang.serialization.Codec<PotionContents> The field for thecustomColorrecord component.private final List<MobEffectInstance> The field for thecustomEffectsrecord component.The field for thecustomNamerecord component.static final PotionContentsprivate static final com.mojang.serialization.Codec<PotionContents> private static final ComponentThe field for thepotionrecord component.static final StreamCodec<RegistryFriendlyByteBuf, PotionContents> -
Constructor Summary
ConstructorsConstructorDescriptionPotionContents(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName) Creates an instance of aPotionContentsrecord class.PotionContents(Holder<Potion> potion) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPotionTooltip(Iterable<MobEffectInstance> effects, Consumer<Component> lines, float durationScale, float tickrate) voidaddToTooltip(Item.TooltipContext context, Consumer<Component> consumer, TooltipFlag flag, DataComponentGetter components) voidapplyToLivingEntity(LivingEntity entity, float durationScale) static ItemStackcreateItemStack(Item item, Holder<Potion> potion) Returns the value of thecustomColorrecord component.Returns the value of thecustomEffectsrecord component.Returns the value of thecustomNamerecord component.final booleanIndicates whether some other object is "equal to" this one.voidforEachEffect(Consumer<MobEffectInstance> consumer, float durationScale) intgetColor()static OptionalIntgetColorOptional(Iterable<MobEffectInstance> effects) intgetColorOr(int defaultColor) static MutableComponentgetPotionDescription(Holder<MobEffect> mobEffect, int amplifier) booleanfinal inthashCode()Returns a hash code value for this object.booleanvoidonConsume(Level level, LivingEntity user, ItemStack stack, Consumable consumable) potion()Returns the value of thepotionrecord component.final StringtoString()Returns a string representation of this record class.withEffectAdded(MobEffectInstance effect) withPotion(Holder<Potion> potion)
-
Field Details
-
potion
-
customColor
-
customEffects
The field for thecustomEffectsrecord component. -
customName
-
EMPTY
-
NO_EFFECT
-
BASE_POTION_COLOR
public static final int BASE_POTION_COLOR- See Also:
-
FULL_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
PotionContents
-
PotionContents
public PotionContents(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName) Creates an instance of aPotionContentsrecord class.- Parameters:
potion- the value for thepotionrecord componentcustomColor- the value for thecustomColorrecord componentcustomEffects- the value for thecustomEffectsrecord componentcustomName- the value for thecustomNamerecord component
-
-
Method Details
-
createItemStack
-
is
-
getAllEffects
-
forEachEffect
-
withPotion
-
withEffectAdded
-
getColor
public int getColor() -
getColorOr
public int getColorOr(int defaultColor) -
getName
-
getColorOptional
-
hasEffects
public boolean hasEffects() -
customEffects
Returns the value of thecustomEffectsrecord component.- Returns:
- the value of the
customEffectsrecord component
-
applyToLivingEntity
-
addPotionTooltip
public static void addPotionTooltip(Iterable<MobEffectInstance> effects, Consumer<Component> lines, float durationScale, float tickrate) -
getPotionDescription
-
onConsume
- Specified by:
onConsumein interfaceConsumableListener
-
addToTooltip
public void addToTooltip(Item.TooltipContext context, Consumer<Component> consumer, TooltipFlag flag, DataComponentGetter components) - Specified by:
addToTooltipin interfaceTooltipProvider
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
potion
-
customColor
-
customName
-