Merge remote-tracking branch 'origin/main' into 1.18
This commit is contained in:
commit
be462e0e28
|
|
@ -87,7 +87,6 @@ dependencies {
|
|||
|
||||
// your forge dependency, this is **required** when using Forge Loom in forge mode!
|
||||
forge "net.minecraftforge:forge:${project.forge_version}"
|
||||
modRuntimeOnly "curse.maven:lazydfu-460819:${lazydfu_version}"
|
||||
|
||||
modCompileOnly("curse.maven:refinedstorage-243076:${refined_storage_version}")
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class ModernFix {
|
|||
if(ModList.get().isLoaded(modId))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ public class ModernFixEarlyConfig {
|
|||
/* Use a simpler ArrayMap if FerriteCore is using the map intelligently anyway */
|
||||
this.addMixinRule("perf.state_definition_construct", modPresent("ferritecore"));
|
||||
this.addMixinRule("perf.cache_strongholds", true);
|
||||
this.addMixinRule("perf.dedup_blockstate_flattening_map", false);
|
||||
this.addMixinRule("perf.clear_mixin_classinfo", false);
|
||||
this.addMixinRule("perf.cache_upgraded_structures", true);
|
||||
this.addMixinRule("perf.compress_blockstate", false);
|
||||
|
|
@ -82,6 +81,7 @@ public class ModernFixEarlyConfig {
|
|||
this.addMixinRule("perf.nbt_memory_usage", true);
|
||||
this.addMixinRule("perf.patchouli_deduplicate_books", modPresent("patchouli"));
|
||||
this.addMixinRule("perf.datapack_reload_exceptions", true);
|
||||
this.addMixinRule("perf.dynamic_dfu", true);
|
||||
this.addMixinRule("perf.faster_texture_stitching", true);
|
||||
this.addMixinRule("perf.faster_texture_loading", true);
|
||||
this.addMixinRule("perf.faster_font_loading", true);
|
||||
|
|
|
|||
96
src/main/java/org/embeddedt/modernfix/dfu/LazyDataFixer.java
Normal file
96
src/main/java/org/embeddedt/modernfix/dfu/LazyDataFixer.java
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
package org.embeddedt.modernfix.dfu;
|
||||
|
||||
import com.mojang.datafixers.DSL;
|
||||
import com.mojang.datafixers.DataFix;
|
||||
import com.mojang.datafixers.DataFixUtils;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.datafixers.schemas.Schema;
|
||||
import com.mojang.datafixers.types.Type;
|
||||
import com.mojang.datafixers.types.constant.EmptyPart;
|
||||
import com.mojang.datafixers.types.templates.TypeTemplate;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class LazyDataFixer implements DataFixer {
|
||||
private static final Logger LOGGER = LogManager.getLogger("ModernFix");
|
||||
private DataFixer backingDataFixer;
|
||||
private final Supplier<DataFixer> dfuSupplier;
|
||||
private static final Schema FAKE_SCHEMA = new EmptySchema();
|
||||
|
||||
public LazyDataFixer(Supplier<DataFixer> dfuSupplier) {
|
||||
LOGGER.info("Bypassed Mojang DFU");
|
||||
this.backingDataFixer = null;
|
||||
this.dfuSupplier = dfuSupplier;
|
||||
}
|
||||
@Override
|
||||
public <T> Dynamic<T> update(DSL.TypeReference type, Dynamic<T> input, int version, int newVersion) {
|
||||
if(version >= newVersion)
|
||||
return input;
|
||||
synchronized (this) {
|
||||
if(backingDataFixer == null) {
|
||||
LOGGER.info("Instantiating Mojang DFU");
|
||||
backingDataFixer = dfuSupplier.get();
|
||||
}
|
||||
}
|
||||
return backingDataFixer.update(type, input, version, newVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* "getSchema is only there for checks that are not important" - fry, 2021
|
||||
*/
|
||||
@Override
|
||||
public Schema getSchema(int key) {
|
||||
return FAKE_SCHEMA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty schema that also returns empty Type<?> instances to prevent crashes.
|
||||
*/
|
||||
static class EmptySchema extends Schema {
|
||||
public EmptySchema() {
|
||||
super(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getWorldVersion()), null);
|
||||
}
|
||||
|
||||
private static final Type<?> EMPTY_TYPE = new EmptyPart();
|
||||
private static final TypeTemplate FAKE_TEMPLATE = EMPTY_TYPE.template();
|
||||
|
||||
|
||||
@Override
|
||||
protected Map<String, Type<?>> buildTypes() {
|
||||
Object2ObjectOpenHashMap<String, Type<?>> map = new Object2ObjectOpenHashMap<>();
|
||||
map.defaultReturnValue(new EmptyPart());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeTemplate resolveTemplate(String name) {
|
||||
return FAKE_TEMPLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<?> getChoiceType(DSL.TypeReference type, String choiceName) {
|
||||
return EMPTY_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTypes(Schema schema, Map<String, Supplier<TypeTemplate>> entityTypes, Map<String, Supplier<TypeTemplate>> blockEntityTypes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Supplier<TypeTemplate>> registerEntities(Schema schema) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Supplier<TypeTemplate>> registerBlockEntities(Schema schema) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.dedup_blockstate_flattening_map;
|
||||
|
||||
import net.minecraft.util.datafix.fixes.BlockStateData;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BlockStateData.class)
|
||||
public class BlockStateDataMixin {
|
||||
@Inject(method = {"register", "finalizeMaps"}, at = @At("HEAD"), cancellable = true)
|
||||
private static void noFlattening(CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = {"upgradeBlockStateTag", "upgradeBlock(I)Ljava/lang/String;", "upgradeBlock(Ljava/lang/String;)Ljava/lang/String;", "getTag"}, at = @At("HEAD"), require = 4)
|
||||
private static void preventCorruption(CallbackInfoReturnable<?> cir) {
|
||||
throw new UnsupportedOperationException("Performing the Flattening is currently disabled in the ModernFix config.");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.dedup_blockstate_flattening_map;
|
||||
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.util.datafix.fixes.ChunkPalettedStorageFix;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mixin(ChunkPalettedStorageFix.class)
|
||||
public class ChunkPalettedStorageFixMixin {
|
||||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/DataFixUtils;make(Ljava/lang/Object;Ljava/util/function/Consumer;)Ljava/lang/Object;"))
|
||||
private static Object skipMakingMap(Object o, Consumer<?> consumer) {
|
||||
return o;
|
||||
}
|
||||
|
||||
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/datafix/fixes/BlockStateData;getTag(I)Lcom/mojang/serialization/Dynamic;"))
|
||||
private static Dynamic<?> getFakeAirTag(int id) {
|
||||
return new Dynamic<>(NbtOps.INSTANCE, new CompoundTag());
|
||||
}
|
||||
|
||||
@Inject(method = "fix", at = @At("HEAD"))
|
||||
private void skipFix(CallbackInfoReturnable<Dynamic<?>> cir) {
|
||||
throw new UnsupportedOperationException("No Flattening for you.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.dynamic_dfu;
|
||||
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.util.datafix.DataFixers;
|
||||
import org.embeddedt.modernfix.dfu.LazyDataFixer;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(DataFixers.class)
|
||||
public abstract class DataFixersMixin {
|
||||
@Shadow protected static DataFixer createFixerUpper() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static LazyDataFixer lazyDataFixer;
|
||||
|
||||
/**
|
||||
* Avoid classloading the DFU logic until we actually need it.
|
||||
*/
|
||||
@Inject(method = "createFixerUpper", at = @At("HEAD"), cancellable = true)
|
||||
private static void createLazyFixerUpper(CallbackInfoReturnable<DataFixer> cir) {
|
||||
if(lazyDataFixer == null) {
|
||||
lazyDataFixer = new LazyDataFixer(DataFixersMixin::createFixerUpper);
|
||||
cir.setReturnValue(lazyDataFixer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
"key.modernfix": "ModernFix",
|
||||
"key.modernfix.config": "Open config screen",
|
||||
"modernfix.jei_load": "Loading JEI, this may take a while",
|
||||
"modernfix.no_lazydfu": "ModernFix detected that DFU rules were compiled on startup. This slows down game launching. Installing LazyDFU to resolve this is highly recommended.",
|
||||
"modernfix.no_lazydfu": "LazyDFU is not installed. If Minecraft needs to update game data from an older version, there may be noticeable lag.",
|
||||
"modernfix.config": "ModernFix mixin config",
|
||||
"modernfix.config.done_restart": "Done (restart required)",
|
||||
"modernfix.option.on": "on",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"bugfix.chunk_deadlock.ServerChunkCacheMixin",
|
||||
"perf.dedicated_reload_executor.MinecraftServerMixin",
|
||||
"perf.fast_forge_dummies.NamespacedHolderHelperMixin",
|
||||
"perf.dynamic_dfu.DataFixersMixin",
|
||||
"perf.remove_biome_temperature_cache.BiomeMixin",
|
||||
"perf.reduce_blockstate_cache_rebuilds.GameDataMixin",
|
||||
"perf.reduce_blockstate_cache_rebuilds.BlockCallbacksMixin",
|
||||
|
|
@ -45,8 +46,6 @@
|
|||
"perf.state_definition_construct.StateDefinitionMixin",
|
||||
"perf.compress_blockstate.BlockStateBaseMixin",
|
||||
"perf.compress_blockstate.BlockBehaviourMixin",
|
||||
"perf.dedup_blockstate_flattening_map.BlockStateDataMixin",
|
||||
"perf.dedup_blockstate_flattening_map.ChunkPalettedStorageFixMixin",
|
||||
"perf.remove_spawn_chunks.ServerChunkCacheAccessor",
|
||||
"perf.remove_spawn_chunks.MinecraftServerMixin",
|
||||
"perf.remove_spawn_chunks.ServerLevelMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user