Search in sources :

Example 1 with IControllerComponent

use of com.lowdragmc.multiblocked.api.tile.IControllerComponent in project Multiblocked by Low-Drag-MC.

the class PartTileEntity method updateCurrentRenderer.

@Override
public IMultiblockedRenderer updateCurrentRenderer() {
    if (definition.workingRenderer != null) {
        for (IControllerComponent controller : getControllers()) {
            if (controller.isFormed() && controller.getStatus().equals("working")) {
                IMultiblockedRenderer renderer = definition.workingRenderer;
                if (Multiblocked.isKubeJSLoaded()) {
                    UpdateRendererEvent event = new UpdateRendererEvent(this, renderer);
                    event.post(ScriptType.SERVER, UpdateRendererEvent.ID, getSubID());
                    renderer = event.getRenderer();
                }
                return renderer;
            }
        }
    }
    return super.updateCurrentRenderer();
}
Also used : UpdateRendererEvent(com.lowdragmc.multiblocked.api.kubejs.events.UpdateRendererEvent) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) IControllerComponent(com.lowdragmc.multiblocked.api.tile.IControllerComponent)

Example 2 with IControllerComponent

use of com.lowdragmc.multiblocked.api.tile.IControllerComponent 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

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