Java Code Examples for codechicken.lib.render.CCRenderState#reset()
The following examples show how to use
codechicken.lib.render.CCRenderState#reset() .
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: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos); ArrayList<IndexedCuboid6> boundingBox = new ArrayList<>(); if (metaTileEntity != null) { metaTileEntity.addCollisionBoundingBox(boundingBox); metaTileEntity.addCoverCollisionBoundingBox(boundingBox); } CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); for (Cuboid6 cuboid : boundingBox) { BlockRenderer.renderCuboid(renderState, cuboid, 0); } }
Example 3
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 4
Source File: FluidPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); BlockFluidPipe blockFluidPipe = (BlockFluidPipe) state.getBlock(); IPipeTile<FluidPipeType, FluidPipeProperties> tileEntityPipe = blockFluidPipe.getPipeTileEntity(world, pos); if (tileEntityPipe == null) { return; } FluidPipeType fluidPipeType = tileEntityPipe.getPipeType(); if (fluidPipeType == null) { return; } float thickness = fluidPipeType.getThickness(); int connectedSidesMask = blockFluidPipe.getActualConnections(tileEntityPipe, world); Cuboid6 baseBox = BlockFluidPipe.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockFluidPipe.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example 5
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 6
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(world, pos); IVertexOperation[] pipeline = {new Translation(pos)}; BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock(); TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos); if (tileEntity == null) { return false; } int paintingColor = tileEntity.getInsulationColor(); int connectedSidesMask = block.getActualConnections(tileEntity, world); BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (renderLayer == BlockRenderLayer.SOLID) { renderPipe(renderState, pipeline, paintingColor, connectedSidesMask); } ICoverable coverable = tileEntity.getCoverableImplementation(); coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer); return true; }
Example 7
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 8
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(world, pos); IVertexOperation[] pipeline = {new Translation(pos)}; BlockCable blockCable = (BlockCable) state.getBlock(); TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos); if (tileEntityCable == null) return false; int paintingColor = tileEntityCable.getInsulationColor(); int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world); Insulation insulation = tileEntityCable.getPipeType(); Material material = tileEntityCable.getPipeMaterial(); if (insulation != null && material != null) { BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (renderLayer == BlockRenderLayer.CUTOUT) { renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask); } ICoverable coverable = tileEntityCable.getCoverableImplementation(); coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer); } return true; }
Example 9
Source File: CableRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite)); BlockCable blockCable = (BlockCable) state.getBlock(); IPipeTile<Insulation, WireProperties> tileEntityCable = blockCable.getPipeTileEntity(world, pos); if (tileEntityCable == null) { return; } Insulation insulation = tileEntityCable.getPipeType(); if (insulation == null) { return; } float thickness = insulation.getThickness(); int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world); Cuboid6 baseBox = BlockCable.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockCable.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example 10
Source File: TileEntityRendererBase.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); if (te.getWorld() != null) { renderState.setBrightness(te.getWorld(), te.getPos()); } Matrix4 translation = new Matrix4().translate(x, y, z); draw(te, renderState, translation, partialTicks); }
Example 11
Source File: EnderTankItemRender.java From EnderStorage with MIT License | 5 votes |
@Override public void renderItem(ItemStack stack, TransformType transformType, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; Frequency freq = Frequency.readFromStack(stack); FluidStack fluid = TankSynchroniser.getClientLiquid(freq); Matrix4 mat = new Matrix4(mStack); RenderTileEnderTank.renderTank(ccrs, mat, getter, 2, (float) (MathHelper.torad * 90F), 0, freq, 0); mat.translate(-0.5, 0, -0.5); RenderTileEnderTank.renderFluid(ccrs, mat, getter, fluid); }
Example 12
Source File: RenderTileEnderChest.java From EnderStorage with MIT License | 5 votes |
public static void renderChest(CCRenderState ccrs, MatrixStack mStack, IRenderTypeBuffer getter, int rotation, double yToCamera, Frequency freq, float lidAngle, int pearlOffset) { Matrix4 mat = new Matrix4(mStack); if (lidAngle != 0) {//Micro optimization, lid closed, dont render starfield. renderEndPortal.render(mat, getter, yToCamera); } ccrs.reset(); mStack.push(); mStack.translate(0, 1.0, 1.0); mStack.scale(1.0F, -1.0F, -1.0F); mStack.translate(0.5, 0.5, 0.5); mStack.rotate(new Quaternion(0, rotation * 90, 0, true)); mStack.translate(-0.5, -0.5, -0.5); model.chestLid.rotateAngleX = lidAngle; model.render(mStack, getter.getBuffer(chestType), ccrs.brightness, ccrs.overlay, freq.hasOwner()); mStack.pop(); //Buttons ccrs.bind(buttonType, getter); EnumColour[] colours = freq.toArray(); for (int i = 0; i < 3; i++) { CCModel button = ButtonModelLibrary.button.copy(); button.apply(BlockEnderChest.buttonT[i]); button.apply(new Translation(0.5, 0, 0.5)); button.apply(new Rotation(lidAngle, 1, 0, 0).at(new Vector3(0, 9D / 16D, 1 / 16D))); button.apply(new Rotation((-90 * (rotation)) * MathHelper.torad, Vector3.Y_POS).at(new Vector3(0.5, 0, 0.5))); button.render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4))); } mat.translate(0.5, 0, 0.5); //Pearl if (lidAngle != 0) {//Micro optimization, lid closed, dont render pearl. double time = ClientUtils.getRenderTime() + pearlOffset; Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.2 + lidAngle * -0.5 + RenderUtils.getPearlBob(time), 0), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04); ccrs.brightness = 15728880; ccrs.bind(pearlType, getter); CCModelLibrary.icosahedron4.render(ccrs, pearlMat); } ccrs.reset(); }
Example 13
Source File: EnderChestRenderer.java From EnderStorage with MIT License | 5 votes |
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); CCRenderState.useNormals = true; TileEnderChest chest = (TileEnderChest) tile; renderChest(chest.rotation, chest.freq, !chest.owner.equals("global"), d, d1, d2, EnderStorageClientProxy.getTimeOffset(chest.xCoord, chest.yCoord, chest.zCoord), (float) chest.getRadianLidAngle(f)); }
Example 14
Source File: ItemEnderStorageRenderer.java From EnderStorage with MIT License | 5 votes |
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { Vector3 d = new Vector3(); if(type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.EQUIPPED) d.add(-0.5, -0.5, -0.5); int freq = item.getItemDamage()&0xFFF; String owner = item.hasTagCompound() ? item.getTagCompound().getString("owner") : "global"; int rotation = 0; if(type == ItemRenderType.ENTITY) rotation = 3; switch(item.getItemDamage()>>12) { case 0: EnderChestRenderer.renderChest(rotation, freq, !owner.equals("global"), d.x, d.y, d.z, 0, 0); break; case 1: CCRenderState.reset(); CCRenderState.pullLightmap(); CCRenderState.useNormals = true; EnderTankRenderer.renderTank(rotation, 0, freq, !owner.equals("global"), d.x, d.y, d.z, 0); EnderTankRenderer.renderLiquid(TankSynchroniser.getClientLiquid(freq, owner), d.x, d.y, d.z); break; } }
Example 15
Source File: MetaTileEntityTESR.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void renderTileEntityFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { MetaTileEntity metaTileEntity = te.getMetaTileEntity(); if (metaTileEntity instanceof IFastRenderMetaTileEntity) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(te.getWorld(), te.getPos()); Matrix4 translation = new Matrix4().translate(x, y, z); ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, translation, partialTicks); } }
Example 16
Source File: EnderTankRenderer.java From EnderStorage with MIT License | 5 votes |
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { TileEnderTank tank = (TileEnderTank)tile; CCRenderState.reset(); CCRenderState.pullLightmap(); CCRenderState.useNormals = true; renderTank(tank.rotation, (float) MathHelper.interpolate(tank.pressure_state.b_rotate, tank.pressure_state.a_rotate, f)*0.01745F, tank.freq, !tank.owner.equals("global"), x, y, z, EnderStorageClientProxy.getTimeOffset(tile.xCoord, tile.yCoord, tile.zCoord)); renderLiquid(tank.liquid_state.c_liquid, x, y, z); }
Example 17
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 18
Source File: FluidPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(world, pos); BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock()); TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos); if (tileEntityPipe == null) { return false; } FluidPipeType fluidPipeType = tileEntityPipe.getPipeType(); Material pipeMaterial = tileEntityPipe.getPipeMaterial(); int paintingColor = tileEntityPipe.getInsulationColor(); if (fluidPipeType != null && pipeMaterial != null) { BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (renderLayer == BlockRenderLayer.CUTOUT) { int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world); IVertexOperation[] pipeline = new IVertexOperation[] {new Translation(pos)}; renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask); } ICoverable coverable = tileEntityPipe.getCoverableImplementation(); coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer); } return true; }
Example 19
Source File: MetaTileEntityRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos); if (metaTileEntity == null) { return false; } CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (metaTileEntity.canRenderInLayer(renderLayer)) { renderState.lightMatrix.locate(world, pos); IVertexOperation[] pipeline = new IVertexOperation[]{renderState.lightMatrix}; metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline); } Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()); metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer); if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) { TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks(); Random posRand = new Random(MathHelper.getPositionRandom(pos)); int destroyStage = posRand.nextInt(10); TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage); for (EnumFacing face : EnumFacing.VALUES) { Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite); } } return true; }
Example 20
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); }