diff --git a/build.gradle b/build.gradle index fec54593..b1204aa7 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath "net.fabricmc:fabric-loom:0.4.3" + classpath "net.fabricmc:fabric-loom:0.4-SNAPSHOT" } } diff --git a/gradle.properties b/gradle.properties index 82a25b0b..1d92a8cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,14 @@ org.gradle.jvmargs=-Xmx1G minecraft_version=1.15.2 -yarn_mappings=1.15.2+build.14 -loader_version=0.8.2+build.194 +yarn_mappings=1.15.2+build.17 +loader_version=0.8.9+build.203 -fabric_version=0.10.1+build.307-1.15 +fabric_version=0.14.0+build.317-1.15 fabric_asm_version=v2.0 zt_zip_version=1.14 slf4j_version=1.7.30 -mod_version = 1.0.0-beta8 +mod_version = 1.0.0 maven_group = me.modmuss50 archives_base_name = optifabric diff --git a/src/main/java/me/modmuss50/optifabric/patcher/fixes/OptifineFixer.java b/src/main/java/me/modmuss50/optifabric/patcher/fixes/OptifineFixer.java index b6dfd377..327cad90 100644 --- a/src/main/java/me/modmuss50/optifabric/patcher/fixes/OptifineFixer.java +++ b/src/main/java/me/modmuss50/optifabric/patcher/fixes/OptifineFixer.java @@ -30,6 +30,9 @@ private OptifineFixer() { //net/minecraft/client/texture/SpriteAtlasTexture registerFix("class_1059", new SpriteAtlasTextureFix()); + //net/minecraft/server/world/ThreadedAnvilChunkStorage + registerFix("class_3898", new ThreadedAnvilChunkStorageFix()); + //net/minecraft/client/particle/ParticleManager skipClass("class_702"); diff --git a/src/main/java/me/modmuss50/optifabric/patcher/fixes/ThreadedAnvilChunkStorageFix.java b/src/main/java/me/modmuss50/optifabric/patcher/fixes/ThreadedAnvilChunkStorageFix.java new file mode 100644 index 00000000..6748b47d --- /dev/null +++ b/src/main/java/me/modmuss50/optifabric/patcher/fixes/ThreadedAnvilChunkStorageFix.java @@ -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); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 12f7db65..c9a999a8 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,6 +32,6 @@ }, "depends": { "fabricloader": ">=0.7.8", - "minecraft": ">=1.15.2" + "minecraft": "1.15.2" } }