public abstract class World extends Object implements WorldAccess, AutoCloseable
| Modifier | Constructor and Description |
|---|---|
protected |
World(MutableWorldProperties properties,
RegistryKey<World> registryRef,
DimensionType dimensionType,
Supplier<Profiler> profiler,
boolean isClient,
boolean debugWorld,
long seed) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBlockEntities(Collection<BlockEntity> blockEntities) |
boolean |
addBlockEntity(BlockEntity blockEntity) |
CrashReportSection |
addDetailsToCrashReport(CrashReport report) |
void |
addFireworkParticle(double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ,
CompoundTag tag) |
void |
addImportantParticle(ParticleEffect parameters,
boolean alwaysSpawn,
double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ) |
void |
addImportantParticle(ParticleEffect parameters,
double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ) |
void |
addParticle(ParticleEffect parameters,
boolean alwaysSpawn,
double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ) |
void |
addParticle(ParticleEffect parameters,
double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ) |
void |
addSyncedBlockEvent(BlockPos pos,
Block block,
int type,
int data) |
boolean |
breakBlock(BlockPos pos,
boolean drop,
Entity breakingEntity,
int maxUpdateDepth) |
void |
calculateAmbientDarkness() |
boolean |
canPlayerModifyAt(PlayerEntity player,
BlockPos pos) |
boolean |
canSetBlock(BlockPos pos) |
void |
close() |
Explosion |
createExplosion(Entity entity,
DamageSource damageSource,
ExplosionBehavior explosionBehavior,
double double2,
double double3,
double double4,
float float2,
boolean bool,
Explosion.DestructionType destructionType) |
Explosion |
createExplosion(Entity entity,
double x,
double y,
double z,
float power,
boolean createFire,
Explosion.DestructionType destructionType) |
Explosion |
createExplosion(Entity entity,
double x,
double y,
double z,
float power,
Explosion.DestructionType destructionType) |
void |
disconnect() |
int |
getAmbientDarkness() |
BiomeAccess |
getBiomeAccess() |
BlockEntity |
getBlockEntity(BlockPos pos) |
BlockState |
getBlockState(BlockPos pos) |
WorldChunk |
getChunk(int int2,
int int3) |
Chunk |
getChunk(int chunkX,
int chunkZ,
ChunkStatus leastStatus,
boolean create) |
String |
getDebugString() |
DimensionType |
getDimension() |
int |
getEmittedRedstonePower(BlockPos pos,
Direction direction) |
<T extends Entity> |
getEntitiesByClass(Class<? extends T> entityClass,
Box box,
Predicate<? super T> predicate)
Computes a list of entities within some box whose runtime Java class is the same as or is
a subclass of the given class.
|
<T extends Entity> |
getEntitiesByType(EntityType<T> type,
Box box,
Predicate<? super T> predicate)
Computes a list of entities of the given type within some region that satisfy the given predicate.
|
<T extends Entity> |
getEntitiesIncludingUngeneratedChunks(Class<? extends T> entityClass,
Box box,
Predicate<? super T> predicate) |
abstract Entity |
getEntityById(int id) |
BlockView |
getExistingChunk(int chunkX,
int chunkZ) |
FluidState |
getFluidState(BlockPos pos) |
GameRules |
getGameRules() |
WorldProperties |
getLevelProperties() |
LightingProvider |
getLightingProvider() |
LocalDifficulty |
getLocalDifficulty(BlockPos pos) |
abstract MapState |
getMapState(String id) |
abstract int |
getNextMapId() |
List<Entity> |
getOtherEntities(Entity except,
Box box,
Predicate<? super Entity> predicate)
Computes a list of entities within some box, excluding the given entity, that satisfy the given predicate.
|
private BlockEntity |
getPendingBlockEntity(BlockPos pos) |
Profiler |
getProfiler() |
Supplier<Profiler> |
getProfilerSupplier() |
float |
getRainGradient(float delta) |
Random |
getRandom() |
BlockPos |
getRandomPosInChunk(int x,
int y,
int z,
int int2) |
int |
getReceivedRedstonePower(BlockPos pos) |
int |
getReceivedStrongRedstonePower(BlockPos pos) |
abstract RecipeManager |
getRecipeManager() |
RegistryKey<World> |
getRegistryKey() |
abstract Scoreboard |
getScoreboard() |
int |
getSeaLevel() |
MinecraftServer |
getServer() |
float |
getSkyAngleRadians(float tickDelta) |
abstract TagManager |
getTagManager() |
float |
getThunderGradient(float delta) |
long |
getTime() |
long |
getTimeOfDay() |
int |
getTopY(Heightmap.Type heightmap,
int x,
int z) |
WorldBorder |
getWorldBorder() |
WorldChunk |
getWorldChunk(BlockPos pos) |
boolean |
hasHighHumidity(BlockPos pos) |
boolean |
hasRain(BlockPos pos) |
protected void |
initWeatherGradients() |
boolean |
isClient()
Checks if this world view is on the logical client.
|
boolean |
isDay() |
boolean |
isDebugWorld()
Checks if this world is a debug world.
|
boolean |
isDirectionSolid(BlockPos pos,
Entity entity,
Direction direction) |
boolean |
isEmittingRedstonePower(BlockPos pos,
Direction direction) |
static boolean |
isHeightInvalid(BlockPos pos) |
static boolean |
isHeightInvalid(int y) |
boolean |
isNight() |
boolean |
isRaining() |
boolean |
isReceivingRedstonePower(BlockPos pos) |
boolean |
isSavingDisabled() |
boolean |
isThundering() |
boolean |
isTopSolid(BlockPos pos,
Entity entity) |
private static boolean |
isValid(BlockPos pos) |
void |
markDirty(BlockPos pos,
BlockEntity blockEntity) |
static boolean |
method_24794(BlockPos blockPos) |
private static boolean |
method_25952(int int2) |
static boolean |
method_25953(BlockPos blockPos) |
void |
onBlockChanged(BlockPos pos,
BlockState oldBlock,
BlockState newBlock) |
void |
playSound(double x,
double y,
double z,
SoundEvent sound,
SoundCategory category,
float volume,
float pitch,
boolean bool) |
void |
playSound(PlayerEntity player,
BlockPos pos,
SoundEvent sound,
SoundCategory category,
float volume,
float pitch) |
abstract void |
playSound(PlayerEntity player,
double x,
double y,
double z,
SoundEvent sound,
SoundCategory category,
float volume,
float pitch) |
abstract void |
playSoundFromEntity(PlayerEntity player,
Entity entity,
SoundEvent sound,
SoundCategory category,
float volume,
float pitch) |
abstract void |
putMapState(MapState mapState) |
boolean |
removeBlock(BlockPos pos,
boolean move) |
void |
removeBlockEntity(BlockPos pos) |
void |
scheduleBlockRerenderIfNeeded(BlockPos pos,
BlockState old,
BlockState updated) |
void |
sendEntityStatus(Entity entity,
byte status) |
void |
sendPacket(Packet<?> packet) |
abstract void |
setBlockBreakingInfo(int entityId,
BlockPos pos,
int progress) |
void |
setBlockEntity(BlockPos pos,
BlockEntity blockEntity) |
boolean |
setBlockState(BlockPos pos,
BlockState state) |
boolean |
setBlockState(BlockPos pos,
BlockState state,
int flags)
Updates the block state at a position, calling appropriate callbacks.
|
boolean |
setBlockState(BlockPos pos,
BlockState state,
int flags,
int maxUpdateDepth)
Updates the block state at a position, calling appropriate callbacks.
|
void |
setLightningTicksLeft(int lightningTicksLeft) |
void |
setMobSpawnOptions(boolean spawnMonsters,
boolean spawnAnimals) |
void |
setRainGradient(float rainGradient) |
void |
setThunderGradient(float thunderGradient) |
void |
syncGlobalEvent(int eventId,
BlockPos pos,
int data) |
boolean |
testBlockState(BlockPos pos,
Predicate<BlockState> state) |
void |
tickBlockEntities() |
void |
tickEntity(Consumer<Entity> tickConsumer,
Entity entity) |
void |
updateComparators(BlockPos pos,
Block block) |
abstract void |
updateListeners(BlockPos pos,
BlockState oldState,
BlockState newState,
int flags) |
void |
updateNeighbor(BlockPos sourcePos,
Block sourceBlock,
BlockPos neighborPos) |
void |
updateNeighborsAlways(BlockPos pos,
Block block) |
void |
updateNeighborsExcept(BlockPos pos,
Block sourceBlock,
Direction direction) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBlockTickScheduler, getChunkManager, getDifficulty, getDimensionHeight, getFluidTickScheduler, getLunarTime, isChunkLoaded, syncWorldEvent, syncWorldEvent, updateNeighborsgetEntityCollisions, getRegistryManager, getTopPosition, intersectsEntities, method_31081getClosestEntity, getClosestEntity, getClosestEntityIncludingUngeneratedChunks, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getEntitiesIncludingUngeneratedChunks, getNonSpectatingEntities, getOtherEntities, getPlayerByUuid, getPlayers, getPlayers, getTargets, isPlayerInRangebreakBlock, breakBlock, spawnEntitygetMoonPhase, getMoonSize, getSkyAnglecontainsFluid, getBiome, getBiomeForNoiseGen, getBrightness, getChunk, getChunk, getColor, getGeneratorStoredBiome, getLightLevel, getLightLevel, getStrongRedstonePower, isAir, isChunkLoaded, isRegionLoaded, isRegionLoaded, isSkyVisibleAllowingSea, isWater, method_29556getBaseLightLevel, getBrightness, getLightLevel, isSkyVisiblecanPlace, getBlockCollisions, getBlockCollisions, getCollisions, intersectsEntities, isBlockSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmptygetDismountHeight, getDismountHeight, getHeight, getLuminance, getMaxLightLevel, method_29546, raycast, raycast, raycastBlockprotected static final Logger LOGGER
public static final com.mojang.serialization.Codec<RegistryKey<World>> CODEC
public static final RegistryKey<World> OVERWORLD
public static final RegistryKey<World> NETHER
public static final RegistryKey<World> END
private static final Direction[] DIRECTIONS
public final List<BlockEntity> blockEntities
public final List<BlockEntity> tickingBlockEntities
protected final List<BlockEntity> pendingBlockEntities
protected final List<BlockEntity> unloadedBlockEntities
private final Thread thread
private final boolean debugWorld
private int ambientDarkness
protected int lcgBlockSeed
protected final int unusedIncrement
protected float rainGradientPrev
protected float rainGradient
protected float thunderGradientPrev
protected float thunderGradient
public final Random random
private final DimensionType dimension
protected final MutableWorldProperties properties
public final boolean isClient
protected boolean iteratingTickingBlockEntities
private final WorldBorder border
private final BiomeAccess biomeAccess
private final RegistryKey<World> registryKey
protected World(MutableWorldProperties properties, RegistryKey<World> registryRef, DimensionType dimensionType, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed)
public boolean isClient()
If the value returned is false, it is expected that this world is present on a logical server.
@Nullable public MinecraftServer getServer()
public static boolean method_24794(BlockPos blockPos)
public static boolean method_25953(BlockPos blockPos)
private static boolean isValid(BlockPos pos)
private static boolean method_25952(int int2)
public static boolean isHeightInvalid(BlockPos pos)
public static boolean isHeightInvalid(int y)
public WorldChunk getWorldChunk(BlockPos pos)
public WorldChunk getChunk(int int2, int int3)
public Chunk getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create)
public boolean setBlockState(BlockPos pos, BlockState state, int flags)
When called on the server, the new block state is stored and propagated to clients and listeners as dictated by the supplied flags. Note that calling this on the client will update the world locally, but may not see the change persisted across loads. It's recommended to check whether this world is client before interacting with the world in this way.
Accepted values of the flags are a bitset combination of the following:
setBlockState in interface ModifiableWorldpos - the target positionstate - the block state to setflags - the bitwise flag combination, as described abovepublic boolean setBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth)
When called on the server, the new block state is stored and propagated to clients and listeners as dictated by the supplied flags. Note that calling this on the client will update the world locally, but may not see the change persisted across loads. It's recommended to check whether this world is client before interacting with the world in this way.
Accepted values of the flags are a bitset combination of the following:
setBlockState in interface ModifiableWorldpos - the target positionstate - the block state to setflags - the bitwise flag combination, as described abovemaxUpdateDepth - the limit for the cascading block updatespublic void onBlockChanged(BlockPos pos, BlockState oldBlock, BlockState newBlock)
public boolean removeBlock(BlockPos pos, boolean move)
removeBlock in interface ModifiableWorldpublic boolean breakBlock(BlockPos pos, boolean drop, @Nullable Entity breakingEntity, int maxUpdateDepth)
breakBlock in interface ModifiableWorldpublic boolean setBlockState(BlockPos pos, BlockState state)
public abstract void updateListeners(BlockPos pos, BlockState oldState, BlockState newState, int flags)
public void scheduleBlockRerenderIfNeeded(BlockPos pos, BlockState old, BlockState updated)
public void updateNeighborsExcept(BlockPos pos, Block sourceBlock, Direction direction)
public void updateNeighbor(BlockPos sourcePos, Block sourceBlock, BlockPos neighborPos)
public int getTopY(Heightmap.Type heightmap, int x, int z)
public LightingProvider getLightingProvider()
getLightingProvider in interface BlockRenderViewpublic BlockState getBlockState(BlockPos pos)
getBlockState in interface BlockViewpublic FluidState getFluidState(BlockPos pos)
getFluidState in interface BlockViewpublic boolean isDay()
public boolean isNight()
public void playSound(@Nullable PlayerEntity player, BlockPos pos, SoundEvent sound, SoundCategory category, float volume, float pitch)
playSound in interface WorldAccesspublic abstract void playSound(@Nullable PlayerEntity player, double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch)
public abstract void playSoundFromEntity(@Nullable PlayerEntity player, Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch)
public void playSound(double x,
double y,
double z,
SoundEvent sound,
SoundCategory category,
float volume,
float pitch,
boolean bool)
public void addParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ)
addParticle in interface WorldAccess@Environment(value=CLIENT) public void addParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ)
public void addImportantParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ)
public void addImportantParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ)
public float getSkyAngleRadians(float tickDelta)
public boolean addBlockEntity(BlockEntity blockEntity)
public void addBlockEntities(Collection<BlockEntity> blockEntities)
public void tickBlockEntities()
public Explosion createExplosion(@Nullable Entity entity, double x, double y, double z, float power, Explosion.DestructionType destructionType)
public Explosion createExplosion(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType)
public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionBehavior explosionBehavior, double double2, double double3, double double4, float float2, boolean bool, Explosion.DestructionType destructionType)
public String getDebugString()
@Nullable public BlockEntity getBlockEntity(BlockPos pos)
getBlockEntity in interface BlockView@Nullable private BlockEntity getPendingBlockEntity(BlockPos pos)
public void setBlockEntity(BlockPos pos, @Nullable BlockEntity blockEntity)
public void removeBlockEntity(BlockPos pos)
public boolean canSetBlock(BlockPos pos)
public void calculateAmbientDarkness()
public void setMobSpawnOptions(boolean spawnMonsters,
boolean spawnAnimals)
protected void initWeatherGradients()
public void close()
throws IOException
close in interface AutoCloseableIOException@Nullable public BlockView getExistingChunk(int chunkX, int chunkZ)
getExistingChunk in interface CollisionViewgetExistingChunk in interface WorldViewpublic List<Entity> getOtherEntities(@Nullable Entity except, Box box, @Nullable Predicate<? super Entity> predicate)
getOtherEntities in interface EntityViewexcept - the entity the box logically surrounds. This entity is ignored if it is inside the box.box - the box in which to search for entitiespredicate - a predicate which entities must satisfy in order to be included in the returned list.public <T extends Entity> List<T> getEntitiesByType(@Nullable EntityType<T> type, Box box, 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 returned entities, or null to return entities of all typesbox - the box in which to search for entitiespredicate - a predicate which entities must satisfy in order to be consideredpublic <T extends Entity> List<T> getEntitiesByClass(Class<? extends T> entityClass, Box box, @Nullable Predicate<? super T> predicate)
getEntitiesByClass in interface EntityViewentityClass - the class the list of entities must extendbox - the box in which to search for entitiespredicate - a predicate which entities must satisfy in order to be included in the returned listpublic <T extends Entity> List<T> getEntitiesIncludingUngeneratedChunks(Class<? extends T> entityClass, Box box, @Nullable Predicate<? super T> predicate)
getEntitiesIncludingUngeneratedChunks in interface EntityViewpublic void markDirty(BlockPos pos, BlockEntity blockEntity)
public int getSeaLevel()
getSeaLevel in interface WorldViewpublic int getReceivedStrongRedstonePower(BlockPos pos)
public boolean isReceivingRedstonePower(BlockPos pos)
public int getReceivedRedstonePower(BlockPos pos)
@Environment(value=CLIENT) public void disconnect()
public long getTime()
public long getTimeOfDay()
public boolean canPlayerModifyAt(PlayerEntity player, BlockPos pos)
public void sendEntityStatus(Entity entity, byte status)
public WorldProperties getLevelProperties()
getLevelProperties in interface WorldAccesspublic GameRules getGameRules()
public float getThunderGradient(float delta)
@Environment(value=CLIENT) public void setThunderGradient(float thunderGradient)
public float getRainGradient(float delta)
@Environment(value=CLIENT) public void setRainGradient(float rainGradient)
public boolean isThundering()
public boolean isRaining()
public boolean hasRain(BlockPos pos)
public boolean hasHighHumidity(BlockPos pos)
public abstract void putMapState(MapState mapState)
public abstract int getNextMapId()
public void syncGlobalEvent(int eventId,
BlockPos pos,
int data)
public CrashReportSection addDetailsToCrashReport(CrashReport report)
public abstract void setBlockBreakingInfo(int entityId,
BlockPos pos,
int progress)
@Environment(value=CLIENT)
public void addFireworkParticle(double x,
double y,
double z,
double velocityX,
double velocityY,
double velocityZ,
@Nullable
CompoundTag tag)
public abstract Scoreboard getScoreboard()
public LocalDifficulty getLocalDifficulty(BlockPos pos)
getLocalDifficulty in interface WorldAccesspublic int getAmbientDarkness()
getAmbientDarkness in interface WorldViewpublic void setLightningTicksLeft(int lightningTicksLeft)
public WorldBorder getWorldBorder()
getWorldBorder in interface CollisionViewpublic void sendPacket(Packet<?> packet)
public DimensionType getDimension()
getDimension in interface WorldViewpublic RegistryKey<World> getRegistryKey()
public Random getRandom()
getRandom in interface WorldAccesspublic boolean testBlockState(BlockPos pos, Predicate<BlockState> state)
testBlockState in interface TestableWorldpublic abstract RecipeManager getRecipeManager()
public abstract TagManager getTagManager()
public BlockPos getRandomPosInChunk(int x, int y, int z, int int2)
public boolean isSavingDisabled()
public Profiler getProfiler()
public BiomeAccess getBiomeAccess()
getBiomeAccess in interface WorldViewpublic final boolean isDebugWorld()
Debug worlds are not modifiable and are typically meant for development and debug use only. See the minecraft wiki as well.