AppendLoot .java

net.minecraft.world.level.levelgen.structure.templatesystem.rule.blockentity.AppendLoot (class, 34 lines): members: lootTable, apply, getType, CODEC.

net.minecraft.world.level.levelgen.structure.templatesystem.rule.blockentityclass34 linescommon1.2 KB

Implements

API Surface (2)

CompoundTag apply(final RandomSource random, final @Nullable CompoundTag existingTag)
RuleBlockEntityModifierType<?> getType()

Fields & Constants (2)

CODEC
lootTable

String literals (3)

"loot_table"
"LootTable"
"LootTableSeed"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

AppendLoot.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.templatesystem.rule.blockentity;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.nbt.CompoundTag;
6
import net.minecraft.resources.ResourceKey;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.level.storage.loot.LootTable;
9
import org.jspecify.annotations.Nullable;
10
11
public class AppendLoot implements RuleBlockEntityModifier {
12
	public static final MapCodec<AppendLoot> CODEC = RecordCodecBuilder.mapCodec(
13
		i -> i.group(LootTable.KEY_CODEC.fieldOf("loot_table").forGetter(c -> c.lootTable)).apply(i, AppendLoot::new)
14
	);
15
	private final ResourceKey<LootTable> lootTable;
16
17
	public AppendLoot(final ResourceKey<LootTable> lootTable) {
18
		this.lootTable = lootTable;
19
	}
20
21
	@Override
22
	public CompoundTag apply(final RandomSource random, final @Nullable CompoundTag existingTag) {
23
		CompoundTag result = existingTag == null ? new CompoundTag() : existingTag.copy();
24
		result.store("LootTable", LootTable.KEY_CODEC, this.lootTable);
25
		result.putLong("LootTableSeed", random.nextLong());
26
		return result;
27
	}
28
29
	@Override
30
	public RuleBlockEntityModifierType<?> getType() {
31
		return RuleBlockEntityModifierType.APPEND_LOOT;
32
	}
33
}
34

Decompiled Minecraft 26.3 source of AppendLoot (net/minecraft/world/level/levelgen/structure/templatesystem/rule/blockentity/AppendLoot.java) with Mojang official mappings, stored verbatim on the site.