Search in sources :

Example 1 with FormedAssembly

use of mekanism.generators.common.content.fission.FissionReactorValidator.FormedAssembly in project Mekanism by mekanism.

the class RenderFissionReactor method render.

@Override
protected void render(TileEntityFissionReactorCasing tile, float partialTick, MatrixStack matrix, IRenderTypeBuffer renderer, int light, int overlayLight, IProfiler profiler) {
    if (tile.isMaster()) {
        FissionReactorMultiblockData multiblock = tile.getMultiblock();
        if (multiblock.isFormed() && multiblock.renderLocation != null) {
            BlockPos pos = tile.getBlockPos();
            IVertexBuilder buffer = renderer.getBuffer(Atlases.translucentCullBlockSheet());
            if (multiblock.isBurning()) {
                // as I am fairly sure that should give a decent boost to performance
                if (glowModel == null) {
                    glowModel = new Model3D();
                    glowModel.minX = 0.05F;
                    glowModel.minY = 0.01F;
                    glowModel.minZ = 0.05F;
                    glowModel.maxX = 0.95F;
                    glowModel.maxY = 0.99F;
                    glowModel.maxZ = 0.95F;
                    glowModel.setTexture(MekanismRenderer.whiteIcon);
                }
                for (FormedAssembly assembly : multiblock.assemblies) {
                    matrix.pushPose();
                    matrix.translate(assembly.getPos().getX() - pos.getX(), assembly.getPos().getY() - pos.getY(), assembly.getPos().getZ() - pos.getZ());
                    matrix.scale(1, assembly.getHeight(), 1);
                    MekanismRenderer.renderObject(glowModel, matrix, buffer, GLOW_ARGB, MekanismRenderer.FULL_LIGHT, overlayLight, FaceDisplay.FRONT);
                    matrix.popPose();
                }
            }
            if (!multiblock.fluidCoolantTank.isEmpty()) {
                int height = multiblock.height() - 2;
                if (height >= 1) {
                    FluidRenderData data = new FluidRenderData(multiblock.fluidCoolantTank.getFluid());
                    int glow = setCoolantDataAndCalculateGlow(data, multiblock, height);
                    matrix.pushPose();
                    matrix.translate(data.location.getX() - pos.getX(), data.location.getY() - pos.getY(), data.location.getZ() - pos.getZ());
                    Model3D model = ModelRenderer.getModel(data, multiblock.prevCoolantScale);
                    MekanismRenderer.renderObject(model, matrix, buffer, data.getColorARGB(multiblock.prevCoolantScale), glow, overlayLight, getFaceDisplay(data, model));
                    matrix.popPose();
                    MekanismRenderer.renderValves(matrix, buffer, multiblock.valves, data, pos, glow, overlayLight, isInsideMultiblock(data));
                }
            }
            if (!multiblock.heatedCoolantTank.isEmpty()) {
                int height = multiblock.height() - 2;
                if (height >= 1) {
                    GasRenderData data = new GasRenderData(multiblock.heatedCoolantTank.getStack());
                    int glow = setCoolantDataAndCalculateGlow(data, multiblock, height);
                    Model3D gasModel;
                    if (cachedHeatedCoolantModels.containsKey(data)) {
                        gasModel = cachedHeatedCoolantModels.get(data);
                    } else {
                        // Create a slightly shrunken version of the model if it is missing to prevent z-fighting
                        gasModel = ModelRenderer.getModel(data, 1).copy();
                        gasModel.minX += 0.01F;
                        gasModel.minY += 0.01F;
                        gasModel.minZ += 0.01F;
                        gasModel.maxX -= 0.01F;
                        gasModel.maxY -= 0.01F;
                        gasModel.maxZ -= 0.01F;
                        cachedHeatedCoolantModels.put(data, gasModel);
                    }
                    matrix.pushPose();
                    matrix.translate(data.location.getX() - pos.getX(), data.location.getY() - pos.getY(), data.location.getZ() - pos.getZ());
                    MekanismRenderer.renderObject(gasModel, matrix, buffer, data.getColorARGB(multiblock.prevHeatedCoolantScale), glow, overlayLight, getFaceDisplay(data, gasModel));
                    matrix.popPose();
                }
            }
        }
    }
}
Also used : Model3D(mekanism.client.render.MekanismRenderer.Model3D) GasRenderData(mekanism.client.render.data.ChemicalRenderData.GasRenderData) FluidRenderData(mekanism.client.render.data.FluidRenderData) FormedAssembly(mekanism.generators.common.content.fission.FissionReactorValidator.FormedAssembly) BlockPos(net.minecraft.util.math.BlockPos) FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Aggregations

IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 Model3D (mekanism.client.render.MekanismRenderer.Model3D)1 GasRenderData (mekanism.client.render.data.ChemicalRenderData.GasRenderData)1 FluidRenderData (mekanism.client.render.data.FluidRenderData)1 FissionReactorMultiblockData (mekanism.generators.common.content.fission.FissionReactorMultiblockData)1 FormedAssembly (mekanism.generators.common.content.fission.FissionReactorValidator.FormedAssembly)1 BlockPos (net.minecraft.util.math.BlockPos)1