BooleanModifier .java

net.minecraft.world.attribute.modifier.BooleanModifier (enum): members: AND, NAND, OR, NOR, XOR, XNOR, argumentKeyframeLerp, argumentCodec, apply.

net.minecraft.world.attribute.modifierenum36 linescommon903 B

Implements

API Surface (3)

Boolean apply(final Boolean subject, final Boolean argument)
Codec<Boolean> argumentCodec(final EnvironmentAttribute<Boolean> type)
LerpFunction<Boolean> argumentKeyframeLerp(final EnvironmentAttribute<Boolean> type)

Fields & Constants (3)

NAND
NOR
XNOR

Code Graph: Dependencies (3)

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

Full Source

BooleanModifier.java36 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.attribute.modifier;
2
3
import com.mojang.serialization.Codec;
4
import net.minecraft.world.attribute.EnvironmentAttribute;
5
import net.minecraft.world.attribute.LerpFunction;
6
7
public enum BooleanModifier implements AttributeModifier<Boolean, Boolean> {
8
	AND,
9
	NAND,
10
	OR,
11
	NOR,
12
	XOR,
13
	XNOR;
14
15
	public Boolean apply(final Boolean subject, final Boolean argument) {
16
		return switch (this) {
17
			case AND -> argument && subject;
18
			case NAND -> !argument || !subject;
19
			case OR -> argument || subject;
20
			case NOR -> !argument && !subject;
21
			case XOR -> argument ^ subject;
22
			case XNOR -> argument == subject;
23
		};
24
	}
25
26
	@Override
27
	public Codec<Boolean> argumentCodec(final EnvironmentAttribute<Boolean> type) {
28
		return Codec.BOOL;
29
	}
30
31
	@Override
32
	public LerpFunction<Boolean> argumentKeyframeLerp(final EnvironmentAttribute<Boolean> type) {
33
		return LerpFunction.ofConstant();
34
	}
35
}
36

Decompiled Minecraft 26.3 source of BooleanModifier (net/minecraft/world/attribute/modifier/BooleanModifier.java) with Mojang official mappings, stored verbatim on the site.