Search in sources :

Example 1 with PacketGeneratorsGuiInteract

use of mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract 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 PacketGeneratorsGuiInteract

use of mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract in project Mekanism by mekanism.

the class GuiFissionReactorLogicAdapter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiElementHolder(this, 16, 31, 130, 90));
    scrollBar = addButton(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
    for (int i = 0; i < DISPLAY_COUNT; i++) {
        int typeShift = 22 * i;
        addButton(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, scrollBar::getCurrentSelection, tile::getModes, type -> {
            if (type == null) {
                return;
            }
            MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.LOGIC_TYPE, tile, type.ordinal()));
        }));
    }
}
Also used : EnumColor(mekanism.api.text.EnumColor) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) MekanismGenerators(mekanism.generators.common.MekanismGenerators) ReactorLogicButton(mekanism.generators.client.gui.element.button.ReactorLogicButton) TileEntityFissionReactorLogicAdapter(mekanism.generators.common.tile.fission.TileEntityFissionReactorLogicAdapter) EmptyTileContainer(mekanism.common.inventory.container.tile.EmptyTileContainer) ITextComponent(net.minecraft.util.text.ITextComponent) GeneratorsLang(mekanism.generators.common.GeneratorsLang) MekanismLang(mekanism.common.MekanismLang) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) Nonnull(javax.annotation.Nonnull) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract) GeneratorsGuiInteraction(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract.GeneratorsGuiInteraction) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)

Example 3 with PacketGeneratorsGuiInteract

use of mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract in project Mekanism by mekanism.

the class GuiFusionReactorFuel method setInjection.

private void setInjection() {
    if (!injectionRateField.getText().isEmpty()) {
        MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.INJECTION_RATE, tile, Integer.parseInt(injectionRateField.getText())));
        injectionRateField.setText("");
    }
}
Also used : PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)

Example 4 with PacketGeneratorsGuiInteract

use of mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract in project Mekanism by mekanism.

the class GuiFusionReactorLogicAdapter method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiElementHolder(this, 16, 31, 130, 90));
    addButton(new ToggleButton(this, 16, 19, 11, tile::isActiveCooled, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.NEXT_MODE, tile)), getOnHover(GeneratorsLang.REACTOR_LOGIC_TOGGLE_COOLING)));
    scrollBar = addButton(new GuiScrollBar(this, 146, 31, 90, () -> tile.getModes().length, () -> DISPLAY_COUNT));
    for (int i = 0; i < DISPLAY_COUNT; i++) {
        int typeShift = 22 * i;
        addButton(new ReactorLogicButton<>(this, 17, 32 + typeShift, i, tile, scrollBar::getCurrentSelection, tile::getModes, type -> {
            if (type == null) {
                return;
            }
            MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.LOGIC_TYPE, tile, type.ordinal()));
        }));
    }
}
Also used : Mekanism(mekanism.common.Mekanism) EnumColor(mekanism.api.text.EnumColor) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) OnOff(mekanism.common.util.text.BooleanStateDisplay.OnOff) MekanismGenerators(mekanism.generators.common.MekanismGenerators) ToggleButton(mekanism.client.gui.element.button.ToggleButton) ReactorLogicButton(mekanism.generators.client.gui.element.button.ReactorLogicButton) EmptyTileContainer(mekanism.common.inventory.container.tile.EmptyTileContainer) ITextComponent(net.minecraft.util.text.ITextComponent) GeneratorsLang(mekanism.generators.common.GeneratorsLang) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) MekanismLang(mekanism.common.MekanismLang) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) Nonnull(javax.annotation.Nonnull) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract) TileEntityFusionReactorLogicAdapter(mekanism.generators.common.tile.fusion.TileEntityFusionReactorLogicAdapter) GeneratorsGuiInteraction(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract.GeneratorsGuiInteraction) ToggleButton(mekanism.client.gui.element.button.ToggleButton) GuiElementHolder(mekanism.client.gui.element.GuiElementHolder) GuiScrollBar(mekanism.client.gui.element.scroll.GuiScrollBar) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)

Example 5 with PacketGeneratorsGuiInteract

use of mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract in project Mekanism by mekanism.

the class GuiFissionReactorStats method setRateLimit.

private void setRateLimit() {
    if (!rateLimitField.getText().isEmpty()) {
        try {
            double limit = Double.parseDouble(rateLimitField.getText());
            if (limit >= 0 && limit <= tile.getMultiblock().getMaxBurnRate()) {
                // round to two decimals
                limit = UnitDisplayUtils.roundDecimals(limit);
                MekanismGenerators.packetHandler.sendToServer(new PacketGeneratorsGuiInteract(GeneratorsGuiInteraction.INJECTION_RATE, tile, limit));
                rateLimitField.setText("");
            }
        } catch (NumberFormatException ignored) {
        }
    }
}
Also used : PacketGeneratorsGuiInteract(mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)

Aggregations

PacketGeneratorsGuiInteract (mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)5 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)3 ITextComponent (net.minecraft.util.text.ITextComponent)3 Nonnull (javax.annotation.Nonnull)2 EnumColor (mekanism.api.text.EnumColor)2 GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)2 GuiElementHolder (mekanism.client.gui.element.GuiElementHolder)2 GuiScrollBar (mekanism.client.gui.element.scroll.GuiScrollBar)2 MekanismLang (mekanism.common.MekanismLang)2 EmptyTileContainer (mekanism.common.inventory.container.tile.EmptyTileContainer)2 ReactorLogicButton (mekanism.generators.client.gui.element.button.ReactorLogicButton)2 GeneratorsLang (mekanism.generators.common.GeneratorsLang)2 MekanismGenerators (mekanism.generators.common.MekanismGenerators)2 GeneratorsGuiInteraction (mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract.GeneratorsGuiInteraction)2 PlayerInventory (net.minecraft.entity.player.PlayerInventory)2 GuiBigLight (mekanism.client.gui.element.GuiBigLight)1 GuiGraph (mekanism.client.gui.element.GuiGraph)1 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)1 IBarInfoHandler (mekanism.client.gui.element.bar.GuiBar.IBarInfoHandler)1 GuiDynamicHorizontalRateBar (mekanism.client.gui.element.bar.GuiDynamicHorizontalRateBar)1