[Change] Different Mixin for Chorus model switch (will no longer show up in error logs tho) (#52)

This commit is contained in:
Frank 2022-07-26 14:34:23 +02:00
parent c77d9678e0
commit fe09d2a249

View file

@ -8,19 +8,28 @@ import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.ModifyArg;
@Mixin(ModelBakery.class) @Mixin(ModelBakery.class)
public abstract class ModelLoaderMixin { public abstract class ModelLoaderMixin {
@ModifyVariable(method = "loadModel", ordinal = 2, at = @At(value = "INVOKE")) @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_switchModel(ResourceLocation id) { public ResourceLocation be_switchModelOnLoad(ResourceLocation loc) {
if (GeneratorOptions.changeChorusPlant() && be_changeModel(id)) { if (GeneratorOptions.changeChorusPlant() && be_changeModel(loc)) {
String path = id.getPath().replace("chorus", "custom_chorus"); String path = loc.getPath().replace("chorus", "custom_chorus");
id = BetterEnd.makeID(path); 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) { private boolean be_changeModel(ResourceLocation id) {
return id.getNamespace().equals("minecraft") return id.getNamespace().equals("minecraft")
&& id.getPath().startsWith("blockstates/") && id.getPath().startsWith("blockstates/")