LootItemKilledByPlayerCondition .java

net.minecraft.world.level.storage.loot.predicates.LootItemKilledByPlayerCondition (class): members: killedByPlayer, getReferencedContextParams, INSTANCE.

net.minecraft.world.level.storage.loot.predicatesclass34 linescommon1.0 KB

Implements

API Surface (4)

MapCodec<LootItemKilledByPlayerCondition> codec()
Set<ContextKey<?>> getReferencedContextParams()
boolean test(final LootContext context)
LootItemCondition.Builder killedByPlayer()

Fields & Constants (2)

INSTANCE
MAP_CODEC

Code Graph: Dependencies (5)

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

Full Source

LootItemKilledByPlayerCondition.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.storage.loot.predicates;
2
3
import com.mojang.serialization.MapCodec;
4
import java.util.Set;
5
import net.minecraft.util.context.ContextKey;
6
import net.minecraft.world.level.storage.loot.LootContext;
7
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
8
9
public class LootItemKilledByPlayerCondition implements LootItemCondition {
10
	private static final LootItemKilledByPlayerCondition INSTANCE = new LootItemKilledByPlayerCondition();
11
	public static final MapCodec<LootItemKilledByPlayerCondition> MAP_CODEC = MapCodec.unit(INSTANCE);
12
13
	private LootItemKilledByPlayerCondition() {
14
	}
15
16
	@Override
17
	public MapCodec<LootItemKilledByPlayerCondition> codec() {
18
		return MAP_CODEC;
19
	}
20
21
	@Override
22
	public Set<ContextKey<?>> getReferencedContextParams() {
23
		return Set.of(LootContextParams.LAST_DAMAGE_PLAYER);
24
	}
25
26
	public boolean test(final LootContext context) {
27
		return context.hasParameter(LootContextParams.LAST_DAMAGE_PLAYER);
28
	}
29
30
	public static LootItemCondition.Builder killedByPlayer() {
31
		return () -> INSTANCE;
32
	}
33
}
34

Decompiled Minecraft 26.3 source of LootItemKilledByPlayerCondition (net/minecraft/world/level/storage/loot/predicates/LootItemKilledByPlayerCondition.java) with Mojang official mappings, stored verbatim on the site.