API Surface (2)
int calculate(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner)
MapCodec<Dye> type()
Code Graph: Dependencies (6)
Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
Dye.java30 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.util.ExtraCodecs;
|
| 9 | import net.minecraft.world.entity.LivingEntity;
|
| 10 | import net.minecraft.world.item.ItemStack;
|
| 11 | import net.minecraft.world.item.component.DyedItemColor;
|
| 12 | import org.jspecify.annotations.Nullable;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public record Dye(int defaultColor) implements ItemTintSource {
|
| 16 | public static final MapCodec<Dye> MAP_CODEC = RecordCodecBuilder.mapCodec(
|
| 17 | i -> i.group(ExtraCodecs.RGB_COLOR_CODEC.fieldOf("default").forGetter(Dye::defaultColor)).apply(i, Dye::new)
|
| 18 | );
|
| 19 |
|
| 20 | @Override
|
| 21 | public int calculate(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner) {
|
| 22 | return DyedItemColor.getOrDefault(itemStack, this.defaultColor);
|
| 23 | }
|
| 24 |
|
| 25 | @Override
|
| 26 | public MapCodec<Dye> type() {
|
| 27 | return MAP_CODEC;
|
| 28 | }
|
| 29 | }
|
| 30 |
|
Decompiled Minecraft 26.3 source of Dye (net/minecraft/client/color/item/Dye.java) with Mojang official mappings, stored verbatim on the site.