Search in sources :

Example 1 with CustomBakedModel

use of com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel in project Multiblocked by Low-Drag-MC.

the class GTRenderer method renderModel.

@Override
@OnlyIn(Dist.CLIENT)
public List<BakedQuad> renderModel(IBlockDisplayReader level, BlockPos pos, BlockState state, Direction side, Random rand, IModelData modelData) {
    TileEntity te = level.getBlockEntity(pos);
    if (formedAsController && te instanceof IPartComponent) {
        IPartComponent part = (IPartComponent) te;
        for (IControllerComponent controller : part.getControllers()) {
            if (controller.isFormed() && controller.getRenderer() instanceof GTRenderer) {
                IBakedModel model = getModel(((GTRenderer) controller.getRenderer()).baseTexture).bake(ModelLoader.instance(), ModelLoader.defaultTextureGetter(), ModelFactory.getRotation(part.getFrontFacing()), modelLocation);
                if (model == null)
                    return Collections.emptyList();
                model = new CustomBakedModel(model);
                if (!((CustomBakedModel) model).shouldRenderInLayer(state, rand))
                    return Collections.emptyList();
                return model.getQuads(state, side, rand, modelData);
            }
        }
    }
    return super.renderModel(level, pos, state, side, rand, modelData);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPartComponent(com.lowdragmc.multiblocked.api.tile.part.IPartComponent) IControllerComponent(com.lowdragmc.multiblocked.api.tile.IControllerComponent) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) CustomBakedModel(com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

CustomBakedModel (com.lowdragmc.lowdraglib.client.model.custommodel.CustomBakedModel)1 IControllerComponent (com.lowdragmc.multiblocked.api.tile.IControllerComponent)1 IPartComponent (com.lowdragmc.multiblocked.api.tile.part.IPartComponent)1 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)1 TileEntity (net.minecraft.tileentity.TileEntity)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1