//  Bake the subcomponents into a CompositeModel
  @Override
  public IFlexibleBakedModel bake(
      IModelState state,
      VertexFormat format,
      Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    IModel subComponent = ModelLoaderRegistry.getModel(MODEL_CORE);
    IBakedModel bakedModelCore = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_UP);
    IBakedModel bakedModelUp = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_DOWN);
    IBakedModel bakedModelDown = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_WEST);
    IBakedModel bakedModelWest = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_EAST);
    IBakedModel bakedModelEast = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_NORTH);
    IBakedModel bakedModelNorth = subComponent.bake(state, format, bakedTextureGetter);

    subComponent = ModelLoaderRegistry.getModel(MODEL_SOUTH);
    IBakedModel bakedModelSouth = subComponent.bake(state, format, bakedTextureGetter);

    return new CompositeModel(
        bakedModelCore,
        bakedModelUp,
        bakedModelDown,
        bakedModelWest,
        bakedModelEast,
        bakedModelNorth,
        bakedModelSouth);
  }
Esempio n. 2
0
 private IBakedModel getBakedModel() {
   // Since we cannot bake in preInit() we do lazy baking of the model as soon as we need it
   // for rendering
   if (bakedModel == null) {
     try {
       model =
           ModelLoaderRegistry.getModel(
               new ResourceLocation(ModTut.MODID, "block/pedestalhandles.obj"));
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
     bakedModel =
         model.bake(
             TRSRTransformation.identity(),
             DefaultVertexFormats.ITEM,
             location ->
                 Minecraft.getMinecraft()
                     .getTextureMapBlocks()
                     .getAtlasSprite(location.toString()));
   }
   return bakedModel;
 }