Skip to content

Commit

Permalink
Fix 1.7.10 support - compile against log4j 2.0-beta9, fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Barteks2x committed Jun 25, 2023
1 parent e5e43b0 commit 7714f0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ configurations {

dependencies {
shadow("org.ow2.asm:asm-debug-all:5.2")
compileOnly 'cpw.mods:modlauncher:4.0.+'
compileOnly('cpw.mods:modlauncher:4.0.+') {
transitive = false
}
compileOnly 'lzma:lzma:0.0.1'
compileOnly('net.minecraft:launchwrapper:1.12') {
transitive = true
transitive = false
}
// log4j version from 1.7.10, the oldest we support
compileOnly("org.apache.logging.log4j:log4j-api:2.0-beta9")
}

task shadowJarLW(type: ShadowJar) {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/ofdev/modlauncher/OFDevRetransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.Nonnull;

public class OFDevRetransformer implements ITransformer<ClassNode> {

private final Set<Target> targets;
Expand Down Expand Up @@ -150,7 +148,7 @@ private static Collection<? extends Target> findOptiFineClasses(IEnvironment env
return newTargets.stream().map(Target::targetClass).collect(Collectors.toList());
}

@Nonnull @Override public ClassNode transform(@Nonnull ClassNode input, @Nonnull ITransformerVotingContext context) {
@Override public ClassNode transform(ClassNode input, ITransformerVotingContext context) {
ClassNode output = new ClassNode();
ClassRemapper classRemapper = new ClassRemapper(output, remapper);
input.accept(classRemapper);
Expand All @@ -164,11 +162,11 @@ private static Collection<? extends Target> findOptiFineClasses(IEnvironment env
return output;
}

@Nonnull @Override public TransformerVoteResult castVote(@Nonnull ITransformerVotingContext context) {
@Override public TransformerVoteResult castVote(ITransformerVotingContext context) {
return TransformerVoteResult.YES;
}

@Nonnull @Override public Set<Target> targets() {
@Override public Set<Target> targets() {
return targets;
}

Expand Down
13 changes: 5 additions & 8 deletions src/main/java/ofdev/modlauncher/OFDevTransformationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.zip.ZipFile;

import javax.annotation.Nonnull;

public class OFDevTransformationService implements ITransformationService {

private static final Logger LOGGER = LogManager.getLogger();
Expand All @@ -58,11 +55,11 @@ public class OFDevTransformationService implements ITransformationService {
private static IEnvironment env;
private static BiConsumer<ClassNode, ClassNode> fixMemberAccess;

@Nonnull @Override public String name() {
@Override public String name() {
return "OptiFineDevTransformationService";
}

@Override public void initialize(@Nonnull IEnvironment environment) {
@Override public void initialize(IEnvironment environment) {
mcJar = Utils.findMinecraftJar();
try {
Path classDump = Paths.get(".").toAbsolutePath().normalize().resolve(".optifineDev.classes");
Expand All @@ -73,11 +70,11 @@ public class OFDevTransformationService implements ITransformationService {
}
}

@Override public void beginScanning(@Nonnull IEnvironment environment) {
@Override public void beginScanning(IEnvironment environment) {

}

@Override public void onLoad(@Nonnull IEnvironment envIn, @Nonnull Set<String> otherServices) throws IncompatibleEnvironmentException {
@Override public void onLoad(IEnvironment envIn, Set<String> otherServices) throws IncompatibleEnvironmentException {
env = envIn;
if (!otherServices.contains("OptiFine")) {
throw new IncompatibleEnvironmentException("Couldn't find OptiFine!");
Expand Down Expand Up @@ -190,7 +187,7 @@ public class OFDevTransformationService implements ITransformationService {
return output;
}

@SuppressWarnings("rawtypes") @Nonnull @Override public List<ITransformer> transformers() {
@SuppressWarnings("rawtypes") @Override public List<ITransformer> transformers() {
return Collections.singletonList(new OFDevRetransformer(env));
}

Expand Down

0 comments on commit 7714f0f

Please sign in to comment.