Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private static boolean isPresent(String modID) {
return FabricLoader.getInstance().isModLoaded(modID);
}

static boolean isPresent(String modID, String versionRange) {
public static boolean isPresent(String modID, String versionRange) {
return isPresent(modID, modMetadata -> compareVersions(versionRange, modMetadata));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package me.modmuss50.optifabric.patcher.fixes;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableSet;

import me.modmuss50.optifabric.mod.OptifabricSetup;
import org.apache.commons.lang3.Validate;

import org.objectweb.asm.Handle;
Expand All @@ -21,17 +24,23 @@

public class KeyboardFix implements ClassFixer {
private final String screenClass = RemappingUtils.getClassName("class_437");
private final Set<String> revertMethods = ImmutableSet.of(
RemappingUtils.getMethodName("class_309", "method_1466", "(JIIII)V"), //Keyboard, onKey
RemappingUtils.getMethodName("class_309", "method_1454", "(IL" + screenClass + ";[ZIII)V"),
RemappingUtils.getMethodName("class_309", "method_1458", "(L" + screenClass + ";II)V"),
RemappingUtils.getMethodName("class_309", "method_1473", "(L" + screenClass + ";CI)V"),
RemappingUtils.getMethodName("class_309", "method_1463", "(Lnet/minecraft/class_2561)V"),
RemappingUtils.getMethodName("class_309", "method_1464", "(Lnet/minecraft/class_2561)V")
);
private Set<String> revertMethods;

@Override
public void fix(ClassNode optifine, ClassNode minecraft) {
List<String> revert = new ArrayList<>(Arrays.asList(
RemappingUtils.getMethodName("class_309", "method_1466", "(JIIII)V"), //Keyboard, onKey
RemappingUtils.getMethodName("class_309", "method_1454", "(IL" + screenClass + ";[ZIII)V"),
RemappingUtils.getMethodName("class_309", "method_1463", "(Lnet/minecraft/class_2561)V"),
RemappingUtils.getMethodName("class_309", "method_1464", "(Lnet/minecraft/class_2561)V")
));

if (OptifabricSetup.isPresent("minecraft", ">=1.18.2")) {
revert.add(RemappingUtils.getMethodName("class_309", "method_1458", "(L" + screenClass + ";II)V"));
revert.add(RemappingUtils.getMethodName("class_309", "method_1473", "(L" + screenClass + ";CI)V"));
}
revertMethods = ImmutableSet.copyOf(revert);

Validate.noNullElements(revertMethods, "Failed to remap Keyboard method name %d"); //ImmutableSet iteration order is stable

//Remove the "broken" OptiFine methods
Expand Down