Skip to content

Commit

Permalink
Add support for 1.19.x-1.20.x, closes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Barteks2x committed Jun 25, 2023
1 parent 37abc14 commit 90afe8c
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 119 deletions.
236 changes: 118 additions & 118 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,118 +1,118 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

buildscript {
repositories {
gradlePluginPortal()
maven {url = 'https://maven.minecraftforge.net/'}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'

version = "2.6.6"
group = "ofdev" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "aa_do_not_rename_OptiFineDevTweaker"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}

repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
maven {
url "https://libraries.minecraft.net/"
}
}

configurations {
shadow
}

dependencies {
shadow("org.ow2.asm:asm-debug-all:5.2")
compileOnly 'cpw.mods:modlauncher:4.0.+'
compileOnly 'lzma:lzma:0.0.1'
compileOnly('net.minecraft:launchwrapper:1.12') {
transitive = true
}
}

task shadowJarLW(type: ShadowJar) {
configurations = [project.configurations.shadow]
from(sourceSets.main.output) {
include('ofdev/launchwrapper/**', 'ofdev/common/**')
}
relocate('org.objectweb', 'ofdev.launchwrapper.org.objectweb')
classifier = "launchwrapper"
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000"
])
}
}

task shadowJarML(type: ShadowJar) {

from sourceSets.main.output
include('ofdev/modlauncher/**', 'ofdev/common/**')
classifier = "modlauncher"
manifest {
attributes([
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

task shadowJarAll(type: ShadowJar) {
dependsOn(shadowJarLW)
from(sourceSets.main.output) {
include('ofdev/modlauncher/**')
include('META-INF/**')
}
from(shadowJarLW.archivePath.absolutePath) {
include('*')
}
classifier = "all"
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000",
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
build.dependsOn(shadowJarAll, shadowJarML, shadowJarLW)

jar {
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000",
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

buildscript {
repositories {
gradlePluginPortal()
maven {url = 'https://maven.minecraftforge.net/'}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'

version = "2.6.7"
group = "ofdev" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "aa_do_not_rename_OptiFineDevTweaker"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}

repositories {
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
maven {
url "https://libraries.minecraft.net/"
}
}

configurations {
shadow
}

dependencies {
shadow("org.ow2.asm:asm-debug-all:5.2")
compileOnly 'cpw.mods:modlauncher:4.0.+'
compileOnly 'lzma:lzma:0.0.1'
compileOnly('net.minecraft:launchwrapper:1.12') {
transitive = true
}
}

task shadowJarLW(type: ShadowJar) {
configurations = [project.configurations.shadow]
from(sourceSets.main.output) {
include('ofdev/launchwrapper/**', 'ofdev/common/**')
}
relocate('org.objectweb', 'ofdev.launchwrapper.org.objectweb')
classifier = "launchwrapper"
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000"
])
}
}

task shadowJarML(type: ShadowJar) {

from sourceSets.main.output
include('ofdev/modlauncher/**', 'ofdev/common/**')
classifier = "modlauncher"
manifest {
attributes([
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

task shadowJarAll(type: ShadowJar) {
dependsOn(shadowJarLW)
from(sourceSets.main.output) {
include('ofdev/modlauncher/**')
include('META-INF/**')
}
from(shadowJarLW.archivePath.absolutePath) {
include('*')
}
classifier = "all"
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000",
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
build.dependsOn(shadowJarAll, shadowJarML, shadowJarLW)

jar {
manifest {
attributes([
"TweakClass": "ofdev.launchwrapper.OptifineDevTweakerWrapper",
"TweakOrder": "-10000",
"Specification-Title": "ofdevtweaker",
"Specification-Vendor": "ofdevtweaker",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"ofdevtweaker",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
7 changes: 6 additions & 1 deletion src/main/java/ofdev/modlauncher/OFDevRetransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ private static Collection<? extends Target> findOptiFineClasses(IEnvironment env
.orElseThrow(() -> new IllegalStateException("modlist not found"));
Map<String, String> optifine = modlist.stream().filter(x -> x.get("name").equals("OptiFine")).findAny()
.orElseThrow(() -> new IllegalStateException("OptiFine not found"));
Map<String, String> fml = modlist.stream().filter(x -> x.get("name").equals("fml")).findAny().orElse(null);
String optifineFile = optifine.get("file");
String fmlFile = fml == null ? "" : fml.get("file");
LOGGER.info("Got OptiFine file name \"{}\"", optifineFile);
// workaround for https://github.com/McModLauncher/securejarhandler/issues/20
if (optifineFile.isEmpty()) {
// NOTE: also do this is fml filename matches optifine file name, in that case the jar appears to be modlauncher jar
// TODO: report a bug to whatever
if (optifineFile.isEmpty() || optifineFile.equals(fmlFile)) {
LOGGER.error("OptiFine file not found through API! Trying ModLauncher internals...");
try {
Field transformationServicesHandlerField = Launcher.class.getDeclaredField("transformationServicesHandler");
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/ofdev/modlauncher/OfDevRemapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ public class OfDevRemapper extends Remapper {
if (owner.equals("net/minecraft/client/model/geom/ModelPart") && name.equals("getChild")) {
return "getChild_OF";
}
// 1.20.1:
if (owner.equals("net/minecraft/client/OptionInstance$Enum") && name.equals("codec")) {
return "codec_OF";
}
if (owner.equals("net/minecraft/client/OptionInstance$AltEnum") && name.equals("valueSetter")) {
return "valueSetter_OF";
}
if (owner.equals("net/minecraft/client/OptionInstance$AltEnum") && name.equals("codec")) {
return "codec_OF";
}
if (owner.equals("net/minecraft/client/OptionInstance$LazyEnum") && name.equals("codec")) {
return "codec_OF";
}
if (owner.equals("net/minecraft/client/resources/model/ModelBakery") && name.equals("loadBlockModel")) {
return "loadBlockModel_OF";
}
String method = srg2mcp.apply(INameMappingService.Domain.METHOD, name);
if (method.equals(name)) {
// record components are technically methods but mapped as fields
Expand Down

0 comments on commit 90afe8c

Please sign in to comment.