codechicken.lib.vec.Matrix4 Java Examples

The following examples show how to use codechicken.lib.vec.Matrix4. 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: StoneRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #2
Source File: MetaTileEntityPump.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    ColourMultiplier multiplier = new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering()));
    IVertexOperation[] coloredPipeline = ArrayUtils.add(pipeline, multiplier);
    for (EnumFacing renderSide : EnumFacing.HORIZONTALS) {
        if (renderSide == getFrontFacing()) {
            Textures.PIPE_OUT_OVERLAY.renderSided(renderSide, renderState, translation, pipeline);
        } else {
            Textures.ADV_PUMP_OVERLAY.renderSided(renderSide, renderState, translation, coloredPipeline);
        }
    }
    Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline);
    Textures.PIPE_IN_OVERLAY.renderSided(EnumFacing.DOWN, renderState, translation, pipeline);
}
 
Example #3
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: RenderCustomEndPortal.java    From EnderStorage with MIT License 6 votes vote down vote up
public void render(Matrix4 mat, IRenderTypeBuffer getter, double yToCamera) {
    Vec3d projectedView = TileEntityRendererDispatcher.instance.renderInfo.getProjectedView();
    mat = mat.copy();//Defensive copy, prevent external modifications.
    randy.setSeed(31100L);
    for (int i = 0; i < 16; i++) {
        RenderType.State state = RENDER_STATES.get(i);
        EndPortalRenderType renderType = new EndPortalRenderType(i, yToCamera, projectedView, mat, state);
        IVertexBuilder builder = getter.getBuffer(renderType);
        float r = (randy.nextFloat() * 0.5F + 0.1F) * renderType.f7;
        float g = (randy.nextFloat() * 0.5F + 0.4F) * renderType.f7;
        float b = (randy.nextFloat() * 0.5F + 0.5F) * renderType.f7;
        if (i == 0) {
            r = g = b = 1.0F * renderType.f7;
        }
        builder.pos(surfaceX1, surfaceY, surfaceZ1).color(r, g, b, 1.0F).endVertex();
        builder.pos(surfaceX1, surfaceY, surfaceZ2).color(r, g, b, 1.0F).endVertex();
        builder.pos(surfaceX2, surfaceY, surfaceZ2).color(r, g, b, 1.0F).endVertex();
        builder.pos(surfaceX2, surfaceY, surfaceZ1).color(r, g, b, 1.0F).endVertex();
    }
}
 
Example #5
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: RenderTracker.java    From WirelessRedstone with MIT License 6 votes vote down vote up
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 #7
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #8
Source File: CTCubeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, int connectionMask) {
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if (hasFaceBit(connectionMask, renderSide)) {
            continue; //do not render faces occluded by connections
        }
        int resultTextureMask = 0b1111;
        if (renderSide.getAxis().isHorizontal()) {
            if (hasFaceBit(connectionMask, EnumFacing.UP)) resultTextureMask &= ~TextureDirection.TOP;
            if (hasFaceBit(connectionMask, EnumFacing.DOWN)) resultTextureMask &= ~TextureDirection.BOTTOM;
            EnumFacing leftFacing = renderSide.rotateY();
            EnumFacing rightFacing = renderSide.rotateYCCW();
            if (hasFaceBit(connectionMask, leftFacing)) resultTextureMask &= ~TextureDirection.LEFT;
            if (hasFaceBit(connectionMask, rightFacing)) resultTextureMask &= ~TextureDirection.RIGHT;
        } else {
            if (hasFaceBit(connectionMask, EnumFacing.NORTH)) resultTextureMask &= ~TextureDirection.TOP;
            if (hasFaceBit(connectionMask, EnumFacing.SOUTH)) resultTextureMask &= ~TextureDirection.BOTTOM;
            if (hasFaceBit(connectionMask, EnumFacing.WEST)) resultTextureMask &= ~TextureDirection.LEFT;
            if (hasFaceBit(connectionMask, EnumFacing.EAST)) resultTextureMask &= ~TextureDirection.RIGHT;
        }
        TextureAtlasSprite sideSprite = ctSprites[resultTextureMask];
        Textures.renderFace(renderState, translation, pipeline, renderSide, Cuboid6.full, sideSprite);
        Matrix4 backTranslation = translation.copy();
        backTranslation.translate(renderSide.getFrontOffsetX(), renderSide.getFrontOffsetY() * 0.999, renderSide.getFrontOffsetZ());
        int backFaceTextureMask;
        if (renderSide.getAxis().isHorizontal()) {
            backFaceTextureMask = resultTextureMask & ~(TextureDirection.RIGHT | TextureDirection.LEFT);
            if ((resultTextureMask & TextureDirection.RIGHT) > 0)
                backFaceTextureMask |= TextureDirection.LEFT;
            if ((resultTextureMask & TextureDirection.LEFT) > 0)
                backFaceTextureMask |= TextureDirection.RIGHT;
        } else {
            backFaceTextureMask = resultTextureMask;
        }
        TextureAtlasSprite backSideSprite = ctSprites[backFaceTextureMask];
        Textures.renderFace(renderState, backTranslation, pipeline, renderSide.getOpposite(), Cuboid6.full, backSideSprite);
    }
}
 
Example #9
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Renders this meta tile entity
 * Note that you shouldn't refer to world-related information in this method, because it
 * will be called on ItemStacks too
 *
 * @param renderState render state (either chunk batched or item)
 * @param pipeline    default set of pipeline transformations
 */
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    TextureAtlasSprite atlasSprite = TextureUtils.getMissingSprite();
    IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    for (EnumFacing face : EnumFacing.VALUES) {
        Textures.renderFace(renderState, translation, renderPipeline, face, Cuboid6.full, atlasSprite);
    }
}
 
Example #11
Source File: SteamMetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    IVertexOperation[] colouredPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    getBaseRenderer().render(renderState, translation, colouredPipeline);
    renderer.render(renderState, translation, pipeline, getFrontFacing(), workableHandler.isActive());
    Textures.PIPE_OUT_OVERLAY.renderSided(workableHandler.getVentingSide(), renderState, translation, pipeline);
}
 
Example #12
Source File: CoverBehavior.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderCoverPlate(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) {
    TextureAtlasSprite casingSide = getPlateSprite();
    for (EnumFacing coverPlateSide : EnumFacing.VALUES) {
        boolean isAttachedSide = attachedSide.getAxis() == coverPlateSide.getAxis();
        if (isAttachedSide) {
            Textures.renderFace(renderState, translation, pipeline, coverPlateSide, plateBox, casingSide);
        } else if (coverHolder.getCoverAtSide(coverPlateSide) == null) {
            Textures.renderFace(renderState, translation, pipeline, coverPlateSide, plateBox, casingSide);
        }
    }
}
 
Example #13
Source File: SimpleMachineMetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    if (outputFacing != null) {
        Textures.PIPE_OUT_OVERLAY.renderSided(outputFacing, renderState, translation, pipeline);
        if (autoOutputItems) {
            Textures.ITEM_OUTPUT_OVERLAY.renderSided(outputFacing, renderState, translation, pipeline);
        }
        if (autoOutputFluids) {
            Textures.FLUID_OUTPUT_OVERLAY.renderSided(outputFacing, renderState, translation, pipeline);
        }
    }
}
 
Example #14
Source File: MetaTileEntityFisher.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline);
    Textures.PIPE_OUT_OVERLAY.renderSided(getFrontFacing(), renderState, translation, pipeline);
    Textures.PIPE_IN_OVERLAY.renderSided(EnumFacing.DOWN, renderState, translation, pipeline);
}
 
Example #15
Source File: EnderTankItemRender.java    From EnderStorage with MIT License 5 votes vote down vote up
@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 #16
Source File: RenderTileEnderChest.java    From EnderStorage with MIT License 5 votes vote down vote up
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 #17
Source File: MetaTileEntityItemBus.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    if (shouldRenderOverlay()) {
        SimpleOverlayRenderer renderer = isExportHatch ? Textures.PIPE_OUT_OVERLAY : Textures.PIPE_IN_OVERLAY;
        renderer.renderSided(getFrontFacing(), renderState, translation, pipeline);
    }
}
 
Example #18
Source File: MetaTileEntityEnergyHatch.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    if (shouldRenderOverlay()) {
        SimpleOverlayRenderer renderer = isExportHatch ? Textures.ENERGY_OUT_MULTI : Textures.ENERGY_IN_MULTI;
        renderer.renderSided(getFrontFacing(), renderState, translation, PipelineUtil.color(pipeline, GTValues.VC[getTier()]));
    }
}
 
Example #19
Source File: MetaTileEntityTransformer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    if (isTransformUp) {
        Textures.ENERGY_OUT_MULTI.renderSided(getFrontFacing(), renderState, translation, PipelineUtil.color(pipeline, GTValues.VC[getTier() - 1]));
        Textures.ENERGY_IN.renderSided(getFrontFacing().getOpposite(), renderState, translation, PipelineUtil.color(pipeline, GTValues.VC[getTier()]));
    } else {
        Textures.ENERGY_IN_MULTI.renderSided(getFrontFacing(), renderState, translation, PipelineUtil.color(pipeline, GTValues.VC[getTier()]));
        Textures.ENERGY_OUT.renderSided(getFrontFacing().getOpposite(), renderState, translation, PipelineUtil.color(pipeline, GTValues.VC[getTier() - 1]));
    }
}
 
Example #20
Source File: MetaTileEntityAirCollector.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    super.renderMetaTileEntity(renderState, translation, pipeline);
    EnumFacing frontFacing = getFrontFacing();
    for (EnumFacing side : EnumFacing.VALUES) {
        if (side.getAxis().isHorizontal()) {
            Textures.AIR_VENT_OVERLAY.renderSided(side, renderState, translation, pipeline);
        } else {
            Textures.FILTER_OVERLAY.renderSided(side, renderState, translation, pipeline);
        }
    }
    Textures.PIPE_OUT_OVERLAY.renderSided(frontFacing, renderState, translation, pipeline);
}
 
Example #21
Source File: MetaTileEntityQuantumTank.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    Textures.VOLTAGE_CASINGS[tier].render(renderState, translation, ArrayUtils.add(pipeline,
        new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering()))));
    translation.translate(0.5, 0.001, 0.5);
    translation.rotate(Math.toRadians(rotations[getFrontFacing().getIndex() - 2]), new Vector3(0.0, 1.0, 0.0));
    translation.translate(-0.5, 0.0, -0.5);
    Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline);
}
 
Example #22
Source File: MetaTileEntityLockedSafe.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntityFast(CCRenderState renderState, Matrix4 translation, float partialTicks) {
    ColourMultiplier colourMultiplier = new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(GTValues.VC[unlockComponentTier]));
    float angle = prevDoorAngle + (doorAngle - prevDoorAngle) * partialTicks;
    angle = 1.0f - (1.0f - angle) * (1.0f - angle) * (1.0f - angle);
    float resultDoorAngle = angle * 120.0f;
    Textures.SAFE.render(renderState, translation, new IVertexOperation[] { colourMultiplier }, getFrontFacing(), resultDoorAngle);
}
 
Example #23
Source File: CCRenderEventHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@OnlyIn (Dist.CLIENT)
@SubscribeEvent (priority = EventPriority.LOW)
public void onBlockHighlight(DrawHighlightEvent.HighlightBlock event) {
    //We have found a CuboidRayTraceResult, Lets render it properly..
    BlockRayTraceResult hit = event.getTarget();
    if (hit instanceof CuboidRayTraceResult) {
        CuboidRayTraceResult cuboidHit = (CuboidRayTraceResult) hit;
        event.setCanceled(true);
        Matrix4 mat = new Matrix4(event.getMatrix());
        mat.translate(cuboidHit.getPos());
        RenderUtils.bufferHitbox(mat, event.getBuffers(), event.getInfo(), cuboidHit.cuboid6);
    }
}
 
Example #24
Source File: MetaTileEntityQuantumChest.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    Textures.VOLTAGE_CASINGS[tier].render(renderState, translation, ArrayUtils.add(pipeline,
        new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering()))));
    translation.translate(0.5, 0.001, 0.5);
    translation.rotate(Math.toRadians(rotations[getFrontFacing().getIndex() - 2]), new Vector3(0.0, 1.0, 0.0));
    translation.translate(-0.5, 0.0, -0.5);
    Textures.SCREEN.renderSided(EnumFacing.UP, renderState, translation, pipeline);
}
 
Example #25
Source File: TileTranslocatorRenderer.java    From Translocators with MIT License 5 votes vote down vote up
public static void renderAttachment(int i, int type, double insertpos, int field, double x, double y, double z)
{
    double tx = field/64D;
    double ty = type/2D;
    
    plates[i].render(x+0.5, y+0.5, z+0.5, tx, ty);
    
    Matrix4 matrix = new Matrix4()
        .translate(new Vector3(x+0.5, y+0.5, z+0.5))
        .apply(sideRotations[i])
        .translate(new Vector3(0, -0.5, 0))
        .scale(new Vector3(1, insertpos*2/3+1/3D, 1));
    
    insert.render(matrix, tx, ty);
}
 
Example #26
Source File: CoverFacade.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #27
Source File: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void renderItemCover(CCRenderState ccrs, int side, ItemStack renderStack, Cuboid6 bounds) {
    Minecraft minecraft = Minecraft.getMinecraft();
    RenderItem renderItem = minecraft.getRenderItem();
    IBakedModel model = renderItem.getItemModelWithOverrides(renderStack, null, null);

    IBlockState state = FacadeHelper.lookupBlockForItem(renderStack);
    String cacheKey = state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state);

    List<CCQuad> renderQuads = itemQuadCache.getIfPresent(cacheKey);
    if (renderQuads == null) {

        List<BakedQuad> quads = new ArrayList<>(model.getQuads(null, null, 0));
        for (EnumFacing face : EnumFacing.VALUES) {
            quads.addAll(model.getQuads(null, face, 0));
        }

        renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack);
        itemQuadCache.put(cacheKey, renderQuads);
    }

    AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs);
    consumer.setTranslation(new Matrix4()
        .translate(Vector3.center.copy().subtract(bounds.center()))
        .scale(1.05, 1.05, 1.05));
    for (CCQuad quad : renderQuads) {
        quad.pipe(consumer);
    }

}
 
Example #28
Source File: FacadeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static VertexLighterFlat setupLighter(CCRenderState ccrs, Matrix4 translation, IBlockState state, IBlockAccess access, BlockPos pos, IBakedModel model) {
    boolean renderAO = Minecraft.isAmbientOcclusionEnabled() && state.getLightValue(access, pos) == 0 && model.isAmbientOcclusion();
    VertexLighterFlat lighter = renderAO ? lighterSmooth.get() : lighterFlat.get();

    AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs);
    lighter.setParent(consumer);
    consumer.setTranslation(translation);
    return lighter;
}
 
Example #29
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #30
Source File: TileEntityRendererBase.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}