LevelLoadingScreen.java
net.minecraft.client.gui.screens.LevelLoadingScreen
信息
- 全限定名:net.minecraft.client.gui.screens.LevelLoadingScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens
- 源码路径:src/main/java/net/minecraft/client/gui/screens/LevelLoadingScreen.java
- 起始行号:L30
- 继承:Screen
- 职责:
TODO
字段/常量
-
DOWNLOADING_TERRAIN_TEXT- 类型:
Component - 修饰符:
private static final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
READY_TO_PLAY_TEXT- 类型:
Component - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
NARRATION_DELAY_MS- 类型:
long - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
PROGRESS_BAR_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
loadTracker- 类型:
LevelLoadTracker - 修饰符:
private - 源码定位:
L35 - 说明:
TODO
- 类型:
-
smoothedProgress- 类型:
float - 修饰符:
private - 源码定位:
L36 - 说明:
TODO
- 类型:
-
lastNarration- 类型:
long - 修饰符:
private - 源码定位:
L37 - 说明:
TODO
- 类型:
-
reason- 类型:
LevelLoadingScreen.Reason - 修饰符:
private - 源码定位:
L38 - 说明:
TODO
- 类型:
-
cachedNetherPortalSprite- 类型:
TextureAtlasSprite - 修饰符:
private - 源码定位:
L39 - 说明:
TODO
- 类型:
-
COLORS- 类型:
Object2IntMap<ChunkStatus> - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.screens.LevelLoadingScreen.Reason- 类型:
enum - 修饰符:
public static - 源码定位:
L195 - 说明:
TODO
- 类型:
构造器
public LevelLoadingScreen(LevelLoadTracker loadTracker, LevelLoadingScreen.Reason reason) @ L56
- 构造器名:LevelLoadingScreen
- 源码定位:L56
- 修饰符:public
参数:
- loadTracker: LevelLoadTracker
- reason: LevelLoadingScreen.Reason
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void update(LevelLoadTracker loadTracker, LevelLoadingScreen.Reason reason) @ L62
- 方法名:update
- 源码定位:L62
- 返回类型:void
- 修饰符:public
参数:
- loadTracker: LevelLoadTracker
- reason: LevelLoadingScreen.Reason
说明:
TODO
public boolean shouldCloseOnEsc() @ L67
- 方法名:shouldCloseOnEsc
- 源码定位:L67
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
protected boolean shouldNarrateNavigation() @ L72
- 方法名:shouldNarrateNavigation
- 源码定位:L72
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void updateNarratedWidget(NarrationElementOutput output) @ L77
- 方法名:updateNarratedWidget
- 源码定位:L77
- 返回类型:void
- 修饰符:protected
参数:
- output: NarrationElementOutput
说明:
TODO
public void tick() @ L84
- 方法名:tick
- 源码定位:L84
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L93
- 方法名:extractRenderState
- 源码定位:L93
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
private void drawProgressBar(GuiGraphicsExtractor graphics, int left, int top, int width, int height, float progress) @ L120
- 方法名:drawProgressBar
- 源码定位:L120
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- left: int
- top: int
- width: int
- height: int
- progress: float
说明:
TODO
public static void extractChunksForRendering(GuiGraphicsExtractor graphics, int xCenter, int yCenter, int size, int margin, ChunkLoadStatusView statusView) @ L125
- 方法名:extractChunksForRendering
- 源码定位:L125
- 返回类型:void
- 修饰符:public static
参数:
- graphics: GuiGraphicsExtractor
- xCenter: int
- yCenter: int
- size: int
- margin: int
- statusView: ChunkLoadStatusView
说明:
TODO
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L146
- 方法名:extractBackground
- 源码定位:L146
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
private TextureAtlasSprite getNetherPortalSprite() @ L170
- 方法名:getNetherPortalSprite
- 源码定位:L170
- 返回类型:TextureAtlasSprite
- 修饰符:private
参数:
- 无
说明:
TODO
public void onClose() @ L183
- 方法名:onClose
- 源码定位:L183
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isPauseScreen() @ L189
- 方法名:isPauseScreen
- 源码定位:L189
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class LevelLoadingScreen extends Screen {
private static final Component DOWNLOADING_TERRAIN_TEXT = Component.translatable("multiplayer.downloadingTerrain");
private static final Component READY_TO_PLAY_TEXT = Component.translatable("narrator.ready_to_play");
private static final long NARRATION_DELAY_MS = 2000L;
private static final int PROGRESS_BAR_WIDTH = 200;
private LevelLoadTracker loadTracker;
private float smoothedProgress;
private long lastNarration = -1L;
private LevelLoadingScreen.Reason reason;
private @Nullable TextureAtlasSprite cachedNetherPortalSprite;
private static final Object2IntMap<ChunkStatus> COLORS = Util.make(new Object2IntOpenHashMap<>(), map -> {
map.defaultReturnValue(0);
map.put(ChunkStatus.EMPTY, 5526612);
map.put(ChunkStatus.STRUCTURE_STARTS, 10066329);
map.put(ChunkStatus.STRUCTURE_REFERENCES, 6250897);
map.put(ChunkStatus.BIOMES, 8434258);
map.put(ChunkStatus.NOISE, 13750737);
map.put(ChunkStatus.SURFACE, 7497737);
map.put(ChunkStatus.CARVERS, 3159410);
map.put(ChunkStatus.FEATURES, 2213376);
map.put(ChunkStatus.INITIALIZE_LIGHT, 13421772);
map.put(ChunkStatus.LIGHT, 16769184);
map.put(ChunkStatus.SPAWN, 15884384);
map.put(ChunkStatus.FULL, 16777215);
});
public LevelLoadingScreen(LevelLoadTracker loadTracker, LevelLoadingScreen.Reason reason) {
super(GameNarrator.NO_TITLE);
this.loadTracker = loadTracker;
this.reason = reason;
}
public void update(LevelLoadTracker loadTracker, LevelLoadingScreen.Reason reason) {
this.loadTracker = loadTracker;
this.reason = reason;
}
@Override
public boolean shouldCloseOnEsc() {
return false;
}
@Override
protected boolean shouldNarrateNavigation() {
return false;
}
@Override
protected void updateNarratedWidget(NarrationElementOutput output) {
if (this.loadTracker.hasProgress()) {
output.add(NarratedElementType.TITLE, Component.translatable("loading.progress", Mth.floor(this.loadTracker.serverProgress() * 100.0F)));
}
}
@Override
public void tick() {
super.tick();
this.smoothedProgress = this.smoothedProgress + (this.loadTracker.serverProgress() - this.smoothedProgress) * 0.2F;
if (this.loadTracker.isLevelReady()) {
this.onClose();
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
long current = Util.getMillis();
if (current - this.lastNarration > 2000L) {
this.lastNarration = current;
this.triggerImmediateNarration(true);
}
int xCenter = this.width / 2;
int yCenter = this.height / 2;
ChunkLoadStatusView statusView = this.loadTracker.statusView();
int textTop;
if (statusView != null) {
int size = 2;
extractChunksForRendering(graphics, xCenter, yCenter, 2, 0, statusView);
textTop = yCenter - statusView.radius() * 2 - 9 * 3;
} else {
textTop = yCenter - 50;
}
graphics.centeredText(this.font, DOWNLOADING_TERRAIN_TEXT, xCenter, textTop, -1);
if (this.loadTracker.hasProgress()) {
this.drawProgressBar(graphics, xCenter - 100, textTop + 9 + 3, 200, 2, this.smoothedProgress);
}
}
private void drawProgressBar(GuiGraphicsExtractor graphics, int left, int top, int width, int height, float progress) {
graphics.fill(left, top, left + width, top + height, -16777216);
graphics.fill(left, top, left + Math.round(progress * width), top + height, -16711936);
}
public static void extractChunksForRendering(GuiGraphicsExtractor graphics, int xCenter, int yCenter, int size, int margin, ChunkLoadStatusView statusView) {
int width = size + margin;
int diameter = statusView.radius() * 2 + 1;
int totalWidth = diameter * width - margin;
int xStart = xCenter - totalWidth / 2;
int yStart = yCenter - totalWidth / 2;
if (Minecraft.getInstance().debugEntries.isCurrentlyEnabled(DebugScreenEntries.VISUALIZE_CHUNKS_ON_SERVER)) {
int centerWidth = width / 2 + 1;
graphics.fill(xCenter - centerWidth, yCenter - centerWidth, xCenter + centerWidth, yCenter + centerWidth, -65536);
}
for (int x = 0; x < diameter; x++) {
for (int z = 0; z < diameter; z++) {
ChunkStatus status = statusView.get(x, z);
int xCellStart = xStart + x * width;
int yCellStart = yStart + z * width;
graphics.fill(xCellStart, yCellStart, xCellStart + size, yCellStart + size, ARGB.opaque(COLORS.getInt(status)));
}
}
}
@Override
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
switch (this.reason) {
case NETHER_PORTAL:
graphics.blitSprite(
RenderPipelines.GUI_OPAQUE_TEXTURED_BACKGROUND, this.getNetherPortalSprite(), 0, 0, graphics.guiWidth(), graphics.guiHeight()
);
break;
case END_PORTAL:
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
AbstractTexture skyTexture = textureManager.getTexture(AbstractEndPortalRenderer.END_SKY_LOCATION);
AbstractTexture portalTexture = textureManager.getTexture(AbstractEndPortalRenderer.END_PORTAL_LOCATION);
TextureSetup textureSetup = TextureSetup.doubleTexture(
skyTexture.getTextureView(), skyTexture.getSampler(), portalTexture.getTextureView(), portalTexture.getSampler()
);
graphics.fill(RenderPipelines.END_PORTAL, textureSetup, 0, 0, this.width, this.height);
break;
case OTHER:
this.extractPanorama(graphics, a);
this.extractBlurredBackground(graphics);
this.extractMenuBackground(graphics);
}
}
private TextureAtlasSprite getNetherPortalSprite() {
if (this.cachedNetherPortalSprite != null) {
return this.cachedNetherPortalSprite;
} else {
this.cachedNetherPortalSprite = this.minecraft
.getModelManager()
.getBlockStateModelSet()
.getParticleMaterial(Blocks.NETHER_PORTAL.defaultBlockState())
.sprite();
return this.cachedNetherPortalSprite;
}
}
@Override
public void onClose() {
this.minecraft.getNarrator().saySystemNow(READY_TO_PLAY_TEXT);
super.onClose();
}
@Override
public boolean isPauseScreen() {
return false;
}
@OnlyIn(Dist.CLIENT)
public static enum Reason {
NETHER_PORTAL,
END_PORTAL,
OTHER;
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
TextureSetup.doubleTexture()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.opaque()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.floor()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getMillis(), Util.make()
- 引用位置:
-
- 引用位置:
字段
- 引用位置: