Package net.minecraft.world.item.alchemy
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 int
static final com.mojang.serialization.Codec
<PotionContents> The field for thecustomColor
record component.private final List
<MobEffectInstance> The field for thecustomEffects
record component.The field for thecustomName
record component.static final PotionContents
private static final com.mojang.serialization.Codec
<PotionContents> private static final Component
The field for thepotion
record 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 aPotionContents
record class.PotionContents
(Holder<Potion> p_331208_) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addPotionTooltip
(Iterable<MobEffectInstance> p_331825_, Consumer<Component> p_331296_, float p_332038_, float p_332014_) void
addToTooltip
(Item.TooltipContext p_399531_, Consumer<Component> p_399764_, TooltipFlag p_400075_, DataComponentGetter p_400022_) void
applyToLivingEntity
(LivingEntity p_366471_, float p_393741_) static ItemStack
createItemStack
(Item p_330388_, Holder<Potion> p_331030_) Returns the value of thecustomColor
record component.Returns the value of thecustomEffects
record component.Returns the value of thecustomName
record component.final boolean
Indicates whether some other object is "equal to" this one.void
forEachEffect
(Consumer<MobEffectInstance> p_331190_, float p_394070_) int
getColor()
static OptionalInt
getColorOptional
(Iterable<MobEffectInstance> p_332699_) int
getColorOr
(int p_388208_) static MutableComponent
getPotionDescription
(Holder<MobEffect> p_397215_, int p_397091_) boolean
final int
hashCode()
Returns a hash code value for this object.boolean
void
onConsume
(Level p_366836_, LivingEntity p_366750_, ItemStack p_366399_, Consumable p_366541_) potion()
Returns the value of thepotion
record component.final String
toString()
Returns a string representation of this record class.withEffectAdded
(MobEffectInstance p_332083_) withPotion
(Holder<Potion> p_330288_)
-
Field Details
-
potion
The field for thepotion
record component. -
customColor
The field for thecustomColor
record component. -
customEffects
The field for thecustomEffects
record component. -
customName
The field for thecustomName
record component. -
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 aPotionContents
record class.- Parameters:
potion
- the value for thepotion
record componentcustomColor
- the value for thecustomColor
record componentcustomEffects
- the value for thecustomEffects
record componentcustomName
- the value for thecustomName
record component
-
-
Method Details
-
createItemStack
-
is
-
getAllEffects
-
forEachEffect
-
withPotion
-
withEffectAdded
-
getColor
public int getColor() -
getColorOr
public int getColorOr(int p_388208_) -
getName
-
getColorOptional
-
hasEffects
public boolean hasEffects() -
customEffects
Returns the value of thecustomEffects
record component.- Returns:
- the value of the
customEffects
record component
-
applyToLivingEntity
-
addPotionTooltip
public static void addPotionTooltip(Iterable<MobEffectInstance> p_331825_, Consumer<Component> p_331296_, float p_332038_, float p_332014_) -
getPotionDescription
-
onConsume
public void onConsume(Level p_366836_, LivingEntity p_366750_, ItemStack p_366399_, Consumable p_366541_) - Specified by:
onConsume
in interfaceConsumableListener
-
addToTooltip
public void addToTooltip(Item.TooltipContext p_399531_, Consumer<Component> p_399764_, TooltipFlag p_400075_, DataComponentGetter p_400022_) - Specified by:
addToTooltip
in interfaceTooltipProvider
-
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
potion
Returns the value of thepotion
record component.- Returns:
- the value of the
potion
record component
-
customColor
Returns the value of thecustomColor
record component.- Returns:
- the value of the
customColor
record component
-
customName
Returns the value of thecustomName
record component.- Returns:
- the value of the
customName
record component
-