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 ae8a677 commit a77c645
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ repositories {
maven { url "https://jitpack.io" }
}

loom {
accessWidenerPath = file("src/main/resources/optifabric.accesswidener")
}

dependencies {
minecraft libs.minecraft
mappings variantOf(libs.feather.mappings) { classifier "v2" }
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-ornithe
archives_name=optifabric
maven_group=me.modmuss50
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/locale/Language getInstance ()Lnet/minecraft/locale/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 a77c645

Please sign in to comment.