EnvironmentAttributeReader .java

net.minecraft.world.attribute.EnvironmentAttributeReader (interface): members: getDimensionValue, getValue, EMPTY. imports: LootContextParams, LootContext.

net.minecraft.world.attributeinterface43 linescommon1.6 KB

API Surface (2)

<Value> Value getDimensionValue(final EnvironmentAttribute<Value> attribute)
<Value> Value getValue(final EnvironmentAttribute<Value> attribute, final Vec3 pos, final @Nullable SpatialAttributeInterpolator biomeInterpolator)

Fields & Constants (1)

EMPTY

Code Graph: Dependencies (6)

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

Full Source

EnvironmentAttributeReader.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.attribute;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.world.level.storage.loot.LootContext;
5
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
6
import net.minecraft.world.phys.Vec3;
7
import org.jspecify.annotations.Nullable;
8
9
public interface EnvironmentAttributeReader {
10
	EnvironmentAttributeReader EMPTY = new EnvironmentAttributeReader() {
11
		@Override
12
		public <Value> Value getDimensionValue(final EnvironmentAttribute<Value> attribute) {
13
			return attribute.defaultValue();
14
		}
15
16
		@Override
17
		public <Value> Value getValue(final EnvironmentAttribute<Value> attribute, final Vec3 pos, final @Nullable SpatialAttributeInterpolator biomeInterpolator) {
18
			return attribute.defaultValue();
19
		}
20
	};
21
22
	<Value> Value getDimensionValue(EnvironmentAttribute<Value> attribute);
23
24
	default <Value> Value getValue(final EnvironmentAttribute<Value> attribute, final BlockPos pos) {
25
		return this.getValue(attribute, Vec3.atCenterOf(pos));
26
	}
27
28
	default <Value> Value getValue(final EnvironmentAttribute<Value> attribute, final Vec3 pos) {
29
		return this.getValue(attribute, pos, null);
30
	}
31
32
	<Value> Value getValue(EnvironmentAttribute<Value> attribute, Vec3 pos, @Nullable SpatialAttributeInterpolator biomeInterpolator);
33
34
	default <Value> Value getValue(final LootContext context, final EnvironmentAttribute<Value> attribute) {
35
		if (attribute.isPositional()) {
36
			Vec3 position = context.getOptional(LootContextParams.ORIGIN);
37
			return position != null ? this.getValue(attribute, position) : attribute.defaultValue();
38
		} else {
39
			return this.getDimensionValue(attribute);
40
		}
41
	}
42
}
43

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