From 991441863763fc5a85929532d52147457e88788b Mon Sep 17 00:00:00 2001 From: Dinolek <18579460+Dinolek@users.noreply.github.com> Date: Sun, 10 Nov 2019 00:42:09 +0100 Subject: [PATCH] Update to support latest loader (#87) --- build.gradle | 20 ++--- gradle.properties | 12 ++- .../optifabric/mixin/MixinChunkCacheOF.java | 5 -- .../optifabric/mixin/MixinReflectorClass.java | 2 +- .../optifabric/mod/OptifineSetup.java | 75 +++++-------------- .../optifabric/patcher/LambadaRebuiler.java | 2 +- 6 files changed, 38 insertions(+), 78 deletions(-) diff --git a/build.gradle b/build.gradle index 52ee3b16..c333594a 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath "net.fabricmc:fabric-loom:0.2.5-SNAPSHOT" + classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT" } } @@ -35,24 +35,24 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}" modCompile "net.fabricmc:fabric-loader:${project.loader_version}" - modCompile 'net.fabricmc.fabric-api:fabric-api:0.3.0+build.200' + modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modCompile 'com.github.Chocohead:Fabric-ASM:9af0ebe992' - include 'com.github.Chocohead:Fabric-ASM:9af0ebe992' + modCompile "com.github.Chocohead:Fabric-ASM:${project.fabric_asm_version}" + include "com.github.Chocohead:Fabric-ASM:${project.fabric_asm_version}" //Used to handle the zip processing - compile 'org.zeroturnaround:zt-zip:1.13' - include 'org.zeroturnaround:zt-zip:1.13' + compile "org.zeroturnaround:zt-zip:${project.zt_zip_version}" + include "org.zeroturnaround:zt-zip:${project.zt_zip_version}" //Required for zt-zip, kinda annoying - include 'org.slf4j:slf4j-simple:1.7.26' - include 'org.slf4j:slf4j-api:1.7.26' + include "org.slf4j:slf4j-simple:${project.slf4j_version}" + include "org.slf4j:slf4j-api:${project.slf4j_version}" //Used only in dev to generate the field names - compile ('net.fabricmc:stitch:0.2.1.61') { + compile ("net.fabricmc:stitch:${project.stitch_version}") { transitive = false } - include 'net.fabricmc:stitch:0.2.1.61' + include "net.fabricmc:stitch:${project.stitch_version}" } task unzip(type: Copy) { diff --git a/gradle.properties b/gradle.properties index d17e39f4..bce87186 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,15 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.14.4 -yarn_mappings=1.14.4+build.2 -loader_version=0.4.8+build.155 +yarn_mappings=1.14.4+build.14 +loader_version=0.6.4+build.169 -mod_version = 0.5.2 +fabric_version=0.4.1+build.245-1.14 +fabric_asm_version=697a7c18da +zt_zip_version=1.13 +slf4j_version=1.7.29 +stitch_version=0.3.0.66 + +mod_version = 0.5.3 maven_group = me.modmuss50 archives_base_name = optifabric diff --git a/src/main/java/me/modmuss50/optifabric/mixin/MixinChunkCacheOF.java b/src/main/java/me/modmuss50/optifabric/mixin/MixinChunkCacheOF.java index 83df55c1..c09b368b 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/MixinChunkCacheOF.java +++ b/src/main/java/me/modmuss50/optifabric/mixin/MixinChunkCacheOF.java @@ -4,10 +4,8 @@ import net.fabricmc.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.render.chunk.ChunkRendererRegion; import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; -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; @@ -18,9 +16,6 @@ public abstract class MixinChunkCacheOF implements AccessChunkRendererRegion { private TerrainRenderContext fabric_renderer; - @Shadow @Final - private ChunkRendererRegion chunkCache; - //This was taken from https://github.com/FabricMC/fabric/blob/master/fabric-renderer-indigo/src/main/java/net/fabricmc/indigo/renderer/mixin/MixinChunkRenderTask.java honesly no idea what it does, but it doesnt crash the game here @Inject(method = "", at = @At("RETURN"), remap = false) private void constructor(ChunkRendererRegion chunkCache, BlockPos posFromIn, BlockPos posToIn, int subIn, CallbackInfo info){ diff --git a/src/main/java/me/modmuss50/optifabric/mixin/MixinReflectorClass.java b/src/main/java/me/modmuss50/optifabric/mixin/MixinReflectorClass.java index bab0cd95..49453aa6 100644 --- a/src/main/java/me/modmuss50/optifabric/mixin/MixinReflectorClass.java +++ b/src/main/java/me/modmuss50/optifabric/mixin/MixinReflectorClass.java @@ -19,7 +19,7 @@ public class MixinReflectorClass { private boolean checked; @Inject(method = "getTargetClass", at = @At("HEAD"), cancellable = true, remap = false) - public void getTargetClass(CallbackInfoReturnable> infoReturnable) { + private void getTargetClass(CallbackInfoReturnable> infoReturnable) { if (!checked) {//Only check the target if it hasn't been done yet String name = targetClassName.replaceAll("/", "."); if (name.startsWith("net.minecraft.launchwrapper") || name.startsWith("net.minecraftforge") || "optifine.OptiFineClassTransformer".equals(name)) { diff --git a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java index 42522dad..2165536b 100644 --- a/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java +++ b/src/main/java/me/modmuss50/optifabric/mod/OptifineSetup.java @@ -12,6 +12,9 @@ import net.fabricmc.loader.util.UrlConversionException; import net.fabricmc.loader.util.UrlUtil; import net.fabricmc.loader.util.mappings.TinyRemapperMappingsHelper; +import net.fabricmc.mapping.reader.v2.TinyMetadata; +import net.fabricmc.mapping.tree.ClassDef; +import net.fabricmc.mapping.tree.TinyTree; import net.fabricmc.mappings.*; import net.fabricmc.stitch.commands.CommandProposeFieldNames; import net.fabricmc.tinyremapper.IMappingProvider; @@ -168,27 +171,12 @@ IMappingProvider createMappings(String from, String to) { if (fabricLauncher.isDevelopment()) { try { File fullMappings = getDevMappings(); - return (classMap, fieldMap, methodMap) -> { - RemapUtils.getTinyRemapper(fullMappings, from, to).load(classMap, fieldMap, methodMap); - - Map extra = new HashMap<>(); - Pattern regex = Pattern.compile("(\\w+)\\/(\\w+);;([\\w/;]+)"); - - for (Entry entry : fieldMap.entrySet()) { - if ("CLOUDS".equals(entry.getValue())) { - Matcher matcher = regex.matcher(entry.getKey()); - if (!matcher.matches()) throw new IllegalStateException("Couldn't match " + entry.getKey() + " => " + entry.getValue()); - extra.put(matcher.group(1) + "/CLOUDS;;" + matcher.group(3), "CLOUDS_OF"); - } - - if ("renderDistance".equals(entry.getValue())) { - Matcher matcher = regex.matcher(entry.getKey()); - if (!matcher.matches()) throw new IllegalStateException("Couldn't match " + entry.getKey() + " => " + entry.getValue()); - extra.put(matcher.group(1) + "/renderDistance;;" + matcher.group(3), "renderDistance_OF"); - } - } - - fieldMap.putAll(extra); + return (out) -> { + RemapUtils.getTinyRemapper(fullMappings, from, to).load(out); + out.acceptField(new IMappingProvider.Member("cyf", "CLOUDS", "Lcxt;"), + "CLOUDS_OF"); + out.acceptField(new IMappingProvider.Member("dng", "renderDistance", "I"), + "renderDistance_OF"); }; } catch (Exception e) { throw new RuntimeException(e); @@ -196,51 +184,22 @@ IMappingProvider createMappings(String from, String to) { } //In prod - Mappings mappingsNew = new Mappings() { - private final Mappings mappings = mappingConfiguration.getMappings(); + TinyTree mappingsNew = new TinyTree() { + private final TinyTree mappings = mappingConfiguration.getMappings(); @Override - public Collection getNamespaces() { - return mappings.getNamespaces(); + public TinyMetadata getMetadata() { + return mappings.getMetadata(); } @Override - public Collection getClassEntries() { - return mappings.getClassEntries(); - } - - @Override - public Collection getFieldEntries() { - Collection fields = mappings.getFieldEntries(); - List extra = new ArrayList<>(); - - for (FieldEntry field : fields) { - String interName = field.get("intermediary").getName(); - - //Option#CLOUDS - if ("field_1937".equals(interName)) { - extra.add(namespace -> { - EntryTriple real = field.get(namespace); - return new EntryTriple(real.getOwner(), "official".equals(namespace) ? "CLOUDS" : "CLOUDS_OF", real.getDesc()); - }); - } - - //WorldRenderer#renderDistance - if ("field_4062".equals(interName)) { - extra.add(namespace -> { - EntryTriple real = field.get(namespace); - return new EntryTriple(real.getOwner(), "official".equals(namespace) ? "renderDistance" : "renderDistance_OF", real.getDesc()); - }); - } - } - - fields.addAll(extra); - return fields; + public Map getDefaultNamespaceClassMap() { + return mappings.getDefaultNamespaceClassMap(); } @Override - public Collection getMethodEntries() { - return mappings.getMethodEntries(); + public Collection getClasses() { + return mappings.getClasses(); } }; return TinyRemapperMappingsHelper.create(mappingsNew, from, to); diff --git a/src/main/java/me/modmuss50/optifabric/patcher/LambadaRebuiler.java b/src/main/java/me/modmuss50/optifabric/patcher/LambadaRebuiler.java index 4850cbd9..6b9c6230 100644 --- a/src/main/java/me/modmuss50/optifabric/patcher/LambadaRebuiler.java +++ b/src/main/java/me/modmuss50/optifabric/patcher/LambadaRebuiler.java @@ -94,7 +94,7 @@ private MethodNode findMethod(MethodNode optifineMethod, ClassNode optifineClass } @Override - public void load(Map classMap, Map fieldMap, Map methodMap) { + public void load(MappingAcceptor out) { methodMap.putAll(this.methodMap); } }