EnvironmentAttribute .java

net.minecraft.world.attribute.EnvironmentAttribute (class): members: isSpatiallyInterpolated, isFullResolutionBiomes, fullResolutionBiomes, isPositional.

net.minecraft.world.attributeclass134 linescommon3.5 KB

API Surface (17)

<Value> EnvironmentAttribute.Builder<Value> builder(final AttributeType<Value> type)
AttributeType<Value> type()
Value defaultValue()
Codec<Value> valueCodec()
Value sanitizeValue(final Value value)
boolean isSyncable()
boolean isPositional()
boolean isSpatiallyInterpolated()
boolean isFullResolutionBiomes()
String toString()
EnvironmentAttribute.Builder<Value> defaultValue(final Value defaultValue)
EnvironmentAttribute.Builder<Value> valueRange(final AttributeRange<Value> valueRange)
EnvironmentAttribute.Builder<Value> syncable()
EnvironmentAttribute.Builder<Value> notPositional()
EnvironmentAttribute.Builder<Value> spatiallyInterpolated()
EnvironmentAttribute.Builder<Value> fullResolutionBiomes()
EnvironmentAttribute<Value> build()

Fields & Constants (7)

type
defaultValue
valueRange
isSyncable
isPositional
isSpatiallyInterpolated
fullResolutionBiomes

String literals (1)

"Missing default value"

Code Graph: Dependencies (4)

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

Full Source

EnvironmentAttribute.java134 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.attribute;
2
3
import com.mojang.serialization.Codec;
4
import java.util.Objects;
5
import net.minecraft.core.registries.BuiltInRegistries;
6
import net.minecraft.util.Util;
7
import org.jspecify.annotations.Nullable;
8
9
public class EnvironmentAttribute<Value> {
10
	private final AttributeType<Value> type;
11
	private final Value defaultValue;
12
	private final AttributeRange<Value> valueRange;
13
	private final boolean isSyncable;
14
	private final boolean isPositional;
15
	private final boolean isSpatiallyInterpolated;
16
	private final boolean fullResolutionBiomes;
17
18
	private EnvironmentAttribute(
19
		final AttributeType<Value> type,
20
		final Value defaultValue,
21
		final AttributeRange<Value> valueRange,
22
		final boolean isSyncable,
23
		final boolean isPositional,
24
		final boolean isSpatiallyInterpolated,
25
		final boolean fullResolutionBiomes
26
	) {
27
		this.type = type;
28
		this.defaultValue = defaultValue;
29
		this.valueRange = valueRange;
30
		this.isSyncable = isSyncable;
31
		this.isPositional = isPositional;
32
		this.isSpatiallyInterpolated = isSpatiallyInterpolated;
33
		this.fullResolutionBiomes = fullResolutionBiomes;
34
	}
35
36
	public static <Value> EnvironmentAttribute.Builder<Value> builder(final AttributeType<Value> type) {
37
		return new EnvironmentAttribute.Builder<>(type);
38
	}
39
40
	public AttributeType<Value> type() {
41
		return this.type;
42
	}
43
44
	public Value defaultValue() {
45
		return this.defaultValue;
46
	}
47
48
	public Codec<Value> valueCodec() {
49
		return this.type.valueCodec().validate(this.valueRange::validate);
50
	}
51
52
	public Value sanitizeValue(final Value value) {
53
		return this.valueRange.sanitize(value);
54
	}
55
56
	public boolean isSyncable() {
57
		return this.isSyncable;
58
	}
59
60
	public boolean isPositional() {
61
		return this.isPositional;
62
	}
63
64
	public boolean isSpatiallyInterpolated() {
65
		return this.isSpatiallyInterpolated;
66
	}
67
68
	public boolean isFullResolutionBiomes() {
69
		return this.fullResolutionBiomes;
70
	}
71
72
	@Override
73
	public String toString() {
74
		return Util.getRegisteredName(BuiltInRegistries.ENVIRONMENT_ATTRIBUTE, this);
75
	}
76
77
	public static class Builder<Value> {
78
		private final AttributeType<Value> type;
79
		private @Nullable Value defaultValue;
80
		private AttributeRange<Value> valueRange = AttributeRange.any();
81
		private boolean isSyncable = false;
82
		private boolean isPositional = true;
83
		private boolean isSpatiallyInterpolated = false;
84
		private boolean fullResolutionBiomes = false;
85
86
		public Builder(final AttributeType<Value> type) {
87
			this.type = type;
88
		}
89
90
		public EnvironmentAttribute.Builder<Value> defaultValue(final Value defaultValue) {
91
			this.defaultValue = defaultValue;
92
			return this;
93
		}
94
95
		public EnvironmentAttribute.Builder<Value> valueRange(final AttributeRange<Value> valueRange) {
96
			this.valueRange = valueRange;
97
			return this;
98
		}
99
100
		public EnvironmentAttribute.Builder<Value> syncable() {
101
			this.isSyncable = true;
102
			return this;
103
		}
104
105
		public EnvironmentAttribute.Builder<Value> notPositional() {
106
			this.isPositional = false;
107
			return this;
108
		}
109
110
		public EnvironmentAttribute.Builder<Value> spatiallyInterpolated() {
111
			this.isSpatiallyInterpolated = true;
112
			return this;
113
		}
114
115
		@Deprecated
116
		public EnvironmentAttribute.Builder<Value> fullResolutionBiomes() {
117
			this.fullResolutionBiomes = true;
118
			return this;
119
		}
120
121
		public EnvironmentAttribute<Value> build() {
122
			return new EnvironmentAttribute<>(
123
				this.type,
124
				Objects.requireNonNull(this.defaultValue, "Missing default value"),
125
				this.valueRange,
126
				this.isSyncable,
127
				this.isPositional,
128
				this.isSpatiallyInterpolated,
129
				this.fullResolutionBiomes
130
			);
131
		}
132
	}
133
}
134

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