Merge remote-tracking branch 'origin/main' into 1.18

This commit is contained in:
embeddedt 2023-02-24 19:42:07 -05:00
commit 11de406065
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
6 changed files with 79 additions and 6 deletions

View File

@ -2,12 +2,13 @@ plugins {
id "dev.architectury.loom" version "1.0.312"
id "maven-publish"
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.palantir.git-version' version '1.0.0'
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
group = 'org.embeddedt'
version = '1.7.0'
version = gitVersion()
java {
archivesBaseName = 'modernfix-mc' + minecraft_version
@ -107,7 +108,7 @@ java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
// withSourcesJar()
}
// Example for how to get properties into the manifest for reading at runtime.
@ -134,9 +135,6 @@ publishing {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

View File

@ -4,15 +4,19 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ConnectScreen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraftforge.client.event.ScreenOpenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.embeddedt.modernfix.load.LoadEvents;
import org.embeddedt.modernfix.screen.DeferredLevelLoadingScreen;
import java.lang.management.ManagementFactory;
import java.util.Optional;
public class ModernFixClient {
public static long worldLoadStartTime;
@ -20,10 +24,17 @@ public class ModernFixClient {
public static float gameStartTimeSeconds = -1;
private String brandingString = null;
public ModernFixClient() {
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.faster_singleplayer_load.ClientEvents")) {
MinecraftForge.EVENT_BUS.register(new LoadEvents());
}
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.branding.F3Screen")) {
Optional<? extends ModContainer> mfContainer = ModList.get().getModContainerById("modernfix");
if(mfContainer.isPresent())
brandingString = "ModernFix " + mfContainer.get().getModInfo().getVersion().toString();
}
}
public void resetWorldLoadStateMachine() {
@ -52,4 +63,12 @@ public class ModernFixClient {
ModernFix.worldLoadSemaphore.countDown();
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
if(brandingString != null && Minecraft.getInstance().options.renderDebug) {
event.getLeft().add("");
event.getLeft().add(brandingString);
}
}
}

View File

@ -18,8 +18,10 @@ public class ModernFixEarlyConfig {
// You must manually add a rule for any new mixins not covered by an existing package rule.
this.addMixinRule("core", true); // TODO: Don't actually allow the user to disable this
this.addMixinRule("perf.modern_resourcepacks", true);
this.addMixinRule("feature.branding", true);
this.addMixinRule("feature.measure_time", true);
this.addMixinRule("feature.reduce_loading_screen_freezes", false);
this.addMixinRule("perf.fast_registry_validation", true);
this.addMixinRule("perf.remove_biome_temperature_cache", true);
this.addMixinRule("perf.reduce_blockstate_cache_rebuilds", true);
this.addMixinRule("perf.parallelize_model_loading", true);

View File

@ -0,0 +1,24 @@
package org.embeddedt.modernfix.mixin.feature.branding;
import com.google.common.collect.ImmutableList;
import net.minecraftforge.internal.BrandingControl;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.List;
import java.util.Optional;
@Mixin(value = BrandingControl.class, remap = false)
public class BrandingControlMixin {
@Inject(method = "computeBranding", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/ModList;get()Lnet/minecraftforge/fml/ModList;"), locals = LocalCapture.CAPTURE_FAILHARD)
private static void addModernFixBranding(CallbackInfo ci, ImmutableList.Builder<String> builder) {
Optional<? extends ModContainer> mfContainer = ModList.get().getModContainerById("modernfix");
if(mfContainer.isPresent())
builder.add("ModernFix " + mfContainer.get().getModInfo().getVersion().toString());
}
}

View File

@ -0,0 +1,28 @@
package org.embeddedt.modernfix.mixin.perf.fast_registry_validation;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import net.minecraftforge.registries.ForgeRegistry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.lang.reflect.Method;
@Mixin(value = ForgeRegistry.class, remap = false)
public class ForgeRegistryMixin {
private static Method bitSetTrimMethod = null;
private static boolean bitSetTrimMethodRetrieved = false;
/**
* Cache the result of findMethod instead of running it multiple times.
* Null checks are not required as the surrounding code handles it already.
*/
@Redirect(method = "validateContent", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/util/ObfuscationReflectionHelper;findMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"))
private Method skipMultipleRemap(Class<?> clz, String methodName, Class<?>[] params) {
if(!bitSetTrimMethodRetrieved) {
bitSetTrimMethodRetrieved = true;
bitSetTrimMethod = ObfuscationReflectionHelper.findMethod(clz, methodName, params);
}
return bitSetTrimMethod;
}
}

View File

@ -24,7 +24,9 @@
"feature.measure_time.BootstrapMixin",
"feature.measure_time.SimpleReloadableResourceManagerMixin",
"feature.measure_time.ProfiledReloadInstanceMixin",
"feature.measure_time.ReloadableServerResourcesMixin"
"feature.measure_time.ReloadableServerResourcesMixin",
"feature.branding.BrandingControlMixin",
"perf.fast_registry_validation.ForgeRegistryMixin"
],
"client": [
"core.MinecraftMixin",