Java Code Examples for codechicken.lib.render.CCRenderState#draw()
The following examples show how to use
codechicken.lib.render.CCRenderState#draw() .
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: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void renderItem(ItemStack rawStack, TransformType transformType) { ItemStack stack = ModCompatibility.getRealItemStack(rawStack); if (!(stack.getItem() instanceof MachineItemBlock)) { return; } MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack); if (metaTileEntity == null) { return; } GlStateManager.enableBlend(); CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); metaTileEntity.setRenderContextStack(stack); metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]); if(metaTileEntity instanceof IFastRenderMetaTileEntity) { ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f); } metaTileEntity.setRenderContextStack(null); renderState.draw(); if(metaTileEntity instanceof IRenderMetaTileEntity) { ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f); } GlStateManager.disableBlend(); }
Example 2
Source File: FluidPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void renderItem(ItemStack rawItemStack, TransformType transformType) { ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack); if (!(stack.getItem() instanceof ItemBlockFluidPipe)) { return; } CCRenderState renderState = CCRenderState.instance(); GlStateManager.enableBlend(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); BlockFluidPipe blockFluidPipe = (BlockFluidPipe) ((ItemBlockFluidPipe) stack.getItem()).getBlock(); FluidPipeType pipeType = blockFluidPipe.getItemPipeType(stack); Material material = blockFluidPipe.getItemMaterial(stack); if (pipeType != null && material != null) { renderPipeBlock(material, pipeType, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 0); } renderState.draw(); GlStateManager.disableBlend(); }
Example 3
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void renderItem(ItemStack rawItemStack, TransformType transformType) { ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack); if (!(stack.getItem() instanceof ItemBlockCable)) { return; } GlStateManager.enableBlend(); CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); BlockCable blockCable = (BlockCable) ((ItemBlockCable) stack.getItem()).getBlock(); Insulation insulation = blockCable.getItemPipeType(stack); Material material = blockCable.getItemMaterial(stack); if (insulation != null && material != null) { renderCableBlock(material, insulation, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 1 << EnumFacing.SOUTH.getIndex() | 1 << EnumFacing.NORTH.getIndex() | 1 << (6 + EnumFacing.SOUTH.getIndex()) | 1 << (6 + EnumFacing.NORTH.getIndex())); } renderState.draw(); GlStateManager.disableBlend(); }
Example 4
Source File: FacadeItemModel.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void renderItem(ItemStack rawStack, TransformType transformType) { ItemStack itemStack = ModCompatibility.getRealItemStack(rawStack); if (!(itemStack.getItem() instanceof MetaItem<?>)) { return; } ItemStack facadeStack = FacadeItem.getFacadeStack(itemStack); CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); try { FacadeRenderer.renderItemCover(renderState, EnumFacing.NORTH.getIndex(), facadeStack, ICoverable.getCoverPlateBox(EnumFacing.NORTH, 2.0 / 16.0)); } catch (Throwable ignored) { } renderState.draw(); }
Example 5
Source File: OptionScrollPane.java From NotEnoughItems with MIT License | 6 votes |
public static void drawOverlayGrad(int x1, int x2, int y1, int y2, float zLevel) { GlStateManager.disableTexture2D(); GlStateManager.disableCull(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.shadeModel(GL11.GL_SMOOTH); CCRenderState ccrs = CCRenderState.instance(); BufferBuilder buffer = ccrs.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); buffer.pos(x2, y1, zLevel).color(0, 0, 0, 255).endVertex(); buffer.pos(x1, y1, zLevel).color(0, 0, 0, 255).endVertex(); buffer.pos(x1, y2, zLevel).color(0, 0, 0, 0).endVertex(); buffer.pos(x2, y2, zLevel).color(0, 0, 0, 0).endVertex(); ccrs.draw(); GlStateManager.disableBlend(); GlStateManager.enableCull(); GlStateManager.enableTexture2D(); }
Example 6
Source File: OptionScrollPane.java From NotEnoughItems with MIT License | 6 votes |
public static void drawOverlayGrad(int x1, int x2, int y1, int y2, float zLevel) { GlStateManager.disableTexture2D(); GlStateManager.disableCull(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.shadeModel(GL11.GL_SMOOTH); WorldRenderer r = CCRenderState.startDrawing(); r.setColorRGBA_I(0, 255); r.addVertex(x2, y1, zLevel); r.addVertex(x1, y1, zLevel); r.setColorRGBA_I(0, 0); r.addVertex(x1, y2, zLevel); r.addVertex(x2, y2, zLevel); CCRenderState.draw(); GlStateManager.disableBlend(); GlStateManager.enableCull(); GlStateManager.enableTexture2D(); }
Example 7
Source File: ItemTranslocatorRenderer.java From Translocators with MIT License | 6 votes |
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { Vector3 d = new Vector3(); if (type != ItemRenderType.EQUIPPED && type != ItemRenderType.EQUIPPED_FIRST_PERSON) d.add(-0.5, -0.5, -0.5); else d.add(0, -0.2, -0.2); d.add(0, 0, 0.5); GL11.glPushMatrix(); GL11.glScaled(1.5, 1.5, 1.5); CCRenderState.changeTexture("translocator:textures/tex.png"); CCRenderState.pullLightmap(); CCRenderState.setColour(-1); CCRenderState.useNormals = true; CCRenderState.startDrawing(4); TileTranslocatorRenderer.renderAttachment(2, item.getItemDamage(), 1, 0, d.x, d.y, d.z); CCRenderState.draw(); GL11.glPopMatrix(); }
Example 8
Source File: RenderTracker.java From WirelessRedstone with MIT License | 6 votes |
public void renderTracker(int freq) { GL11.glDisable(GL11.GL_LIGHTING); TextureUtils.bindAtlas(0); CCRenderState.reset(); CCRenderState.startDrawing(7); CCRenderState.setColour(0xFFFFFFFF); model.render(new IconTransformation(Blocks.obsidian.getIcon(0, 0))); CCRenderState.draw(); Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(0, 0.44+RedstoneEther.getSineWave(ClientUtils.getRenderTime(), 7)*0.02, 0), new Rotation(RedstoneEther.getRotation(ClientUtils.getRenderTime(), freq), new Vector3(0, 1, 0)), 0.04); CCRenderState.changeTexture("wrcbe_core:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCRenderState.setColour(freq == 0 ? 0xC0C0C0FF : 0xFFFFFFFF); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example 9
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderItem(ItemStack rawItemStack, TransformType transformType) { GlStateManager.enableBlend(); CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM); renderPipe(renderState, new IVertexOperation[0], IPipeTile.DEFAULT_INSULATION_COLOR, 12); renderState.draw(); GlStateManager.disableBlend(); }
Example 10
Source File: OptionScrollPane.java From NotEnoughItems with MIT License | 5 votes |
public static void drawOverlayTex(int x, int y, int w, int h, float zLevel) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().renderEngine.bindTexture(Gui.OPTIONS_BACKGROUND); CCRenderState ccrs = CCRenderState.instance(); BufferBuilder buffer = ccrs.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buffer.pos(x, y, zLevel).tex(0, 0).endVertex(); buffer.pos(x, y + h, zLevel).tex(0, h / 16D).endVertex(); buffer.pos(x + w, y + h, zLevel).tex(w / 16D, h / 16D).endVertex(); buffer.pos(x + w, y, zLevel).tex(w / 16D, 0).endVertex(); ccrs.draw(); }
Example 11
Source File: EnderChestRenderer.java From EnderStorage with MIT License | 5 votes |
public static void renderChest(int rotation, int freq, boolean owned, double x, double y, double z, int offset, float lidAngle) { TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance; renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e); GL11.glColor4f(1, 1, 1, 1); CCRenderState.changeTexture("enderstorage:textures/enderchest.png"); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1, 1, 1, 1); GL11.glTranslated(x, y + 1.0, z + 1.0F); GL11.glScalef(1.0F, -1F, -1F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef(rotation * 90, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); model.chestLid.rotateAngleX = lidAngle; model.render(owned); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); renderButtons(freq, rotation, lidAngle); GL11.glPopMatrix(); double time = ClientUtils.getRenderTime() + offset; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(x + 0.5, y + 0.2 + lidAngle * -0.5 + EnderStorageClientProxy.getPearlBob(time), z + 0.5), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("enderstorage:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example 12
Source File: OptionScrollPane.java From NotEnoughItems with MIT License | 5 votes |
public static void drawOverlayTex(int x, int y, int w, int h, float zLevel) { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().renderEngine.bindTexture(Gui.optionsBackground); WorldRenderer r = CCRenderState.startDrawing(); r.addVertexWithUV(x, y, zLevel, 0, 0); r.addVertexWithUV(x, y + h, zLevel, 0, h / 16D); r.addVertexWithUV(x + w, y + h, zLevel, w / 16D, h / 16D); r.addVertexWithUV(x + w, y, zLevel, w / 16D, 0); CCRenderState.draw(); }
Example 13
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 14
Source File: EnderTankRenderer.java From EnderStorage with MIT License | 4 votes |
public static void renderTank(int rotation, float valve, int freq, boolean owned, double x, double y, double z, int offset) { TileEntityRendererDispatcher info = TileEntityRendererDispatcher.instance; renderEndPortal.render(x, y, z, 0, info.field_147560_j, info.field_147560_j, info.field_147561_k, info.field_147553_e); GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); GL11.glTranslated(x+0.5, y, z+0.5); GL11.glRotatef(-90*(rotation+2), 0, 1, 0); CCRenderState.changeTexture("enderstorage:textures/endertank.png"); CCRenderState.startDrawing(4); tankModel.render(); CCRenderState.draw(); CCRenderState.changeTexture("enderstorage:textures/buttons.png"); CCRenderState.startDrawing(7); for(int i = 0; i < 3; i++) { int colour = EnderStorageManager.getColourFromFreq(freq, i); buttons[i].render(new UVTranslation(0.25 * (colour % 4), 0.25 * (colour / 4))); } CCRenderState.draw(); new Rotation(valve, new Vector3(0, 0, 1)).at(new Vector3(0, 0.4165, 0)).glApply(); CCRenderState.changeTexture("enderstorage:textures/endertank.png"); CCRenderState.startDrawing(4); valveModel.render(new UVTranslation(0, owned ? 13/64D : 0)); CCRenderState.draw(); GL11.glPopMatrix(); double time = ClientUtils.getRenderTime()+offset; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(x+0.5, y+0.45+EnderStorageClientProxy.getPearlBob(time)*2, z+0.5), new Rotation(time/3, new Vector3(0, 1, 0)), 0.04); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("enderstorage:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example 15
Source File: TileChunkLoaderRenderer.java From ChickenChunks with MIT License | 4 votes |
@Override public void renderTileEntityAt(TileEntity tile, double d, double d1, double d2, float f) { CCRenderState.reset(); CCRenderState.setBrightness(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); double rot = ClientUtils.getRenderTime()*2; double height; double size; double updown = (ClientUtils.getRenderTime()%50) / 25F; updown = (float) Math.sin(updown*3.141593); updown *= 0.2; TileChunkLoaderBase chunkLoader = (TileChunkLoaderBase)tile; if(chunkLoader instanceof TileChunkLoader) { TileChunkLoader ctile = (TileChunkLoader)chunkLoader; rot /= Math.pow(ctile.radius, 0.2); height = 0.9; size = 0.08; } else if(chunkLoader instanceof TileSpotLoader) { height = 0.5; size = 0.05; } else return; RenderInfo renderInfo = chunkLoader.renderInfo; double active = (renderInfo.activationCounter)/20D; if(chunkLoader.active && renderInfo.activationCounter < 20) active += f/20D; else if(!chunkLoader.active && renderInfo.activationCounter > 0) active -= f/20D; if(renderInfo.showLasers) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); drawRays(d, d1, d2, rot, updown, tile.xCoord, tile.yCoord, tile.zCoord, chunkLoader.getChunks()); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_FOG); } rot = ClientUtils.getRenderTime()*active / 3F; Matrix4 pearlMat = CCModelLibrary.getRenderMatrix( new Vector3(d+0.5, d1+height+(updown + 0.3)*active, d2+0.5), new Rotation(rot, new Vector3(0, 1, 0)), size); GL11.glDisable(GL11.GL_LIGHTING); CCRenderState.changeTexture("chickenchunks:textures/hedronmap.png"); CCRenderState.startDrawing(4); CCModelLibrary.icosahedron4.render(pearlMat); CCRenderState.draw(); GL11.glEnable(GL11.GL_LIGHTING); }
Example 16
Source File: TileTranslocatorRenderer.java From Translocators with MIT License | 4 votes |
private void drawLiquidSpiral(int src, int dst, FluidStack stack, double start, double end, double time, double theta0, double x, double y, double z) { IIcon tex = RenderUtils.prepareFluidRender(stack, 255); CCRenderState.startDrawing(7); Tessellator t = Tessellator.instance; t.setTranslation(x, y, z); Vector3[] last = new Vector3[]{new Vector3(), new Vector3(), new Vector3(), new Vector3()}; Vector3[] next = new Vector3[]{new Vector3(), new Vector3(), new Vector3(), new Vector3()}; double tess = 0.05; Vector3 a = getPerp(src, dst); boolean rev = sum(a.copy().crossProduct(getPathNormal(src, dst, 0))) != sum(sideVec[src]); for(double di = end; di <= start; di+=tess) { Vector3 b = getPathNormal(src, dst, di); Vector3 c = getPath(src, dst, di); if(rev) b.negate(); double r = (2*di-time/10+theta0+dst/6)*2*Math.PI; double sz = 0.1; Vector3 p = c.add(a.copy().multiply(MathHelper.sin(r)*sz)).add(b.copy().multiply(MathHelper.cos(r)*sz)); double s1 = 0.02; double s2 =-0.02; next[0].set(p).add(a.x*s1+b.x*s1, a.y*s1+b.y*s1, a.z*s1+b.z*s1); next[1].set(p).add(a.x*s2+b.x*s1, a.y*s2+b.y*s1, a.z*s2+b.z*s1); next[2].set(p).add(a.x*s2+b.x*s2, a.y*s2+b.y*s2, a.z*s2+b.z*s2); next[3].set(p).add(a.x*s1+b.x*s2, a.y*s1+b.y*s2, a.z*s1+b.z*s2); if(di > end) { double u1 = tex.getInterpolatedU(Math.abs(di)*16); double u2 = tex.getInterpolatedU(Math.abs(di-tess)*16); for(int i = 0; i < 4; i++) { int j = (i+1)%4; Vector3 axis = next[j].copy().subtract(next[i]); double v1 = tex.getInterpolatedV(Math.abs(next[i].scalarProject(axis))*16); double v2 = tex.getInterpolatedV(Math.abs(next[j].scalarProject(axis))*16); t.addVertexWithUV(next[i].x, next[i].y, next[i].z, u1, v1); t.addVertexWithUV(next[j].x, next[j].y, next[j].z, u1, v2); t.addVertexWithUV(last[j].x, last[j].y, last[j].z, u2, v2); t.addVertexWithUV(last[i].x, last[i].y, last[i].z, u2, v1); } } Vector3[] tmp = last; last = next; next = tmp; } CCRenderState.draw(); t.setTranslation(0, 0, 0); RenderUtils.postFluidRender(); }