Java Code Examples for net.minecraftforge.client.ForgeHooksClient#setRenderLayer()
The following examples show how to use
net.minecraftforge.client.ForgeHooksClient#setRenderLayer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoverFacade.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) { BlockRenderLayer oldLayer = MinecraftForgeClient.getRenderLayer(); ForgeHooksClient.setRenderLayer(layer); FacadeRenderer.renderBlockCover(renderState, translation, coverHolder.getWorld(), coverHolder.getPos(), attachedSide.getIndex(), facadeState, plateBox); ForgeHooksClient.setRenderLayer(oldLayer); }
Example 2
Source File: WorldSceneRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
/** * Renders scene on given coordinates with given width and height, and RGB background color * Note that this will ignore any transformations applied currently to projection/view matrix, * so specified coordinates are scaled MC gui coordinates. * It will return matrices of projection and view in previous state after rendering */ public void render(int x, int y, int width, int height, int backgroundColor) { Vec2f mousePosition = setupCamera(x, y, width, height, backgroundColor); if (renderCallback != null) { renderCallback.preRenderScene(this); } Minecraft minecraft = Minecraft.getMinecraft(); minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); BlockRendererDispatcher dispatcher = minecraft.getBlockRendererDispatcher(); BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); for (BlockPos pos : renderedBlocks) { if (renderFilter != null && !renderFilter.test(pos)) continue; //do not render if position is skipped IBlockState blockState = world.getBlockState(pos); for(BlockRenderLayer renderLayer : BlockRenderLayer.values()) { if (!blockState.getBlock().canRenderInLayer(blockState, renderLayer)) continue; ForgeHooksClient.setRenderLayer(renderLayer); dispatcher.renderBlock(blockState, pos, world, bufferBuilder); } } tessellator.draw(); ForgeHooksClient.setRenderLayer(oldRenderLayer); if (mousePosition != null) { this.lastHitBlock = handleMouseHit(mousePosition); } else { this.lastHitBlock = null; } if (lastHitBlock != null) { GlStateManager.disableTexture2D(); CCRenderState renderState = CCRenderState.instance(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR, tessellator.getBuffer()); ColourMultiplier multiplier = new ColourMultiplier(0); renderState.setPipeline(new Translation(lastHitBlock), multiplier); BlockFace blockFace = new BlockFace(); renderState.setModel(blockFace); for (EnumFacing renderSide : EnumFacing.VALUES) { float diffuse = LightUtil.diffuseLight(renderSide); int color = (int) (255 * diffuse); multiplier.colour = RenderUtil.packColor(color, color, color, 100); blockFace.loadCuboidFace(Cuboid6.full, renderSide.getIndex()); renderState.render(); } renderState.draw(); GlStateManager.enableTexture2D(); } resetCamera(); }
Example 3
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
private void updateList(BlockRenderLayer layerToUpdate) { if (parent.toRender.getShipRenderer() == null) { return; } BlockPos offsetPos = parent.toRender.getShipRenderer().offsetPos; if (offsetPos == null) { return; } Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(7, DefaultVertexFormats.BLOCK); worldrenderer.setTranslation(-offsetPos.getX(), -offsetPos.getY(), -offsetPos.getZ()); GL11.glPushMatrix(); switch (layerToUpdate) { case CUTOUT: GLAllocation.deleteDisplayLists(glCallListCutout); GL11.glNewList(glCallListCutout, GL11.GL_COMPILE); break; case CUTOUT_MIPPED: GLAllocation.deleteDisplayLists(glCallListCutoutMipped); GL11.glNewList(glCallListCutoutMipped, GL11.GL_COMPILE); break; case SOLID: GLAllocation.deleteDisplayLists(glCallListSolid); GL11.glNewList(glCallListSolid, GL11.GL_COMPILE); break; case TRANSLUCENT: GLAllocation.deleteDisplayLists(glCallListTranslucent); GL11.glNewList(glCallListTranslucent, GL11.GL_COMPILE); break; default: break; } GlStateManager.pushMatrix(); // worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); IBlockState iblockstate; BlockRenderLayer oldLayer = MinecraftForgeClient.getRenderLayer(); ForgeHooksClient.setRenderLayer(layerToUpdate); MutableBlockPos pos = new MutableBlockPos(); for (int x = chunkToRender.x * 16; x < chunkToRender.x * 16 + 16; x++) { for (int z = chunkToRender.z * 16; z < chunkToRender.z * 16 + 16; z++) { for (int y = yMin; y <= yMax; y++) { pos.setPos(x, y, z); iblockstate = chunkToRender.getBlockState(pos); try { if (iblockstate.getBlock() .canRenderInLayer(iblockstate, layerToUpdate)) { Minecraft.getMinecraft().getBlockRendererDispatcher() .renderBlock(iblockstate, pos, chunkToRender.world, worldrenderer); } } catch (NullPointerException e) { System.out.println( "Something was null! LValkyrienSkiesBase/render/PhysRenderChunk#updateList"); } } } } tessellator.draw(); // worldrenderer.finishDrawing(); ForgeHooksClient.setRenderLayer(oldLayer); GlStateManager.popMatrix(); GL11.glEndList(); GL11.glPopMatrix(); worldrenderer.setTranslation(0, 0, 0); switch (layerToUpdate) { case CUTOUT: needsCutoutUpdate = false; break; case CUTOUT_MIPPED: needsCutoutMippedUpdate = false; break; case SOLID: needsSolidUpdate = false; break; case TRANSLUCENT: needsTranslucentUpdate = false; break; default: break; } }