Package net.minecraft.client.renderer
Class LevelRenderer
java.lang.Object
net.minecraft.client.renderer.LevelRenderer
- All Implemented Interfaces:
AutoCloseable
,PreparableReloadListener
,ResourceManagerReloadListener
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
PreparableReloadListener.PreparationBarrier
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BlockEntityRenderDispatcher
private Frustum
private boolean
private VertexBuffer
protected static final ResourceLocation
private RenderTarget
private int
private Frustum
private VertexBuffer
private final it.unimi.dsi.fastutil.ints.Int2ObjectMap
<BlockDestructionProgress> private final it.unimi.dsi.fastutil.longs.Long2ObjectMap
<SortedSet<BlockDestructionProgress>> static final Direction[]
private static final ResourceLocation
private PostChain
private final EntityRenderDispatcher
private RenderTarget
private static final ResourceLocation
private final RunningTrimmedMean
private final org.joml.Vector4f[]
private final org.joml.Vector3d
private boolean
private final Set
<BlockEntity> Global block entities; these are always rendered, even if off-screen.static final int
private RenderTarget
private int
private int
private int
private int
private ClientLevel
private static final org.slf4j.Logger
private static final int
private final Minecraft
private static final ResourceLocation
private boolean
Neo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepathsprivate RenderTarget
private final Map
<BlockPos, SoundInstance> private double
private double
private double
private double
private double
private Vec3
private CloudStatus
private int
private int
private int
private static final int
private static final ResourceLocation
private static final int
private final float[]
private final float[]
private int
private final RenderBuffers
private int
static final int
private final SectionOcclusionGraph
private SectionRenderDispatcher
private static final float
private VertexBuffer
private static final ResourceLocation
private VertexBuffer
private static final ResourceLocation
private int
private RenderTarget
private PostChain
private static final int
private ViewArea
private final it.unimi.dsi.fastutil.objects.ObjectArrayList
<SectionRenderDispatcher.RenderSection> private RenderTarget
private double
private double
private double
-
Constructor Summary
ConstructorsConstructorDescriptionLevelRenderer
(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addChainedFilledBoxVertices
(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) static void
addChainedFilledBoxVertices
(PoseStack poseStack, VertexConsumer consumer, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float red, float green, float blue, float alpha) private void
addFrustumQuad
(VertexConsumer consumer, org.joml.Matrix4f matrix, int index1, int index2, int index3, int index4, int red, int green, int blue) private void
addFrustumVertex
(VertexConsumer consumer, org.joml.Matrix4f matrix, int vertexIndex) void
addParticle
(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) void
addParticle
(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private <T extends ParticleOptions>
voidaddParticle
(T options, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private Particle
addParticleInternal
(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) private Particle
addParticleInternal
(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) void
addRecentlyCompiledSection
(SectionRenderDispatcher.RenderSection renderSection) void
private void
applyFrustum
(Frustum frustum) void
blockChanged
(BlockGetter level, BlockPos pos, BlockState oldState, BlockState newState, int flags) private MeshData
buildClouds
(Tesselator tesselator, double x, double y, double z, Vec3 cloudColor) private static MeshData
buildSkyDisc
(Tesselator tesselator, float y) private ParticleStatus
calculateParticleLevel
(boolean decreased) Calculates the level of particles to use based on the particles option and the specifieddecreased
parameter.void
private void
captureFrustum
(org.joml.Matrix4f viewMatrix, org.joml.Matrix4f projectionMatrix, double camX, double camY, double camZ, Frustum capturedFrustrum) private void
checkPoseStack
(PoseStack poseStack) Asserts that the specifiedposeStack
is clear.void
clear()
void
close()
private void
compileSections
(Camera camera) int
private void
private void
private void
private void
void
destroyBlockProgress
(int breakerId, BlockPos pos, int progress) void
private boolean
doesMobEffectBlockSky
(Camera camera) private MeshData
drawStars
(Tesselator tesselator) double
static int
getLightColor
(BlockAndTintGetter level, BlockPos pos) static int
getLightColor
(BlockAndTintGetter level, BlockState state, BlockPos pos) int
getTicks()
double
void
globalLevelEvent
(int type, BlockPos pos, int data) Handles a global level event.void
boolean
void
private void
boolean
void
iterateVisibleBlockEntities
(Consumer<BlockEntity> blockEntityConsumer) void
void
levelEvent
(int type, BlockPos pos, int data) private static Vec3
mixColor
(float hue) void
private void
notifyNearbyEntities
(Level level, BlockPos pos, boolean playing) Notifies living entities in a 3 block range of the specifiedpos
that a record is or isn't playing nearby, dependent on the specifiedplaying
parameter.static Frustum
offsetFrustum
(Frustum frustum) void
onChunkLoaded
(ChunkPos chunkPos) void
onResourceManagerReload
(ResourceManager resourceManager) void
playJukeboxSong
(Holder<JukeboxSong> song, BlockPos pos) void
prepareCullFrustum
(Vec3 cameraPosition, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) private void
removeProgress
(BlockDestructionProgress progress) void
renderClouds
(PoseStack poseStack, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ) private void
renderDebug
(PoseStack poseStack, MultiBufferSource buffer, Camera camera) private void
renderEndSky
(PoseStack poseStack) private void
renderEntity
(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) static void
renderFace
(PoseStack poseStack, VertexConsumer buffer, Direction face, float x1, float y1, float z1, float x2, float y2, float z2, float red, float green, float blue, float alpha) private void
renderHitOutline
(PoseStack poseStack, VertexConsumer consumer, Entity entity, double camX, double camY, double camZ, BlockPos pos, BlockState state) void
renderLevel
(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) static void
renderLineBox
(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) static void
renderLineBox
(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha, float red2, float green2, float blue2) static void
renderLineBox
(PoseStack poseStack, VertexConsumer buffer, AABB box, float red, float green, float blue, float alpha) static void
renderLineBox
(VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) private void
renderSectionLayer
(RenderType renderType, double x, double y, double z, org.joml.Matrix4f frustrumMatrix, org.joml.Matrix4f projectionMatrix) private static void
renderShape
(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha) void
renderSky
(org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, Camera camera, boolean isFoggy, Runnable skyFogSetup) private void
renderSnowAndRain
(LightTexture lightTexture, float partialTick, double camX, double camY, double camZ) static void
renderVoxelShape
(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha, boolean p_286443_) private void
renderWorldBorder
(Camera camera) void
Neo: Request outline effect post-processing to be enabled for the current frame.void
resize
(int width, int height) private void
setBlockDirty
(BlockPos pos, boolean reRenderOnMainThread) void
setBlockDirty
(BlockPos pos, BlockState oldState, BlockState newState) void
setBlocksDirty
(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Re-renders all blocks in the specified range.void
setLevel
(ClientLevel level) void
setSectionDirty
(int sectionX, int sectionY, int sectionZ) private void
setSectionDirty
(int sectionX, int sectionY, int sectionZ, boolean reRenderOnMainThread) void
setSectionDirtyWithNeighbors
(int sectionX, int sectionY, int sectionZ) private void
setupRender
(Camera camera, Frustum frustum, boolean hasCapturedFrustum, boolean isSpectator) private static Vec3
shiftHue
(float red, float green, float blue, float hue) private void
shootParticles
(int p_direction, BlockPos pos, RandomSource random, SimpleParticleType particleType) boolean
private void
stopJukeboxSong
(BlockPos pos) void
void
tick()
void
void
updateGlobalBlockEntities
(Collection<BlockEntity> blockEntitiesToRemove, Collection<BlockEntity> blockEntitiesToAdd) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
getName
Methods inherited from interface net.minecraft.server.packs.resources.ResourceManagerReloadListener
reload
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
SECTION_SIZE
public static final int SECTION_SIZE- See Also:
-
HALF_SECTION_SIZE
public static final int HALF_SECTION_SIZE- See Also:
-
SKY_DISC_RADIUS
private static final float SKY_DISC_RADIUS- See Also:
-
MIN_FOG_DISTANCE
private static final int MIN_FOG_DISTANCE- See Also:
-
RAIN_RADIUS
private static final int RAIN_RADIUS- See Also:
-
RAIN_DIAMETER
private static final int RAIN_DIAMETER- See Also:
-
TRANSPARENT_SORT_COUNT
private static final int TRANSPARENT_SORT_COUNT- See Also:
-
MOON_LOCATION
-
SUN_LOCATION
-
CLOUDS_LOCATION
-
END_SKY_LOCATION
-
FORCEFIELD_LOCATION
-
RAIN_LOCATION
-
SNOW_LOCATION
-
DIRECTIONS
-
minecraft
-
entityRenderDispatcher
-
blockEntityRenderDispatcher
-
renderBuffers
-
level
-
sectionOcclusionGraph
-
visibleSections
private final it.unimi.dsi.fastutil.objects.ObjectArrayList<SectionRenderDispatcher.RenderSection> visibleSections -
globalBlockEntities
Global block entities; these are always rendered, even if off-screen. Any block entity is added to this ifBlockEntityRenderer.shouldRenderOffScreen(net.minecraft.world.level.block.entity.BlockEntity)
returnstrue
. -
viewArea
-
starBuffer
-
skyBuffer
-
darkBuffer
-
generateClouds
private boolean generateClouds -
cloudBuffer
-
frameTimes
-
ticks
private int ticks -
destroyingBlocks
-
destructionProgress
private final it.unimi.dsi.fastutil.longs.Long2ObjectMap<SortedSet<BlockDestructionProgress>> destructionProgress -
playingJukeboxSongs
-
entityTarget
-
entityEffect
-
translucentTarget
-
itemEntityTarget
-
particlesTarget
-
weatherTarget
-
cloudsTarget
-
transparencyChain
-
lastCameraSectionX
private int lastCameraSectionX -
lastCameraSectionY
private int lastCameraSectionY -
lastCameraSectionZ
private int lastCameraSectionZ -
prevCamX
private double prevCamX -
prevCamY
private double prevCamY -
prevCamZ
private double prevCamZ -
prevCamRotX
private double prevCamRotX -
prevCamRotY
private double prevCamRotY -
prevCloudX
private int prevCloudX -
prevCloudY
private int prevCloudY -
prevCloudZ
private int prevCloudZ -
prevCloudColor
-
prevCloudsType
-
sectionRenderDispatcher
-
lastViewDistance
private int lastViewDistance -
renderedEntities
private int renderedEntities -
culledEntities
private int culledEntities -
cullingFrustum
-
captureFrustum
private boolean captureFrustum -
capturedFrustum
-
frustumPoints
private final org.joml.Vector4f[] frustumPoints -
frustumPos
private final org.joml.Vector3d frustumPos -
xTransparentOld
private double xTransparentOld -
yTransparentOld
private double yTransparentOld -
zTransparentOld
private double zTransparentOld -
rainSoundTime
private int rainSoundTime -
rainSizeX
private final float[] rainSizeX -
rainSizeZ
private final float[] rainSizeZ -
outlineEffectRequested
private boolean outlineEffectRequestedNeo: Indicates whether outline effect post-processing was requested for the current frame outside of vanilla codepaths
-
-
Constructor Details
-
LevelRenderer
public LevelRenderer(Minecraft minecraft, EntityRenderDispatcher entityRenderDispatcher, BlockEntityRenderDispatcher blockEntityRenderDispatcher, RenderBuffers renderBuffers)
-
-
Method Details
-
renderSnowAndRain
private void renderSnowAndRain(LightTexture lightTexture, float partialTick, double camX, double camY, double camZ) -
tickRain
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
onResourceManagerReload
- Specified by:
onResourceManagerReload
in interfaceResourceManagerReloadListener
-
initOutline
public void initOutline() -
initTransparency
private void initTransparency() -
deinitTransparency
private void deinitTransparency() -
doEntityOutline
public void doEntityOutline() -
shouldShowEntityOutlines
public boolean shouldShowEntityOutlines() -
createDarkSky
private void createDarkSky() -
createLightSky
private void createLightSky() -
buildSkyDisc
-
createStars
private void createStars() -
drawStars
-
setLevel
- Parameters:
level
- the level to set, ornull
to clear
-
graphicsChanged
public void graphicsChanged() -
allChanged
public void allChanged() -
resize
public void resize(int width, int height) -
getSectionStatistics
-
getSectionRenderDispatcher
-
getTotalSections
public double getTotalSections() -
getLastViewDistance
public double getLastViewDistance() -
countRenderedSections
public int countRenderedSections() -
getEntityStatistics
-
setupRender
-
offsetFrustum
-
applyFrustum
-
addRecentlyCompiledSection
-
captureFrustum
private void captureFrustum(org.joml.Matrix4f viewMatrix, org.joml.Matrix4f projectionMatrix, double camX, double camY, double camZ, Frustum capturedFrustrum) -
prepareCullFrustum
public void prepareCullFrustum(Vec3 cameraPosition, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) -
renderLevel
public void renderLevel(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix) -
checkPoseStack
Asserts that the specifiedposeStack
is clear.- Throws:
IllegalStateException
- if the specifiedposeStack
is not clear
-
renderEntity
private void renderEntity(Entity entity, double camX, double camY, double camZ, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) -
renderSectionLayer
private void renderSectionLayer(RenderType renderType, double x, double y, double z, org.joml.Matrix4f frustrumMatrix, org.joml.Matrix4f projectionMatrix) -
renderDebug
-
addFrustumVertex
-
addFrustumQuad
private void addFrustumQuad(VertexConsumer consumer, org.joml.Matrix4f matrix, int index1, int index2, int index3, int index4, int red, int green, int blue) -
captureFrustum
public void captureFrustum() -
killFrustum
public void killFrustum() -
tick
public void tick() -
removeProgress
-
renderEndSky
-
renderSky
-
doesMobEffectBlockSky
-
renderClouds
public void renderClouds(PoseStack poseStack, org.joml.Matrix4f frustumMatrix, org.joml.Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ) -
buildClouds
-
compileSections
-
renderWorldBorder
-
renderHitOutline
private void renderHitOutline(PoseStack poseStack, VertexConsumer consumer, Entity entity, double camX, double camY, double camZ, BlockPos pos, BlockState state) -
mixColor
-
shiftHue
-
renderVoxelShape
public static void renderVoxelShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha, boolean p_286443_) -
renderShape
private static void renderShape(PoseStack poseStack, VertexConsumer consumer, VoxelShape shape, double x, double y, double z, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer buffer, AABB box, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
renderLineBox
public static void renderLineBox(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha, float red2, float green2, float blue2) -
addChainedFilledBoxVertices
public static void addChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha) -
addChainedFilledBoxVertices
public static void addChainedFilledBoxVertices(PoseStack poseStack, VertexConsumer consumer, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, float red, float green, float blue, float alpha) -
renderFace
public static void renderFace(PoseStack poseStack, VertexConsumer buffer, Direction face, float x1, float y1, float z1, float x2, float y2, float z2, float red, float green, float blue, float alpha) -
blockChanged
public void blockChanged(BlockGetter level, BlockPos pos, BlockState oldState, BlockState newState, int flags) -
setBlockDirty
-
setBlocksDirty
public void setBlocksDirty(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Re-renders all blocks in the specified range. -
setBlockDirty
-
setSectionDirtyWithNeighbors
public void setSectionDirtyWithNeighbors(int sectionX, int sectionY, int sectionZ) -
setSectionDirty
public void setSectionDirty(int sectionX, int sectionY, int sectionZ) -
setSectionDirty
private void setSectionDirty(int sectionX, int sectionY, int sectionZ, boolean reRenderOnMainThread) -
getFrustum
-
getTicks
public int getTicks() -
iterateVisibleBlockEntities
-
requestOutlineEffect
public void requestOutlineEffect()Neo: Request outline effect post-processing to be enabled for the current frame. Must be called before block entities are done rendering, ideally early during the frame -
playJukeboxSong
-
stopJukeboxSong
-
stopJukeboxSongAndNotifyNearby
-
notifyNearbyEntities
Notifies living entities in a 3 block range of the specifiedpos
that a record is or isn't playing nearby, dependent on the specifiedplaying
parameter. This is used to make parrots start or stop partying. -
addParticle
public void addParticle(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force
- iftrue
, the particle will be created regardless of its distance from the camera and theinvalid @linkplain
{@linkplain #
-
addParticle
public void addParticle(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force
- iftrue
, the particle will be created regardless of its distance from the camera and theinvalid @linkplain
{@linkplain #
decreased
- iftrue
, and the particles option is set to minimal, attempts to spawn the particle at a decreased level
-
addParticle
private <T extends ParticleOptions> void addParticle(T options, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) -
addParticleInternal
@Nullable private Particle addParticleInternal(ParticleOptions options, boolean force, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force
- iftrue
, the particle will be created regardless of its distance from the camera and theinvalid @linkplain
{@linkplain #
-
addParticleInternal
@Nullable private Particle addParticleInternal(ParticleOptions options, boolean force, boolean decreased, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) - Parameters:
force
- iftrue
, the particle will be created regardless of its distance from the camera and theinvalid @linkplain
{@linkplain #
decreased
- iftrue
, and the particles option is set to minimal, attempts to spawn the particle at a decreased level
-
calculateParticleLevel
Calculates the level of particles to use based on the particles option and the specifieddecreased
parameter. This leads to randomly generating more or less particles than the set option.- Parameters:
decreased
- iftrue
, and the particles option is set to minimal, has a 1 in 10 chance to return a decreased level and a further 1 in 3 chance to minimise it
-
clear
public void clear() -
globalLevelEvent
Handles a global level event. This includes playing sounds that should be heard by any player, regardless of position and dimension, such as the Wither spawning.- Parameters:
type
- the type of level event to handle. This method only handles invalid input: '{@' linkplain net.minecraft.world.level.block.LevelEvent# SOUND_WITHER_BOSS_SPAWN the wither boss spawn sound}, the dragon's death sound, and the end portal spawn sound.
-
levelEvent
-
destroyBlockProgress
-
hasRenderedAllSections
public boolean hasRenderedAllSections() -
onChunkLoaded
-
needsUpdate
public void needsUpdate() -
updateGlobalBlockEntities
public void updateGlobalBlockEntities(Collection<BlockEntity> blockEntitiesToRemove, Collection<BlockEntity> blockEntitiesToAdd) -
getLightColor
-
getLightColor
-
isSectionCompiled
-
entityTarget
-
getTranslucentTarget
-
getItemEntityTarget
-
getParticlesTarget
-
getWeatherTarget
-
getCloudsTarget
-
shootParticles
private void shootParticles(int p_direction, BlockPos pos, RandomSource random, SimpleParticleType particleType)
-