Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Fix crash with latest fabric-api.
Browse files Browse the repository at this point in the history
Closes #220
  • Loading branch information
modmuss50 committed Jun 30, 2020
1 parent 597daea commit 973c361
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.4.3"
classpath "net.fabricmc:fabric-loom:0.4-SNAPSHOT"
}
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
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);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
},
"depends": {
"fabricloader": ">=0.7.8",
"minecraft": ">=1.15.2"
"minecraft": "1.15.2"
}
}

0 comments on commit 973c361

Please sign in to comment.