Merge remote-tracking branch 'origin/1.18' into 1.19.2
This commit is contained in:
commit
a218d84931
|
|
@ -1,6 +1,7 @@
|
||||||
package org.embeddedt.modernfix;
|
package org.embeddedt.modernfix;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
|
import net.minecraft.Util;
|
||||||
import net.minecraft.server.level.ChunkHolder;
|
import net.minecraft.server.level.ChunkHolder;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
@ -24,6 +25,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.embeddedt.modernfix.classloading.ModFileScanDataDeduplicator;
|
import org.embeddedt.modernfix.classloading.ModFileScanDataDeduplicator;
|
||||||
|
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
||||||
import org.embeddedt.modernfix.core.config.ModernFixConfig;
|
import org.embeddedt.modernfix.core.config.ModernFixConfig;
|
||||||
import org.embeddedt.modernfix.entity.EntityDataIDSyncHandler;
|
import org.embeddedt.modernfix.entity.EntityDataIDSyncHandler;
|
||||||
import org.embeddedt.modernfix.packet.PacketHandler;
|
import org.embeddedt.modernfix.packet.PacketHandler;
|
||||||
|
|
@ -32,9 +34,8 @@ import org.embeddedt.modernfix.util.ClassInfoManager;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
// The value here should match an entry in the META-INF/mods.toml file
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
|
|
@ -53,6 +54,26 @@ public class ModernFix {
|
||||||
|
|
||||||
public static CountDownLatch worldLoadSemaphore = null;
|
public static CountDownLatch worldLoadSemaphore = null;
|
||||||
|
|
||||||
|
private static ExecutorService resourceReloadService = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.dedicated_reload_executor.ReloadExecutor")) {
|
||||||
|
Method makeExecutorMethod = ObfuscationReflectionHelper.findMethod(Util.class, "m_137477_", String.class);
|
||||||
|
resourceReloadService = (ExecutorService)makeExecutorMethod.invoke(null, "ResourceReload");
|
||||||
|
} else {
|
||||||
|
resourceReloadService = Util.backgroundExecutor();
|
||||||
|
}
|
||||||
|
} catch(RuntimeException | ReflectiveOperationException e) {
|
||||||
|
LOGGER.error("Could not create resource reload executor", e);
|
||||||
|
resourceReloadService = Util.backgroundExecutor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExecutorService resourceReloadExecutor() {
|
||||||
|
return resourceReloadService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple mechanism used to delay some background processes until the client is actually in-game, to reduce
|
* Simple mechanism used to delay some background processes until the client is actually in-game, to reduce
|
||||||
* launch time.
|
* launch time.
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
||||||
config.getOptionCount(), config.getOptionOverrideCount());
|
config.getOptionCount(), config.getOptionOverrideCount());
|
||||||
|
|
||||||
FastAccessTransformerList.attemptReplace();
|
FastAccessTransformerList.attemptReplace();
|
||||||
ModWorkManagerQueue.replace();
|
|
||||||
DFUBlaster.blastMaps();
|
DFUBlaster.blastMaps();
|
||||||
|
|
||||||
/* https://github.com/FabricMC/Mixin/pull/99 */
|
/* https://github.com/FabricMC/Mixin/pull/99 */
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ public class ModernFixEarlyConfig {
|
||||||
this.addMixinRule("perf.reduce_blockstate_cache_rebuilds", true);
|
this.addMixinRule("perf.reduce_blockstate_cache_rebuilds", true);
|
||||||
this.addMixinRule("perf.model_optimizations", true);
|
this.addMixinRule("perf.model_optimizations", true);
|
||||||
this.addMixinRule("perf.dynamic_resources", false);
|
this.addMixinRule("perf.dynamic_resources", false);
|
||||||
|
this.addMixinRule("perf.dedicated_reload_executor", true);
|
||||||
/* Use a simpler ArrayMap if FerriteCore is using the map intelligently anyway */
|
/* Use a simpler ArrayMap if FerriteCore is using the map intelligently anyway */
|
||||||
this.addMixinRule("perf.state_definition_construct", modPresent("ferritecore"));
|
this.addMixinRule("perf.state_definition_construct", modPresent("ferritecore"));
|
||||||
this.addMixinRule("perf.cache_strongholds", true);
|
this.addMixinRule("perf.cache_strongholds", true);
|
||||||
|
|
@ -65,6 +66,7 @@ public class ModernFixEarlyConfig {
|
||||||
|
|
||||||
/* Mod compat */
|
/* Mod compat */
|
||||||
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot");
|
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot");
|
||||||
|
disableIfModPresent("mixin.perf.boost_worker_count", "smoothboot");
|
||||||
disableIfModPresent("mixin.perf.async_jei", "modernui");
|
disableIfModPresent("mixin.perf.async_jei", "modernui");
|
||||||
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge");
|
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge");
|
||||||
disableIfModPresent("mixin.bugfix.mc218112", "performant");
|
disableIfModPresent("mixin.bugfix.mc218112", "performant");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.core;
|
||||||
|
|
||||||
|
import net.minecraft.server.Bootstrap;
|
||||||
|
import org.embeddedt.modernfix.load.ModWorkManagerQueue;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Bootstrap.class)
|
||||||
|
public class BootstrapMixin {
|
||||||
|
@Shadow private static boolean isBootstrapped;
|
||||||
|
|
||||||
|
@Shadow @Final private static Logger LOGGER;
|
||||||
|
|
||||||
|
@Inject(method = "bootStrap", at = @At("HEAD"))
|
||||||
|
private static void doModernFixBootstrap(CallbackInfo ci) {
|
||||||
|
if(!isBootstrapped) {
|
||||||
|
LOGGER.info("ModernFix bootstrap");
|
||||||
|
ModWorkManagerQueue.replace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.perf.dedicated_reload_executor;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
@Mixin(CreateWorldScreen.class)
|
||||||
|
public class CreateWorldScreenMixin {
|
||||||
|
@ModifyArg(method = "tryApplyNewDataPacks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldLoader;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Lnet/minecraft/server/WorldLoader$ResultFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), index = 3)
|
||||||
|
private Executor getReloadExecutorService(Executor e) {
|
||||||
|
return ModernFix.resourceReloadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldLoader;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Lnet/minecraft/server/WorldLoader$ResultFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), index = 3)
|
||||||
|
private static Executor getCreationExecutorService(Executor e) {
|
||||||
|
return ModernFix.resourceReloadExecutor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.perf.dedicated_reload_executor;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public class MinecraftMixin {
|
||||||
|
@Redirect(method = { "<init>", "reloadResourcePacks(Z)Ljava/util/concurrent/CompletableFuture;" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/Util;backgroundExecutor()Ljava/util/concurrent/ExecutorService;", ordinal = 0))
|
||||||
|
private ExecutorService getResourceReloadExecutor() {
|
||||||
|
return ModernFix.resourceReloadExecutor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.perf.dedicated_reload_executor;
|
||||||
|
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
@Mixin(MinecraftServer.class)
|
||||||
|
public class MinecraftServerMixin {
|
||||||
|
@ModifyArg(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/ReloadableServerResources;loadResources(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess$Frozen;Lnet/minecraft/commands/Commands$CommandSelection;ILjava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), index = 4)
|
||||||
|
private Executor getReloadExecutor(Executor asyncExecutor) {
|
||||||
|
return ModernFix.resourceReloadExecutor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.perf.dedicated_reload_executor;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
@Mixin(WorldOpenFlows.class)
|
||||||
|
public class WorldOpenFlowsMixin {
|
||||||
|
@ModifyArg(method = "loadWorldStem(Lnet/minecraft/server/WorldLoader$PackConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;)Lnet/minecraft/server/WorldStem;", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/WorldStem;load(Lnet/minecraft/server/WorldLoader$InitConfig;Lnet/minecraft/server/WorldLoader$WorldDataSupplier;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"), index = 2)
|
||||||
|
private Executor getResourceReloadExecutor(Executor service) {
|
||||||
|
return ModernFix.resourceReloadExecutor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Pair.of(blockstate, null);
|
return Pair.of(blockstate, null);
|
||||||
}, Util.backgroundExecutor()));
|
}, ModernFix.resourceReloadExecutor()));
|
||||||
}
|
}
|
||||||
blockStateFiles = null;
|
blockStateFiles = null;
|
||||||
CompletableFuture.allOf(blockStateData.toArray(new CompletableFuture[0])).join();
|
CompletableFuture.allOf(blockStateData.toArray(new CompletableFuture[0])).join();
|
||||||
|
|
@ -284,7 +284,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Pair.of(fileLocation, null);
|
return Pair.of(fileLocation, null);
|
||||||
}, Util.backgroundExecutor()));
|
}, ModernFix.resourceReloadExecutor()));
|
||||||
}
|
}
|
||||||
modelFiles.clear();
|
modelFiles.clear();
|
||||||
CompletableFuture.allOf(modelBytes.toArray(new CompletableFuture[0])).join();
|
CompletableFuture.allOf(modelBytes.toArray(new CompletableFuture[0])).join();
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public abstract class CreateWorldScreenMixin extends Screen {
|
||||||
}, (argx, arg2x, arg3, arg4) -> {
|
}, (argx, arg2x, arg3, arg4) -> {
|
||||||
argx.close();
|
argx.close();
|
||||||
return new WorldCreationContext(arg4, Lifecycle.stable(), arg3, arg2x);
|
return new WorldCreationContext(arg4, Lifecycle.stable(), arg3, arg2x);
|
||||||
}, Util.backgroundExecutor(), this.minecraft);
|
}, ModernFix.resourceReloadExecutor(), this.minecraft);
|
||||||
this.minecraft.managedBlock(completablefuture::isDone);
|
this.minecraft.managedBlock(completablefuture::isDone);
|
||||||
this.worldGenSettingsComponent.updateSettings(completablefuture.join());
|
this.worldGenSettingsComponent.updateSettings(completablefuture.join());
|
||||||
this.rebuildWidgets();
|
this.rebuildWidgets();
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"refmap": "modernfix.refmap.json",
|
"refmap": "modernfix.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"core.BootstrapMixin",
|
||||||
"bugfix.edge_chunk_not_saved.ChunkManagerMixin",
|
"bugfix.edge_chunk_not_saved.ChunkManagerMixin",
|
||||||
"perf.modern_resourcepacks.VanillaPackResourcesMixin",
|
"perf.modern_resourcepacks.VanillaPackResourcesMixin",
|
||||||
"perf.modern_resourcepacks.PathPackResourcesMixin",
|
"perf.modern_resourcepacks.PathPackResourcesMixin",
|
||||||
"perf.dynamic_structure_manager.StructureManagerMixin",
|
"perf.dynamic_structure_manager.StructureManagerMixin",
|
||||||
"bugfix.chunk_deadlock.ServerChunkCacheMixin",
|
"bugfix.chunk_deadlock.ServerChunkCacheMixin",
|
||||||
|
"perf.dedicated_reload_executor.MinecraftServerMixin",
|
||||||
"perf.remove_biome_temperature_cache.BiomeMixin",
|
"perf.remove_biome_temperature_cache.BiomeMixin",
|
||||||
"perf.reduce_blockstate_cache_rebuilds.GameDataMixin",
|
"perf.reduce_blockstate_cache_rebuilds.GameDataMixin",
|
||||||
"perf.reduce_blockstate_cache_rebuilds.BlockCallbacksMixin",
|
"perf.reduce_blockstate_cache_rebuilds.BlockCallbacksMixin",
|
||||||
|
|
@ -44,6 +46,9 @@
|
||||||
"feature.measure_time.MinecraftMixin",
|
"feature.measure_time.MinecraftMixin",
|
||||||
"feature.reduce_loading_screen_freezes.ModelBakeryMixin",
|
"feature.reduce_loading_screen_freezes.ModelBakeryMixin",
|
||||||
"bugfix.concurrency.MinecraftMixin",
|
"bugfix.concurrency.MinecraftMixin",
|
||||||
|
"perf.dedicated_reload_executor.CreateWorldScreenMixin",
|
||||||
|
"perf.dedicated_reload_executor.MinecraftMixin",
|
||||||
|
"perf.dedicated_reload_executor.WorldOpenFlowsMixin",
|
||||||
"perf.dynamic_resources.BlockElementFaceDeserializerMixin",
|
"perf.dynamic_resources.BlockElementFaceDeserializerMixin",
|
||||||
"perf.dynamic_resources.BlockModelShaperMixin",
|
"perf.dynamic_resources.BlockModelShaperMixin",
|
||||||
"perf.dynamic_resources.ItemModelShaperMixin",
|
"perf.dynamic_resources.ItemModelShaperMixin",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user