LevelAccessor .java

net.minecraft.world.level.LevelAccessor (interface): members: neighborShapeChanged, createTick, updateNeighborsAt, nextSubTickCount, getChunkSource, pos.

net.minecraft.world.levelinterface107 linescommonextends CommonLevelAccessor4.1 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (5)

direction
pos
neighborPos
neighborState
updateFlags

Full Source

LevelAccessor.java107 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.core.Direction;
5
import net.minecraft.core.Holder;
6
import net.minecraft.core.particles.ParticleOptions;
7
import net.minecraft.core.registries.Registries;
8
import net.minecraft.resources.ResourceKey;
9
import net.minecraft.server.MinecraftServer;
10
import net.minecraft.sounds.SoundEvent;
11
import net.minecraft.sounds.SoundSource;
12
import net.minecraft.util.RandomSource;
13
import net.minecraft.world.Difficulty;
14
import net.minecraft.world.entity.Entity;
15
import net.minecraft.world.level.block.Block;
16
import net.minecraft.world.level.block.LevelEvent;
17
import net.minecraft.world.level.block.state.BlockState;
18
import net.minecraft.world.level.chunk.ChunkSource;
19
import net.minecraft.world.level.gameevent.GameEvent;
20
import net.minecraft.world.level.redstone.NeighborUpdater;
21
import net.minecraft.world.level.storage.LevelData;
22
import net.minecraft.world.phys.Vec3;
23
import net.minecraft.world.ticks.ScheduledTick;
24
import net.minecraft.world.ticks.TickPriority;
25
import org.jspecify.annotations.Nullable;
26
27
public interface LevelAccessor extends CommonLevelAccessor, ScheduledTickAccess {
28
	long nextSubTickCount();
29
30
	@Override
31
	default <T> ScheduledTick<T> createTick(final BlockPos pos, final T type, final int tickDelay, final TickPriority priority) {
32
		return new ScheduledTick<>(type, pos, this.getGameTime() + tickDelay, priority, this.nextSubTickCount());
33
	}
34
35
	@Override
36
	default <T> ScheduledTick<T> createTick(final BlockPos pos, final T type, final int tickDelay) {
37
		return new ScheduledTick<>(type, pos, this.getGameTime() + tickDelay, this.nextSubTickCount());
38
	}
39
40
	LevelData getLevelData();
41
42
	default long getGameTime() {
43
		return this.getLevelData().getGameTime();
44
	}
45
46
	@Nullable MinecraftServer getServer();
47
48
	default Difficulty getDifficulty() {
49
		return this.getLevelData().getDifficulty();
50
	}
51
52
	ChunkSource getChunkSource();
53
54
	@Override
55
	default boolean hasChunk(final int chunkX, final int chunkZ) {
56
		return this.getChunkSource().hasChunk(chunkX, chunkZ);
57
	}
58
59
	RandomSource getRandom();
60
61
	default void updateNeighborsAt(final BlockPos pos, final Block sourceBlock) {
62
	}
63
64
	default void neighborShapeChanged(
65
		final Direction direction,
66
		final BlockPos pos,
67
		final BlockPos neighborPos,
68
		final BlockState neighborState,
69
		final @Block.UpdateFlags int updateFlags,
70
		final int updateLimit
71
	) {
72
		NeighborUpdater.executeShapeUpdate(this, direction, pos, neighborPos, neighborState, updateFlags, updateLimit - 1);
73
	}
74
75
	default void playSound(final @Nullable Entity except, final BlockPos pos, final SoundEvent soundEvent, final SoundSource source) {
76
		this.playSound(except, pos, soundEvent, source, 1.0F, 1.0F);
77
	}
78
79
	void playSound(final @Nullable Entity except, final BlockPos pos, final SoundEvent sound, final SoundSource source, final float volume, final float pitch);
80
81
	void addParticle(final ParticleOptions particle, final double x, final double y, final double z, final double xd, final double yd, final double zd);
82
83
	void levelEvent(final @Nullable Entity source, final @LevelEvent.Value int type, final BlockPos pos, final int data);
84
85
	default void levelEvent(final @LevelEvent.Value int type, final BlockPos pos, final int data) {
86
		this.levelEvent(null, type, pos, data);
87
	}
88
89
	void gameEvent(Holder<GameEvent> gameEvent, Vec3 position, GameEvent.Context context);
90
91
	default void gameEvent(final @Nullable Entity sourceEntity, final Holder<GameEvent> gameEvent, final Vec3 pos) {
92
		this.gameEvent(gameEvent, pos, new GameEvent.Context(sourceEntity, null));
93
	}
94
95
	default void gameEvent(final @Nullable Entity sourceEntity, final Holder<GameEvent> gameEvent, final BlockPos pos) {
96
		this.gameEvent(gameEvent, pos, new GameEvent.Context(sourceEntity, null));
97
	}
98
99
	default void gameEvent(final Holder<GameEvent> gameEvent, final BlockPos pos, final GameEvent.Context context) {
100
		this.gameEvent(gameEvent, Vec3.atCenterOf(pos), context);
101
	}
102
103
	default void gameEvent(final ResourceKey<GameEvent> gameEvent, final BlockPos pos, final GameEvent.Context context) {
104
		this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context);
105
	}
106
}
107

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