| 1 | package net.minecraft.server.level;
|
| 2 |
|
| 3 | import com.mojang.logging.LogUtils;
|
| 4 | import java.util.Collections;
|
| 5 | import java.util.List;
|
| 6 | import java.util.Locale;
|
| 7 | import java.util.concurrent.atomic.AtomicLong;
|
| 8 | import java.util.function.Predicate;
|
| 9 | import java.util.function.Supplier;
|
| 10 | import net.minecraft.CrashReport;
|
| 11 | import net.minecraft.CrashReportCategory;
|
| 12 | import net.minecraft.ReportedException;
|
| 13 | import net.minecraft.core.BlockPos;
|
| 14 | import net.minecraft.core.Holder;
|
| 15 | import net.minecraft.core.RegistryAccess;
|
| 16 | import net.minecraft.core.SectionPos;
|
| 17 | import net.minecraft.core.particles.ParticleOptions;
|
| 18 | import net.minecraft.nbt.CompoundTag;
|
| 19 | import net.minecraft.resources.Identifier;
|
| 20 | import net.minecraft.server.MinecraftServer;
|
| 21 | import net.minecraft.sounds.SoundEvent;
|
| 22 | import net.minecraft.sounds.SoundSource;
|
| 23 | import net.minecraft.util.RandomSource;
|
| 24 | import net.minecraft.util.StaticCache2D;
|
| 25 | import net.minecraft.util.Util;
|
| 26 | import net.minecraft.world.DifficultyInstance;
|
| 27 | import net.minecraft.world.attribute.EnvironmentAttributeReader;
|
| 28 | import net.minecraft.world.attribute.EnvironmentAttributeSystem;
|
| 29 | import net.minecraft.world.entity.Entity;
|
| 30 | import net.minecraft.world.entity.player.Player;
|
| 31 | import net.minecraft.world.flag.FeatureFlagSet;
|
| 32 | import net.minecraft.world.level.ChunkPos;
|
| 33 | import net.minecraft.world.level.LevelHeightAccessor;
|
| 34 | import net.minecraft.world.level.WorldGenLevel;
|
| 35 | import net.minecraft.world.level.biome.Biome;
|
| 36 | import net.minecraft.world.level.biome.BiomeManager;
|
| 37 | import net.minecraft.world.level.biome.BiomeResolver;
|
| 38 | import net.minecraft.world.level.block.Block;
|
| 39 | import net.minecraft.world.level.block.Blocks;
|
| 40 | import net.minecraft.world.level.block.EntityBlock;
|
| 41 | import net.minecraft.world.level.block.LevelEvent;
|
| 42 | import net.minecraft.world.level.block.entity.BlockEntity;
|
| 43 | import net.minecraft.world.level.block.state.BlockState;
|
| 44 | import net.minecraft.world.level.blockscan.BlockMatcher;
|
| 45 | import net.minecraft.world.level.border.WorldBorder;
|
| 46 | import net.minecraft.world.level.chunk.ChunkAccess;
|
| 47 | import net.minecraft.world.level.chunk.ChunkSource;
|
| 48 | import net.minecraft.world.level.chunk.status.ChunkStatus;
|
| 49 | import net.minecraft.world.level.chunk.status.ChunkStep;
|
| 50 | import net.minecraft.world.level.chunk.status.ChunkType;
|
| 51 | import net.minecraft.world.level.dimension.DimensionType;
|
| 52 | import net.minecraft.world.level.entity.EntityTypeTest;
|
| 53 | import net.minecraft.world.level.gameevent.GameEvent;
|
| 54 | import net.minecraft.world.level.levelgen.Heightmap;
|
| 55 | import net.minecraft.world.level.levelgen.RandomState;
|
| 56 | import net.minecraft.world.level.lighting.LevelLightEngine;
|
| 57 | import net.minecraft.world.level.material.Fluid;
|
| 58 | import net.minecraft.world.level.material.FluidState;
|
| 59 | import net.minecraft.world.level.storage.LevelData;
|
| 60 | import net.minecraft.world.phys.AABB;
|
| 61 | import net.minecraft.world.phys.Vec3;
|
| 62 | import net.minecraft.world.ticks.LevelTickAccess;
|
| 63 | import net.minecraft.world.ticks.WorldGenTickAccess;
|
| 64 | import org.jspecify.annotations.Nullable;
|
| 65 | import org.slf4j.Logger;
|
| 66 |
|
| 67 | public class WorldGenRegion implements WorldGenLevel {
|
| 68 | private static final Logger LOGGER = LogUtils.getLogger();
|
| 69 | private static final Identifier WORLDGEN_REGION_RANDOM = Identifier.withDefaultNamespace("worldgen_region_random");
|
| 70 | private final StaticCache2D<@Nullable ChunkAccess> cache;
|
| 71 | private final ChunkAccess center;
|
| 72 | private final ServerLevel level;
|
| 73 | private final long seed;
|
| 74 | private final LevelData levelData;
|
| 75 | private final RandomSource random;
|
| 76 | private final DimensionType dimensionType;
|
| 77 | private final WorldGenTickAccess<Block> blockTicks = new WorldGenTickAccess<>(pos -> this.getChunk(pos).getBlockTicks());
|
| 78 | private final WorldGenTickAccess<Fluid> fluidTicks = new WorldGenTickAccess<>(pos -> this.getChunk(pos).getFluidTicks());
|
| 79 | private final BiomeManager biomeManager;
|
| 80 | private final ChunkStep generatingStep;
|
| 81 | private @Nullable Supplier<String> currentlyGenerating;
|
| 82 | private final AtomicLong subTickCount = new AtomicLong();
|
| 83 | private final EnvironmentAttributeSystem environmentAttributes;
|
| 84 | private final BiomeResolver uncachedBiomeResolver;
|
| 85 | private final int centerChunkX;
|
| 86 | private final int centerChunkZ;
|
| 87 | private final int writeRadius;
|
| 88 |
|
| 89 | public WorldGenRegion(final ServerLevel level, final StaticCache2D<GenerationChunkHolder> cache, final ChunkStep generatingStep, final ChunkAccess center) {
|
| 90 | this.generatingStep = generatingStep;
|
| 91 | this.cache = cache.map((holder, x, z) -> {
|
| 92 | int distance = center.getPos().getChessboardDistance(x, z);
|
| 93 | ChunkStatus maxAllowedStatus = distance >= generatingStep.directDependencies().size() ? null : generatingStep.directDependencies().get(distance);
|
| 94 | return maxAllowedStatus == null ? null : holder.getChunkIfPresentUnchecked(maxAllowedStatus);
|
| 95 | });
|
| 96 | this.center = center;
|
| 97 | this.level = level;
|
| 98 | this.seed = level.getSeed();
|
| 99 | this.levelData = level.getLevelData();
|
| 100 | RandomState randomState = level.getChunkSource().randomState();
|
| 101 | this.random = randomState.getOrCreateRandomFactory(WORLDGEN_REGION_RANDOM).at(this.center.getPos().getWorldPosition());
|
| 102 | this.dimensionType = level.dimensionType();
|
| 103 | this.uncachedBiomeResolver = level.uncachedBiomeResolver();
|
| 104 | this.biomeManager = new BiomeManager(this, BiomeManager.obfuscateSeed(this.seed));
|
| 105 | ChunkPos centerPos = center.getPos();
|
| 106 | this.centerChunkX = centerPos.x();
|
| 107 | this.centerChunkZ = centerPos.z();
|
| 108 | this.writeRadius = generatingStep.blockStateWriteRadius();
|
| 109 | this.environmentAttributes = EnvironmentAttributeSystem.builder().addStaticLayers(this).build();
|
| 110 | }
|
| 111 |
|
| 112 | public boolean isOldChunkAround(final ChunkPos pos, final int range) {
|
| 113 | return this.level.getChunkSource().chunkMap.isOldChunkAround(pos, range);
|
| 114 | }
|
| 115 |
|
| 116 | public ChunkPos getCenter() {
|
| 117 | return this.center.getPos();
|
| 118 | }
|
| 119 |
|
| 120 | @Override
|
| 121 | public void setCurrentlyGenerating(final @Nullable Supplier<String> currentlyGenerating) {
|
| 122 | this.currentlyGenerating = currentlyGenerating;
|
| 123 | }
|
| 124 |
|
| 125 | @Override
|
| 126 | public ChunkAccess getChunk(final int chunkX, final int chunkZ) {
|
| 127 | return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY);
|
| 128 | }
|
| 129 |
|
| 130 | @Override
|
| 131 | public @Nullable ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatus targetStatus, final boolean loadOrGenerate) {
|
| 132 | int distance = this.center.getPos().getChessboardDistance(chunkX, chunkZ);
|
| 133 | ChunkStatus maxAllowedStatus = distance >= this.generatingStep.directDependencies().size() ? null : this.generatingStep.directDependencies().get(distance);
|
| 134 | ChunkAccess chunk;
|
| 135 | if (maxAllowedStatus != null) {
|
| 136 | chunk = this.cache.get(chunkX, chunkZ);
|
| 137 | if (chunk != null && targetStatus.isOrBefore(maxAllowedStatus)) {
|
| 138 | return chunk;
|
| 139 | }
|
| 140 | } else {
|
| 141 | chunk = null;
|
| 142 | }
|
| 143 |
|
| 144 | CrashReport report = CrashReport.forThrowable(
|
| 145 | new IllegalStateException("Requested chunk unavailable during world generation"), "Exception generating new chunk"
|
| 146 | );
|
| 147 | CrashReportCategory category = report.addCategory("Chunk request details");
|
| 148 | category.setDetail("Requested chunk", String.format(Locale.ROOT, "%d, %d", chunkX, chunkZ));
|
| 149 | category.setDetail("Generating status", () -> this.generatingStep.targetStatus().getName());
|
| 150 | category.setDetail("Requested status", targetStatus::getName);
|
| 151 | category.setDetail("Actual status", () -> chunk == null ? "[out of cache bounds]" : chunk.getPersistedStatus().getName());
|
| 152 | category.setDetail("Maximum allowed status", () -> maxAllowedStatus == null ? "null" : maxAllowedStatus.getName());
|
| 153 | category.setDetail("Dependencies", this.generatingStep.directDependencies()::toString);
|
| 154 | category.setDetail("Requested distance", distance);
|
| 155 | category.setDetail("Generating chunk", this.center.getPos()::toString);
|
| 156 | throw new ReportedException(report);
|
| 157 | }
|
| 158 |
|
| 159 | @Override
|
| 160 | public boolean hasChunk(final int chunkX, final int chunkZ) {
|
| 161 | int distance = this.center.getPos().getChessboardDistance(chunkX, chunkZ);
|
| 162 | return distance < this.generatingStep.directDependencies().size();
|
| 163 | }
|
| 164 |
|
| 165 | @Override
|
| 166 | public BlockState getBlockState(final BlockPos pos) {
|
| 167 | int chunkX = SectionPos.blockToSectionCoord(pos.getX());
|
| 168 | int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
|
| 169 | this.warnIfReadOutsideWriteZone(chunkX, chunkZ);
|
| 170 | return this.getChunk(chunkX, chunkZ).getBlockState(pos);
|
| 171 | }
|
| 172 |
|
| 173 | @Override
|
| 174 | public FluidState getFluidState(final BlockPos pos) {
|
| 175 | int chunkX = SectionPos.blockToSectionCoord(pos.getX());
|
| 176 | int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
|
| 177 | this.warnIfReadOutsideWriteZone(chunkX, chunkZ);
|
| 178 | return this.getChunk(chunkX, chunkZ).getFluidState(pos);
|
| 179 | }
|
| 180 |
|
| 181 | @Override
|
| 182 | public @Nullable Player getNearestPlayer(final double x, final double y, final double z, final double maxDist, final @Nullable Predicate<Entity> predicate) {
|
| 183 | return null;
|
| 184 | }
|
| 185 |
|
| 186 | @Override
|
| 187 | public int getSkyDarken() {
|
| 188 | return 0;
|
| 189 | }
|
| 190 |
|
| 191 | @Override
|
| 192 | public BiomeManager getBiomeManager() {
|
| 193 | return this.biomeManager;
|
| 194 | }
|
| 195 |
|
| 196 | @Override
|
| 197 | public Holder<Biome> getUncachedNoiseBiome(final int quartX, final int quartY, final int quartZ) {
|
| 198 | return this.uncachedBiomeResolver.getNoiseBiome(quartX, quartY, quartZ);
|
| 199 | }
|
| 200 |
|
| 201 | @Override
|
| 202 | public LevelLightEngine getLightEngine() {
|
| 203 | return this.level.getLightEngine();
|
| 204 | }
|
| 205 |
|
| 206 | @Override
|
| 207 | public boolean destroyBlock(final BlockPos pos, final boolean dropResources, final @Nullable Entity breaker, final int updateLimit) {
|
| 208 | BlockState blockState = this.getBlockState(pos);
|
| 209 | return blockState.isAir() ? false : this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, updateLimit);
|
| 210 | }
|
| 211 |
|
| 212 | @Override
|
| 213 | public @Nullable BlockEntity getBlockEntity(final BlockPos pos) {
|
| 214 | ChunkAccess chunk = this.getChunk(pos);
|
| 215 | BlockEntity blockEntity = chunk.getBlockEntity(pos);
|
| 216 | if (blockEntity != null) {
|
| 217 | return blockEntity;
|
| 218 | }
|
| 219 |
|
| 220 | CompoundTag tag = chunk.getBlockEntityNbt(pos);
|
| 221 | BlockState state = chunk.getBlockState(pos);
|
| 222 | if (tag != null) {
|
| 223 | if ("DUMMY".equals(tag.getStringOr("id", ""))) {
|
| 224 | if (!state.hasBlockEntity()) {
|
| 225 | return null;
|
| 226 | }
|
| 227 |
|
| 228 | blockEntity = ((EntityBlock)state.getBlock()).newBlockEntity(pos, state);
|
| 229 | } else {
|
| 230 | blockEntity = BlockEntity.loadStatic(pos, state, tag, this.level.registryAccess());
|
| 231 | }
|
| 232 |
|
| 233 | if (blockEntity != null) {
|
| 234 | chunk.setBlockEntity(blockEntity);
|
| 235 | return blockEntity;
|
| 236 | }
|
| 237 | }
|
| 238 |
|
| 239 | if (state.hasBlockEntity()) {
|
| 240 | LOGGER.warn("Tried to access a block entity before it was created. {}", pos);
|
| 241 | }
|
| 242 |
|
| 243 | return null;
|
| 244 | }
|
| 245 |
|
| 246 | private void warnIfReadOutsideWriteZone(final int chunkX, final int chunkZ) {
|
| 247 | if (this.centerChunkX != chunkX || this.centerChunkZ != chunkZ) {
|
| 248 | if (!this.isWithinWriteZone(chunkX, chunkZ)) {
|
| 249 | int readDistance = Math.max(Math.abs(this.centerChunkX - chunkX), Math.abs(this.centerChunkZ - chunkZ));
|
| 250 | String warning = "Detected unsafe terrain read during worldgen: reading from chunk ["
|
| 251 | + chunkX
|
| 252 | + ", "
|
| 253 | + chunkZ
|
| 254 | + "] while generating chunk ["
|
| 255 | + this.centerChunkX
|
| 256 | + ", "
|
| 257 | + this.centerChunkZ
|
| 258 | + "] (distance: "
|
| 259 | + readDistance
|
| 260 | + ", write radius: "
|
| 261 | + this.writeRadius
|
| 262 | + "), step: "
|
| 263 | + this.generatingStep.targetStatus().getName()
|
| 264 | + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get());
|
| 265 | Util.logAndPauseIfInIde(warning);
|
| 266 | }
|
| 267 | }
|
| 268 | }
|
| 269 |
|
| 270 | @Override
|
| 271 | public BlockMatcher findBlocksIn(final BlockPos from, final BlockPos to) {
|
| 272 | int fromChunkX = SectionPos.blockToSectionCoord(from.getX());
|
| 273 | int fromChunkZ = SectionPos.blockToSectionCoord(from.getZ());
|
| 274 | int toChunkX = SectionPos.blockToSectionCoord(to.getX());
|
| 275 | int toChunkZ = SectionPos.blockToSectionCoord(to.getZ());
|
| 276 |
|
| 277 | for (int chunkZ = fromChunkZ; chunkZ <= toChunkZ; chunkZ++) {
|
| 278 | for (int chunkX = fromChunkX; chunkX <= toChunkX; chunkX++) {
|
| 279 | this.warnIfReadOutsideWriteZone(chunkX, chunkZ);
|
| 280 | }
|
| 281 | }
|
| 282 |
|
| 283 | return WorldGenLevel.super.findBlocksIn(from, to);
|
| 284 | }
|
| 285 |
|
| 286 | public boolean isWithinWriteZone(final BlockPos pos) {
|
| 287 | int chunkX = SectionPos.blockToSectionCoord(pos.getX());
|
| 288 | int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
|
| 289 | return this.isWithinWriteZone(chunkX, chunkZ);
|
| 290 | }
|
| 291 |
|
| 292 | private boolean isWithinWriteZone(final int chunkX, final int chunkZ) {
|
| 293 | return Math.abs(this.centerChunkX - chunkX) <= this.writeRadius && Math.abs(this.centerChunkZ - chunkZ) <= this.writeRadius;
|
| 294 | }
|
| 295 |
|
| 296 | @Override
|
| 297 | public boolean ensureCanWrite(final BlockPos pos) {
|
| 298 | if (!this.isWithinWriteZone(pos)) {
|
| 299 | int chunkX = SectionPos.blockToSectionCoord(pos.getX());
|
| 300 | int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
|
| 301 | Util.logAndPauseIfInIde(
|
| 302 | "Detected setBlock in a far chunk ["
|
| 303 | + chunkX
|
| 304 | + ", "
|
| 305 | + chunkZ
|
| 306 | + "], pos: "
|
| 307 | + pos
|
| 308 | + ", status: "
|
| 309 | + this.generatingStep.targetStatus()
|
| 310 | + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get())
|
| 311 | );
|
| 312 | return false;
|
| 313 | } else if (this.center.isUpgrading()) {
|
| 314 | LevelHeightAccessor levelHeightAccessor = this.center.getHeightAccessorForGeneration();
|
| 315 | return !levelHeightAccessor.isOutsideBuildHeight(pos.getY());
|
| 316 | } else {
|
| 317 | return true;
|
| 318 | }
|
| 319 | }
|
| 320 |
|
| 321 | @Override
|
| 322 | public boolean setBlock(final BlockPos pos, final BlockState blockState, final @Block.UpdateFlags int updateFlags, final int updateLimit) {
|
| 323 | if (!this.ensureCanWrite(pos)) {
|
| 324 | return false;
|
| 325 | }
|
| 326 |
|
| 327 | ChunkAccess chunk = this.getChunk(pos);
|
| 328 | BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags);
|
| 329 | if (oldState != null) {
|
| 330 | this.level.updatePOIOnBlockStateChange(pos, oldState, blockState);
|
| 331 | }
|
| 332 |
|
| 333 | if (blockState.hasBlockEntity()) {
|
| 334 | if (chunk.getPersistedStatus().getChunkType() == ChunkType.LEVELCHUNK) {
|
| 335 | BlockEntity blockEntity = ((EntityBlock)blockState.getBlock()).newBlockEntity(pos, blockState);
|
| 336 | if (blockEntity != null) {
|
| 337 | chunk.setBlockEntity(blockEntity);
|
| 338 | } else {
|
| 339 | chunk.removeBlockEntity(pos);
|
| 340 | }
|
| 341 | } else {
|
| 342 | CompoundTag tag = new CompoundTag();
|
| 343 | tag.putInt("x", pos.getX());
|
| 344 | tag.putInt("y", pos.getY());
|
| 345 | tag.putInt("z", pos.getZ());
|
| 346 | tag.putString("id", "DUMMY");
|
| 347 | chunk.setBlockEntityNbt(tag);
|
| 348 | }
|
| 349 | } else if (oldState != null && oldState.hasBlockEntity()) {
|
| 350 | chunk.removeBlockEntity(pos);
|
| 351 | }
|
| 352 |
|
| 353 | if ((updateFlags & 16) == 0) {
|
| 354 | BlockPos postProcessPos = blockState.getPostProcessPos(this, pos);
|
| 355 | if (postProcessPos != null) {
|
| 356 | this.markPosForPostProcessing(postProcessPos);
|
| 357 | }
|
| 358 | }
|
| 359 |
|
| 360 | return true;
|
| 361 | }
|
| 362 |
|
| 363 | private void markPosForPostProcessing(final BlockPos blockPos) {
|
| 364 | this.getChunk(blockPos).markPosForPostProcessing(blockPos);
|
| 365 | }
|
| 366 |
|
| 367 | @Override
|
| 368 | public boolean addFreshEntity(final Entity entity) {
|
| 369 | int xc = SectionPos.blockToSectionCoord(entity.getBlockX());
|
| 370 | int zc = SectionPos.blockToSectionCoord(entity.getBlockZ());
|
| 371 | this.getChunk(xc, zc).addEntity(entity);
|
| 372 | return true;
|
| 373 | }
|
| 374 |
|
| 375 | @Override
|
| 376 | public boolean removeBlock(final BlockPos pos, final boolean movedByPiston) {
|
| 377 | return this.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
| 378 | }
|
| 379 |
|
| 380 | @Override
|
| 381 | public WorldBorder getWorldBorder() {
|
| 382 | return this.level.getWorldBorder();
|
| 383 | }
|
| 384 |
|
| 385 | @Override
|
| 386 | public boolean isClientSide() {
|
| 387 | return false;
|
| 388 | }
|
| 389 |
|
| 390 | @Deprecated
|
| 391 | @Override
|
| 392 | public ServerLevel getLevel() {
|
| 393 | return this.level;
|
| 394 | }
|
| 395 |
|
| 396 | @Override
|
| 397 | public RegistryAccess registryAccess() {
|
| 398 | return this.level.registryAccess();
|
| 399 | }
|
| 400 |
|
| 401 | @Override
|
| 402 | public FeatureFlagSet enabledFeatures() {
|
| 403 | return this.level.enabledFeatures();
|
| 404 | }
|
| 405 |
|
| 406 | @Override
|
| 407 | public LevelData getLevelData() {
|
| 408 | return this.levelData;
|
| 409 | }
|
| 410 |
|
| 411 | @Override
|
| 412 | public DifficultyInstance getCurrentDifficultyAt(final BlockPos pos) {
|
| 413 | if (!this.hasChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()))) {
|
| 414 | throw new RuntimeException("We are asking a region for a chunk out of bound");
|
| 415 | } else {
|
| 416 | return new DifficultyInstance(this.level.getDifficulty(), this.level.getOverworldClockTime(), 0L, this.level.getMoonBrightness(pos));
|
| 417 | }
|
| 418 | }
|
| 419 |
|
| 420 | @Override
|
| 421 | public @Nullable MinecraftServer getServer() {
|
| 422 | return this.level.getServer();
|
| 423 | }
|
| 424 |
|
| 425 | @Override
|
| 426 | public ChunkSource getChunkSource() {
|
| 427 | return this.level.getChunkSource();
|
| 428 | }
|
| 429 |
|
| 430 | @Override
|
| 431 | public long getSeed() {
|
| 432 | return this.seed;
|
| 433 | }
|
| 434 |
|
| 435 | @Override
|
| 436 | public LevelTickAccess<Block> getBlockTicks() {
|
| 437 | return this.blockTicks;
|
| 438 | }
|
| 439 |
|
| 440 | @Override
|
| 441 | public LevelTickAccess<Fluid> getFluidTicks() {
|
| 442 | return this.fluidTicks;
|
| 443 | }
|
| 444 |
|
| 445 | @Override
|
| 446 | public int getSeaLevel() {
|
| 447 | return this.level.getSeaLevel();
|
| 448 | }
|
| 449 |
|
| 450 | @Override
|
| 451 | public RandomSource getRandom() {
|
| 452 | return this.random;
|
| 453 | }
|
| 454 |
|
| 455 | @Override
|
| 456 | public int getHeight(final Heightmap.Types type, final int x, final int z) {
|
| 457 | int chunkX = SectionPos.blockToSectionCoord(x);
|
| 458 | int chunkZ = SectionPos.blockToSectionCoord(z);
|
| 459 | this.warnIfReadOutsideWriteZone(chunkX, chunkZ);
|
| 460 | return this.getChunk(chunkX, chunkZ).getHeight(type, x & 15, z & 15) + 1;
|
| 461 | }
|
| 462 |
|
| 463 | @Override
|
| 464 | public void playSound(
|
| 465 | final @Nullable Entity except, final BlockPos pos, final SoundEvent sound, final SoundSource source, final float volume, final float pitch
|
| 466 | ) {
|
| 467 | }
|
| 468 |
|
| 469 | @Override
|
| 470 | public void addParticle(final ParticleOptions particle, final double x, final double y, final double z, final double xd, final double yd, final double zd) {
|
| 471 | }
|
| 472 |
|
| 473 | @Override
|
| 474 | public void levelEvent(final @Nullable Entity source, final @LevelEvent.Value int type, final BlockPos pos, final int data) {
|
| 475 | }
|
| 476 |
|
| 477 | @Override
|
| 478 | public void gameEvent(final Holder<GameEvent> gameEvent, final Vec3 position, final GameEvent.Context context) {
|
| 479 | }
|
| 480 |
|
| 481 | @Override
|
| 482 | public DimensionType dimensionType() {
|
| 483 | return this.dimensionType;
|
| 484 | }
|
| 485 |
|
| 486 | @Override
|
| 487 | public boolean isStateAtPosition(final BlockPos pos, final Predicate<BlockState> predicate) {
|
| 488 | return predicate.test(this.getBlockState(pos));
|
| 489 | }
|
| 490 |
|
| 491 | @Override
|
| 492 | public boolean isFluidAtPosition(final BlockPos pos, final Predicate<FluidState> predicate) {
|
| 493 | return predicate.test(this.getFluidState(pos));
|
| 494 | }
|
| 495 |
|
| 496 | @Override
|
| 497 | public <T extends Entity> List<T> getEntities(final EntityTypeTest<Entity, T> type, final AABB bb, final Predicate<? super T> selector) {
|
| 498 | return Collections.emptyList();
|
| 499 | }
|
| 500 |
|
| 501 | @Override
|
| 502 | public List<Entity> getEntities(final @Nullable Entity except, final AABB bb, final @Nullable Predicate<? super Entity> selector) {
|
| 503 | return Collections.emptyList();
|
| 504 | }
|
| 505 |
|
| 506 | @Override
|
| 507 | public List<Player> players() {
|
| 508 | return Collections.emptyList();
|
| 509 | }
|
| 510 |
|
| 511 | @Override
|
| 512 | public int getMinY() {
|
| 513 | return this.level.getMinY();
|
| 514 | }
|
| 515 |
|
| 516 | @Override
|
| 517 | public int getHeight() {
|
| 518 | return this.level.getHeight();
|
| 519 | }
|
| 520 |
|
| 521 | @Override
|
| 522 | public long nextSubTickCount() {
|
| 523 | return this.subTickCount.getAndIncrement();
|
| 524 | }
|
| 525 |
|
| 526 | @Override
|
| 527 | public EnvironmentAttributeReader environmentAttributes() {
|
| 528 | return this.environmentAttributes;
|
| 529 | }
|
| 530 | }
|
| 531 |
|