Class World

java.lang.Object
net.minecraft.world.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 Details

    • LOGGER

      protected static final Logger LOGGER
    • CODEC

      public static final com.mojang.serialization.Codec<RegistryKey<World>> CODEC
    • OVERWORLD

      public static final RegistryKey<World> OVERWORLD
    • NETHER

      public static final RegistryKey<World> NETHER
    • END

      public static final RegistryKey<World> END
    • DIRECTIONS

      private static final Direction[] DIRECTIONS
    • blockEntities

      public final List<BlockEntity> blockEntities
    • tickingBlockEntities

      public final List<BlockEntity> tickingBlockEntities
    • pendingBlockEntities

      protected final List<BlockEntity> pendingBlockEntities
    • unloadedBlockEntities

      protected final List<BlockEntity> unloadedBlockEntities
    • thread

      private final Thread 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

      public final Random random
    • dimension

      private final DimensionType dimension
    • properties

      protected final MutableWorldProperties properties
    • profiler

      private final Supplier<Profiler> profiler
    • isClient

      public final boolean isClient
    • iteratingTickingBlockEntities

      protected boolean iteratingTickingBlockEntities
    • border

      private final WorldBorder border
    • biomeAccess

      private final BiomeAccess biomeAccess
    • registryKey

      private final RegistryKey<World> registryKey
  • Constructor Details

  • 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.

      Specified by:
      isClient in interface WorldView
    • getServer

      @Nullable public MinecraftServer getServer()
    • isInBuildLimit

      public static boolean isInBuildLimit​(BlockPos pos)
    • isValid

      public static boolean isValid​(BlockPos pos)
    • isValidHorizontally

      private static boolean isValidHorizontally​(BlockPos pos)
    • isInvalidVertically

      private static boolean isInvalidVertically​(int y)
    • isOutOfBuildLimitVertically

      public static boolean isOutOfBuildLimitVertically​(BlockPos pos)
    • isOutOfBuildLimitVertically

      public static boolean isOutOfBuildLimitVertically​(int y)
    • getWorldChunk

      public WorldChunk getWorldChunk​(BlockPos pos)
    • getChunk

      public WorldChunk getChunk​(int int2, int int3)
      Specified by:
      getChunk in interface WorldView
    • getChunk

      public Chunk getChunk​(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create)
      Specified by:
      getChunk in interface WorldView
    • setBlockState

      public boolean setBlockState​(BlockPos pos, BlockState state, int flags)
      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 interface ModifiableWorld
      Parameters:
      pos - the target position
      state - the block state to set
      flags - the bitwise flag combination, as described above
    • setBlockState

      public boolean setBlockState​(BlockPos pos, BlockState state, int flags, int maxUpdateDepth)
      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 interface ModifiableWorld
      Parameters:
      pos - the target position
      state - the block state to set
      flags - the bitwise flag combination, as described above
      maxUpdateDepth - the limit for the cascading block updates
    • onBlockChanged

      public void onBlockChanged​(BlockPos pos, BlockState oldBlock, BlockState newBlock)
    • removeBlock

      public boolean removeBlock​(BlockPos pos, boolean move)
      Specified by:
      removeBlock in interface ModifiableWorld
    • breakBlock

      public boolean breakBlock​(BlockPos pos, boolean drop, @Nullable Entity breakingEntity, int maxUpdateDepth)
      Specified by:
      breakBlock in interface ModifiableWorld
    • setBlockState

      public boolean setBlockState​(BlockPos pos, BlockState state)
    • updateListeners

      public abstract void updateListeners​(BlockPos pos, BlockState oldState, BlockState newState, int flags)
    • scheduleBlockRerenderIfNeeded

      public void scheduleBlockRerenderIfNeeded​(BlockPos pos, BlockState old, BlockState updated)
    • updateNeighborsAlways

      public void updateNeighborsAlways​(BlockPos pos, Block block)
    • updateNeighborsExcept

      public void updateNeighborsExcept​(BlockPos pos, Block sourceBlock, Direction direction)
    • updateNeighbor

      public void updateNeighbor​(BlockPos sourcePos, Block sourceBlock, BlockPos neighborPos)
    • getTopY

      public int getTopY​(Heightmap.Type heightmap, int x, int z)
      Specified by:
      getTopY in interface WorldView
    • getLightingProvider

      public LightingProvider getLightingProvider()
      Specified by:
      getLightingProvider in interface BlockRenderView
    • getBlockState

      public BlockState getBlockState​(BlockPos pos)
      Specified by:
      getBlockState in interface BlockView
    • getFluidState

      public FluidState getFluidState​(BlockPos pos)
      Specified by:
      getFluidState in interface BlockView
    • 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 interface WorldAccess
    • 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 interface WorldAccess
    • 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

      public boolean addBlockEntity​(BlockEntity blockEntity)
    • addBlockEntities

      public void addBlockEntities​(Collection<BlockEntity> blockEntities)
    • tickBlockEntities

      public void tickBlockEntities()
    • tickEntity

      public void tickEntity​(Consumer<Entity> tickConsumer, Entity entity)
    • 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

      public String getDebugString()
    • getBlockEntity

      @Nullable public BlockEntity getBlockEntity​(BlockPos pos)
      Specified by:
      getBlockEntity in interface BlockView
    • getPendingBlockEntity

      @Nullable private BlockEntity getPendingBlockEntity​(BlockPos pos)
    • setBlockEntity

      public void setBlockEntity​(BlockPos pos, @Nullable BlockEntity blockEntity)
    • removeBlockEntity

      public void removeBlockEntity​(BlockPos pos)
    • canSetBlock

      public boolean canSetBlock​(BlockPos pos)
    • isDirectionSolid

      public boolean isDirectionSolid​(BlockPos pos, Entity entity, Direction direction)
    • isTopSolid

      public boolean isTopSolid​(BlockPos pos, Entity entity)
    • calculateAmbientDarkness

      public void calculateAmbientDarkness()
    • setMobSpawnOptions

      public void setMobSpawnOptions​(boolean spawnMonsters, boolean spawnAnimals)
    • initWeatherGradients

      protected void initWeatherGradients()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • getExistingChunk

      @Nullable public BlockView getExistingChunk​(int chunkX, int chunkZ)
      Specified by:
      getExistingChunk in interface CollisionView
      Specified by:
      getExistingChunk in interface WorldView
    • 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 interface EntityView
      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 entities
      predicate - 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: If 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.
      Parameters:
      type - the entity type of the returned entities, or null to return entities of all types
      box - the box in which to search for entities
      predicate - 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 interface EntityView
      Parameters:
      entityClass - the class the list of entities must extend
      box - the box in which to search for entities
      predicate - 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 interface EntityView
    • getEntityById

      @Nullable public abstract Entity getEntityById​(int id)
    • markDirty

      public void markDirty​(BlockPos pos, BlockEntity blockEntity)
    • getSeaLevel

      public int getSeaLevel()
      Specified by:
      getSeaLevel in interface WorldView
    • getReceivedStrongRedstonePower

      public int getReceivedStrongRedstonePower​(BlockPos pos)
    • isEmittingRedstonePower

      public boolean isEmittingRedstonePower​(BlockPos pos, Direction direction)
    • getEmittedRedstonePower

      public int getEmittedRedstonePower​(BlockPos pos, Direction direction)
    • isReceivingRedstonePower

      public boolean isReceivingRedstonePower​(BlockPos pos)
    • getReceivedRedstonePower

      public int getReceivedRedstonePower​(BlockPos pos)
    • disconnect

      @Environment(CLIENT) public void disconnect()
    • getTime

      public long getTime()
    • getTimeOfDay

      public long getTimeOfDay()
    • canPlayerModifyAt

      public boolean canPlayerModifyAt​(PlayerEntity player, BlockPos pos)
    • sendEntityStatus

      public void sendEntityStatus​(Entity entity, byte status)
    • addSyncedBlockEvent

      public void addSyncedBlockEvent​(BlockPos pos, Block block, int type, int data)
    • getLevelProperties

      public WorldProperties getLevelProperties()
      Specified by:
      getLevelProperties in interface WorldAccess
    • getGameRules

      public GameRules 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

      public boolean hasRain​(BlockPos pos)
    • hasHighHumidity

      public boolean hasHighHumidity​(BlockPos pos)
    • getMapState

      @Nullable public abstract MapState getMapState​(String id)
    • putMapState

      public abstract void putMapState​(MapState mapState)
    • getNextMapId

      public abstract int getNextMapId()
    • syncGlobalEvent

      public void syncGlobalEvent​(int eventId, BlockPos pos, int data)
    • addDetailsToCrashReport

      public CrashReportSection addDetailsToCrashReport​(CrashReport report)
    • setBlockBreakingInfo

      public abstract void setBlockBreakingInfo​(int entityId, BlockPos pos, int progress)
    • addFireworkParticle

      @Environment(CLIENT) public void addFireworkParticle​(double x, double y, double z, double velocityX, double velocityY, double velocityZ, @Nullable CompoundTag tag)
    • getScoreboard

      public abstract Scoreboard getScoreboard()
    • updateComparators

      public void updateComparators​(BlockPos pos, Block block)
    • getLocalDifficulty

      public LocalDifficulty getLocalDifficulty​(BlockPos pos)
      Specified by:
      getLocalDifficulty in interface WorldAccess
    • getAmbientDarkness

      public int getAmbientDarkness()
      Specified by:
      getAmbientDarkness in interface WorldView
    • setLightningTicksLeft

      public void setLightningTicksLeft​(int lightningTicksLeft)
    • getWorldBorder

      public WorldBorder getWorldBorder()
      Specified by:
      getWorldBorder in interface CollisionView
    • sendPacket

      public void sendPacket​(Packet<?> packet)
    • getDimension

      public DimensionType getDimension()
      Specified by:
      getDimension in interface WorldView
    • getRegistryKey

      public RegistryKey<World> getRegistryKey()
    • getRandom

      public Random getRandom()
      Specified by:
      getRandom in interface WorldAccess
    • testBlockState

      public boolean testBlockState​(BlockPos pos, Predicate<BlockState> state)
      Specified by:
      testBlockState in interface TestableWorld
    • getRecipeManager

      public abstract RecipeManager getRecipeManager()
    • getTagManager

      public abstract TagManager getTagManager()
    • getRandomPosInChunk

      public BlockPos getRandomPosInChunk​(int x, int y, int z, int int2)
    • isSavingDisabled

      public boolean isSavingDisabled()
    • getProfiler

      public Profiler getProfiler()
    • getProfilerSupplier

      public Supplier<Profiler> getProfilerSupplier()
    • getBiomeAccess

      public BiomeAccess getBiomeAccess()
      Specified by:
      getBiomeAccess in interface WorldView
    • 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.