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

This commit is contained in:
embeddedt 2023-08-12 12:02:43 -04:00
commit b776587f2d
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
28 changed files with 81 additions and 31 deletions

View File

@ -95,6 +95,11 @@ allprojects {
url 'https://maven.terraformersmc.com/releases'
}
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Werror"
}
}
}
configure(subprojects.findAll {it.name == "common" || it.name == "forge" || it.name == "fabric"}) {

View File

@ -11,6 +11,10 @@ import org.spongepowered.asm.mixin.Overwrite;
@Mixin(Minecraft.class)
@ClientOnlyMixin
public class MinecraftMixin {
/**
* @author embeddedt
* @reason avoid exception stacktrace being printed in dev
*/
@Overwrite
private UserApiService createUserApiService(YggdrasilAuthenticationService yggdrasilAuthenticationService, GameConfig arg) {
return UserApiService.OFFLINE;

View File

@ -36,7 +36,7 @@ public class StateHolderMixin {
}
});
@Redirect(method = "codec", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;dispatch(Ljava/lang/String;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;"))
@Redirect(method = "codec", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Codec;dispatch(Ljava/lang/String;Ljava/util/function/Function;Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;", remap = false))
private static <O, S extends StateHolder<O, S>> Codec<S> obtainCodec(Codec<O> codec, String typeKey, Function<S, O> type, Function<O, ? extends Codec<S>> codecFn, Codec<O> codecMethodArg, Function<O, S> stateSupplier) {
return codec.dispatch(typeKey, type, block -> {
if(block instanceof Block) {

View File

@ -16,7 +16,7 @@ import java.lang.reflect.Type;
public class BlockElementFaceDeserializerMixin {
@Redirect(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/renderer/block/model/BlockElementFace;",
at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonDeserializationContext;deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;)Ljava/lang/Object;", ordinal = 0))
at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonDeserializationContext;deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;)Ljava/lang/Object;", ordinal = 0, remap = false))
private Object skipUvsForInitialLoad(JsonDeserializationContext context, JsonElement element, Type type) {
return UVController.useDummyUv.get() ? UVController.dummyUv : context.deserialize(element, type);
}

View File

@ -48,6 +48,7 @@ public abstract class ItemModelShaperMixin {
}
/**
* @author embeddedt
* @reason Get the stored location for that item and meta, and get the model
* from that location from the model manager.
**/
@ -58,6 +59,7 @@ public abstract class ItemModelShaperMixin {
}
/**
* @author embeddedt
* @reason Don't get all models during init (with dynamic loading, that would
* generate them all). Just store location instead.
**/
@ -67,6 +69,7 @@ public abstract class ItemModelShaperMixin {
}
/**
* @author embeddedt
* @reason Disable cache rebuilding (with dynamic loading, that would generate
* all models).
**/

View File

@ -24,7 +24,7 @@ import java.util.function.Function;
@RequiresMod("ae2")
@ClientOnlyMixin
public class RegistrationMixin {
@Shadow @Final private static Map<String, Function<BakedModel, BakedModel>> CUSTOMIZERS;
@Shadow(remap = false) @Final private static Map<String, Function<BakedModel, BakedModel>> CUSTOMIZERS;
@Inject(method = "init", at = @At("TAIL"), remap = false)
private static void doRegisterDynBake(CallbackInfo ci) {

View File

@ -15,7 +15,7 @@ public class MappedRegistryMixin {
*/
@Redirect(
method = "registerMapping(ILnet/minecraft/resources/ResourceKey;Ljava/lang/Object;Lcom/mojang/serialization/Lifecycle;Z)Lnet/minecraft/core/Holder;",
at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/ObjectList;size(I)V")
at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/ObjectList;size(I)V", remap = false)
)
private void setSizeSmart(ObjectList<?> list, int size) {
if(list instanceof ObjectArrayList && size > list.size()) {

View File

@ -18,7 +18,7 @@ public abstract class BiomeMixin {
* @return
*/
@Overwrite
public final float getTemperature(BlockPos pos) {
private float getTemperature(BlockPos pos) {
return this.getHeightAdjustedTemperature(pos);
}
}

View File

@ -9,6 +9,7 @@ import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@SuppressWarnings("unchecked")
public class DirectStorageBiMap<K, V> implements BiMap<K, V> {
private final Function<V, K> keyGetter;
private final BiConsumer<V, K> keySetter;

View File

@ -4,10 +4,11 @@
"modernfix.jei_load": "Loading JEI, this may take a while",
"modernfix.no_lazydfu": "LazyDFU is not installed. If Minecraft needs to update game data from an older version, there may be noticeable lag.",
"modernfix.no_ferritecore": "FerriteCore is not installed. Memory usage will be very high.",
"modernfix.connectedness_dynresoruces": "Connectedness and ModernFix's dynamic resources option are not compatible. Remove Connectedness or disable dynamic resources in the ModernFix config.",
"modernfix.perf_mod_warning": "It is recommended to install the mods, but the warning(s) can be disabled in the ModernFix config.",
"modernfix.config": "ModernFix mixin config",
"modernfix.config.done_restart": "Done (restart required)",
"modernfix.message.reload_config": "Run /mfrc after changing configs on disk for them to take effect.",
"modernfix.message.reload_config": "A mod config file change was detected. To prevent loading files that aren't done saving, reloading must be triggered by running /mfrc.",
"modernfix.option.on": "on",
"modernfix.option.off": "off",
"modernfix.option.disabled": "disabled",

View File

@ -1,6 +1,9 @@
package org.embeddedt.modernfix;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import net.fabricmc.loader.impl.gui.FabricGuiEntry;
import net.fabricmc.loader.impl.gui.FabricStatusTree;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.embeddedt.modernfix.fabric.mappings.MappingsClearer;
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
@ -19,5 +22,18 @@ public class ModernFixPreLaunchFabric implements PreLaunchEntrypoint {
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.clear_fabric_mapping_tables.MappingsClearer")) {
MappingsClearer.clear();
}
// Prevent launching with Continuity when dynamic resources is on
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.dynamic_resources.ContinuityCheck")
&& FabricLoader.getInstance().isModLoaded("continuity")) {
CommonModUtil.runWithoutCrash(() -> {
FabricGuiEntry.displayError("Compatibility warning", null, tree -> {
FabricStatusTree.FabricStatusTab crashTab = tree.addTab("Warning");
crashTab.node.addMessage("Continuity and ModernFix's dynamic resources option are not compatible before Minecraft 1.19.4.", FabricStatusTree.FabricTreeWarningLevel.ERROR);
crashTab.node.addMessage("Remove Continuity or disable dynamic resources in the ModernFix config.", FabricStatusTree.FabricTreeWarningLevel.ERROR);
tree.tabs.removeIf(tab -> tab != crashTab);
}, true);
}, "display Continuity warning");
}
}
}

View File

@ -17,7 +17,7 @@ public class SuggestionsBuilderMixin {
@Unique
private static final int MAX_SUGGESTIONS = 10000;
@Shadow @Final @Mutable
@Shadow(remap = false) @Final @Mutable
private List<Suggestion> result;
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z"), require = 0)

View File

@ -27,8 +27,8 @@ import java.util.Set;
public abstract class ModNioResourcePackMixin implements ICachingResourcePack {
@Shadow public abstract Set<String> getNamespaces(PackType type);
@Shadow @Final private List<Path> basePaths;
@Shadow @Final private ModMetadata modInfo;
@Shadow(remap = false) @Final private List<Path> basePaths;
@Shadow(remap = false) @Final private ModMetadata modInfo;
private PackResourcesCacheEngine cacheEngine;
@Inject(method = "<init>", at = @At("RETURN"))

View File

@ -19,10 +19,12 @@ import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.*;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import org.embeddedt.modernfix.ModernFixClient;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.embeddedt.modernfix.forge.config.NightConfigFixer;
import org.embeddedt.modernfix.screen.ModernFixConfigScreen;
@ -35,6 +37,7 @@ public class ModernFixClientForge {
public ModernFixClientForge() {
commonMod = new ModernFixClient();
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::keyBindRegister);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
ModLoadingContext.get().registerExtensionPoint(
ConfigScreenHandler.ConfigScreenFactory.class,
() -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new ModernFixConfigScreen(screen))
@ -48,6 +51,15 @@ public class ModernFixClientForge {
event.register(configKey);
}
private void onClientSetup(FMLClientSetupEvent event) {
if(ModernFixMixinPlugin.instance.isOptionEnabled("perf.dynamic_resources.ConnectednessCheck")
&& ModList.get().isLoaded("connectedness")) {
event.enqueueWork(() -> {
ModLoader.get().addWarning(new ModLoadingWarning(ModLoadingContext.get().getActiveContainer().getModInfo(), ModLoadingStage.SIDED_SETUP, "modernfix.connectedness_dynresoruces"));
});
}
}
@SubscribeEvent
public void onConfigKey(TickEvent.ClientTickEvent event) {
if(event.phase == TickEvent.Phase.START && configKey.consumeClick()) {

View File

@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ObjectModificationManager.class)
@RequiresMod("blueprint")
public abstract class ObjectModificationManagerMixin extends SimpleJsonResourceReloadListener {
@Shadow protected SelectionSpace selectionSpace;
@Shadow(remap = false) protected SelectionSpace selectionSpace;
public ObjectModificationManagerMixin(Gson gson, String string) {
super(gson, string);

View File

@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentMap;
@ClientOnlyMixin
@SuppressWarnings({"rawtypes", "unchecked"})
public class ResourceUtilMixin {
@Shadow @Final @Mutable
@Shadow(remap = false) @Final @Mutable
private static Map metadataCache;
/**

View File

@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(GameData.class)
public class GameDataMixin {
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/registries/ForgeRegistry;dump(Lnet/minecraft/resources/ResourceLocation;)V"))
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/registries/ForgeRegistry;dump(Lnet/minecraft/resources/ResourceLocation;)V", remap = false))
private static void noDump(ForgeRegistry<?> reg, ResourceLocation id) {
}
}

View File

@ -22,7 +22,7 @@ import java.util.Map;
@Mixin(ForgeItemModelShaper.class)
@ClientOnlyMixin
public abstract class ItemModelMesherForgeMixin extends ItemModelShaper {
@Shadow @Final @Mutable private Map<Holder.Reference<Item>, ModelResourceLocation> locations;
@Shadow(remap = false) @Final @Mutable private Map<Holder.Reference<Item>, ModelResourceLocation> locations;
private Map<Holder.Reference<Item>, ModelResourceLocation> overrideLocations;
@ -50,6 +50,7 @@ public abstract class ItemModelMesherForgeMixin extends ItemModelShaper {
}
/**
* @author embeddedt
* @reason Get the stored location for that item and meta, and get the model
* from that location from the model manager.
**/
@ -61,6 +62,7 @@ public abstract class ItemModelMesherForgeMixin extends ItemModelShaper {
}
/**
* @author embeddedt
* @reason Don't get all models during init (with dynamic loading, that would
* generate them all). Just store location instead.
**/
@ -71,6 +73,7 @@ public abstract class ItemModelMesherForgeMixin extends ItemModelShaper {
}
/**
* @author embeddedt
* @reason Disable cache rebuilding (with dynamic loading, that would generate
* all models).
**/

View File

@ -92,7 +92,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
@Shadow @Final @Mutable private BlockColors blockColors;
@Shadow @Nullable public abstract BakedModel bake(ResourceLocation arg, ModelState arg2, Function<Material, TextureAtlasSprite> sprites);
@Shadow(remap = false) @Nullable public abstract BakedModel bake(ResourceLocation arg, ModelState arg2, Function<Material, TextureAtlasSprite> sprites);
@Shadow @Final private static Logger LOGGER;
@Shadow @org.jetbrains.annotations.Nullable public abstract BakedModel bake(ResourceLocation location, ModelState transform);

View File

@ -36,22 +36,27 @@ import java.util.function.Predicate;
@ClientOnlyMixin
public abstract class CTMPackReloadListenerMixin implements ModernFixClientIntegration {
/* caches the original render checks */
@Shadow @Final private static Map<Holder.Reference<Block>, Predicate<RenderType>> blockRenderChecks;
@Shadow(remap = false) @Final private static Map<Holder.Reference<Block>, Predicate<RenderType>> blockRenderChecks;
private static Map<Holder.Reference<Block>, Predicate<RenderType>> renderCheckOverrides = new ConcurrentHashMap<>();
private static ChunkRenderTypeSet DEFAULT_TYPE_SET = ChunkRenderTypeSet.of(RenderType.solid());
@Shadow protected abstract Predicate<RenderType> getLayerCheck(BlockState state, BakedModel model);
@Shadow(remap = false) protected abstract Predicate<RenderType> getLayerCheck(BlockState state, BakedModel model);
@Shadow protected abstract ChunkRenderTypeSet getExistingRenderCheck(Block block);
@Shadow(remap = false) protected abstract ChunkRenderTypeSet getExistingRenderCheck(Block block);
@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(CallbackInfo ci) {
ModernFixClient.CLIENT_INTEGRATIONS.add(this);
}
/**
* @author embeddedt
* @reason handle layer changes dynamically
*/
@Overwrite(remap = false)
@SuppressWarnings("removal")
private void refreshLayerHacks() {
renderCheckOverrides.clear();
if(blockRenderChecks.isEmpty()) {

View File

@ -27,7 +27,7 @@ import java.util.*;
@ClientOnlyMixin
public abstract class TextureMetadataHandlerMixin implements ModernFixClientIntegration {
@Shadow @Nonnull protected abstract BakedModel wrap(ResourceLocation loc, UnbakedModel model, BakedModel object, ModelBakery loader) throws IOException;
@Shadow(remap = false) @Nonnull protected abstract BakedModel wrap(ResourceLocation loc, UnbakedModel model, BakedModel object, ModelBakery loader) throws IOException;
@Inject(method = "<init>", at = @At("RETURN"))
private void subscribeDynamic(CallbackInfo ci) {

View File

@ -20,7 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@RequiresMod("refinedstorage")
@ClientOnlyMixin
public class ClientSetupMixin {
@Shadow @Final private static BakedModelOverrideRegistry BAKED_MODEL_OVERRIDE_REGISTRY;
@Shadow(remap = false) @Final private static BakedModelOverrideRegistry BAKED_MODEL_OVERRIDE_REGISTRY;
@Inject(method = "<init>", at = @At("RETURN"))
private void addDynamicListener(CallbackInfo ci) {

View File

@ -31,7 +31,7 @@ import java.util.stream.Stream;
@RequiresMod("supermartijn642corelib")
@ClientOnlyMixin
public class ClientRegistrationHandlerMixin {
@Shadow @Final private List<Pair<Supplier<Stream<ResourceLocation>>, Function<BakedModel, BakedModel>>> modelOverwrites;
@Shadow(remap = false) @Final private List<Pair<Supplier<Stream<ResourceLocation>>, Function<BakedModel, BakedModel>>> modelOverwrites;
private Map<ResourceLocation, Function<BakedModel, BakedModel>> modelOverwritesByLocation = new Object2ObjectOpenHashMap<>();

View File

@ -17,13 +17,13 @@ import java.util.function.Function;
@Mixin(targets = { "net/minecraftforge/registries/NamespacedHolderHelper" })
public class NamespacedHolderHelperMixin<T> {
@Shadow private Map<ResourceLocation, Holder.Reference<T>> holdersByName;
@Shadow(remap = false) private Map<ResourceLocation, Holder.Reference<T>> holdersByName;
@Shadow @Final private @Nullable Function<T, Holder.Reference<T>> holderLookup;
@Shadow(remap = false) @Final private @Nullable Function<T, Holder.Reference<T>> holderLookup;
@Shadow private Map<T, Holder.Reference<T>> holders;
@Shadow(remap = false) private Map<T, Holder.Reference<T>> holders;
@Shadow @Final private Registry<T> self;
@Shadow(remap = false) @Final private Registry<T> self;
@Inject(method = "freeze", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraftforge/registries/NamespacedHolderHelper;holdersByName:Ljava/util/Map;"), cancellable = true, remap = false)
private void fastDummyCheck(CallbackInfoReturnable<Registry<T>> cir) {

View File

@ -29,9 +29,9 @@ import java.util.function.Predicate;
*/
@Mixin(PathPackResources.class)
public abstract class ModFileResourcePackMixin implements ICachingResourcePack {
@Shadow protected abstract Path resolve(String... paths);
@Shadow(remap = false) protected abstract Path resolve(String... paths);
@Shadow @NotNull
@Shadow(remap = false) @NotNull
protected abstract Set<String> getNamespacesFromDisk(PackType type);
private PackResourcesCacheEngine cacheEngine;

View File

@ -19,9 +19,9 @@ import java.util.Set;
@Mixin(ForgeRegistry.Snapshot.class)
@IgnoreOutsideDev
public class ForgeRegistrySnapshotMixin {
@Shadow @Final @Mutable public Map<ResourceLocation, Integer> ids;
@Shadow(remap = false) @Final @Mutable public Map<ResourceLocation, Integer> ids;
@Shadow @Final @Mutable public Set<ResourceLocation> dummied;
@Shadow(remap = false) @Final @Mutable public Set<ResourceLocation> dummied;
/**
* The only good reason to use tree maps here is to keep the order the same. But we are tracking IDs

View File

@ -19,7 +19,7 @@ public class TagEntryMixin {
* @reason use cached location, overwrite rather than inject to avoid allocs
*/
@Overwrite
public ExtraCodecs.TagOrElementLocation elementOrTag() {
private ExtraCodecs.TagOrElementLocation elementOrTag() {
ExtraCodecs.TagOrElementLocation loc = cachedLoc;
if(loc == null) {
loc = new ExtraCodecs.TagOrElementLocation(this.id, this.tag);

View File

@ -18,7 +18,7 @@ public class TagOrElementLocationMixin {
* @reason use cached ID, overwrite rather than inject to avoid allocs
*/
@Overwrite
public String decoratedId() {
private String decoratedId() {
String id = cachedDecoratedId;
if(id == null) {
id = this.tag ? "#" + this.id : this.id.toString();