Fixed Mixin crash

This commit is contained in:
Frank 2022-12-09 17:16:16 +01:00
parent 26cd2e6c19
commit d7caa09f5f

View file

@ -12,7 +12,8 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(ModelBakery.class) @Mixin(ModelBakery.class)
public abstract class ModelLoaderMixin { public abstract class ModelLoaderMixin {
@ModifyArg(method = "loadModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ResourceManager;getResourceStack(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;")) //TODO: 1.19.3 validate that alternative chorus model is loaded
@ModifyArg(method = "loadModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/resources/FileToIdConverter;idToFile(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/resources/ResourceLocation;"))
public ResourceLocation be_switchModelOnLoad(ResourceLocation loc) { public ResourceLocation be_switchModelOnLoad(ResourceLocation loc) {
if (GeneratorOptions.changeChorusPlant() && be_changeModel(loc)) { if (GeneratorOptions.changeChorusPlant() && be_changeModel(loc)) {
String path = loc.getPath().replace("chorus", "custom_chorus"); String path = loc.getPath().replace("chorus", "custom_chorus");
@ -21,19 +22,14 @@ public abstract class ModelLoaderMixin {
return loc; return loc;
} }
// @ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE"))
// public ResourceLocation be_switchModel(ResourceLocation id) {
// if (GeneratorOptions.changeChorusPlant() && be_changeModel(id)) {
// String path = id.getPath().replace("chorus", "custom_chorus");
// id = BetterEnd.makeID(path);
// }
// return id;
// }
private boolean be_changeModel(ResourceLocation id) { private boolean be_changeModel(ResourceLocation id) {
return id.getNamespace().equals("minecraft") if (id.getNamespace().equals("minecraft")) {
&& id.getPath().startsWith("blockstates/") if (id.getPath().contains("chorus") && !id.getPath().contains("custom_")) {
&& id.getPath().contains("chorus") return true || id.getPath().startsWith("blockstates/");
&& !id.getPath().contains("custom_");
}
return false;
}
return false;
} }
} }