Class World
- All Implemented Interfaces:
AutoCloseable
,class_5423
,BiomeAccess.Storage
,BlockRenderView
,BlockView
,CollisionView
,EntityView
,LunarWorldView
,ModifiableTestableWorld
,ModifiableWorld
,TestableWorld
,WorldAccess
,WorldView
- Direct Known Subclasses:
ClientWorld
,ServerWorld
public abstract class World extends Object implements WorldAccess, AutoCloseable
-
Field Summary
Fields Modifier and Type Field Description private int
ambientDarkness
private BiomeAccess
biomeAccess
List<BlockEntity>
blockEntities
private WorldBorder
border
static com.mojang.serialization.Codec<RegistryKey<World>>
CODEC
private boolean
debugWorld
private DimensionType
dimension
private static Direction[]
DIRECTIONS
static RegistryKey<World>
END
boolean
isClient
protected boolean
iteratingTickingBlockEntities
protected int
lcgBlockSeed
protected static Logger
LOGGER
static RegistryKey<World>
NETHER
static RegistryKey<World>
OVERWORLD
protected List<BlockEntity>
pendingBlockEntities
private Supplier<Profiler>
profiler
protected MutableWorldProperties
properties
protected float
rainGradient
protected float
rainGradientPrev
Random
random
private RegistryKey<World>
registryKey
private Thread
thread
protected float
thunderGradient
protected float
thunderGradientPrev
List<BlockEntity>
tickingBlockEntities
protected List<BlockEntity>
unloadedBlockEntities
protected int
unusedIncrement
-
Constructor Summary
Constructors Modifier Constructor Description protected
World(MutableWorldProperties properties, RegistryKey<World> registryRef, DimensionType dimensionType, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed)
-
Method Summary
Modifier and Type Method 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, 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)
Explosion
createExplosion(Entity entity, DamageSource damageSource, ExplosionBehavior explosionBehavior, double double2, double double3, double double4, float float2, boolean bool, 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>
List<T>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>
List<T>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>
List<T>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
isInBuildLimit(BlockPos pos)
private static boolean
isInvalidVertically(int y)
boolean
isNight()
static boolean
isOutOfBuildLimitVertically(int y)
static boolean
isOutOfBuildLimitVertically(BlockPos pos)
boolean
isRaining()
boolean
isReceivingRedstonePower(BlockPos pos)
boolean
isSavingDisabled()
boolean
isThundering()
boolean
isTopSolid(BlockPos pos, Entity entity)
static boolean
isValid(BlockPos pos)
private static boolean
isValidHorizontally(BlockPos pos)
void
markDirty(BlockPos pos, BlockEntity blockEntity)
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)
abstract void
playSound(PlayerEntity player, double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch)
void
playSound(PlayerEntity player, BlockPos pos, 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)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.world.BlockRenderView
getBaseLightLevel, getBrightness, getLightLevel, isSkyVisible
Methods inherited from interface net.minecraft.world.BlockView
getDismountHeight, getDismountHeight, getHeight, getLuminance, getMaxLightLevel, method_29546, raycast, raycastBlock
Methods inherited from interface net.minecraft.class_5423
getEntityCollisions, getRegistryManager, getTopPosition, intersectsEntities, method_31081
Methods inherited from interface net.minecraft.world.CollisionView
canPlace, getBlockCollisions, getBlockCollisions, getCollisions, getEntityCollisions, intersectsEntities, intersectsEntities, isBlockSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmpty
Methods inherited from interface net.minecraft.world.EntityView
getClosestEntity, getClosestEntity, getClosestEntityIncludingUngeneratedChunks, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getEntitiesIncludingUngeneratedChunks, getNonSpectatingEntities, getOtherEntities, getPlayerByUuid, getPlayers, getPlayers, getTargets, isPlayerInRange
Methods inherited from interface net.minecraft.world.LunarWorldView
getMoonPhase, getMoonSize, getSkyAngle
Methods inherited from interface net.minecraft.world.ModifiableWorld
breakBlock, breakBlock, spawnEntity
Methods inherited from interface net.minecraft.world.WorldAccess
getBlockTickScheduler, getChunkManager, getDifficulty, getDimensionHeight, getFluidTickScheduler, getLunarTime, isChunkLoaded, syncWorldEvent, syncWorldEvent, updateNeighbors
Methods inherited from interface net.minecraft.world.WorldView
containsFluid, getBiome, getBiomeForNoiseGen, getBrightness, getChunk, getChunk, getColor, getGeneratorStoredBiome, getLightLevel, getLightLevel, getStrongRedstonePower, isAir, isChunkLoaded, isRegionLoaded, isRegionLoaded, isSkyVisibleAllowingSea, isWater, method_29556
-
Field Details
-
LOGGER
-
CODEC
-
OVERWORLD
-
NETHER
-
END
-
DIRECTIONS
-
blockEntities
-
tickingBlockEntities
-
pendingBlockEntities
-
unloadedBlockEntities
-
thread
-
debugWorld
private final boolean debugWorld -
ambientDarkness
private int ambientDarkness -
lcgBlockSeed
protected int lcgBlockSeed -
unusedIncrement
protected final int unusedIncrement- See Also:
- Constant Field Values
-
rainGradientPrev
protected float rainGradientPrev -
rainGradient
protected float rainGradient -
thunderGradientPrev
protected float thunderGradientPrev -
thunderGradient
protected float thunderGradient -
random
-
dimension
-
properties
-
profiler
-
isClient
public final boolean isClient -
iteratingTickingBlockEntities
protected boolean iteratingTickingBlockEntities -
border
-
biomeAccess
-
registryKey
-
-
Constructor Details
-
World
protected World(MutableWorldProperties properties, RegistryKey<World> registryRef, DimensionType dimensionType, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed)
-
-
Method Details
-
isClient
public boolean isClient()Checks if this world view is on the logical client.If the value returned is false, it is expected that this world is present on a logical server.
-
getServer
-
isInBuildLimit
-
isValid
-
isValidHorizontally
-
isInvalidVertically
private static boolean isInvalidVertically(int y) -
isOutOfBuildLimitVertically
-
isOutOfBuildLimitVertically
public static boolean isOutOfBuildLimitVertically(int y) -
getWorldChunk
-
getChunk
-
getChunk
-
setBlockState
Updates the block state at a position, calling appropriate callbacks.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:
- 0b0000001 // 1 - PROPAGATE_CHANGE - Propagates a change event to surrounding blocks.
- 0b0000010 // 2 - NOTIFY_LISTENERS - Notifies listeners and clients who need to react when the block changes
- 0b0000100 // 4 - NO_REDRAW - Used in conjunction with NOTIFY_LISTENERS to suppress the render pass on clients.
- 0b0001000 // 8 - REDRAW_ON_MAIN_THREAD - Forces a synchronous redraw on clients.
- 0b0010000 // 16 - FORCE_STATE - Bypass virtual block state changes and forces the passed state to be stored as-is.
- 0b0100000 // 32 - SKIP_DROPS - Prevents the previous block (container) from dropping items when destroyed.
- 0b1000000 // 64 - MOVED - Signals that the current block is being moved to a different location, usually because of a piston.
- Specified by:
setBlockState
in interfaceModifiableWorld
- Parameters:
pos
- the target positionstate
- the block state to setflags
- the bitwise flag combination, as described above
-
setBlockState
Updates the block state at a position, calling appropriate callbacks.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:
- 0b0000001 // 1 - PROPAGATE_CHANGE - Propagates a change event to surrounding blocks.
- 0b0000010 // 2 - NOTIFY_LISTENERS - Notifies listeners and clients who need to react when the block changes
- 0b0000100 // 4 - NO_REDRAW - Used in conjunction with NOTIFY_LISTENERS to suppress the render pass on clients.
- 0b0001000 // 8 - REDRAW_ON_MAIN_THREAD - Forces a synchronous redraw on clients.
- 0b0010000 // 16 - FORCE_STATE - Bypass virtual block state changes and forces the passed state to be stored as-is.
- 0b0100000 // 32 - SKIP_DROPS - Prevents the previous block (container) from dropping items when destroyed.
- 0b1000000 // 64 - MOVED - Signals that the current block is being moved to a different location, usually because of a piston.
- Specified by:
setBlockState
in interfaceModifiableWorld
- Parameters:
pos
- the target positionstate
- the block state to setflags
- the bitwise flag combination, as described abovemaxUpdateDepth
- the limit for the cascading block updates
-
onBlockChanged
-
removeBlock
- Specified by:
removeBlock
in interfaceModifiableWorld
-
breakBlock
public boolean breakBlock(BlockPos pos, boolean drop, @Nullable Entity breakingEntity, int maxUpdateDepth)- Specified by:
breakBlock
in interfaceModifiableWorld
-
setBlockState
-
updateListeners
public abstract void updateListeners(BlockPos pos, BlockState oldState, BlockState newState, int flags) -
scheduleBlockRerenderIfNeeded
-
updateNeighborsAlways
-
updateNeighborsExcept
-
updateNeighbor
-
getTopY
-
getLightingProvider
- Specified by:
getLightingProvider
in interfaceBlockRenderView
-
getBlockState
- Specified by:
getBlockState
in interfaceBlockView
-
getFluidState
- Specified by:
getFluidState
in interfaceBlockView
-
isDay
public boolean isDay() -
isNight
public boolean isNight() -
playSound
public void playSound(@Nullable PlayerEntity player, BlockPos pos, SoundEvent sound, SoundCategory category, float volume, float pitch)- Specified by:
playSound
in interfaceWorldAccess
-
playSound
public abstract void playSound(@Nullable PlayerEntity player, double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch) -
playSoundFromEntity
public abstract void playSoundFromEntity(@Nullable PlayerEntity player, Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch) -
playSound
public void playSound(double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean bool) -
addParticle
public void addParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ)- Specified by:
addParticle
in interfaceWorldAccess
-
addParticle
@Environment(CLIENT) public void addParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ) -
addImportantParticle
public void addImportantParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ) -
addImportantParticle
public void addImportantParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ) -
getSkyAngleRadians
public float getSkyAngleRadians(float tickDelta) -
addBlockEntity
-
addBlockEntities
-
tickBlockEntities
public void tickBlockEntities() -
tickEntity
-
createExplosion
public Explosion createExplosion(@Nullable Entity entity, double x, double y, double z, float power, Explosion.DestructionType destructionType) -
createExplosion
public Explosion createExplosion(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType) -
createExplosion
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) -
getDebugString
-
getBlockEntity
- Specified by:
getBlockEntity
in interfaceBlockView
-
getPendingBlockEntity
-
setBlockEntity
-
removeBlockEntity
-
canSetBlock
-
isDirectionSolid
-
isTopSolid
-
calculateAmbientDarkness
public void calculateAmbientDarkness() -
setMobSpawnOptions
public void setMobSpawnOptions(boolean spawnMonsters, boolean spawnAnimals) -
initWeatherGradients
protected void initWeatherGradients() -
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getExistingChunk
- Specified by:
getExistingChunk
in interfaceCollisionView
- Specified by:
getExistingChunk
in interfaceWorldView
-
getOtherEntities
public List<Entity> getOtherEntities(@Nullable Entity except, Box box, @Nullable Predicate<? super Entity> predicate)Computes a list of entities within some box, excluding the given entity, that satisfy the given predicate.- Specified by:
getOtherEntities
in interfaceEntityView
- Parameters:
except
- 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.- Returns:
- a list of entities within a box, excluding the given entity, all satisfying the given predicate
-
getEntitiesByType
public <T extends Entity> List<T> getEntitiesByType(@Nullable 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. Warning: Ifnull
is passed as the entity type filter, care should be taken that the type argumentT
is set toEntity
, otherwise heap pollution in the output list orClassCastException
can occur.- Parameters:
type
- the entity type of the returned entities, ornull
to return entities of all typesbox
- the box in which to search for entitiespredicate
- a predicate which entities must satisfy in order to be considered- Returns:
- a list of entities
-
getEntitiesByClass
public <T extends Entity> List<T> getEntitiesByClass(Class<? extends T> entityClass, Box box, @Nullable 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.- Specified by:
getEntitiesByClass
in interfaceEntityView
- Parameters:
entityClass
- 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 list- Returns:
- a list of entities within the box whose runtime class is a subclass of the given class
-
getEntitiesIncludingUngeneratedChunks
public <T extends Entity> List<T> getEntitiesIncludingUngeneratedChunks(Class<? extends T> entityClass, Box box, @Nullable Predicate<? super T> predicate)- Specified by:
getEntitiesIncludingUngeneratedChunks
in interfaceEntityView
-
getEntityById
-
markDirty
-
getSeaLevel
public int getSeaLevel()- Specified by:
getSeaLevel
in interfaceWorldView
-
getReceivedStrongRedstonePower
-
isEmittingRedstonePower
-
getEmittedRedstonePower
-
isReceivingRedstonePower
-
getReceivedRedstonePower
-
disconnect
@Environment(CLIENT) public void disconnect() -
getTime
public long getTime() -
getTimeOfDay
public long getTimeOfDay() -
canPlayerModifyAt
-
sendEntityStatus
-
addSyncedBlockEvent
-
getLevelProperties
- Specified by:
getLevelProperties
in interfaceWorldAccess
-
getGameRules
-
getThunderGradient
public float getThunderGradient(float delta) -
setThunderGradient
@Environment(CLIENT) public void setThunderGradient(float thunderGradient) -
getRainGradient
public float getRainGradient(float delta) -
setRainGradient
@Environment(CLIENT) public void setRainGradient(float rainGradient) -
isThundering
public boolean isThundering() -
isRaining
public boolean isRaining() -
hasRain
-
hasHighHumidity
-
getMapState
-
putMapState
-
getNextMapId
public abstract int getNextMapId() -
syncGlobalEvent
-
addDetailsToCrashReport
-
setBlockBreakingInfo
-
addFireworkParticle
@Environment(CLIENT) public void addFireworkParticle(double x, double y, double z, double velocityX, double velocityY, double velocityZ, @Nullable CompoundTag tag) -
getScoreboard
-
updateComparators
-
getLocalDifficulty
- Specified by:
getLocalDifficulty
in interfaceWorldAccess
-
getAmbientDarkness
public int getAmbientDarkness()- Specified by:
getAmbientDarkness
in interfaceWorldView
-
setLightningTicksLeft
public void setLightningTicksLeft(int lightningTicksLeft) -
getWorldBorder
- Specified by:
getWorldBorder
in interfaceCollisionView
-
sendPacket
-
getDimension
- Specified by:
getDimension
in interfaceWorldView
-
getRegistryKey
-
getRandom
- Specified by:
getRandom
in interfaceWorldAccess
-
testBlockState
- Specified by:
testBlockState
in interfaceTestableWorld
-
getRecipeManager
-
getTagManager
-
getRandomPosInChunk
-
isSavingDisabled
public boolean isSavingDisabled() -
getProfiler
-
getProfilerSupplier
-
getBiomeAccess
- Specified by:
getBiomeAccess
in interfaceWorldView
-
isDebugWorld
public final boolean isDebugWorld()Checks if this world is a debug world.Debug worlds are not modifiable and are typically meant for development and debug use only. See the minecraft wiki as well.
-