Search in sources :

Example 1 with ITileRenderListener

use of com.builtbroken.mc.api.tile.listeners.client.ITileRenderListener in project Engine by VoltzEngine-Project.

the class TileRenderHandler method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
    GL11.glPushMatrix();
    try {
        GL11.glTranslated(x + 0.5, y, z + 0.5);
        RenderData data = getRenderData(tile);
        if (data != null && data.renderType.equalsIgnoreCase("tile")) {
            //Try to get tile specific state
            String key = getRenderStateKey(tile);
            //Loop default keys
            for (String de : new String[] { key, "tile", "entity", "item.entity" }) {
                if (de != null) {
                    IRenderState state = data.getState(de);
                    if (state instanceof IModelState && ((IModelState) state).render(false)) {
                        break;
                    }
                }
            }
        }
    } catch (Exception e) {
        Engine.logger().error("TileRenderHandler: Error rendering " + tile, e);
    }
    GL11.glPopMatrix();
    //If BlockBase, iterate listeners
    if (tile.getBlockType() instanceof BlockBase) {
        ListenerIterator it = new ListenerIterator(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, (BlockBase) tile.getBlockType(), "tilerender");
        while (it.hasNext()) {
            ITileEventListener next = it.next();
            if (next instanceof ITileRenderListener) {
                GL11.glPushMatrix();
                try {
                    ((ITileRenderListener) next).renderDynamic(tile, x, y, z, f);
                } catch (Exception e) {
                    Engine.logger().error("TileRenderHandler: Error calling listener[" + next + "] for  Tile[" + tile + "]", e);
                }
                GL11.glPopMatrix();
            }
        }
    }
}
Also used : ListenerIterator(com.builtbroken.mc.prefab.tile.listeners.ListenerIterator) BlockBase(com.builtbroken.mc.framework.block.BlockBase) RenderData(com.builtbroken.mc.client.json.render.RenderData) ITileEventListener(com.builtbroken.mc.api.tile.listeners.ITileEventListener) IRenderState(com.builtbroken.mc.client.json.imp.IRenderState) IModelState(com.builtbroken.mc.client.json.imp.IModelState) ITileRenderListener(com.builtbroken.mc.api.tile.listeners.client.ITileRenderListener)

Aggregations

ITileEventListener (com.builtbroken.mc.api.tile.listeners.ITileEventListener)1 ITileRenderListener (com.builtbroken.mc.api.tile.listeners.client.ITileRenderListener)1 IModelState (com.builtbroken.mc.client.json.imp.IModelState)1 IRenderState (com.builtbroken.mc.client.json.imp.IRenderState)1 RenderData (com.builtbroken.mc.client.json.render.RenderData)1 BlockBase (com.builtbroken.mc.framework.block.BlockBase)1 ListenerIterator (com.builtbroken.mc.prefab.tile.listeners.ListenerIterator)1