IsCarried .java

net.minecraft.client.renderer.item.properties.conditional.IsCarried (record): members: seed, get, MAP_CODEC, type. imports: LocalPlayer, ClientLevel.

net.minecraft.client.renderer.item.properties.conditionalrecord29 linesclient1016 B

Implements

API Surface (2)

boolean get(final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner, final int seed, final ItemDisplayContext displayContext)
MapCodec<IsCarried> type()

Fields & Constants (2)

MAP_CODEC
seed

Code Graph: Dependencies (6)

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

Full Source

IsCarried.java29 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.item.properties.conditional;
2
3
import com.mojang.serialization.MapCodec;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.multiplayer.ClientLevel;
7
import net.minecraft.client.player.LocalPlayer;
8
import net.minecraft.world.entity.LivingEntity;
9
import net.minecraft.world.item.ItemDisplayContext;
10
import net.minecraft.world.item.ItemStack;
11
import org.jspecify.annotations.Nullable;
12
13
@Environment(EnvType.CLIENT)
14
public record IsCarried() implements ConditionalItemModelProperty {
15
	public static final MapCodec<IsCarried> MAP_CODEC = MapCodec.unit(new IsCarried());
16
17
	@Override
18
	public boolean get(
19
		final ItemStack itemStack, final @Nullable ClientLevel level, final @Nullable LivingEntity owner, final int seed, final ItemDisplayContext displayContext
20
	) {
21
		return owner instanceof LocalPlayer player && player.containerMenu.getCarried() == itemStack;
22
	}
23
24
	@Override
25
	public MapCodec<IsCarried> type() {
26
		return MAP_CODEC;
27
	}
28
}
29

Decompiled Minecraft 26.3 source of IsCarried (net/minecraft/client/renderer/item/properties/conditional/IsCarried.java) with Mojang official mappings, stored verbatim on the site.