public class WorldChunk extends Object implements Chunk
Modifier and Type | Class and Description |
---|---|
static class |
WorldChunk.CreationType |
Constructor and Description |
---|
WorldChunk(World world,
ChunkPos pos,
BiomeArray biomes) |
WorldChunk(World world,
ChunkPos pos,
BiomeArray biomes,
UpgradeData upgradeData,
TickScheduler<Block> blockTickScheduler,
TickScheduler<Fluid> fluidTickScheduler,
long inhabitedTime,
ChunkSection[] sections,
Consumer<WorldChunk> loadToWorldConsumer) |
WorldChunk(World world,
ProtoChunk protoChunk) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
areSectionsEmptyBetween, getHighestNonEmptySection, getHighestNonEmptySectionYOffset, getList, markBlockForPostProcessing, markBlockForPostProcessing
getDismountHeight, getDismountHeight, getHeight, getLuminance, getMaxLightLevel, method_29546, raycast, raycast, raycastBlock
private static final Logger LOGGER
@Nullable public static final ChunkSection EMPTY_SECTION
private final ChunkSection[] sections
private BiomeArray biomeArray
private final Map<BlockPos,CompoundTag> pendingBlockEntityTags
private boolean loadedToWorld
private final World world
private final Map<Heightmap.Type,Heightmap> heightmaps
private final UpgradeData upgradeData
private final Map<BlockPos,BlockEntity> blockEntities
private final TypeFilterableList<Entity>[] entitySections
private final Map<StructureFeature<?>,StructureStart<?>> structureStarts
private final Map<StructureFeature<?>,it.unimi.dsi.fastutil.longs.LongSet> structureReferences
private final it.unimi.dsi.fastutil.shorts.ShortList[] postProcessingLists
private TickScheduler<Block> blockTickScheduler
private TickScheduler<Fluid> fluidTickScheduler
private boolean unsaved
private long lastSaveTime
private volatile boolean shouldSave
private long inhabitedTime
@Nullable private Supplier<ChunkHolder.LevelType> levelTypeProvider
@Nullable private Consumer<WorldChunk> loadToWorldConsumer
private final ChunkPos pos
private volatile boolean lightOn
public WorldChunk(World world, ChunkPos pos, BiomeArray biomes)
public WorldChunk(World world, ChunkPos pos, BiomeArray biomes, UpgradeData upgradeData, TickScheduler<Block> blockTickScheduler, TickScheduler<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable ChunkSection[] sections, @Nullable Consumer<WorldChunk> loadToWorldConsumer)
public WorldChunk(World world, ProtoChunk protoChunk)
public Heightmap getHeightmap(Heightmap.Type type)
getHeightmap
in interface Chunk
public Set<BlockPos> getBlockEntityPositions()
getBlockEntityPositions
in interface Chunk
public ChunkSection[] getSectionArray()
getSectionArray
in interface Chunk
public BlockState getBlockState(BlockPos pos)
getBlockState
in interface BlockView
public FluidState getFluidState(BlockPos pos)
getFluidState
in interface BlockView
public FluidState getFluidState(int x, int y, int z)
@Nullable public BlockState setBlockState(BlockPos pos, BlockState state, boolean moved)
setBlockState
in interface Chunk
@Nullable public LightingProvider getLightingProvider()
public void setHeightmap(Heightmap.Type type, long[] heightmap)
setHeightmap
in interface Chunk
public void remove(Entity entity)
public void remove(Entity entity, int section)
public int sampleHeightmap(Heightmap.Type type, int x, int z)
sampleHeightmap
in interface Chunk
@Nullable private BlockEntity createBlockEntity(BlockPos pos)
@Nullable public BlockEntity getBlockEntity(BlockPos pos)
getBlockEntity
in interface BlockView
@Nullable public BlockEntity getBlockEntity(BlockPos pos, WorldChunk.CreationType creationType)
public void addBlockEntity(BlockEntity blockEntity)
public void setBlockEntity(BlockPos pos, BlockEntity blockEntity)
setBlockEntity
in interface Chunk
public void addPendingBlockEntityTag(CompoundTag tag)
addPendingBlockEntityTag
in interface Chunk
@Nullable public CompoundTag getPackedBlockEntityTag(BlockPos pos)
getPackedBlockEntityTag
in interface Chunk
public void removeBlockEntity(BlockPos pos)
removeBlockEntity
in interface Chunk
public void loadToWorld()
public void markDirty()
public void collectOtherEntities(@Nullable Entity except, Box box, List<Entity> entityList, @Nullable Predicate<? super Entity> predicate)
public <T extends Entity> void collectEntities(@Nullable EntityType<?> type, Box box, List<? super T> result, Predicate<? super T> predicate)
null
is passed as the entity type filter, care should be
taken that the type argument T
is set to Entity
, otherwise heap pollution in
the output list or ClassCastException
can occur.type
- the entity type of the entities to collect, or null
to collect entities of all types.box
- the box within which collected entities must beresult
- a list in which to store the collected entitiespredicate
- a predicate which entities must satisfy in order to be collectedpublic <T extends Entity> void collectEntitiesByClass(Class<? extends T> entityClass, Box box, List<T> result, @Nullable Predicate<? super T> predicate)
entityClass
- the class object representing the type collected entities must extendbox
- the box in which to collect entitiesresult
- a list in which to store the collected entitiespredicate
- a predicate which entities must satisfy in order to be collectedpublic boolean isEmpty()
@Environment(value=CLIENT) public void loadFromPacket(@Nullable BiomeArray biomes, PacketByteBuf buf, CompoundTag tag, int verticalStripBitmask)
public BiomeArray getBiomeArray()
getBiomeArray
in interface Chunk
public void setLoadedToWorld(boolean loaded)
public World getWorld()
public Collection<Map.Entry<Heightmap.Type,Heightmap>> getHeightmaps()
getHeightmaps
in interface Chunk
public Map<BlockPos,BlockEntity> getBlockEntities()
public TypeFilterableList<Entity>[] getEntitySectionArray()
public CompoundTag getBlockEntityTag(BlockPos pos)
getBlockEntityTag
in interface Chunk
public Stream<BlockPos> getLightSourcesStream()
getLightSourcesStream
in interface Chunk
public TickScheduler<Block> getBlockTickScheduler()
getBlockTickScheduler
in interface Chunk
public TickScheduler<Fluid> getFluidTickScheduler()
getFluidTickScheduler
in interface Chunk
public void setShouldSave(boolean shouldSave)
setShouldSave
in interface Chunk
public boolean needsSaving()
needsSaving
in interface Chunk
public void setUnsaved(boolean unsaved)
public void setLastSaveTime(long lastSaveTime)
setLastSaveTime
in interface Chunk
@Nullable public StructureStart<?> getStructureStart(StructureFeature<?> structure)
getStructureStart
in interface StructureHolder
public void setStructureStart(StructureFeature<?> structure, StructureStart<?> start)
setStructureStart
in interface StructureHolder
public Map<StructureFeature<?>,StructureStart<?>> getStructureStarts()
getStructureStarts
in interface Chunk
public void setStructureStarts(Map<StructureFeature<?>,StructureStart<?>> structureStarts)
setStructureStarts
in interface Chunk
public it.unimi.dsi.fastutil.longs.LongSet getStructureReferences(StructureFeature<?> structure)
getStructureReferences
in interface StructureHolder
public void addStructureReference(StructureFeature<?> structure, long reference)
addStructureReference
in interface StructureHolder
public Map<StructureFeature<?>,it.unimi.dsi.fastutil.longs.LongSet> getStructureReferences()
getStructureReferences
in interface StructureHolder
public void setStructureReferences(Map<StructureFeature<?>,it.unimi.dsi.fastutil.longs.LongSet> structureReferences)
setStructureReferences
in interface StructureHolder
public long getInhabitedTime()
getInhabitedTime
in interface Chunk
public void setInhabitedTime(long inhabitedTime)
setInhabitedTime
in interface Chunk
public void runPostProcessing()
@Nullable private BlockEntity loadBlockEntity(BlockPos pos, CompoundTag tag)
public UpgradeData getUpgradeData()
getUpgradeData
in interface Chunk
public it.unimi.dsi.fastutil.shorts.ShortList[] getPostProcessingLists()
getPostProcessingLists
in interface Chunk
public void disableTickSchedulers()
public void enableTickSchedulers(ServerWorld world)
public ChunkStatus getStatus()
public ChunkHolder.LevelType getLevelType()
public void setLevelTypeProvider(Supplier<ChunkHolder.LevelType> levelTypeProvider)
public void setLightOn(boolean lightOn)
setLightOn
in interface Chunk