BooleanProperty .java

net.minecraft.world.level.block.state.properties.BooleanProperty (class): members: FALSE_INDEX, TRUE_INDEX, getPossibleValues, getInternalIndex, VALUES.

net.minecraft.world.level.block.state.propertiesclass41 linescommonextends Property<Boolean>948 B

API Surface (5)

List<Boolean> getPossibleValues()
BooleanProperty create(final String name)
Optional<Boolean> getValue(final String name)
String getName(final Boolean value)
int getInternalIndex(final Boolean value)

Fields & Constants (3)

VALUES
TRUE_INDEX
FALSE_INDEX

Code Graph: Dependencies (1)

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

Full Source

BooleanProperty.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.block.state.properties;
2
3
import java.util.List;
4
import java.util.Optional;
5
6
public final class BooleanProperty extends Property<Boolean> {
7
	private static final List<Boolean> VALUES = List.of(true, false);
8
	private static final int TRUE_INDEX = 0;
9
	private static final int FALSE_INDEX = 1;
10
11
	private BooleanProperty(final String name) {
12
		super(name, Boolean.class);
13
	}
14
15
	@Override
16
	public List<Boolean> getPossibleValues() {
17
		return VALUES;
18
	}
19
20
	public static BooleanProperty create(final String name) {
21
		return new BooleanProperty(name);
22
	}
23
24
	@Override
25
	public Optional<Boolean> getValue(final String name) {
26
		return switch (name) {
27
			case "true" -> Optional.of(true);
28
			case "false" -> Optional.of(false);
29
			default -> Optional.empty();
30
		};
31
	}
32
33
	public String getName(final Boolean value) {
34
		return value.toString();
35
	}
36
37
	public int getInternalIndex(final Boolean value) {
38
		return value ? 0 : 1;
39
	}
40
}
41

Decompiled Minecraft 26.3 source of BooleanProperty (net/minecraft/world/level/block/state/properties/BooleanProperty.java) with Mojang official mappings, stored verbatim on the site.