#Load a model from json
1 messages · Page 1 of 1 (latest)
Easist way would be to make a mixin to ModelLoader.class
and use the addModel method
@Mixin(ModelLoader.class)
public abstract class ModelLoaderMixin {
@Shadow
protected abstract void addModel(ModelIdentifier modelId);
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelLoader;addModel(Lnet/minecraft/client/util/ModelIdentifier;)V", ordinal = 2, shift = At.Shift.BEFORE))
public void addModels(BlockColors blockColors, Profiler profiler, Map<Identifier, JsonUnbakedModel> jsonUnbakedModels, Map<Identifier, List<ModelLoader.SourceTrackedData>> blockStates, CallbackInfo ci) {;
this.addModel(new ModelIdentifier(NAMESPACE (modID), PATH (path to your model (assets/modid/), VARIANT (use "inventory" for general gui stuff));
}
}
}
With this, Minecraft will do your model loading.
Then you can just use one of the model managesr to get your model
MinecraftClient.getInstance().getBakedModelManager().getModel(ModelIdentifier);
I remember seeing a model loader fapi module? Maybe that might help?
But the how would I actually render it?
Wait are you trying to make a 3D renderer for a item when it is held in the hand just like a spyglass or something?
@torn sand
No, I am trying to render an item sprite at an specific moment. I already know how to do the spyglass/trident model thing
Oh
Thank you for asking, tough