记录类 PotionContents
java.lang.Object
java.lang.Record
net.minecraft.world.item.alchemy.PotionContents
- 所有已实现的接口:
ConsumableListener
,TooltipProvider
public record PotionContents(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName)
extends Record
implements ConsumableListener, TooltipProvider
-
字段概要
字段修饰符和类型字段说明static final int
static final com.mojang.serialization.Codec
<PotionContents> customColor
记录组件的字段。private final List
<MobEffectInstance> customEffects
记录组件的字段。customName
记录组件的字段。static final PotionContents
private static final com.mojang.serialization.Codec
<PotionContents> private static final Component
potion
记录组件的字段。static final StreamCodec
<RegistryFriendlyByteBuf, PotionContents> -
构造器概要
构造器构造器说明PotionContents
(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName) 创建PotionContents
记录类的实例。PotionContents
(Holder<Potion> p_331208_) -
方法概要
修饰符和类型方法说明static 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_) 返回customColor
记录组件的值。返回customEffects
记录组件的值。返回customName
记录组件的值。final boolean
指示某个其他对象是否“等于”此对象。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()
返回此对象的哈希代码值。boolean
void
onConsume
(Level p_366836_, LivingEntity p_366750_, ItemStack p_366399_, Consumable p_366541_) potion()
返回potion
记录组件的值。final String
toString()
返回此记录类的字符串表示形式。withEffectAdded
(MobEffectInstance p_332083_) withPotion
(Holder<Potion> p_330288_)
-
字段详细资料
-
potion
potion
记录组件的字段。 -
customColor
customColor
记录组件的字段。 -
customEffects
customEffects
记录组件的字段。 -
customName
customName
记录组件的字段。 -
EMPTY
-
NO_EFFECT
-
BASE_POTION_COLOR
public static final int BASE_POTION_COLOR- 另请参阅:
-
FULL_CODEC
-
CODEC
-
STREAM_CODEC
-
-
构造器详细资料
-
PotionContents
-
PotionContents
public PotionContents(Optional<Holder<Potion>> potion, Optional<Integer> customColor, List<MobEffectInstance> customEffects, Optional<String> customName) 创建PotionContents
记录类的实例。- 参数:
potion
-potion
记录组件的值customColor
-customColor
记录组件的值customEffects
-customEffects
记录组件的值customName
-customName
记录组件的值
-
-
方法详细资料
-
createItemStack
-
is
-
getAllEffects
-
forEachEffect
-
withPotion
-
withEffectAdded
-
getColor
public int getColor() -
getColorOr
public int getColorOr(int p_388208_) -
getName
-
getColorOptional
-
hasEffects
public boolean hasEffects() -
customEffects
返回customEffects
记录组件的值。- 返回:
customEffects
记录组件的值
-
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_) - 指定者:
onConsume
在接口中ConsumableListener
-
addToTooltip
public void addToTooltip(Item.TooltipContext p_399531_, Consumer<Component> p_399764_, TooltipFlag p_400075_, DataComponentGetter p_400022_) - 指定者:
addToTooltip
在接口中TooltipProvider
-
toString
返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。 -
hashCode
public final int hashCode()返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。 -
equals
指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录类中的所有组件都使用Objects::equals(Object,Object)
进行比较。 -
potion
返回potion
记录组件的值。- 返回:
potion
记录组件的值
-
customColor
返回customColor
记录组件的值。- 返回:
customColor
记录组件的值
-
customName
返回customName
记录组件的值。- 返回:
customName
记录组件的值
-