Search in sources :

Example 1 with FissionReactorMultiblockData

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

the class GuiFissionReactor method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiFissionReactorTab(this, tile, FissionReactorTab.STAT));
    addButton(new GuiInnerScreen(this, 45, 17, 105, 56, () -> {
        FissionReactorMultiblockData multiblock = tile.getMultiblock();
        return Arrays.asList(MekanismLang.STATUS.translate(multiblock.isActive() ? EnumColor.BRIGHT_GREEN : EnumColor.RED, ActiveDisabled.of(multiblock.isActive())), GeneratorsLang.GAS_BURN_RATE.translate(multiblock.lastBurnRate), GeneratorsLang.FISSION_HEATING_RATE.translate(TextUtils.format(multiblock.lastBoilRate)), MekanismLang.TEMPERATURE.translate(tile.getTempColor(), MekanismUtils.getTemperatureDisplay(multiblock.heatCapacitor.getTemperature(), TemperatureUnit.KELVIN, true)), GeneratorsLang.FISSION_DAMAGE.translate(tile.getDamageColor(), tile.getDamageString()));
    }).spacing(2).jeiCategories(JEI_LOCATION));
    addButton(new GuiHybridGauge(() -> tile.getMultiblock().gasCoolantTank, () -> tile.getMultiblock().getGasTanks(null), () -> tile.getMultiblock().fluidCoolantTank, () -> tile.getMultiblock().getFluidTanks(null), GaugeType.STANDARD, this, 6, 13).setLabel(GeneratorsLang.FISSION_COOLANT_TANK.translateColored(EnumColor.AQUA)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().fuelTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 25, 13).setLabel(GeneratorsLang.FISSION_FUEL_TANK.translateColored(EnumColor.DARK_GREEN)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().heatedCoolantTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 152, 13).setLabel(GeneratorsLang.FISSION_HEATED_COOLANT_TANK.translateColored(EnumColor.ORANGE)));
    addButton(new GuiGasGauge(() -> tile.getMultiblock().wasteTank, () -> tile.getMultiblock().getGasTanks(null), GaugeType.STANDARD, this, 171, 13).setLabel(GeneratorsLang.FISSION_WASTE_TANK.translateColored(EnumColor.BROWN)));
    addButton(new GuiHeatTab(this, () -> {
        ITextComponent environment = MekanismUtils.getTemperatureDisplay(tile.getMultiblock().lastEnvironmentLoss, TemperatureUnit.KELVIN, false);
        return Collections.singletonList(MekanismLang.DISSIPATED_RATE.translate(environment));
    }));
    activateButton = addButton(new TranslationButton(this, 6, 75, 81, 16, GeneratorsLang.FISSION_ACTIVATE, () -> MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.FISSION_ACTIVE, tile, 1)), null, () -> EnumColor.DARK_GREEN) {

        @Override
        public void renderForeground(MatrixStack matrix, int mouseX, int mouseY) {
            super.renderForeground(matrix, mouseX, mouseY);
            if (!active && tile.getMultiblock().isForceDisabled()) {
                active = true;
                // Temporarily set active to true, so we can easily check if the mouse is over the button
                if (isMouseOverCheckWindows(mouseX, mouseY)) {
                    displayTooltip(matrix, GeneratorsLang.FISSION_FORCE_DISABLED.translate(), mouseX - getGuiLeft(), mouseY - getGuiTop());
                }
                active = false;
            }
        }
    });
    scramButton = addButton(new TranslationButton(this, 89, 75, 81, 16, GeneratorsLang.FISSION_SCRAM, () -> MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.FISSION_ACTIVE, tile, 0)), null, () -> EnumColor.DARK_RED));
    addButton(new GuiBigLight(this, 173, 76, tile.getMultiblock()::isActive));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return MekanismUtils.getTemperatureDisplay(tile.getMultiblock().heatCapacitor.getTemperature(), TemperatureUnit.KELVIN, true);
        }

        @Override
        public double getLevel() {
            return Math.min(1, tile.getMultiblock().heatCapacitor.getTemperature() / FissionReactorMultiblockData.MAX_DAMAGE_TEMPERATURE);
        }
    }, 5, 102, imageWidth - 12));
    heatGraph = addButton(new GuiGraph(this, 5, 123, imageWidth - 10, 38, temp -> MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.KELVIN, true)));
    heatGraph.setMinScale(1_600);
    updateButtons();
}
Also used : GuiFissionReactorTab(mekanism.generators.client.gui.element.GuiFissionReactorTab) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiGraph(mekanism.client.gui.element.GuiGraph) TranslationButton(mekanism.client.gui.element.button.TranslationButton) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ITextComponent(net.minecraft.util.text.ITextComponent) FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData) GuiHeatTab(mekanism.client.gui.element.tab.GuiHeatTab) GuiHybridGauge(mekanism.client.gui.element.gauge.GuiHybridGauge) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) GuiBigLight(mekanism.client.gui.element.GuiBigLight)

Example 2 with FissionReactorMultiblockData

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

the class GuiFissionReactor method updateButtons.

private void updateButtons() {
    FissionReactorMultiblockData multiblock = tile.getMultiblock();
    activateButton.active = !multiblock.isActive() && !multiblock.isForceDisabled();
    scramButton.active = multiblock.isActive();
}
Also used : FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData)

Example 3 with FissionReactorMultiblockData

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

the class GuiFissionReactorStats method drawForegroundText.

@Override
protected void drawForegroundText(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
    drawTitleText(matrix, GeneratorsLang.FISSION_REACTOR_STATS.translate(), titleLabelY);
    FissionReactorMultiblockData multiblock = tile.getMultiblock();
    // heat stats
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_HEAT_STATISTICS.translate(), 6, 20, headingTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_HEAT_CAPACITY.translate(TextUtils.format((long) multiblock.heatCapacitor.getHeatCapacity())), 6, 32, titleTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_SURFACE_AREA.translate(TextUtils.format(multiblock.surfaceArea)), 6, 42, titleTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_BOIL_EFFICIENCY.translate(tile.getBoilEfficiency()), 6, 52, titleTextColor(), imageWidth - 12);
    // fuel stats
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_FUEL_STATISTICS.translate(), 6, 68, headingTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_MAX_BURN_RATE.translate(TextUtils.format(multiblock.getMaxBurnRate())), 6, 80, titleTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_RATE_LIMIT.translate(multiblock.rateLimit), 6, 90, titleTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_CURRENT_BURN_RATE.translate(), 6, 104, titleTextColor(), imageWidth - 12);
    drawTextScaledBound(matrix, GeneratorsLang.FISSION_SET_RATE_LIMIT.translate(), 6, 130, titleTextColor(), 69);
    super.drawForegroundText(matrix, mouseX, mouseY);
}
Also used : FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData)

Example 4 with FissionReactorMultiblockData

use of mekanism.generators.common.content.fission.FissionReactorMultiblockData 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)

Example 5 with FissionReactorMultiblockData

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

the class GuiFissionReactorStats method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiFissionReactorTab(this, tile, FissionReactorTab.MAIN));
    addButton(new GuiDynamicHorizontalRateBar(this, new IBarInfoHandler() {

        @Override
        public ITextComponent getTooltip() {
            return GeneratorsLang.GAS_BURN_RATE.translate(tile.getMultiblock().lastBurnRate);
        }

        @Override
        public double getLevel() {
            FissionReactorMultiblockData multiblock = tile.getMultiblock();
            return Math.min(1, multiblock.lastBurnRate / multiblock.getMaxBurnRate());
        }
    }, 5, 114, imageWidth - 12));
    rateLimitField = addButton(new GuiTextField(this, 77, 128, 49, 12));
    rateLimitField.setEnterHandler(this::setRateLimit);
    rateLimitField.setInputValidator(InputValidator.DECIMAL);
    rateLimitField.setMaxStringLength(4);
    rateLimitField.addCheckmarkButton(this::setRateLimit);
}
Also used : GuiFissionReactorTab(mekanism.generators.client.gui.element.GuiFissionReactorTab) IBarInfoHandler(mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler) GuiDynamicHorizontalRateBar(mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar) FissionReactorMultiblockData(mekanism.generators.common.content.fission.FissionReactorMultiblockData) GuiTextField(mekanism.client.gui.element.text.GuiTextField)

Aggregations

FissionReactorMultiblockData (mekanism.generators.common.content.fission.FissionReactorMultiblockData)7 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)2 GuiDynamicHorizontalRateBar (mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar)2 GuiFissionReactorTab (mekanism.generators.client.gui.element.GuiFissionReactorTab)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 Nonnull (javax.annotation.Nonnull)1 GuiBigLight (mekanism.client.gui.element.GuiBigLight)1 GuiGraph (mekanism.client.gui.element.GuiGraph)1 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)1 TranslationButton (mekanism.client.gui.element.button.TranslationButton)1 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)1 GuiHybridGauge (mekanism.client.gui.element.gauge.GuiHybridGauge)1 GuiHeatTab (mekanism.client.gui.element.tab.GuiHeatTab)1 GuiTextField (mekanism.client.gui.element.text.GuiTextField)1 Model3D (mekanism.client.render.MekanismRenderer.Model3D)1 GasRenderData (mekanism.client.render.data.ChemicalRenderData.GasRenderData)1 FluidRenderData (mekanism.client.render.data.FluidRenderData)1 FormedAssembly (mekanism.generators.common.content.fission.FissionReactorValidator.FormedAssembly)1 PacketGeneratorsGuiInteract (mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)1