API Surface (2)
int calculate(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner)
MapCodec<Potion> type()
Code Graph: Dependencies (8)
Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
Potion.java37 lines · Minecraft 26.3 · verbatim
| 1 | package net.minecraft.client.color.item;
|
| 2 |
|
| 3 | import com.mojang.serialization.MapCodec;
|
| 4 | import com.mojang.serialization.codecs.RecordCodecBuilder;
|
| 5 | import net.fabricmc.api.EnvType;
|
| 6 | import net.fabricmc.api.Environment;
|
| 7 | import net.minecraft.client.multiplayer.ClientLevel;
|
| 8 | import net.minecraft.core.component.DataComponents;
|
| 9 | import net.minecraft.util.ARGB;
|
| 10 | import net.minecraft.util.ExtraCodecs;
|
| 11 | import net.minecraft.world.entity.LivingEntity;
|
| 12 | import net.minecraft.world.item.ItemStack;
|
| 13 | import net.minecraft.world.item.alchemy.PotionContents;
|
| 14 | import org.jspecify.annotations.Nullable;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public record Potion(int defaultColor) implements ItemTintSource {
|
| 18 | public static final MapCodec<Potion> MAP_CODEC = RecordCodecBuilder.mapCodec(
|
| 19 | i -> i.group(ExtraCodecs.RGB_COLOR_CODEC.fieldOf("default").forGetter(Potion::defaultColor)).apply(i, Potion::new)
|
| 20 | );
|
| 21 |
|
| 22 | public Potion() {
|
| 23 | this(-13083194);
|
| 24 | }
|
| 25 |
|
| 26 | @Override
|
| 27 | public int calculate(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner) {
|
| 28 | PotionContents contents = itemStack.get(DataComponents.POTION_CONTENTS);
|
| 29 | return contents != null ? ARGB.opaque(contents.getColorOr(this.defaultColor)) : ARGB.opaque(this.defaultColor);
|
| 30 | }
|
| 31 |
|
| 32 | @Override
|
| 33 | public MapCodec<Potion> type() {
|
| 34 | return MAP_CODEC;
|
| 35 | }
|
| 36 | }
|
| 37 |
|
Decompiled Minecraft 26.3 source of Potion (net/minecraft/client/color/item/Potion.java) with Mojang official mappings, stored verbatim on the site.