minecraft-src/net/minecraft/world/level/levelgen/placement/PlacementContext.java
2025-07-04 01:41:11 +03:00

54 lines
1.7 KiB
Java

package net.minecraft.world.level.levelgen.placement;
import java.util.Optional;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.CarvingMask;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.WorldGenerationContext;
public class PlacementContext extends WorldGenerationContext {
private final WorldGenLevel level;
private final ChunkGenerator generator;
private final Optional<PlacedFeature> topFeature;
public PlacementContext(WorldGenLevel level, ChunkGenerator generator, Optional<PlacedFeature> topFeature) {
super(generator, level);
this.level = level;
this.generator = generator;
this.topFeature = topFeature;
}
public int getHeight(Heightmap.Types heightmapType, int x, int z) {
return this.level.getHeight(heightmapType, x, z);
}
public CarvingMask getCarvingMask(ChunkPos chunkPos, GenerationStep.Carving step) {
return ((ProtoChunk)this.level.getChunk(chunkPos.x, chunkPos.z)).getOrCreateCarvingMask(step);
}
public BlockState getBlockState(BlockPos pos) {
return this.level.getBlockState(pos);
}
public int getMinBuildHeight() {
return this.level.getMinBuildHeight();
}
public WorldGenLevel getLevel() {
return this.level;
}
public Optional<PlacedFeature> topFeature() {
return this.topFeature;
}
public ChunkGenerator generator() {
return this.generator;
}
}