Class World
- All Implemented Interfaces:
AutoCloseable,class_5423,BiomeAccess.Storage,BlockRenderView,BlockView,CollisionView,EntityView,HeightLimitView,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 intambientDarknessprivate BiomeAccessbiomeAccessprotected List<BlockEntityTickInvoker>blockEntityTickersprivate WorldBorderborderstatic com.mojang.serialization.Codec<RegistryKey<World>>CODECprivate booleandebugWorldprivate DimensionTypedimensionprivate static Direction[]DIRECTIONSstatic RegistryKey<World>ENDbooleanisClientprivate booleaniteratingTickingBlockEntitiesprotected intlcgBlockSeedprotected static LoggerLOGGERstatic RegistryKey<World>NETHERstatic RegistryKey<World>OVERWORLDprivate List<BlockEntityTickInvoker>pendingBlockEntityTickersprivate Supplier<Profiler>profilerprotected MutableWorldPropertiespropertiesprotected floatrainGradientprotected floatrainGradientPrevRandomrandomprivate RegistryKey<World>registryKeyprivate Threadthreadprotected floatthunderGradientprotected floatthunderGradientPrevprotected intunusedIncrement -
Constructor Summary
Constructors Modifier Constructor Description protectedWorld(MutableWorldProperties properties, RegistryKey<World> registryRef, DimensionType dimensionType, Supplier<Profiler> profiler, boolean isClient, boolean debugWorld, long seed) -
Method Summary
Modifier and Type Method Description voidaddBlockBreakParticles(BlockPos pos, BlockState state)voidaddBlockEntity(BlockEntity blockEntity)voidaddBlockEntityTicker(BlockEntityTickInvoker blockEntityTickInvoker)CrashReportSectionaddDetailsToCrashReport(CrashReport report)voidaddFireworkParticle(double x, double y, double z, double velocityX, double velocityY, double velocityZ, CompoundTag tag)voidaddImportantParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ)voidaddImportantParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ)voidaddParticle(ParticleEffect parameters, boolean alwaysSpawn, double x, double y, double z, double velocityX, double velocityY, double velocityZ)voidaddParticle(ParticleEffect parameters, double x, double y, double z, double velocityX, double velocityY, double velocityZ)voidaddSyncedBlockEvent(BlockPos pos, Block block, int type, int data)booleanbreakBlock(BlockPos pos, boolean drop, Entity breakingEntity, int maxUpdateDepth)voidcalculateAmbientDarkness()booleancanPlayerModifyAt(PlayerEntity player, BlockPos pos)booleancanSetBlock(BlockPos pos)voidclose()ExplosioncreateExplosion(Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType)ExplosioncreateExplosion(Entity entity, double x, double y, double z, float power, Explosion.DestructionType destructionType)ExplosioncreateExplosion(Entity entity, DamageSource damageSource, ExplosionBehavior behavior, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType)voiddisconnect()intgetAmbientDarkness()BiomeAccessgetBiomeAccess()BlockEntitygetBlockEntity(BlockPos pos)BlockStategetBlockState(BlockPos pos)WorldChunkgetChunk(int int2, int int3)ChunkgetChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create)DimensionTypegetDimension()intgetEmittedRedstonePower(BlockPos pos, Direction direction)<T extends Entity>
List<T>getEntitiesByType(class_5575<Entity,T> class_5575, Box box, Predicate<? super T> predicate)abstract EntitygetEntityById(int id)BlockViewgetExistingChunk(int chunkX, int chunkZ)FluidStategetFluidState(BlockPos pos)GameRulesgetGameRules()WorldPropertiesgetLevelProperties()LightingProvidergetLightingProvider()LocalDifficultygetLocalDifficulty(BlockPos pos)abstract MapStategetMapState(String id)abstract intgetNextMapId()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.ProfilergetProfiler()Supplier<Profiler>getProfilerSupplier()floatgetRainGradient(float delta)RandomgetRandom()BlockPosgetRandomPosInChunk(int x, int y, int z, int int2)intgetReceivedRedstonePower(BlockPos pos)intgetReceivedStrongRedstonePower(BlockPos pos)abstract RecipeManagergetRecipeManager()RegistryKey<World>getRegistryKey()abstract ScoreboardgetScoreboard()intgetSeaLevel()MinecraftServergetServer()floatgetSkyAngleRadians(float tickDelta)abstract TagManagergetTagManager()floatgetThunderGradient(float delta)longgetTime()longgetTimeOfDay()intgetTopY(Heightmap.Type heightmap, int x, int z)WorldBordergetWorldBorder()WorldChunkgetWorldChunk(BlockPos pos)booleanhasHighHumidity(BlockPos pos)booleanhasRain(BlockPos pos)protected voidinitWeatherGradients()booleanisClient()Checks if this world view is on the logical client.booleanisDay()booleanisDebugWorld()Checks if this world is a debug world.booleanisDirectionSolid(BlockPos pos, Entity entity, Direction direction)booleanisEmittingRedstonePower(BlockPos pos, Direction direction)booleanisInBuildLimit(BlockPos pos)private static booleanisInvalidVertically(int y)booleanisNight()booleanisRaining()booleanisReceivingRedstonePower(BlockPos pos)booleanisSavingDisabled()booleanisThundering()booleanisTopSolid(BlockPos pos, Entity entity)static booleanisValid(BlockPos pos)private static booleanisValidHorizontally(BlockPos pos)voidmarkDirty(BlockPos pos)protected abstract class_5577<Entity>method_31592()protected voidmethod_32886(Entity entity, GameEvent gameEvent, BlockPos blockPos, int int2)voidonBlockChanged(BlockPos pos, BlockState oldBlock, BlockState newBlock)voidplaySound(double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch, boolean bool)abstract voidplaySound(PlayerEntity player, double x, double y, double z, SoundEvent sound, SoundCategory category, float volume, float pitch)voidplaySound(PlayerEntity player, BlockPos pos, SoundEvent sound, SoundCategory category, float volume, float pitch)abstract voidplaySoundFromEntity(PlayerEntity player, Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch)abstract voidputMapState(String string, MapState mapState)booleanremoveBlock(BlockPos pos, boolean move)voidremoveBlockEntity(BlockPos pos)voidscheduleBlockRerenderIfNeeded(BlockPos pos, BlockState old, BlockState updated)voidsendEntityStatus(Entity entity, byte status)voidsendPacket(Packet<?> packet)abstract voidsetBlockBreakingInfo(int entityId, BlockPos pos, int progress)booleansetBlockState(BlockPos pos, BlockState state)booleansetBlockState(BlockPos pos, BlockState state, int flags)Updates the block state at a position, calling appropriate callbacks.booleansetBlockState(BlockPos pos, BlockState state, int flags, int maxUpdateDepth)Updates the block state at a position, calling appropriate callbacks.voidsetLightningTicksLeft(int lightningTicksLeft)voidsetMobSpawnOptions(boolean spawnMonsters, boolean spawnAnimals)voidsetRainGradient(float rainGradient)voidsetThunderGradient(float thunderGradient)voidsyncGlobalEvent(int eventId, BlockPos pos, int data)booleantestBlockState(BlockPos pos, Predicate<BlockState> state)protected voidtickBlockEntities()<T extends Entity>
voidtickEntity(Consumer<T> tickConsumer, T entity)voidupdateComparators(BlockPos pos, Block block)abstract voidupdateListeners(BlockPos pos, BlockState oldState, BlockState newState, int flags)voidupdateNeighbor(BlockPos pos, Block sourceBlock, BlockPos neighborPos)voidupdateNeighborsAlways(BlockPos pos, Block block)voidupdateNeighborsExcept(BlockPos pos, Block sourceBlock, Direction direction)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.biome.source.BiomeAccess.Storage
method_31609Methods inherited from interface net.minecraft.world.BlockRenderView
getBaseLightLevel, getBrightness, getLightLevel, isSkyVisibleMethods inherited from interface net.minecraft.world.BlockView
getDismountHeight, getDismountHeight, getLuminance, getMaxLightLevel, getStatesInBox, raycast, raycast, raycastBlockMethods inherited from interface net.minecraft.class_5423
getBiomeKey, getEntityCollisions, getRegistryManager, getTopPosition, intersectsEntitiesMethods inherited from interface net.minecraft.world.CollisionView
canPlace, getBlockCollisions, getBlockCollisions, getCollisions, getEntityCollisions, intersectsEntities, intersectsEntities, isBlockSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmpty, isSpaceEmptyMethods inherited from interface net.minecraft.world.EntityView
getClosestEntity, getClosestEntity, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getClosestPlayer, getEntitiesByClass, getNonSpectatingEntities, getOtherEntities, getPlayerByUuid, getPlayers, getPlayers, getTargets, isPlayerInRangeMethods inherited from interface net.minecraft.world.HeightLimitView
getSection, getSectionIndex, getSectionIndexFromSection, getTopHeightLimit, getTopSectionLimit, isOutOfHeightLimit, isOutOfHeightLimit, method_32890, method_32891Methods inherited from interface net.minecraft.world.LunarWorldView
getMoonPhase, getMoonSize, getSkyAngleMethods inherited from interface net.minecraft.world.ModifiableWorld
breakBlock, breakBlock, spawnEntityMethods inherited from interface net.minecraft.world.WorldAccess
emitGameEvent, emitGameEvent, emitGameEvent, getBlockTickScheduler, getChunkManager, getDifficulty, getFluidTickScheduler, getLunarTime, isChunkLoaded, syncWorldEvent, syncWorldEvent, updateNeighborsMethods inherited from interface net.minecraft.world.WorldView
containsFluid, getBiome, getBiomeForNoiseGen, getBottomSectionLimit, getBrightness, getChunk, getChunk, getColor, getGeneratorStoredBiome, getLightLevel, getLightLevel, getSectionCount, getStrongRedstonePower, isAir, isChunkLoaded, isRegionLoaded, isRegionLoaded, isSkyVisibleAllowingSea, isWater, method_29556
-
Field Details
-
LOGGER
-
CODEC
-
OVERWORLD
-
NETHER
-
END
-
DIRECTIONS
-
blockEntityTickers
-
pendingBlockEntityTickers
-
iteratingTickingBlockEntities
private boolean iteratingTickingBlockEntities -
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 -
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) -
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:
setBlockStatein 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:
setBlockStatein 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:
removeBlockin interfaceModifiableWorld
-
breakBlock
public boolean breakBlock(BlockPos pos, boolean drop, @Nullable Entity breakingEntity, int maxUpdateDepth)- Specified by:
breakBlockin interfaceModifiableWorld
-
addBlockBreakParticles
-
setBlockState
-
updateListeners
public abstract void updateListeners(BlockPos pos, BlockState oldState, BlockState newState, int flags) -
scheduleBlockRerenderIfNeeded
-
updateNeighborsAlways
-
updateNeighborsExcept
-
updateNeighbor
-
getTopY
-
getLightingProvider
- Specified by:
getLightingProviderin interfaceBlockRenderView
-
getBlockState
- Specified by:
getBlockStatein interfaceBlockView
-
getFluidState
- Specified by:
getFluidStatein 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:
playSoundin 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:
addParticlein 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) -
addBlockEntityTicker
-
tickBlockEntities
protected 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 behavior, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType) -
getBlockEntity
- Specified by:
getBlockEntityin interfaceBlockView
-
addBlockEntity
-
removeBlockEntity
-
canSetBlock
-
isDirectionSolid
-
isTopSolid
-
calculateAmbientDarkness
public void calculateAmbientDarkness() -
setMobSpawnOptions
public void setMobSpawnOptions(boolean spawnMonsters, boolean spawnAnimals) -
initWeatherGradients
protected void initWeatherGradients() -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
getExistingChunk
- Specified by:
getExistingChunkin interfaceCollisionView- Specified by:
getExistingChunkin interfaceWorldView
-
getOtherEntities
public List<Entity> getOtherEntities(@Nullable 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.- Specified by:
getOtherEntitiesin 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(class_5575<Entity,T> class_5575, Box box, Predicate<? super T> predicate)- Specified by:
getEntitiesByTypein interfaceEntityView
-
getEntityById
-
markDirty
-
getSeaLevel
public int getSeaLevel()- Specified by:
getSeaLevelin 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:
getLevelPropertiesin 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:
getLocalDifficultyin interfaceWorldAccess
-
getAmbientDarkness
public int getAmbientDarkness()- Specified by:
getAmbientDarknessin interfaceWorldView
-
setLightningTicksLeft
public void setLightningTicksLeft(int lightningTicksLeft) -
getWorldBorder
- Specified by:
getWorldBorderin interfaceCollisionView
-
sendPacket
-
getDimension
- Specified by:
getDimensionin interfaceWorldView
-
getRegistryKey
-
getRandom
- Specified by:
getRandomin interfaceWorldAccess
-
testBlockState
- Specified by:
testBlockStatein interfaceTestableWorld
-
getRecipeManager
-
getTagManager
-
getRandomPosInChunk
-
isSavingDisabled
public boolean isSavingDisabled() -
getProfiler
-
getProfilerSupplier
-
getBiomeAccess
- Specified by:
getBiomeAccessin 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.
-
method_31592
-
method_32886
-