DebugStickState .java

net.minecraft.world.item.component.DebugStickState (record): members: properties, withProperty, EMPTY, CODEC. strings: "No property on ", " with name: ".

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

API Surface (2)

record DebugStickState(Map<Holder<Block>, Property<?>> properties)
DebugStickState withProperty(final Holder<Block> block, final Property<?> property)

Fields & Constants (2)

EMPTY
CODEC

String literals (2)

"No property on "
" with name: "

Code Graph: Dependencies (5)

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

Full Source

DebugStickState.java26 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item.component;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.DataResult;
5
import java.util.Map;
6
import net.minecraft.core.Holder;
7
import net.minecraft.core.registries.BuiltInRegistries;
8
import net.minecraft.util.Util;
9
import net.minecraft.world.level.block.Block;
10
import net.minecraft.world.level.block.state.properties.Property;
11
12
public record DebugStickState(Map<Holder<Block>, Property<?>> properties) {
13
	public static final DebugStickState EMPTY = new DebugStickState(Map.of());
14
	public static final Codec<DebugStickState> CODEC = Codec.<Holder<Block>, Property<?>>dispatchedMap(
15
			BuiltInRegistries.BLOCK.holderByNameCodec(), block -> Codec.STRING.comapFlatMap(name -> {
16
				Property<?> property = block.value().getStateDefinition().getProperty(name);
17
				return property != null ? DataResult.success(property) : DataResult.error(() -> "No property on " + block.getRegisteredName() + " with name: " + name);
18
			}, Property::getName)
19
		)
20
		.xmap(DebugStickState::new, DebugStickState::properties);
21
22
	public DebugStickState withProperty(final Holder<Block> block, final Property<?> property) {
23
		return new DebugStickState(Util.copyAndPut(this.properties, block, property));
24
	}
25
}
26

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