Class Level

All Implemented Interfaces:
AutoCloseable, BiomeManager.NoiseBiomeSource, BlockAndTintGetter, BlockGetter, CollisionGetter, CommonLevelAccessor, EntityGetter, LevelAccessor, LevelHeightAccessor, LevelReader, LevelSimulatedReader, LevelSimulatedRW, LevelTimeAccess, LevelWriter, IForgeBlockAndTintGetter, ICapabilityProvider, ICapabilityProviderImpl<Level>, IForgeBlockGetter, IForgeLevel
Direct Known Subclasses:
ClientLevel, ServerLevel

public abstract class Level extends CapabilityProvider<Level> implements LevelAccessor, AutoCloseable, IForgeLevel
  • Field Details

    • RESOURCE_KEY_CODEC

      public static final com.mojang.serialization.Codec<ResourceKey<Level>> RESOURCE_KEY_CODEC
    • OVERWORLD

      public static final ResourceKey<Level> OVERWORLD
    • NETHER

      public static final ResourceKey<Level> NETHER
    • END

      public static final ResourceKey<Level> END
    • MAX_LEVEL_SIZE

      public static final int MAX_LEVEL_SIZE
      See Also:
    • LONG_PARTICLE_CLIP_RANGE

      public static final int LONG_PARTICLE_CLIP_RANGE
      See Also:
    • SHORT_PARTICLE_CLIP_RANGE

      public static final int SHORT_PARTICLE_CLIP_RANGE
      See Also:
    • DIRECTIONS

      private static final Direction[] DIRECTIONS
    • MAX_BRIGHTNESS

      public static final int MAX_BRIGHTNESS
      See Also:
    • TICKS_PER_DAY

      public static final int TICKS_PER_DAY
      See Also:
    • MAX_ENTITY_SPAWN_Y

      public static final int MAX_ENTITY_SPAWN_Y
      See Also:
    • MIN_ENTITY_SPAWN_Y

      public static final int MIN_ENTITY_SPAWN_Y
      See Also:
    • blockEntityTickers

      protected final List<TickingBlockEntity> blockEntityTickers
    • neighborUpdater

      protected final NeighborUpdater neighborUpdater
    • pendingBlockEntityTickers

      private final List<TickingBlockEntity> pendingBlockEntityTickers
    • tickingBlockEntities

      private boolean tickingBlockEntities
    • thread

      private final Thread thread
    • isDebug

      private final boolean isDebug
    • skyDarken

      private int skyDarken
    • randValue

      protected int randValue
    • addend

      protected final int addend
      See Also:
    • oRainLevel

      public float oRainLevel
    • rainLevel

      public float rainLevel
    • oThunderLevel

      public float oThunderLevel
    • thunderLevel

      public float thunderLevel
    • random

      public final RandomSource random
    • threadSafeRandom

      @Deprecated private final RandomSource threadSafeRandom
      Deprecated.
    • dimensionTypeId

      private final ResourceKey<DimensionType> dimensionTypeId
    • dimensionTypeRegistration

      private final Holder<DimensionType> dimensionTypeRegistration
    • levelData

      protected final WritableLevelData levelData
    • profiler

      private final Supplier<ProfilerFiller> profiler
    • isClientSide

      public final boolean isClientSide
    • worldBorder

      private final WorldBorder worldBorder
    • biomeManager

      private final BiomeManager biomeManager
    • dimension

      private final ResourceKey<Level> dimension
    • subTickCount

      private long subTickCount
    • restoringBlockSnapshots

      public boolean restoringBlockSnapshots
    • captureBlockSnapshots

      public boolean captureBlockSnapshots
    • capturedBlockSnapshots

      public ArrayList<BlockSnapshot> capturedBlockSnapshots
    • freshBlockEntities

      private final ArrayList<BlockEntity> freshBlockEntities
    • pendingFreshBlockEntities

      private final ArrayList<BlockEntity> pendingFreshBlockEntities
    • maxEntityRadius

      private double maxEntityRadius
  • Constructor Details

  • Method Details

    • isClientSide

      public boolean isClientSide()
      Specified by:
      isClientSide in interface LevelReader
    • getServer

      @Nullable public MinecraftServer getServer()
      Specified by:
      getServer in interface LevelAccessor
    • isInWorldBounds

      public boolean isInWorldBounds(BlockPos p_46740_)
    • isInSpawnableBounds

      public static boolean isInSpawnableBounds(BlockPos p_46742_)
    • isInWorldBoundsHorizontal

      private static boolean isInWorldBoundsHorizontal(BlockPos p_46458_)
    • isOutsideSpawnableHeight

      private static boolean isOutsideSpawnableHeight(int p_46725_)
    • getChunkAt

      public LevelChunk getChunkAt(BlockPos p_46746_)
    • getChunk

      public LevelChunk getChunk(int p_46727_, int p_46728_)
      Specified by:
      getChunk in interface LevelReader
    • getChunk

      @Nullable public ChunkAccess getChunk(int p_46502_, int p_46503_, ChunkStatus p_46504_, boolean p_46505_)
      Specified by:
      getChunk in interface LevelReader
    • setBlock

      public boolean setBlock(BlockPos p_46601_, BlockState p_46602_, int p_46603_)
      Specified by:
      setBlock in interface LevelWriter
    • setBlock

      public boolean setBlock(BlockPos p_46605_, BlockState p_46606_, int p_46607_, int p_46608_)
      Specified by:
      setBlock in interface LevelWriter
    • markAndNotifyBlock

      public void markAndNotifyBlock(BlockPos p_46605_, @Nullable LevelChunk levelchunk, BlockState blockstate, BlockState p_46606_, int p_46607_, int p_46608_)
    • onBlockStateChange

      public void onBlockStateChange(BlockPos p_46609_, BlockState p_46610_, BlockState p_46611_)
    • removeBlock

      public boolean removeBlock(BlockPos p_46623_, boolean p_46624_)
      Specified by:
      removeBlock in interface LevelWriter
    • destroyBlock

      public boolean destroyBlock(BlockPos p_46626_, boolean p_46627_, @Nullable Entity p_46628_, int p_46629_)
      Specified by:
      destroyBlock in interface LevelWriter
    • addDestroyBlockEffect

      public void addDestroyBlockEffect(BlockPos p_151531_, BlockState p_151532_)
    • setBlockAndUpdate

      public boolean setBlockAndUpdate(BlockPos p_46598_, BlockState p_46599_)
    • sendBlockUpdated

      public abstract void sendBlockUpdated(BlockPos p_46612_, BlockState p_46613_, BlockState p_46614_, int p_46615_)
    • setBlocksDirty

      public void setBlocksDirty(BlockPos p_46678_, BlockState p_46679_, BlockState p_46680_)
    • updateNeighborsAt

      public void updateNeighborsAt(BlockPos p_46673_, Block p_46674_)
    • updateNeighborsAtExceptFromFacing

      public void updateNeighborsAtExceptFromFacing(BlockPos p_46591_, Block p_46592_, Direction p_46593_)
    • neighborChanged

      public void neighborChanged(BlockPos p_46587_, Block p_46588_, BlockPos p_46589_)
    • neighborChanged

      public void neighborChanged(BlockState p_220379_, BlockPos p_220380_, Block p_220381_, BlockPos p_220382_, boolean p_220383_)
    • neighborShapeChanged

      public void neighborShapeChanged(Direction p_220385_, BlockState p_220386_, BlockPos p_220387_, BlockPos p_220388_, int p_220389_, int p_220390_)
      Specified by:
      neighborShapeChanged in interface LevelAccessor
    • getHeight

      public int getHeight(Heightmap.Types p_46571_, int p_46572_, int p_46573_)
      Specified by:
      getHeight in interface LevelReader
    • getLightEngine

      public LevelLightEngine getLightEngine()
      Specified by:
      getLightEngine in interface BlockAndTintGetter
    • getBlockState

      public BlockState getBlockState(BlockPos p_46732_)
      Specified by:
      getBlockState in interface BlockGetter
    • getFluidState

      public FluidState getFluidState(BlockPos p_46671_)
      Specified by:
      getFluidState in interface BlockGetter
    • isDay

      public boolean isDay()
    • isNight

      public boolean isNight()
    • playSound

      public void playSound(@Nullable Player p_46560_, BlockPos p_46561_, SoundEvent p_46562_, SoundSource p_46563_, float p_46564_, float p_46565_)
      Specified by:
      playSound in interface LevelAccessor
    • playSeededSound

      public abstract void playSeededSound(@Nullable Player p_220363_, double p_220364_, double p_220365_, double p_220366_, SoundEvent p_220367_, SoundSource p_220368_, float p_220369_, float p_220370_, long p_220371_)
    • playSeededSound

      public abstract void playSeededSound(@Nullable Player p_220372_, Entity p_220373_, SoundEvent p_220374_, SoundSource p_220375_, float p_220376_, float p_220377_, long p_220378_)
    • playSound

      public void playSound(@Nullable Player p_46543_, double p_46544_, double p_46545_, double p_46546_, SoundEvent p_46547_, SoundSource p_46548_, float p_46549_, float p_46550_)
    • playSound

      public void playSound(@Nullable Player p_46551_, Entity p_46552_, SoundEvent p_46553_, SoundSource p_46554_, float p_46555_, float p_46556_)
    • playLocalSound

      public void playLocalSound(double p_46482_, double p_46483_, double p_46484_, SoundEvent p_46485_, SoundSource p_46486_, float p_46487_, float p_46488_, boolean p_46489_)
    • addParticle

      public void addParticle(ParticleOptions p_46631_, double p_46632_, double p_46633_, double p_46634_, double p_46635_, double p_46636_, double p_46637_)
      Specified by:
      addParticle in interface LevelAccessor
    • addParticle

      public void addParticle(ParticleOptions p_46638_, boolean p_46639_, double p_46640_, double p_46641_, double p_46642_, double p_46643_, double p_46644_, double p_46645_)
    • addAlwaysVisibleParticle

      public void addAlwaysVisibleParticle(ParticleOptions p_46684_, double p_46685_, double p_46686_, double p_46687_, double p_46688_, double p_46689_, double p_46690_)
    • addAlwaysVisibleParticle

      public void addAlwaysVisibleParticle(ParticleOptions p_46691_, boolean p_46692_, double p_46693_, double p_46694_, double p_46695_, double p_46696_, double p_46697_, double p_46698_)
    • getSunAngle

      public float getSunAngle(float p_46491_)
    • addBlockEntityTicker

      public void addBlockEntityTicker(TickingBlockEntity p_151526_)
    • addFreshBlockEntities

      public void addFreshBlockEntities(Collection<BlockEntity> beList)
    • tickBlockEntities

      protected void tickBlockEntities()
    • guardEntityTick

      public <T extends Entity> void guardEntityTick(Consumer<T> p_46654_, T p_46655_)
    • shouldTickDeath

      public boolean shouldTickDeath(Entity p_186458_)
    • shouldTickBlocksAt

      public boolean shouldTickBlocksAt(long p_186456_)
    • shouldTickBlocksAt

      public boolean shouldTickBlocksAt(BlockPos p_220394_)
    • explode

      public Explosion explode(@Nullable Entity p_46512_, double p_46513_, double p_46514_, double p_46515_, float p_46516_, Explosion.BlockInteraction p_46517_)
    • explode

      public Explosion explode(@Nullable Entity p_46519_, double p_46520_, double p_46521_, double p_46522_, float p_46523_, boolean p_46524_, Explosion.BlockInteraction p_46525_)
    • explode

      public Explosion explode(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_)
    • gatherChunkSourceStats

      public abstract String gatherChunkSourceStats()
    • getBlockEntity

      @Nullable public BlockEntity getBlockEntity(BlockPos p_46716_)
      Specified by:
      getBlockEntity in interface BlockGetter
    • setBlockEntity

      public void setBlockEntity(BlockEntity p_151524_)
    • removeBlockEntity

      public void removeBlockEntity(BlockPos p_46748_)
    • isLoaded

      public boolean isLoaded(BlockPos p_46750_)
    • loadedAndEntityCanStandOnFace

      public boolean loadedAndEntityCanStandOnFace(BlockPos p_46579_, Entity p_46580_, Direction p_46581_)
    • loadedAndEntityCanStandOn

      public boolean loadedAndEntityCanStandOn(BlockPos p_46576_, Entity p_46577_)
    • updateSkyBrightness

      public void updateSkyBrightness()
    • setSpawnSettings

      public void setSpawnSettings(boolean p_46704_, boolean p_46705_)
    • getSharedSpawnPos

      public BlockPos getSharedSpawnPos()
    • getSharedSpawnAngle

      public float getSharedSpawnAngle()
    • prepareWeather

      protected void prepareWeather()
    • close

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

      @Nullable public BlockGetter getChunkForCollisions(int p_46711_, int p_46712_)
      Specified by:
      getChunkForCollisions in interface CollisionGetter
      Specified by:
      getChunkForCollisions in interface LevelReader
    • getEntities

      public List<Entity> getEntities(@Nullable Entity p_46536_, AABB p_46537_, Predicate<? super Entity> p_46538_)
      Specified by:
      getEntities in interface EntityGetter
    • getEntities

      public <T extends Entity> List<T> getEntities(EntityTypeTest<Entity,T> p_151528_, AABB p_151529_, Predicate<? super T> p_151530_)
      Specified by:
      getEntities in interface EntityGetter
    • getEntity

      @Nullable public abstract Entity getEntity(int p_46492_)
    • blockEntityChanged

      public void blockEntityChanged(BlockPos p_151544_)
    • getSeaLevel

      public int getSeaLevel()
      Specified by:
      getSeaLevel in interface LevelReader
    • getDirectSignalTo

      public int getDirectSignalTo(BlockPos p_46752_)
    • hasSignal

      public boolean hasSignal(BlockPos p_46617_, Direction p_46618_)
    • getSignal

      public int getSignal(BlockPos p_46682_, Direction p_46683_)
    • hasNeighborSignal

      public boolean hasNeighborSignal(BlockPos p_46754_)
    • getBestNeighborSignal

      public int getBestNeighborSignal(BlockPos p_46756_)
    • disconnect

      public void disconnect()
    • getGameTime

      public long getGameTime()
    • getDayTime

      public long getDayTime()
    • mayInteract

      public boolean mayInteract(Player p_46557_, BlockPos p_46558_)
    • broadcastEntityEvent

      public void broadcastEntityEvent(Entity p_46509_, byte p_46510_)
    • blockEvent

      public void blockEvent(BlockPos p_46582_, Block p_46583_, int p_46584_, int p_46585_)
    • getLevelData

      public LevelData getLevelData()
      Specified by:
      getLevelData in interface LevelAccessor
    • getGameRules

      public GameRules getGameRules()
    • getThunderLevel

      public float getThunderLevel(float p_46662_)
    • setThunderLevel

      public void setThunderLevel(float p_46708_)
    • getRainLevel

      public float getRainLevel(float p_46723_)
    • setRainLevel

      public void setRainLevel(float p_46735_)
    • isThundering

      public boolean isThundering()
    • isRaining

      public boolean isRaining()
    • isRainingAt

      public boolean isRainingAt(BlockPos p_46759_)
    • isHumidAt

      public boolean isHumidAt(BlockPos p_46762_)
    • getMapData

      @Nullable public abstract MapItemSavedData getMapData(String p_46650_)
    • setMapData

      public abstract void setMapData(String p_151533_, MapItemSavedData p_151534_)
    • getFreeMapId

      public abstract int getFreeMapId()
    • globalLevelEvent

      public void globalLevelEvent(int p_46665_, BlockPos p_46666_, int p_46667_)
    • fillReportDetails

      public CrashReportCategory fillReportDetails(CrashReport p_46656_)
    • destroyBlockProgress

      public abstract void destroyBlockProgress(int p_46506_, BlockPos p_46507_, int p_46508_)
    • createFireworks

      public void createFireworks(double p_46475_, double p_46476_, double p_46477_, double p_46478_, double p_46479_, double p_46480_, @Nullable CompoundTag p_46481_)
    • getScoreboard

      public abstract Scoreboard getScoreboard()
    • updateNeighbourForOutputSignal

      public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_)
    • getCurrentDifficultyAt

      public DifficultyInstance getCurrentDifficultyAt(BlockPos p_46730_)
      Specified by:
      getCurrentDifficultyAt in interface LevelAccessor
    • getSkyDarken

      public int getSkyDarken()
      Specified by:
      getSkyDarken in interface LevelReader
    • setSkyFlashTime

      public void setSkyFlashTime(int p_46709_)
    • getWorldBorder

      public WorldBorder getWorldBorder()
      Specified by:
      getWorldBorder in interface CollisionGetter
    • sendPacketToServer

      public void sendPacketToServer(Packet<?> p_46657_)
    • dimensionType

      public DimensionType dimensionType()
      Specified by:
      dimensionType in interface LevelReader
    • dimensionTypeId

      public ResourceKey<DimensionType> dimensionTypeId()
    • dimensionTypeRegistration

      public Holder<DimensionType> dimensionTypeRegistration()
    • dimension

      public ResourceKey<Level> dimension()
    • getRandom

      public RandomSource getRandom()
      Specified by:
      getRandom in interface LevelAccessor
    • isStateAtPosition

      public boolean isStateAtPosition(BlockPos p_46620_, Predicate<BlockState> p_46621_)
      Specified by:
      isStateAtPosition in interface LevelSimulatedReader
    • isFluidAtPosition

      public boolean isFluidAtPosition(BlockPos p_151541_, Predicate<FluidState> p_151542_)
      Specified by:
      isFluidAtPosition in interface LevelSimulatedReader
    • getRecipeManager

      public abstract RecipeManager getRecipeManager()
    • getBlockRandomPos

      public BlockPos getBlockRandomPos(int p_46497_, int p_46498_, int p_46499_, int p_46500_)
    • noSave

      public boolean noSave()
    • getProfiler

      public ProfilerFiller getProfiler()
    • getProfilerSupplier

      public Supplier<ProfilerFiller> getProfilerSupplier()
    • getBiomeManager

      public BiomeManager getBiomeManager()
      Specified by:
      getBiomeManager in interface LevelReader
    • getMaxEntityRadius

      public double getMaxEntityRadius()
      Description copied from interface: IForgeLevel
      The maximum radius to scan for entities when trying to check bounding boxes. Vanilla's default is 2.0D But mods that add larger entities may increase this.
      Specified by:
      getMaxEntityRadius in interface IForgeLevel
    • increaseMaxEntityRadius

      public double increaseMaxEntityRadius(double value)
      Description copied from interface: IForgeLevel
      Increases the max entity radius, this is safe to call with any value. The setter will verify the input value is larger then the current setting.
      Specified by:
      increaseMaxEntityRadius in interface IForgeLevel
      Parameters:
      value - New max radius to set.
      Returns:
      The new max radius
    • isDebug

      public final boolean isDebug()
    • getEntities

      protected abstract LevelEntityGetter<Entity> getEntities()
    • nextSubTickCount

      public long nextSubTickCount()
      Specified by:
      nextSubTickCount in interface LevelAccessor