Minestom/src/main/java/net/minestom/server/snapshot/InstanceSnapshot.java
TheMode fdd3e2c53c Seal snapshot interfaces
Signed-off-by: TheMode <themode@outlook.fr>
2022-05-04 13:25:24 +02:00

49 lines
1.6 KiB
Java

package net.minestom.server.snapshot;
import net.minestom.server.coordinate.Point;
import net.minestom.server.instance.block.Block;
import net.minestom.server.tag.TagReadable;
import net.minestom.server.world.DimensionType;
import net.minestom.server.world.biomes.Biome;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
import java.util.Collection;
import java.util.Objects;
import static net.minestom.server.utils.chunk.ChunkUtils.getChunkCoordinate;
public sealed interface InstanceSnapshot extends Snapshot, Block.Getter, Biome.Getter, TagReadable
permits SnapshotImpl.Instance {
@NotNull DimensionType dimensionType();
long worldAge();
long time();
@Override
default @UnknownNullability Block getBlock(int x, int y, int z, @NotNull Condition condition) {
ChunkSnapshot chunk = chunk(getChunkCoordinate(x), getChunkCoordinate(z));
return Objects.requireNonNull(chunk).getBlock(x, y, z, condition);
}
@Override
default @NotNull Biome getBiome(int x, int y, int z) {
ChunkSnapshot chunk = chunk(getChunkCoordinate(x), getChunkCoordinate(z));
return Objects.requireNonNull(chunk).getBiome(x, y, z);
}
@Nullable ChunkSnapshot chunk(int chunkX, int chunkZ);
default @Nullable ChunkSnapshot chunkAt(@NotNull Point point) {
return chunk(point.chunkX(), point.chunkZ());
}
@NotNull Collection<@NotNull ChunkSnapshot> chunks();
@NotNull Collection<@NotNull EntitySnapshot> entities();
@NotNull ServerSnapshot server();
}