WorldGenRegion.java

net.minecraft.server.level.WorldGenRegion

信息

  • 全限定名:net.minecraft.server.level.WorldGenRegion
  • 类型:public class
  • 包:net.minecraft.server.level
  • 源码路径:src/main/java/net/minecraft/server/level/WorldGenRegion.java
  • 起始行号:L62
  • 实现:WorldGenLevel
  • 职责:

    TODO

字段/常量

  • LOGGER

    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L63
    • 说明:

      TODO

  • cache

    • 类型: StaticCache2D<GenerationChunkHolder>
    • 修饰符: private final
    • 源码定位: L64
    • 说明:

      TODO

  • center

    • 类型: ChunkAccess
    • 修饰符: private final
    • 源码定位: L65
    • 说明:

      TODO

  • level

    • 类型: ServerLevel
    • 修饰符: private final
    • 源码定位: L66
    • 说明:

      TODO

  • seed

    • 类型: long
    • 修饰符: private final
    • 源码定位: L67
    • 说明:

      TODO

  • levelData

    • 类型: LevelData
    • 修饰符: private final
    • 源码定位: L68
    • 说明:

      TODO

  • random

    • 类型: RandomSource
    • 修饰符: private final
    • 源码定位: L69
    • 说明:

      TODO

  • dimensionType

    • 类型: DimensionType
    • 修饰符: private final
    • 源码定位: L70
    • 说明:

      TODO

  • blockTicks

    • 类型: WorldGenTickAccess<Block>
    • 修饰符: private final
    • 源码定位: L71
    • 说明:

      TODO

  • fluidTicks

    • 类型: WorldGenTickAccess<Fluid>
    • 修饰符: private final
    • 源码定位: L72
    • 说明:

      TODO

  • biomeManager

    • 类型: BiomeManager
    • 修饰符: private final
    • 源码定位: L73
    • 说明:

      TODO

  • generatingStep

    • 类型: ChunkStep
    • 修饰符: private final
    • 源码定位: L74
    • 说明:

      TODO

  • currentlyGenerating

    • 类型: Supplier<String>
    • 修饰符: private
    • 源码定位: L75
    • 说明:

      TODO

  • subTickCount

    • 类型: AtomicLong
    • 修饰符: private final
    • 源码定位: L76
    • 说明:

      TODO

  • WORLDGEN_REGION_RANDOM

    • 类型: Identifier
    • 修饰符: private static final
    • 源码定位: L77
    • 说明:

      TODO

内部类/嵌套类型

构造器

public WorldGenRegion(ServerLevel level, StaticCache2D<GenerationChunkHolder> cache, ChunkStep generatingStep, ChunkAccess center) @ L79

  • 构造器名:WorldGenRegion
  • 源码定位:L79
  • 修饰符:public

参数:

  • level: ServerLevel
  • cache: StaticCache2D
  • generatingStep: ChunkStep
  • center: ChunkAccess

说明:

TODO

方法

下面的方法块按源码顺序生成。

public boolean isOldChunkAround(ChunkPos pos, int range) @ L91

  • 方法名:isOldChunkAround
  • 源码定位:L91
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: ChunkPos
  • range: int

说明:

TODO

public ChunkPos getCenter() @ L95

  • 方法名:getCenter
  • 源码定位:L95
  • 返回类型:ChunkPos
  • 修饰符:public

参数:

说明:

TODO

public void setCurrentlyGenerating(Supplier<String> currentlyGenerating) @ L99

  • 方法名:setCurrentlyGenerating
  • 源码定位:L99
  • 返回类型:void
  • 修饰符:public

参数:

  • currentlyGenerating: Supplier

说明:

TODO

public ChunkAccess getChunk(int chunkX, int chunkZ) @ L104

  • 方法名:getChunk
  • 源码定位:L104
  • 返回类型:ChunkAccess
  • 修饰符:public

参数:

  • chunkX: int
  • chunkZ: int

说明:

TODO

public ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus targetStatus, boolean loadOrGenerate) @ L109

  • 方法名:getChunk
  • 源码定位:L109
  • 返回类型:ChunkAccess
  • 修饰符:public

参数:

  • chunkX: int
  • chunkZ: int
  • targetStatus: ChunkStatus
  • loadOrGenerate: boolean

说明:

TODO

public boolean hasChunk(int chunkX, int chunkZ) @ L143

  • 方法名:hasChunk
  • 源码定位:L143
  • 返回类型:boolean
  • 修饰符:public

参数:

  • chunkX: int
  • chunkZ: int

说明:

TODO

public BlockState getBlockState(BlockPos pos) @ L149

  • 方法名:getBlockState
  • 源码定位:L149
  • 返回类型:BlockState
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public FluidState getFluidState(BlockPos pos) @ L154

  • 方法名:getFluidState
  • 源码定位:L154
  • 返回类型:FluidState
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public Player getNearestPlayer(double x, double y, double z, double maxDist, Predicate<Entity> predicate) @ L159

  • 方法名:getNearestPlayer
  • 源码定位:L159
  • 返回类型:Player
  • 修饰符:public

参数:

  • x: double
  • y: double
  • z: double
  • maxDist: double
  • predicate: Predicate

说明:

TODO

public int getSkyDarken() @ L164

  • 方法名:getSkyDarken
  • 源码定位:L164
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public BiomeManager getBiomeManager() @ L169

  • 方法名:getBiomeManager
  • 源码定位:L169
  • 返回类型:BiomeManager
  • 修饰符:public

参数:

说明:

TODO

public Holder<Biome> getUncachedNoiseBiome(int quartX, int quartY, int quartZ) @ L174

  • 方法名:getUncachedNoiseBiome
  • 源码定位:L174
  • 返回类型:Holder
  • 修饰符:public

参数:

  • quartX: int
  • quartY: int
  • quartZ: int

说明:

TODO

public LevelLightEngine getLightEngine() @ L179

  • 方法名:getLightEngine
  • 源码定位:L179
  • 返回类型:LevelLightEngine
  • 修饰符:public

参数:

说明:

TODO

public boolean destroyBlock(BlockPos pos, boolean dropResources, Entity breaker, int updateLimit) @ L184

  • 方法名:destroyBlock
  • 源码定位:L184
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos
  • dropResources: boolean
  • breaker: Entity
  • updateLimit: int

说明:

TODO

public BlockEntity getBlockEntity(BlockPos pos) @ L190

  • 方法名:getBlockEntity
  • 源码定位:L190
  • 返回类型:BlockEntity
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public boolean ensureCanWrite(BlockPos pos) @ L224

  • 方法名:ensureCanWrite
  • 源码定位:L224
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public boolean setBlock(BlockPos pos, BlockState blockState, int updateFlags, int updateLimit) @ L256

  • 方法名:setBlock
  • 源码定位:L256
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos
  • blockState: BlockState
  • updateFlags: int
  • updateLimit: int

说明:

TODO

private void markPosForPostprocessing(BlockPos blockPos) @ L298

  • 方法名:markPosForPostprocessing
  • 源码定位:L298
  • 返回类型:void
  • 修饰符:private

参数:

  • blockPos: BlockPos

说明:

TODO

public boolean addFreshEntity(Entity entity) @ L302

  • 方法名:addFreshEntity
  • 源码定位:L302
  • 返回类型:boolean
  • 修饰符:public

参数:

  • entity: Entity

说明:

TODO

public boolean removeBlock(BlockPos pos, boolean movedByPiston) @ L310

  • 方法名:removeBlock
  • 源码定位:L310
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos
  • movedByPiston: boolean

说明:

TODO

public WorldBorder getWorldBorder() @ L315

  • 方法名:getWorldBorder
  • 源码定位:L315
  • 返回类型:WorldBorder
  • 修饰符:public

参数:

说明:

TODO

public boolean isClientSide() @ L320

  • 方法名:isClientSide
  • 源码定位:L320
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public ServerLevel getLevel() @ L325

  • 方法名:getLevel
  • 源码定位:L325
  • 返回类型:ServerLevel
  • 修饰符:public

参数:

说明:

TODO

public RegistryAccess registryAccess() @ L331

  • 方法名:registryAccess
  • 源码定位:L331
  • 返回类型:RegistryAccess
  • 修饰符:public

参数:

说明:

TODO

public FeatureFlagSet enabledFeatures() @ L336

  • 方法名:enabledFeatures
  • 源码定位:L336
  • 返回类型:FeatureFlagSet
  • 修饰符:public

参数:

说明:

TODO

public LevelData getLevelData() @ L341

  • 方法名:getLevelData
  • 源码定位:L341
  • 返回类型:LevelData
  • 修饰符:public

参数:

说明:

TODO

public DifficultyInstance getCurrentDifficultyAt(BlockPos pos) @ L346

  • 方法名:getCurrentDifficultyAt
  • 源码定位:L346
  • 返回类型:DifficultyInstance
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public MinecraftServer getServer() @ L355

  • 方法名:getServer
  • 源码定位:L355
  • 返回类型:MinecraftServer
  • 修饰符:public

参数:

说明:

TODO

public ChunkSource getChunkSource() @ L360

  • 方法名:getChunkSource
  • 源码定位:L360
  • 返回类型:ChunkSource
  • 修饰符:public

参数:

说明:

TODO

public long getSeed() @ L365

  • 方法名:getSeed
  • 源码定位:L365
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

public LevelTickAccess<Block> getBlockTicks() @ L370

  • 方法名:getBlockTicks
  • 源码定位:L370
  • 返回类型:LevelTickAccess
  • 修饰符:public

参数:

说明:

TODO

public LevelTickAccess<Fluid> getFluidTicks() @ L375

  • 方法名:getFluidTicks
  • 源码定位:L375
  • 返回类型:LevelTickAccess
  • 修饰符:public

参数:

说明:

TODO

public int getSeaLevel() @ L380

  • 方法名:getSeaLevel
  • 源码定位:L380
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public RandomSource getRandom() @ L385

  • 方法名:getRandom
  • 源码定位:L385
  • 返回类型:RandomSource
  • 修饰符:public

参数:

说明:

TODO

public int getHeight(Heightmap.Types type, int x, int z) @ L390

  • 方法名:getHeight
  • 源码定位:L390
  • 返回类型:int
  • 修饰符:public

参数:

  • type: Heightmap.Types
  • x: int
  • z: int

说明:

TODO

public void playSound(Entity except, BlockPos pos, SoundEvent sound, SoundSource source, float volume, float pitch) @ L395

  • 方法名:playSound
  • 源码定位:L395
  • 返回类型:void
  • 修饰符:public

参数:

  • except: Entity
  • pos: BlockPos
  • sound: SoundEvent
  • source: SoundSource
  • volume: float
  • pitch: float

说明:

TODO

public void addParticle(ParticleOptions particle, double x, double y, double z, double xd, double yd, double zd) @ L399

  • 方法名:addParticle
  • 源码定位:L399
  • 返回类型:void
  • 修饰符:public

参数:

  • particle: ParticleOptions
  • x: double
  • y: double
  • z: double
  • xd: double
  • yd: double
  • zd: double

说明:

TODO

public void levelEvent(Entity source, int type, BlockPos pos, int data) @ L403

  • 方法名:levelEvent
  • 源码定位:L403
  • 返回类型:void
  • 修饰符:public

参数:

  • source: Entity
  • type: int
  • pos: BlockPos
  • data: int

说明:

TODO

public void gameEvent(Holder<GameEvent> gameEvent, Vec3 position, GameEvent.Context context) @ L407

  • 方法名:gameEvent
  • 源码定位:L407
  • 返回类型:void
  • 修饰符:public

参数:

  • gameEvent: Holder
  • position: Vec3
  • context: GameEvent.Context

说明:

TODO

public DimensionType dimensionType() @ L411

  • 方法名:dimensionType
  • 源码定位:L411
  • 返回类型:DimensionType
  • 修饰符:public

参数:

说明:

TODO

public boolean isStateAtPosition(BlockPos pos, Predicate<BlockState> predicate) @ L416

  • 方法名:isStateAtPosition
  • 源码定位:L416
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos
  • predicate: Predicate

说明:

TODO

public boolean isFluidAtPosition(BlockPos pos, Predicate<FluidState> predicate) @ L421

  • 方法名:isFluidAtPosition
  • 源码定位:L421
  • 返回类型:boolean
  • 修饰符:public

参数:

  • pos: BlockPos
  • predicate: Predicate

说明:

TODO

public <T extends Entity> List<T> getEntities(EntityTypeTest<Entity,T> type, AABB bb, Predicate<?super T> selector) @ L426

  • 方法名:getEntities
  • 源码定位:L426
  • 返回类型: List
  • 修饰符:public

参数:

  • type: EntityTypeTest<Entity,T>
  • bb: AABB
  • selector: Predicate<?super T>

说明:

TODO

public List<Entity> getEntities(Entity except, AABB bb, Predicate<?super Entity> selector) @ L431

  • 方法名:getEntities
  • 源码定位:L431
  • 返回类型:List
  • 修饰符:public

参数:

  • except: Entity
  • bb: AABB
  • selector: Predicate<?super Entity>

说明:

TODO

public List<Player> players() @ L436

  • 方法名:players
  • 源码定位:L436
  • 返回类型:List
  • 修饰符:public

参数:

说明:

TODO

public int getMinY() @ L441

  • 方法名:getMinY
  • 源码定位:L441
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getHeight() @ L446

  • 方法名:getHeight
  • 源码定位:L446
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public long nextSubTickCount() @ L451

  • 方法名:nextSubTickCount
  • 源码定位:L451
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

public EnvironmentAttributeReader environmentAttributes() @ L456

  • 方法名:environmentAttributes
  • 源码定位:L456
  • 返回类型:EnvironmentAttributeReader
  • 修饰符:public

参数:

说明:

TODO

代码

public class WorldGenRegion implements WorldGenLevel {
    private static final Logger LOGGER = LogUtils.getLogger();
    private final StaticCache2D<GenerationChunkHolder> cache;
    private final ChunkAccess center;
    private final ServerLevel level;
    private final long seed;
    private final LevelData levelData;
    private final RandomSource random;
    private final DimensionType dimensionType;
    private final WorldGenTickAccess<Block> blockTicks = new WorldGenTickAccess<>(pos -> this.getChunk(pos).getBlockTicks());
    private final WorldGenTickAccess<Fluid> fluidTicks = new WorldGenTickAccess<>(pos -> this.getChunk(pos).getFluidTicks());
    private final BiomeManager biomeManager;
    private final ChunkStep generatingStep;
    private @Nullable Supplier<String> currentlyGenerating;
    private final AtomicLong subTickCount = new AtomicLong();
    private static final Identifier WORLDGEN_REGION_RANDOM = Identifier.withDefaultNamespace("worldgen_region_random");
 
    public WorldGenRegion(ServerLevel level, StaticCache2D<GenerationChunkHolder> cache, ChunkStep generatingStep, ChunkAccess center) {
        this.generatingStep = generatingStep;
        this.cache = cache;
        this.center = center;
        this.level = level;
        this.seed = level.getSeed();
        this.levelData = level.getLevelData();
        this.random = level.getChunkSource().randomState().getOrCreateRandomFactory(WORLDGEN_REGION_RANDOM).at(this.center.getPos().getWorldPosition());
        this.dimensionType = level.dimensionType();
        this.biomeManager = new BiomeManager(this, BiomeManager.obfuscateSeed(this.seed));
    }
 
    public boolean isOldChunkAround(ChunkPos pos, int range) {
        return this.level.getChunkSource().chunkMap.isOldChunkAround(pos, range);
    }
 
    public ChunkPos getCenter() {
        return this.center.getPos();
    }
 
    @Override
    public void setCurrentlyGenerating(@Nullable Supplier<String> currentlyGenerating) {
        this.currentlyGenerating = currentlyGenerating;
    }
 
    @Override
    public ChunkAccess getChunk(int chunkX, int chunkZ) {
        return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY);
    }
 
    @Override
    public @Nullable ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus targetStatus, boolean loadOrGenerate) {
        int distance = this.center.getPos().getChessboardDistance(chunkX, chunkZ);
        ChunkStatus maxAllowedStatus = distance >= this.generatingStep.directDependencies().size()
            ? null
            : this.generatingStep.directDependencies().get(distance);
        GenerationChunkHolder chunkHolder;
        if (maxAllowedStatus != null) {
            chunkHolder = this.cache.get(chunkX, chunkZ);
            if (targetStatus.isOrBefore(maxAllowedStatus)) {
                ChunkAccess chunk = chunkHolder.getChunkIfPresentUnchecked(maxAllowedStatus);
                if (chunk != null) {
                    return chunk;
                }
            }
        } else {
            chunkHolder = null;
        }
 
        CrashReport report = CrashReport.forThrowable(
            new IllegalStateException("Requested chunk unavailable during world generation"), "Exception generating new chunk"
        );
        CrashReportCategory category = report.addCategory("Chunk request details");
        category.setDetail("Requested chunk", String.format(Locale.ROOT, "%d, %d", chunkX, chunkZ));
        category.setDetail("Generating status", () -> this.generatingStep.targetStatus().getName());
        category.setDetail("Requested status", targetStatus::getName);
        category.setDetail("Actual status", () -> chunkHolder == null ? "[out of cache bounds]" : chunkHolder.getPersistedStatus().getName());
        category.setDetail("Maximum allowed status", () -> maxAllowedStatus == null ? "null" : maxAllowedStatus.getName());
        category.setDetail("Dependencies", this.generatingStep.directDependencies()::toString);
        category.setDetail("Requested distance", distance);
        category.setDetail("Generating chunk", this.center.getPos()::toString);
        throw new ReportedException(report);
    }
 
    @Override
    public boolean hasChunk(int chunkX, int chunkZ) {
        int distance = this.center.getPos().getChessboardDistance(chunkX, chunkZ);
        return distance < this.generatingStep.directDependencies().size();
    }
 
    @Override
    public BlockState getBlockState(BlockPos pos) {
        return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos);
    }
 
    @Override
    public FluidState getFluidState(BlockPos pos) {
        return this.getChunk(pos).getFluidState(pos);
    }
 
    @Override
    public @Nullable Player getNearestPlayer(double x, double y, double z, double maxDist, @Nullable Predicate<Entity> predicate) {
        return null;
    }
 
    @Override
    public int getSkyDarken() {
        return 0;
    }
 
    @Override
    public BiomeManager getBiomeManager() {
        return this.biomeManager;
    }
 
    @Override
    public Holder<Biome> getUncachedNoiseBiome(int quartX, int quartY, int quartZ) {
        return this.level.getUncachedNoiseBiome(quartX, quartY, quartZ);
    }
 
    @Override
    public LevelLightEngine getLightEngine() {
        return this.level.getLightEngine();
    }
 
    @Override
    public boolean destroyBlock(BlockPos pos, boolean dropResources, @Nullable Entity breaker, int updateLimit) {
        BlockState blockState = this.getBlockState(pos);
        return blockState.isAir() ? false : this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, updateLimit);
    }
 
    @Override
    public @Nullable BlockEntity getBlockEntity(BlockPos pos) {
        ChunkAccess chunk = this.getChunk(pos);
        BlockEntity blockEntity = chunk.getBlockEntity(pos);
        if (blockEntity != null) {
            return blockEntity;
        } else {
            CompoundTag tag = chunk.getBlockEntityNbt(pos);
            BlockState state = chunk.getBlockState(pos);
            if (tag != null) {
                if ("DUMMY".equals(tag.getStringOr("id", ""))) {
                    if (!state.hasBlockEntity()) {
                        return null;
                    }
 
                    blockEntity = ((EntityBlock)state.getBlock()).newBlockEntity(pos, state);
                } else {
                    blockEntity = BlockEntity.loadStatic(pos, state, tag, this.level.registryAccess());
                }
 
                if (blockEntity != null) {
                    chunk.setBlockEntity(blockEntity);
                    return blockEntity;
                }
            }
 
            if (state.hasBlockEntity()) {
                LOGGER.warn("Tried to access a block entity before it was created. {}", pos);
            }
 
            return null;
        }
    }
 
    @Override
    public boolean ensureCanWrite(BlockPos pos) {
        int chunkX = SectionPos.blockToSectionCoord(pos.getX());
        int chunkZ = SectionPos.blockToSectionCoord(pos.getZ());
        ChunkPos centerPos = this.getCenter();
        int distanceX = Math.abs(centerPos.x() - chunkX);
        int distanceZ = Math.abs(centerPos.z() - chunkZ);
        if (distanceX <= this.generatingStep.blockStateWriteRadius() && distanceZ <= this.generatingStep.blockStateWriteRadius()) {
            if (this.center.isUpgrading()) {
                LevelHeightAccessor levelHeightAccessor = this.center.getHeightAccessorForGeneration();
                if (levelHeightAccessor.isOutsideBuildHeight(pos.getY())) {
                    return false;
                }
            }
 
            return true;
        } else {
            Util.logAndPauseIfInIde(
                "Detected setBlock in a far chunk ["
                    + chunkX
                    + ", "
                    + chunkZ
                    + "], pos: "
                    + pos
                    + ", status: "
                    + this.generatingStep.targetStatus()
                    + (this.currentlyGenerating == null ? "" : ", currently generating: " + this.currentlyGenerating.get())
            );
            return false;
        }
    }
 
    @Override
    public boolean setBlock(BlockPos pos, BlockState blockState, @Block.UpdateFlags int updateFlags, int updateLimit) {
        if (!this.ensureCanWrite(pos)) {
            return false;
        } else {
            ChunkAccess chunk = this.getChunk(pos);
            BlockState oldState = chunk.setBlockState(pos, blockState, updateFlags);
            if (oldState != null) {
                this.level.updatePOIOnBlockStateChange(pos, oldState, blockState);
            }
 
            if (blockState.hasBlockEntity()) {
                if (chunk.getPersistedStatus().getChunkType() == ChunkType.LEVELCHUNK) {
                    BlockEntity blockEntity = ((EntityBlock)blockState.getBlock()).newBlockEntity(pos, blockState);
                    if (blockEntity != null) {
                        chunk.setBlockEntity(blockEntity);
                    } else {
                        chunk.removeBlockEntity(pos);
                    }
                } else {
                    CompoundTag tag = new CompoundTag();
                    tag.putInt("x", pos.getX());
                    tag.putInt("y", pos.getY());
                    tag.putInt("z", pos.getZ());
                    tag.putString("id", "DUMMY");
                    chunk.setBlockEntityNbt(tag);
                }
            } else if (oldState != null && oldState.hasBlockEntity()) {
                chunk.removeBlockEntity(pos);
            }
 
            if ((updateFlags & 16) == 0) {
                BlockPos postProcessPos = blockState.getPostProcessPos(this, pos);
                if (postProcessPos != null) {
                    this.markPosForPostprocessing(postProcessPos);
                }
            }
 
            return true;
        }
    }
 
    private void markPosForPostprocessing(BlockPos blockPos) {
        this.getChunk(blockPos).markPosForPostprocessing(blockPos);
    }
 
    @Override
    public boolean addFreshEntity(Entity entity) {
        int xc = SectionPos.blockToSectionCoord(entity.getBlockX());
        int zc = SectionPos.blockToSectionCoord(entity.getBlockZ());
        this.getChunk(xc, zc).addEntity(entity);
        return true;
    }
 
    @Override
    public boolean removeBlock(BlockPos pos, boolean movedByPiston) {
        return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
    }
 
    @Override
    public WorldBorder getWorldBorder() {
        return this.level.getWorldBorder();
    }
 
    @Override
    public boolean isClientSide() {
        return false;
    }
 
    @Deprecated
    @Override
    public ServerLevel getLevel() {
        return this.level;
    }
 
    @Override
    public RegistryAccess registryAccess() {
        return this.level.registryAccess();
    }
 
    @Override
    public FeatureFlagSet enabledFeatures() {
        return this.level.enabledFeatures();
    }
 
    @Override
    public LevelData getLevelData() {
        return this.levelData;
    }
 
    @Override
    public DifficultyInstance getCurrentDifficultyAt(BlockPos pos) {
        if (!this.hasChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()))) {
            throw new RuntimeException("We are asking a region for a chunk out of bound");
        } else {
            return new DifficultyInstance(this.level.getDifficulty(), this.level.getOverworldClockTime(), 0L, this.level.getMoonBrightness(pos));
        }
    }
 
    @Override
    public @Nullable MinecraftServer getServer() {
        return this.level.getServer();
    }
 
    @Override
    public ChunkSource getChunkSource() {
        return this.level.getChunkSource();
    }
 
    @Override
    public long getSeed() {
        return this.seed;
    }
 
    @Override
    public LevelTickAccess<Block> getBlockTicks() {
        return this.blockTicks;
    }
 
    @Override
    public LevelTickAccess<Fluid> getFluidTicks() {
        return this.fluidTicks;
    }
 
    @Override
    public int getSeaLevel() {
        return this.level.getSeaLevel();
    }
 
    @Override
    public RandomSource getRandom() {
        return this.random;
    }
 
    @Override
    public int getHeight(Heightmap.Types type, int x, int z) {
        return this.getChunk(SectionPos.blockToSectionCoord(x), SectionPos.blockToSectionCoord(z)).getHeight(type, x & 15, z & 15) + 1;
    }
 
    @Override
    public void playSound(@Nullable Entity except, BlockPos pos, SoundEvent sound, SoundSource source, float volume, float pitch) {
    }
 
    @Override
    public void addParticle(ParticleOptions particle, double x, double y, double z, double xd, double yd, double zd) {
    }
 
    @Override
    public void levelEvent(@Nullable Entity source, int type, BlockPos pos, int data) {
    }
 
    @Override
    public void gameEvent(Holder<GameEvent> gameEvent, Vec3 position, GameEvent.Context context) {
    }
 
    @Override
    public DimensionType dimensionType() {
        return this.dimensionType;
    }
 
    @Override
    public boolean isStateAtPosition(BlockPos pos, Predicate<BlockState> predicate) {
        return predicate.test(this.getBlockState(pos));
    }
 
    @Override
    public boolean isFluidAtPosition(BlockPos pos, Predicate<FluidState> predicate) {
        return predicate.test(this.getFluidState(pos));
    }
 
    @Override
    public <T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> type, AABB bb, Predicate<? super T> selector) {
        return Collections.emptyList();
    }
 
    @Override
    public List<Entity> getEntities(@Nullable Entity except, AABB bb, @Nullable Predicate<? super Entity> selector) {
        return Collections.emptyList();
    }
 
    @Override
    public List<Player> players() {
        return Collections.emptyList();
    }
 
    @Override
    public int getMinY() {
        return this.level.getMinY();
    }
 
    @Override
    public int getHeight() {
        return this.level.getHeight();
    }
 
    @Override
    public long nextSubTickCount() {
        return this.subTickCount.getAndIncrement();
    }
 
    @Override
    public EnvironmentAttributeReader environmentAttributes() {
        return EnvironmentAttributeReader.EMPTY;
    }
}

引用的其他类