This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #220
- Loading branch information
Showing
5 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/me/modmuss50/optifabric/patcher/fixes/ThreadedAnvilChunkStorageFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package me.modmuss50.optifabric.patcher.fixes; | ||
|
||
import me.modmuss50.optifabric.util.RemappingUtils; | ||
import org.apache.commons.lang3.Validate; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
|
||
public class ThreadedAnvilChunkStorageFix implements ClassFixer { | ||
|
||
private String method_20458 = RemappingUtils.getMethodName("class_3898", "method_20460", "(Lnet/minecraft/server/world/ChunkHolder;Lcom/mojang/datafixers/util/Either;)Lcom/mojang/datafixers/util/Either;"); | ||
private String lambda_method_17227 = RemappingUtils.getMethodName("class_3898", "method_17227", "(Lnet/minecraft/server/world/ChunkHolder;Lnet/minecraft/world/chunk/Chunk;)Lnet/minecraft/world/chunk/Chunk;"); | ||
private String lambda_method_18843 = RemappingUtils.getMethodName("class_3898", "method_18843", "(Lnet/minecraft/server/world/ChunkHolder;Ljava/util/concurrent/CompletableFuture;JLnet/minecraft/world/chunk/Chunk;)V"); | ||
|
||
@Override | ||
public void fix(ClassNode optifine, ClassNode minecraft) { | ||
Validate.notNull(method_20458, "Failed to find name"); | ||
Validate.notNull(lambda_method_17227, "Failed to lambda name"); | ||
|
||
//put the old methods backs | ||
replaceOrCopyMethod(optifine, minecraft, method_20458); | ||
replaceOrCopyMethod(optifine, minecraft, lambda_method_17227); | ||
replaceOrCopyMethod(optifine, minecraft, lambda_method_18843); | ||
} | ||
|
||
private void replaceOrCopyMethod(ClassNode optifine, ClassNode minecraft, String name) { | ||
MethodNode vanillaNode = null; | ||
|
||
for (MethodNode method : minecraft.methods) { | ||
if (method.name.equals(name)) { | ||
vanillaNode = method; | ||
break; | ||
} | ||
} | ||
|
||
optifine.methods.removeIf((m) -> m.name.equals(name)); | ||
optifine.methods.add(vanillaNode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,6 @@ | |
}, | ||
"depends": { | ||
"fabricloader": ">=0.7.8", | ||
"minecraft": ">=1.15.2" | ||
"minecraft": "1.15.2" | ||
} | ||
} |