SeededContainerLoot .java

net.minecraft.world.item.component.SeededContainerLoot (record, 28 lines): members: lootTable, seed, UNKNOWN_CONTENTS, addToTooltip, CODEC. imports: Item.

net.minecraft.world.item.componentrecord28 linescommon1.2 KB

Implements

API Surface (1)

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

Fields & Constants (2)

UNKNOWN_CONTENTS
CODEC

String literals (3)

"item.container.loot_table.unknown"
"loot_table"
"seed"

Full Source

SeededContainerLoot.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.component;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import java.util.function.Consumer;
6
import net.minecraft.core.component.DataComponentGetter;
7
import net.minecraft.network.chat.Component;
8
import net.minecraft.resources.ResourceKey;
9
import net.minecraft.world.item.Item;
10
import net.minecraft.world.item.TooltipFlag;
11
import net.minecraft.world.level.storage.loot.LootTable;
12
13
public record SeededContainerLoot(ResourceKey<LootTable> lootTable, long seed) implements TooltipProvider {
14
	private static final Component UNKNOWN_CONTENTS = Component.translatable("item.container.loot_table.unknown");
15
	public static final Codec<SeededContainerLoot> CODEC = RecordCodecBuilder.create(
16
		i -> i.group(
17
				LootTable.KEY_CODEC.fieldOf("loot_table").forGetter(SeededContainerLoot::lootTable),
18
				Codec.LONG.optionalFieldOf("seed", 0L).forGetter(SeededContainerLoot::seed)
19
			)
20
			.apply(i, SeededContainerLoot::new)
21
	);
22
23
	@Override
24
	public void addToTooltip(final Item.TooltipContext context, final Consumer<Component> consumer, final TooltipFlag flag, final DataComponentGetter components) {
25
		consumer.accept(UNKNOWN_CONTENTS);
26
	}
27
}
28

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