use of com.builtbroken.mc.client.json.imp.IModelState 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();
}
}
}
}
use of com.builtbroken.mc.client.json.imp.IModelState in project Engine by VoltzEngine-Project.
the class ModelState method render.
@Override
public boolean render(boolean subRender) {
TextureData textureData = getTexture();
ModelData data = getModel();
if (data != null && data.getModel() != null) {
//Starts rendering by storing previous matrix
GL11.glPushMatrix();
if (!subRender) {
//Scales object by value
if (scale != null) {
GL11.glScaled(scale.x(), scale.y(), scale.z());
} else if (parentState instanceof IModelState && ((IModelState) parentState).getScale() != null) {
GL11.glScaled(((IModelState) parentState).getScale().x(), ((IModelState) parentState).getScale().y(), ((IModelState) parentState).getScale().z());
}
//Rotates object, needs to be handled after scaling
if (rotation != null) {
GL11.glRotated(rotation.pitch(), 1, 0, 0);
GL11.glRotated(rotation.yaw(), 0, 1, 0);
GL11.glRotated(rotation.roll(), 0, 0, 1);
} else if (parentState instanceof IModelState && ((IModelState) parentState).getRotation() != null) {
GL11.glRotated(((IModelState) parentState).getRotation().pitch(), 1, 0, 0);
GL11.glRotated(((IModelState) parentState).getRotation().yaw(), 0, 1, 0);
GL11.glRotated(((IModelState) parentState).getRotation().roll(), 0, 0, 1);
}
//Moves the object
if (offset != null) {
GL11.glTranslated(offset.x(), offset.y(), offset.z());
} else if (parentState instanceof IModelState && ((IModelState) parentState).getOffset() != null) {
GL11.glTranslated(((IModelState) parentState).getOffset().x(), ((IModelState) parentState).getOffset().y(), ((IModelState) parentState).getOffset().z());
}
}
//Render parent
GL11.glPushMatrix();
if (parentState instanceof IModelState) {
if (renderParent) {
((IModelState) parentState).render(true);
} else if (parts == null && parentState instanceof ModelState && ((ModelState) parentState).renderParent) {
if (((ModelState) parentState).parentState instanceof IModelState) {
((IModelState) ((ModelState) parentState).parentState).render(true);
}
}
}
GL11.glPopMatrix();
//Binds texture
if (textureData != null) {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureData.getLocation());
} else {
//Backup texture bind, if no texture
FMLClientHandler.instance().getClient().renderEngine.bindTexture(SharedAssets.GREY_TEXTURE);
}
//Render model
data.render(renderOnlyParts, getPartsToRender());
//Ends render by restoring previous matrix(rotation, position, etc)
GL11.glPopMatrix();
return true;
}
return false;
}
Aggregations