From fe09d2a249f0fed3fd5db0418bdd0655ad70acda Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 26 Jul 2022 14:34:23 +0200 Subject: [PATCH] [Change] Different Mixin for Chorus model switch (will no longer show up in error logs tho) (#52) --- .../mixin/client/ModelLoaderMixin.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/betterx/betterend/mixin/client/ModelLoaderMixin.java b/src/main/java/org/betterx/betterend/mixin/client/ModelLoaderMixin.java index 9f2a4500..29a8bcf6 100644 --- a/src/main/java/org/betterx/betterend/mixin/client/ModelLoaderMixin.java +++ b/src/main/java/org/betterx/betterend/mixin/client/ModelLoaderMixin.java @@ -8,19 +8,28 @@ import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(ModelBakery.class) public abstract class ModelLoaderMixin { - @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); + @ModifyArg(method = "loadModel", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/packs/resources/ResourceManager;getResourceStack(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/List;")) + public ResourceLocation be_switchModelOnLoad(ResourceLocation loc) { + if (GeneratorOptions.changeChorusPlant() && be_changeModel(loc)) { + String path = loc.getPath().replace("chorus", "custom_chorus"); + return BetterEnd.makeID(path); } - return id; + 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) { return id.getNamespace().equals("minecraft") && id.getPath().startsWith("blockstates/")