Search in sources :

Example 1 with UnbakedModel

use of net.minecraft.client.render.model.UnbakedModel in project fabric by FabricMC.

the class MixinModelLoader method loadModelHook.

@Inject(at = @At("HEAD"), method = "loadModel", cancellable = true)
private void loadModelHook(Identifier id, CallbackInfo ci) {
    UnbakedModel customModel = fabric_mlrLoaderInstance.loadModelFromVariant(id);
    if (customModel != null) {
        putModel(id, customModel);
        ci.cancel();
    }
}
Also used : UnbakedModel(net.minecraft.client.render.model.UnbakedModel) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with UnbakedModel

use of net.minecraft.client.render.model.UnbakedModel in project AurorasDecorations by LambdAurora.

the class RestModelManager method loadModelEntry.

private RestModelEntry loadModelEntry(WoodType woodType, ResourceManager resourceManager, ModelVariantMap.DeserializationContext deserializationContext) {
    var pathName = woodType.getPathName();
    // Bench rest
    UnbakedModel benchRest = null;
    var benchBlock = Registry.BLOCK.get(AurorasDeco.id("bench/" + pathName));
    var benchRestId = AurorasDeco.id("blockstates/bench/" + pathName + "_rest.json");
    if (benchBlock != Blocks.AIR) {
        try {
            var resource = resourceManager.getResource(benchRestId);
            var stateFactory = deserializationContext.getStateFactory();
            deserializationContext.setStateFactory(benchBlock.getStateManager());
            var map = ModelVariantMap.fromJson(deserializationContext, new InputStreamReader(resource.getInputStream()));
            benchRest = map.getMultipartModel();
            deserializationContext.setStateFactory(stateFactory);
            resource.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return new RestModelEntry(AurorasDeco.id("bench/" + pathName + "_rest"), benchRest);
}
Also used : UnbakedModel(net.minecraft.client.render.model.UnbakedModel) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException)

Aggregations

UnbakedModel (net.minecraft.client.render.model.UnbakedModel)2 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1