Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ nightconfig_version=3.8.3
jetbrains_annotations_version=24.0.1
apache_maven_artifact_version=3.9.9
jarjar_version=0.4.1
fancy_mod_loader_version=11.0.13
fancy_mod_loader_version=11.0.24-pr-430-els_backend
typetools_version=0.6.3
mixin_extras_version=0.5.4

Expand Down
41 changes: 5 additions & 36 deletions patches/com/mojang/blaze3d/platform/Window.java.patch
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
--- a/com/mojang/blaze3d/platform/Window.java
+++ b/com/mojang/blaze3d/platform/Window.java
@@ -102,6 +_,16 @@
this.windowedWidth = this.width = allowedWindowMinSize(displayData.width());
this.windowedHeight = this.height = allowedWindowMinSize(displayData.height());
this.handle = this.createWindow(backend, this.width, this.height, title, this.fullscreen && initialMonitor != null ? initialMonitor.monitor() : 0L);
+ // Neo: If the window was taken over from EarlyLoadingScreen, inherit a potentially resized window size
+ var earlyLoadingScreen = net.neoforged.fml.loading.EarlyLoadingScreenController.current();
+ if (earlyLoadingScreen != null) {
+ var width = new int[1];
+ var height = new int[1];
+ GLFW.glfwGetWindowSize(this.handle, width, height);
+ // The window height and width can be 0 if minimized
+ this.width = this.windowedWidth = Math.max(width[0], 1);
+ this.height = this.windowedHeight = Math.max(height[0], 1);
+ }
this.backend = backend;
if (initialMonitor != null) {
VideoMode mode = initialMonitor.getPreferredVidMode(this.fullscreen ? this.preferredFullscreenVideoMode : Optional.empty());
@@ -132,6 +_,11 @@
try (GLFWErrorScope var9 = new GLFWErrorScope(glfwErrors)) {
backend.setWindowHints();
GLFW.glfwWindowHint(131076, 0);
+ var earlyLoadingScreen = net.neoforged.fml.loading.EarlyLoadingScreenController.current();
+ if (earlyLoadingScreen != null) {
+ windowHandle = earlyLoadingScreen.takeOverGlfwWindow();
+ GLFW.glfwSetWindowTitle(windowHandle, title);
+ } else
windowHandle = GLFW.glfwCreateWindow(width, height, title, monitor, 0L);
if (windowHandle == 0L) {
backend.handleWindowCreationErrors(glfwErrors.firstError());
@@ -237,11 +_,11 @@
}

public void defaultErrorCallback(int errorCode, long description) {
- if (!RenderSystem.isOnRenderThread()) {
+ String errorString = MemoryUtil.memUTF8(description);
if (!RenderSystem.isOnRenderThread()) {
- LOGGER.error("Error callback from invalid thread ({})", Thread.currentThread().getName());
- }
-
String errorString = MemoryUtil.memUTF8(description);
+ if (!RenderSystem.isOnRenderThread()) {
+ LOGGER.error("Error callback from invalid thread ({}): {}: {}", Thread.currentThread().getName(), errorCode, errorString);
+ }
+
}

- String errorString = MemoryUtil.memUTF8(description);
LOGGER.error("########## GL ERROR ##########");
LOGGER.error("@ {}", this.errorSection);
LOGGER.error("{}: {}", errorCode, errorString);
26 changes: 15 additions & 11 deletions patches/net/minecraft/client/Minecraft.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,18 @@
this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.modelManager);
WindowRenderState windowRenderState = this.gameRenderer.gameRenderState().windowRenderState;
windowRenderState.width = this.window.getWidth();
@@ -654,6 +_,9 @@
this.gpuWarnlistManager = new GpuWarnlistManager();
this.resourceManager.registerReloadListener(this.gpuWarnlistManager);
this.resourceManager.registerReloadListener(this.regionalCompliancies);
+ // NEO: Moved keyboard and mouse handler setup below ingame gui creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window);
this.gui = new Gui(this, new Hud(this), this.gameRenderer.gameRenderState().guiRenderState);
this.gui.registerReloadListeners(this.resourceManager);
RealmsClient realmsClient = RealmsClient.getOrCreate(this);
@@ -688,6 +_,7 @@
@@ -688,9 +_,11 @@
}
}

+ net.neoforged.neoforge.client.ClientHooks.initClientHooks(this, this.resourceManager);
this.window.updateRawMouseInput(this.options.rawMouseInput().get());
this.window.setAllowCursorChanges(this.options.allowCursorChanges().get());
this.window.setDefaultErrorCallback();
+ net.neoforged.neoforge.client.ClientHooks.takeOverLoadingScreen(this.window);
GLFW.glfwShowWindow(windowCandidate.handle());
this.resizeGui();
this.loadCriticalShaders();
@@ -704,6 +_,7 @@
TitleScreen.registerTextures(this.textureManager);
LoadingOverlay.registerTextures(this.textureManager);
Expand All @@ -118,6 +112,16 @@
this.selfTest();
}

@@ -722,6 +_,9 @@
}), false));
this.quickPlayLog = QuickPlayLog.of(gameConfig.quickPlay.logPath());
this.framerateLimitTracker = new FramerateLimitTracker(this.options, this);
+ // NEO: Moved keyboard and mouse handler setup below ingame gui and framerate limiter creation to prevent NPEs in them.
+ this.mouseHandler.setup(this.window);
+ this.keyboardHandler.setup(this.window);
this.fpsPieProfiler = new ContinuousProfiler(Util.timeSource(), () -> this.fpsPieRenderTicks, this.framerateLimitTracker::isHeavilyThrottled);
if (TracyClient.isAvailable() && gameConfig.game.captureTracyImages) {
this.tracyFrameCapture = new TracyFrameCapture();
@@ -767,6 +_,7 @@
}

Expand Down
9 changes: 9 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ dependencyResolutionManagement {
rulesMode = RulesMode.FAIL_ON_PROJECT_RULES
repositories {
mavenCentral()
maven {
name = "Maven for PR #430" // https://github.com/neoforged/FancyModLoader/pull/430
url = uri("https://prmaven.neoforged.net/FancyModLoader/pr430")
content {
includeModule("net.neoforged.fancymodloader", "earlydisplay")
includeModule("net.neoforged.fancymodloader", "junit-fml")
includeModule("net.neoforged.fancymodloader", "loader")
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/client/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
import net.minecraft.world.level.material.FogType;
import net.neoforged.bus.api.Event;
import net.neoforged.fml.ModLoader;
import net.neoforged.fml.loading.EarlyLoadingScreenController;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.client.config.NeoForgeClientConfig;
import net.neoforged.neoforge.client.entity.animation.json.AnimationTypeManager;
Expand Down Expand Up @@ -190,6 +191,7 @@
import net.neoforged.neoforge.client.gui.ClientTooltipComponentManager;
import net.neoforged.neoforge.client.gui.PictureInPictureRendererRegistration;
import net.neoforged.neoforge.client.gui.map.MapDecorationRendererManager;
import net.neoforged.neoforge.client.loading.earlydisplay.Blaze3DRenderBackend;
import net.neoforged.neoforge.client.model.block.BlockStateModelHooks;
import net.neoforged.neoforge.client.pipeline.PipelineModifiers;
import net.neoforged.neoforge.client.renderstate.RegisterRenderStateModifiersEvent;
Expand Down Expand Up @@ -1025,4 +1027,12 @@ public static Map<Fluid, FluidModel> gatherFluidModels(Map<Fluid, FluidModel> mo
}
return Map.copyOf(models);
}

public static void takeOverLoadingScreen(Window window) {
EarlyLoadingScreenController earlyLoadingScreen = EarlyLoadingScreenController.current();
if (earlyLoadingScreen != null) {
earlyLoadingScreen.handOverToMinecraft(() -> new Blaze3DRenderBackend(window));
earlyLoadingScreen.periodicTick();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.loading.earlydisplay;

import com.mojang.blaze3d.buffers.GpuBuffer;
import java.util.Set;
import net.neoforged.fml.earlydisplay.render.backend.ELSBuffer;

@SuppressWarnings("UnstableApiUsage")
final class Blaze3DBuffer implements ELSBuffer {
private final GpuBuffer b3dBuffer;
private final Set<Usage> usage;
private final int usageMask;
private final Blaze3DBufferSlice defaultSlice;

Blaze3DBuffer(GpuBuffer b3dBuffer, Set<Usage> usage, int usageMask) {
this.b3dBuffer = b3dBuffer;
this.usage = usage;
this.usageMask = usageMask;
this.defaultSlice = new Blaze3DBufferSlice(this, b3dBuffer.slice(0, b3dBuffer.size()));
}

@Override
public Set<Usage> usage() {
return this.usage;
}

@Override
public long size() {
return this.b3dBuffer.size();
}

@Override
public Blaze3DBufferSlice slice() {
return this.defaultSlice;
}

@Override
public Blaze3DBufferSlice slice(long offset, long length) {
return new Blaze3DBufferSlice(this, this.b3dBuffer.slice(offset, length));
}

@Override
public void close() {
this.b3dBuffer.close();
}

int getUsageMask() {
return this.usageMask;
}

GpuBuffer unwrap() {
return this.b3dBuffer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.loading.earlydisplay;

import com.mojang.blaze3d.buffers.GpuBufferSlice;
import net.neoforged.fml.earlydisplay.render.backend.ELSBufferSlice;

@SuppressWarnings("UnstableApiUsage")
final class Blaze3DBufferSlice implements ELSBufferSlice {
private final Blaze3DBuffer buffer;
private final GpuBufferSlice b3dBufferSlice;

Blaze3DBufferSlice(Blaze3DBuffer buffer, GpuBufferSlice b3dBufferSlice) {
this.buffer = buffer;
this.b3dBufferSlice = b3dBufferSlice;
}

@Override
public Blaze3DBuffer buffer() {
return this.buffer;
}

@Override
public long offset() {
return this.b3dBufferSlice.offset();
}

@Override
public long length() {
return this.b3dBufferSlice.length();
}

GpuBufferSlice unwrap() {
return this.b3dBufferSlice;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.loading.earlydisplay;

import com.mojang.blaze3d.buffers.GpuBuffer;
import java.util.Set;
import net.neoforged.fml.earlydisplay.render.backend.ELSBuffer;

@SuppressWarnings("UnstableApiUsage")
final class Blaze3DConst {
static int elsUsageToB3D(Set<ELSBuffer.Usage> usage) {
int mask = 0;
for (ELSBuffer.Usage entry : usage) {
mask |= switch (entry) {
case MAP_READ -> GpuBuffer.USAGE_MAP_READ;
case MAP_WRITE -> GpuBuffer.USAGE_MAP_WRITE;
case HINT_CLIENT_STORAGE -> GpuBuffer.USAGE_HINT_CLIENT_STORAGE;
case COPY_DST -> GpuBuffer.USAGE_COPY_DST;
case COPY_SRC -> GpuBuffer.USAGE_COPY_SRC;
case VERTEX -> GpuBuffer.USAGE_VERTEX;
case INDEX -> GpuBuffer.USAGE_INDEX;
case UNIFORM -> GpuBuffer.USAGE_UNIFORM;
};
}
return mask;
}

private Blaze3DConst() {}
}
Loading
Loading