Skip to content

Commit 79751da

Browse files
committed
Merge 1.20 into 1.20.2
2 parents 1339fc7 + b6a47da commit 79751da

File tree

6 files changed

+113
-60
lines changed

6 files changed

+113
-60
lines changed

common/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ dependencies {
2727
transitive = false
2828
}
2929

30-
modCompileOnly("curse.maven:diagonal-fences-458048:${diagonal_fences_version}")
31-
3230
modCompileOnly "curse.maven:spark-361579:${rootProject.spark_version}"
3331
// compile against the JEI API but do not include it at runtime
3432
modCompileOnly("mezz.jei:jei-${jei_minecraft_version}-common:${jei_version}")

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources/diagonalfences/MultipartAppenderMixin.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public DefaultSettingMapBuilder put(String key, Boolean value) {
176176
.put("mixin.perf.remove_spawn_chunks", isDevEnv)
177177
.putConditionally(() -> !isFabric, "mixin.bugfix.fix_config_crashes", true)
178178
.putConditionally(() -> !isFabric, "mixin.bugfix.forge_at_inject_error", true)
179+
.putConditionally(() -> !isFabric, "mixin.feature.registry_event_progress", false)
179180
.putConditionally(() -> isFabric, "mixin.perf.clear_fabric_mapping_tables", false)
180181
.build();
181182

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package org.embeddedt.modernfix.forge.mixin.feature.registry_event_progress;
2+
3+
import net.minecraftforge.eventbus.api.Event;
4+
import net.minecraftforge.fml.ModList;
5+
import net.minecraftforge.fml.ModLoader;
6+
import net.minecraftforge.fml.ModLoadingContext;
7+
import net.minecraftforge.fml.StartupMessageManager;
8+
import net.minecraftforge.fml.event.IModBusEvent;
9+
import net.minecraftforge.registries.GameData;
10+
import net.minecraftforge.registries.RegisterEvent;
11+
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
12+
import org.embeddedt.modernfix.forge.util.AsyncLoadingScreen;
13+
import org.spongepowered.asm.mixin.Mixin;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
import org.spongepowered.asm.mixin.injection.Inject;
16+
import org.spongepowered.asm.mixin.injection.Redirect;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18+
19+
@Mixin(value = GameData.class, remap = false)
20+
@ClientOnlyMixin
21+
public class GameDataMixin {
22+
23+
private static AsyncLoadingScreen mfix$asyncScreen;
24+
25+
@Inject(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;", ordinal = 0))
26+
private static void createAsyncScreen(CallbackInfo ci) {
27+
mfix$asyncScreen = new AsyncLoadingScreen();
28+
}
29+
30+
@Inject(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Ljava/lang/RuntimeException;getSuppressed()[Ljava/lang/Throwable;", ordinal = 0))
31+
private static void closeAsyncScreen(CallbackInfo ci) {
32+
mfix$asyncScreen.close();
33+
mfix$asyncScreen = null;
34+
}
35+
36+
@Redirect(method = "postRegisterEvents", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/ModLoader;postEventWrapContainerInModOrder(Lnet/minecraftforge/eventbus/api/Event;)V"))
37+
private static <T extends Event & IModBusEvent> void swapThreadAndPost(ModLoader loader, T event) {
38+
RegisterEvent registryEvent = (RegisterEvent)event;
39+
var pb = StartupMessageManager.addProgressBar(registryEvent.getRegistryKey().location().toString(), ModList.get().size());
40+
try {
41+
loader.postEventWithWrapInModOrder(event, (mc, e) -> {
42+
ModLoadingContext.get().setActiveContainer(mc);
43+
pb.label(pb.name() + " - " + mc.getModInfo().getDisplayName());
44+
pb.increment();
45+
}, (mc, e) -> {
46+
ModLoadingContext.get().setActiveContainer(null);
47+
});
48+
} finally {
49+
pb.complete();
50+
}
51+
}
52+
}

forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/dynamic_resources/rs/ClientSetupMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
public class ClientSetupMixin {
2323
@Shadow(remap = false) @Final private static BakedModelOverrideRegistry BAKED_MODEL_OVERRIDE_REGISTRY;
2424

25-
@Inject(method = "<init>", at = @At("RETURN"))
26-
private void addDynamicListener(CallbackInfo ci) {
25+
@Inject(method = "registerBakedModelOverrides", at = @At("RETURN"), remap = false)
26+
private static void addDynamicListener(CallbackInfo ci) {
2727
ModernFixClient.CLIENT_INTEGRATIONS.add(new ModernFixClientIntegration() {
2828
@Override
2929
public BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.embeddedt.modernfix.forge.util;
2+
3+
import net.minecraftforge.fml.loading.ImmediateWindowHandler;
4+
import org.lwjgl.glfw.GLFW;
5+
import org.lwjgl.opengl.GL;
6+
import org.lwjgl.opengl.GLCapabilities;
7+
8+
import java.util.concurrent.TimeUnit;
9+
import java.util.concurrent.atomic.AtomicBoolean;
10+
import java.util.concurrent.locks.LockSupport;
11+
12+
public class AsyncLoadingScreen extends Thread implements AutoCloseable {
13+
private final long theWindow;
14+
private final AtomicBoolean keepRunning;
15+
16+
private static int splashThreadNum = 1;
17+
18+
private static GLCapabilities caps;
19+
20+
public AsyncLoadingScreen() {
21+
this.setName("ModernFix splash thread " + splashThreadNum++);
22+
this.theWindow = GLFW.glfwGetCurrentContext();
23+
if(caps == null)
24+
caps = GL.createCapabilities();
25+
if(this.theWindow == 0)
26+
throw new IllegalStateException("No context found but async loading screen was requested");
27+
this.keepRunning = new AtomicBoolean(true);
28+
this.start();
29+
}
30+
31+
@Override
32+
public synchronized void start() {
33+
GLFW.glfwMakeContextCurrent(0);
34+
super.start();
35+
}
36+
37+
@Override
38+
public void run() {
39+
GLFW.glfwMakeContextCurrent(theWindow);
40+
GL.setCapabilities(caps);
41+
while(keepRunning.get()) {
42+
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(50));
43+
ImmediateWindowHandler.renderTick();
44+
}
45+
GLFW.glfwMakeContextCurrent(0);
46+
}
47+
48+
@Override
49+
public void close() {
50+
keepRunning.set(false);
51+
try {
52+
this.join();
53+
} catch(InterruptedException e) {
54+
Thread.currentThread().interrupt();
55+
}
56+
GLFW.glfwMakeContextCurrent(theWindow);
57+
}
58+
}

0 commit comments

Comments
 (0)