Skip to content

Commit

Permalink
fix access issues and copy redlime's accesswidener
Browse files Browse the repository at this point in the history
  • Loading branch information
tildejustin committed Dec 17, 2023
1 parent 6629412 commit dfd29ba
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
8 changes: 0 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ base {
}

repositories {
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://jitpack.io" }
}

loom {
decompilers {
vineflower {
options.put("mark-corresponding-synthetics", "1")
options.put("ind", " ")
}
}
accessWidenerPath = file("src/main/resources/optifabric.accesswidener")
}

dependencies {
minecraft libs.minecraft
mappings legacy.yarn(libs.versions.minecraft.get(), libs.versions.yarn.build.get())
modImplementation libs.fabric.loader
vineflowerDecompilerClasspath libs.vineflower
include(modImplementation libs.fabric.asm.get())
include(implementation libs.zt.zip.get())
include(runtimeOnly libs.slf4j.api.get())
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
mod_version=2.2.0
mod_version=2.2.1
target_version=1.6-1.7.10
archives_name=optifabric
maven_group=me.modmuss50
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ minecraft = "1.7.10"
yarn_build = "533"
fabric-loader = "0.15.2"
loom = "1.4-SNAPSHOT"
vineflower = "1.10.0-SNAPSHOT"
fabric-asm = "v2.3.3"
zt-zip = "1.16"
slf4j-api = "2.0.9"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
vineflower = { module = "org.vineflower:vineflower", version.ref = "vineflower" }
fabric-asm = { module = "com.github.Minecraft-Java-Edition-Speedrunning:fabric-asm", version.ref = "fabric-asm" }
zt-zip = { module = "org.zeroturnaround:zt-zip", version.ref = "zt-zip" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j-api" }
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/me/modmuss50/optifabric/mod/OptifineInjector.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package me.modmuss50.optifabric.mod;

import com.chocohead.mm.api.ClassTinkerers;
import com.chocohead.mm.api.*;
import me.modmuss50.optifabric.patcher.*;
import org.objectweb.asm.Opcodes;
import net.fabricmc.loader.api.*;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;

import java.util.*;
import java.util.function.Consumer;
import java.util.function.*;

public class OptifineInjector {

private static final List<String> patched = new ArrayList<>();
ClassCache classCache;
// i have no idea why and how this works, if you know better please let me know
@SuppressWarnings("CommentedOutCode")
public final Consumer<ClassNode> transformer = target -> {
if (patched.contains(target.name)) {
System.out.println("Already patched" + target.name);
Expand Down Expand Up @@ -42,12 +42,11 @@ public class OptifineInjector {
}

// let's make every class we touch public
// is this necessary? I don't think so
// if (!FabricLoader.getInstance().isDevelopmentEnvironment()) {
// target.access = modAccess(target.access);
// target.methods.forEach(methodNode -> methodNode.access = modAccess(methodNode.access));
// target.fields.forEach(fieldNode -> fieldNode.access = modAccess(fieldNode.access));
// }
if (!FabricLoader.getInstance().isDevelopmentEnvironment()) {
target.access = modAccess(target.access);
target.methods.forEach(methodNode -> methodNode.access = modAccess(methodNode.access));
target.fields.forEach(fieldNode -> fieldNode.access = modAccess(fieldNode.access));
}
};

public OptifineInjector(ClassCache classCache) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/optifabric.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ accessible field net/minecraft/client/gui/widget/ButtonWidget width I
accessible field net/minecraft/client/gui/widget/ButtonWidget height I
accessible method net/minecraft/util/Language getInstance ()Lnet/minecraft/util/Language;
accessible method net/minecraft/block/Block setOpacity (I)Lnet/minecraft/block/Block;
accessible field net/minecraft/entity/LivingEntity despawnCounter I
accessible field net/minecraft/resource/AbstractFileResourcePack base Ljava/io/File;

0 comments on commit dfd29ba

Please sign in to comment.