SulfurCubeContent .java

net.minecraft.world.item.component.SulfurCubeContent (record, 32 lines): members: absorbedBlockItemStack, ofNonEmpty, addToTooltip, STREAM_CODEC, CODEC.

net.minecraft.world.item.componentrecord32 linescommon1.5 KB

Implements

API Surface (2)

SulfurCubeContent ofNonEmpty(final ItemStack itemStack)
void addToTooltip(final Item.TooltipContext context, final Consumer<Component> consumer, final TooltipFlag flag, final DataComponentGetter components)

Fields & Constants (2)

CODEC
STREAM_CODEC

String literals (1)

"entity.minecraft.sulfur_cube.content"

Full Source

SulfurCubeContent.java32 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.component;
2
3
import com.mojang.serialization.Codec;
4
import java.util.function.Consumer;
5
import net.minecraft.ChatFormatting;
6
import net.minecraft.core.component.DataComponentGetter;
7
import net.minecraft.network.RegistryFriendlyByteBuf;
8
import net.minecraft.network.chat.Component;
9
import net.minecraft.network.codec.StreamCodec;
10
import net.minecraft.world.item.Item;
11
import net.minecraft.world.item.ItemStack;
12
import net.minecraft.world.item.ItemStackTemplate;
13
import net.minecraft.world.item.TooltipFlag;
14
15
public record SulfurCubeContent(ItemStackTemplate absorbedBlockItemStack) implements TooltipProvider {
16
	public static final Codec<SulfurCubeContent> CODEC = ItemStackTemplate.CODEC.xmap(SulfurCubeContent::new, SulfurCubeContent::absorbedBlockItemStack);
17
	public static final StreamCodec<RegistryFriendlyByteBuf, SulfurCubeContent> STREAM_CODEC = ItemStackTemplate.STREAM_CODEC
18
		.map(SulfurCubeContent::new, SulfurCubeContent::absorbedBlockItemStack);
19
20
	public static SulfurCubeContent ofNonEmpty(final ItemStack itemStack) {
21
		return new SulfurCubeContent(ItemStackTemplate.fromNonEmptyStack(itemStack));
22
	}
23
24
	@Override
25
	public void addToTooltip(final Item.TooltipContext context, final Consumer<Component> consumer, final TooltipFlag flag, final DataComponentGetter components) {
26
		ItemStack currentStack = this.absorbedBlockItemStack.create();
27
		consumer.accept(
28
			Component.translatable("entity.minecraft.sulfur_cube.content", currentStack.getHoverName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY)
29
		);
30
	}
31
}
32

Decompiled Minecraft 26.3 source of SulfurCubeContent (net/minecraft/world/item/component/SulfurCubeContent.java) with Mojang official mappings, stored verbatim on the site.