Search in sources :

Example 1 with ModelItemPropertyOverrideList

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

the class ModelModClient method onInitializeClient.

@Override
public void onInitializeClient() {
    ModelLoadingRegistry.INSTANCE.registerAppender((manager, out) -> {
        System.out.println("--- ModelAppender called! ---");
        out.accept(new ModelIdentifier("fabric:model#custom"));
    });
    ModelLoadingRegistry.INSTANCE.registerVariantProvider(manager -> ((modelId, context) -> {
        if (modelId.getVariant().equals("custom") && modelId.getNamespace().equals("fabric")) {
            System.out.println("--- ModelVariantProvider called! ---");
            return context.loadModel(new Identifier("fabric:custom"));
        } else {
            return null;
        }
    }));
    ModelLoadingRegistry.INSTANCE.registerResourceProvider(manager -> ((id, context) -> {
        if (id.toString().equals("fabric:custom")) {
            return context.loadModel(new Identifier("fabric:custom2"));
        } else if (id.toString().equals("fabric:custom2")) {
            System.out.println("--- ModelResourceProvider called! ---");
            return new UnbakedModel() {

                @Override
                public Collection<Identifier> getModelDependencies() {
                    return Collections.emptyList();
                }

                @Override
                public Collection<Identifier> getTextureDependencies(Function<Identifier, UnbakedModel> var1, Set<String> var2) {
                    return Collections.emptyList();
                }

                @Override
                public BakedModel bake(ModelLoader var1, Function<Identifier, Sprite> var2, ModelBakeSettings var3) {
                    System.out.println("--- Model baked! ---");
                    return bakedModel = new BakedModel() {

                        @Override
                        public List<BakedQuad> getQuads(BlockState var1, Direction var2, Random var3) {
                            return Collections.emptyList();
                        }

                        @Override
                        public boolean useAmbientOcclusion() {
                            return false;
                        }

                        @Override
                        public boolean hasDepthInGui() {
                            return false;
                        }

                        @Override
                        public boolean isBuiltin() {
                            return false;
                        }

                        @Override
                        public Sprite getSprite() {
                            return MinecraftClient.getInstance().getSpriteAtlas().getSprite("missingno");
                        }

                        @Override
                        public ModelTransformation getTransformation() {
                            return ModelTransformation.NONE;
                        }

                        @Override
                        public ModelItemPropertyOverrideList getItemPropertyOverrides() {
                            return ModelItemPropertyOverrideList.EMPTY;
                        }
                    };
                }
            };
        } else {
            return null;
        }
    }));
    ClientTickCallback.EVENT.register((client) -> {
        if (client.getBakedModelManager().getModel(new ModelIdentifier("fabric:model#custom")) == bakedModel && bakedModel != null) {
            System.out.println("--- MODEL LOADED! ---");
        } else {
            System.out.println("--- MODEL NOT LOADED! ---");
        }
    });
}
Also used : ClientModInitializer(net.fabricmc.api.ClientModInitializer) ModelItemPropertyOverrideList(net.minecraft.client.render.model.json.ModelItemPropertyOverrideList) Direction(net.minecraft.util.math.Direction) Sprite(net.minecraft.client.texture.Sprite) ModelIdentifier(net.minecraft.client.util.ModelIdentifier) ModelLoadingRegistry(net.fabricmc.fabric.api.client.model.ModelLoadingRegistry) Identifier(net.minecraft.util.Identifier) ClientTickCallback(net.fabricmc.fabric.api.event.client.ClientTickCallback) MinecraftClient(net.minecraft.client.MinecraftClient) BlockState(net.minecraft.block.BlockState) Function(java.util.function.Function) ModelTransformation(net.minecraft.client.render.model.json.ModelTransformation) Sprite(net.minecraft.client.texture.Sprite) ModelItemPropertyOverrideList(net.minecraft.client.render.model.json.ModelItemPropertyOverrideList) Direction(net.minecraft.util.math.Direction) Function(java.util.function.Function) ModelIdentifier(net.minecraft.client.util.ModelIdentifier) Identifier(net.minecraft.util.Identifier) BlockState(net.minecraft.block.BlockState) ModelIdentifier(net.minecraft.client.util.ModelIdentifier) ModelTransformation(net.minecraft.client.render.model.json.ModelTransformation) ModelItemPropertyOverrideList(net.minecraft.client.render.model.json.ModelItemPropertyOverrideList)

Aggregations

Function (java.util.function.Function)1 ClientModInitializer (net.fabricmc.api.ClientModInitializer)1 ModelLoadingRegistry (net.fabricmc.fabric.api.client.model.ModelLoadingRegistry)1 ClientTickCallback (net.fabricmc.fabric.api.event.client.ClientTickCallback)1 BlockState (net.minecraft.block.BlockState)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ModelItemPropertyOverrideList (net.minecraft.client.render.model.json.ModelItemPropertyOverrideList)1 ModelTransformation (net.minecraft.client.render.model.json.ModelTransformation)1 Sprite (net.minecraft.client.texture.Sprite)1 ModelIdentifier (net.minecraft.client.util.ModelIdentifier)1 Identifier (net.minecraft.util.Identifier)1 Direction (net.minecraft.util.math.Direction)1