Search in sources :

Example 1 with ReactorLogicButton

use of mekanism.generators.client.gui.element.button.ReactorLogicButton 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 2 with ReactorLogicButton

use of mekanism.generators.client.gui.element.button.ReactorLogicButton 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)

Aggregations

MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 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 PacketGeneratorsGuiInteract (mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract)2 GeneratorsGuiInteraction (mekanism.generators.common.network.to_server.PacketGeneratorsGuiInteract.GeneratorsGuiInteraction)2 PlayerInventory (net.minecraft.entity.player.PlayerInventory)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 ToggleButton (mekanism.client.gui.element.button.ToggleButton)1 Mekanism (mekanism.common.Mekanism)1 PacketGuiInteract (mekanism.common.network.to_server.PacketGuiInteract)1 GuiInteraction (mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction)1 OnOff (mekanism.common.util.text.BooleanStateDisplay.OnOff)1