ContainerLevelAccess .java

net.minecraft.world.inventory.ContainerLevelAccess (interface, 39 lines): members: NULL, evaluate, execute, create. imports: Level.

net.minecraft.world.inventoryinterface39 linescommon1.1 KB

API Surface (2)

<T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> action)
<T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> action)

Fields & Constants (1)

NULL

Code Graph: Dependencies (2)

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

Full Source

ContainerLevelAccess.java39 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.inventory;
2
3
import java.util.Optional;
4
import java.util.function.BiConsumer;
5
import java.util.function.BiFunction;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.world.level.Level;
8
9
public interface ContainerLevelAccess {
10
	ContainerLevelAccess NULL = new ContainerLevelAccess() {
11
		@Override
12
		public <T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> action) {
13
			return Optional.empty();
14
		}
15
	};
16
17
	static ContainerLevelAccess create(final Level level, final BlockPos pos) {
18
		return new ContainerLevelAccess() {
19
			@Override
20
			public <T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> action) {
21
				return Optional.of(action.apply(level, pos));
22
			}
23
		};
24
	}
25
26
	<T> Optional<T> evaluate(BiFunction<Level, BlockPos, T> action);
27
28
	default <T> T evaluate(final BiFunction<Level, BlockPos, T> action, final T defaultValue) {
29
		return this.evaluate(action).orElse(defaultValue);
30
	}
31
32
	default void execute(final BiConsumer<Level, BlockPos> action) {
33
		this.evaluate((level, pos) -> {
34
			action.accept(level, pos);
35
			return Optional.empty();
36
		});
37
	}
38
}
39

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