use of blusunrize.immersiveengineering.client.render.TileRenderAutoWorkbench.BlueprintLines in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderItemFrame.
/*
@SubscribeEvent()
public void lastWorldRender(RenderWorldLastEvent event)
{
connectionsRendered = false;
ParticleRenderer.dispatch();
}
static boolean connectionsRendered = false;
public static void renderAllIEConnections(float partial)
{
if(connectionsRendered)
return;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
// GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
RenderHelper.enableStandardItemLighting();
Tessellator.instance.startDrawing(GL11.GL_QUADS);
EntityLivingBase viewer = ClientUtils.mc().renderViewEntity;
double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial;//(double)event.partialTicks;
double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial;//(double)event.partialTicks;
double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial;//(double)event.partialTicks;
for(Object o : ClientUtils.mc().renderGlobal.tileEntities)
if(o instanceof IImmersiveConnectable)
{
TileEntity tile = (TileEntity)o;
// int lb = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
// int lb_j = lb % 65536;
// int lb_k = lb / 65536;
// OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lb_j / 1.0F, (float)lb_k / 1.0F);
Tessellator.instance.setTranslation(tile.xCoord-dx, tile.yCoord-dy, tile.zCoord-dz);
// GL11.glTranslated((tile.xCoord+.5-dx), (tile.yCoord+.5-dy), (tile.zCoord+.5-dz));
ClientUtils.renderAttachedConnections((TileEntity)tile);
// GL11.glTranslated(-(tile.xCoord+.5-dx), -(tile.yCoord+.5-dy), -(tile.zCoord+.5-dz));
}
Iterator<ImmersiveNetHandler.Connection> it = skyhookGrabableConnections.iterator();
World world = viewer.worldObj;
while(it.hasNext())
{
ImmersiveNetHandler.Connection con = it.next();
Tessellator.instance.setTranslation(con.start.posX-dx, con.start.posY-dy, con.start.posZ-dz);
double r = con.cableType.getRenderDiameter()/2;
ClientUtils.drawConnection(con, Utils.toIIC(con.start, world), Utils.toIIC(con.end, world), 0x00ff99,128,r*1.75, con.cableType.getIcon(con));
}
Tessellator.instance.setTranslation(0,0,0);
Tessellator.instance.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
connectionsRendered = true;
}
*/
@SubscribeEvent
public void onRenderItemFrame(RenderItemInFrameEvent event) {
if (event.getItem() != null && event.getItem().getItem() instanceof ItemEngineersBlueprint) {
double playerDistanceSq = ClientUtils.mc().thePlayer.getDistanceSq(event.getEntityItemFrame().getPosition());
if (playerDistanceSq < 1000) {
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(event.getItem(), "blueprint"));
if (recipes != null && recipes.length > 0) {
int i = event.getEntityItemFrame().getRotation();
BlueprintCraftingRecipe recipe = recipes[i % recipes.length];
BlueprintLines blueprint = recipe == null ? null : TileRenderAutoWorkbench.getBlueprintDrawable(recipe, event.getEntityItemFrame().getEntityWorld());
if (blueprint != null) {
GlStateManager.rotate(-i * 45.0F, 0.0F, 0.0F, 1.0F);
ClientUtils.bindTexture("immersiveengineering:textures/models/blueprintFrame.png");
GlStateManager.translate(-.5, .5, -.001);
ClientUtils.drawTexturedRect(.125f, -.875f, .75f, .75f, 1d, 0d, 1d, 0d);
//Width depends on distance
float lineWidth = playerDistanceSq < 3 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
GlStateManager.translate(.75, -.25, -.002);
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
float scale = .0375f / (blueprint.getTextureScale() / 16f);
GlStateManager.scale(-scale, -scale, scale);
GlStateManager.color(1, 1, 1, 1);
blueprint.draw(lineWidth);
GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableCull();
event.setCanceled(true);
}
}
}
}
}
Aggregations