Java Code Examples for codechicken.lib.render.CCRenderState#bind()
The following examples show how to use
codechicken.lib.render.CCRenderState#bind() .
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 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 2
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 3
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 4
Source File: InvPipeRenderer.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)); BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock(); TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos); if (tileEntity == null) { return; } InventoryPipeType pipeType = tileEntity.getPipeType(); if (pipeType == null) { return; } float thickness = pipeType.getThickness(); int connectedSidesMask = block.getActualConnections(tileEntity, world); Cuboid6 baseBox = BlockPipe.getSideBox(null, thickness); BlockRenderer.renderCuboid(renderState, baseBox, 0); for (EnumFacing renderSide : EnumFacing.VALUES) { if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) { Cuboid6 sideBox = BlockPipe.getSideBox(renderSide, thickness); BlockRenderer.renderCuboid(renderState, sideBox, 0); } } }
Example 5
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 6
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 7
Source File: StoneRenderer.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) { //otherwise, we are in solid rendering layer and render primary stone CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); Matrix4 translation = new Matrix4(); translation.translate(pos.getX(), pos.getY(), pos.getZ()); TextureAtlasSprite stoneSprite = TextureUtils.getBlockTexture("stone"); Material material = ((BlockSurfaceRock) state.getBlock()).getStoneMaterial(world, pos, state); int renderingColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB); IVertexOperation[] operations = new IVertexOperation[] { new IconTransformation(stoneSprite), new ColourMultiplier(renderingColor), new TransformationList(translation)}; if (world != null) { renderState.setBrightness(world, pos); } renderState.setPipeline(operations); CCModel actualModel = getActualModel(world, pos); renderState.setModel(actualModel); renderState.render(); return true; }
Example 8
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 9
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 10
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 11
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 12
Source File: StoneRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 5 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)); Cuboid6 baseBox = new Cuboid6(state.getBoundingBox(world, pos)); BlockRenderer.renderCuboid(renderState, baseBox, 0); }
Example 13
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(); }