Search in sources :

Example 1 with PacketGuiButtonPress

use of mekanism.common.network.to_server.PacketGuiButtonPress in project Mekanism by mekanism.

the class GuiQIOItemFrequencySelect method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiFrequencySelector<>(this, 17));
    addButton(new MekanismImageButton(this, 6, 6, 14, getButtonLocation("back"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedItemButton.BACK_BUTTON, menu.getHand()))));
}
Also used : PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton)

Example 2 with PacketGuiButtonPress

use of mekanism.common.network.to_server.PacketGuiButtonPress in project Mekanism by mekanism.

the class GuiRobitMain method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiSecurityTab(this, robit, 120));
    addButton(GuiSideHolder.create(this, 176, 6, 106, false, false, SpecialColors.TAB_ROBIT_MENU));
    addButton(new GuiInnerScreen(this, 27, 16, 122, 56));
    addButton(new GuiHorizontalPowerBar(this, robit.getEnergyContainer(), 27, 74, 120));
    addButton(new MekanismImageButton(this, 6, 16, 18, getButtonLocation("home"), () -> {
        Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.GO_HOME, robit));
        getMinecraft().setScreen(null);
    }, getOnHover(MekanismLang.ROBIT_TELEPORT)));
    renameButton = addButton(new MekanismImageButton(this, 6, 35, 18, getButtonLocation("rename"), () -> openWindow(new GuiRobitRename(this, 27, 16, robit), () -> renameButton), getOnHover(MekanismLang.ROBIT_RENAME)));
    skinButton = addButton(new MekanismImageButton(this, 6, 54, 18, getButtonLocation("skin"), () -> openWindow(new GuiRobitSkinSelect(this, 4, -12, robit), () -> skinButton), getOnHover(MekanismLang.ROBIT_SKIN_SELECT)));
    addButton(new MekanismImageButton(this, 152, 35, 18, getButtonLocation("drop"), () -> Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.DROP_PICKUP, robit)), getOnHover(MekanismLang.ROBIT_TOGGLE_PICKUP)));
    addButton(new MekanismImageButton(this, 152, 54, 18, getButtonLocation("follow"), () -> Mekanism.packetHandler.sendToServer(new PacketRobit(RobitPacketType.FOLLOW, robit)), getOnHover(MekanismLang.ROBIT_TOGGLE_FOLLOW)));
    addButton(new MekanismImageButton(this, 179, 10, 18, getButtonLocation("main"), () -> {
    // Clicking main button doesn't do anything while already on the main GUI
    }, getOnHover(MekanismLang.ROBIT)));
    addButton(new MekanismImageButton(this, 179, 30, 18, getButtonLocation("crafting"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_CRAFTING, robit)), getOnHover(MekanismLang.ROBIT_CRAFTING)));
    addButton(new MekanismImageButton(this, 179, 50, 18, getButtonLocation("inventory"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_INVENTORY, robit)), getOnHover(MekanismLang.ROBIT_INVENTORY)));
    addButton(new MekanismImageButton(this, 179, 70, 18, getButtonLocation("smelting"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_SMELTING, robit)), getOnHover(MekanismLang.ROBIT_SMELTING)));
    addButton(new MekanismImageButton(this, 179, 90, 18, getButtonLocation("repair"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedEntityButton.ROBIT_REPAIR, robit)), getOnHover(MekanismLang.ROBIT_REPAIR)));
}
Also used : GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) GuiRobitSkinSelect(mekanism.client.gui.element.window.GuiRobitSkinSelect) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) GuiSecurityTab(mekanism.client.gui.element.tab.GuiSecurityTab) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) PacketRobit(mekanism.common.network.to_server.PacketRobit) GuiRobitRename(mekanism.client.gui.element.window.GuiRobitRename) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton)

Example 3 with PacketGuiButtonPress

use of mekanism.common.network.to_server.PacketGuiButtonPress in project Mekanism by mekanism.

the class GuiDigitalMiner method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new GuiInnerScreen(this, 7, 19, 77, 69, () -> {
        List<ITextComponent> list = new ArrayList<>();
        ILangEntry runningType;
        if (tile.getEnergyContainer().getEnergyPerTick().greaterThan(tile.getEnergyContainer().getMaxEnergy())) {
            runningType = MekanismLang.MINER_LOW_POWER;
        } else if (tile.isRunning()) {
            runningType = MekanismLang.MINER_RUNNING;
        } else {
            runningType = MekanismLang.IDLE;
        }
        list.add(runningType.translate());
        list.add(tile.searcher.state.getTextComponent());
        list.add(MekanismLang.MINER_TO_MINE.translate(TextUtils.format(tile.getToMine())));
        return list;
    }).spacing(1).clearFormat());
    addButton(new GuiDigitalSwitch(this, 19, 56, EJECT, tile::getDoEject, MekanismLang.AUTO_EJECT.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_EJECT_BUTTON, tile)), SwitchType.LOWER_ICON));
    addButton(new GuiDigitalSwitch(this, 38, 56, INPUT, tile::getDoPull, MekanismLang.AUTO_PULL.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.AUTO_PULL_BUTTON, tile)), SwitchType.LOWER_ICON));
    addButton(new GuiDigitalSwitch(this, 57, 56, SILK, tile::getSilkTouch, MekanismLang.MINER_SILK.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.SILK_TOUCH_BUTTON, tile)), SwitchType.LOWER_ICON));
    addButton(new GuiVerticalPowerBar(this, tile.getEnergyContainer(), 157, 39, 47));
    addButton(new GuiVisualsTab(this, tile));
    addButton(new GuiSlot(SlotType.DIGITAL, this, 64, 21).setRenderAboveSlots().validity(() -> tile.missingStack).with(() -> tile.missingStack.isEmpty() ? SlotOverlay.CHECK : null).hover(getOnHover(() -> tile.missingStack.isEmpty() ? MekanismLang.MINER_WELL.translate() : MekanismLang.MINER_MISSING_BLOCK.translate())));
    addButton(new GuiEnergyTab(this, () -> {
        MinerEnergyContainer energyContainer = tile.getEnergyContainer();
        FloatingLong perTick = energyContainer.getEnergyPerTick();
        ArrayList<ITextComponent> ret = new ArrayList<>(4);
        ret.add(MekanismLang.MINER_ENERGY_CAPACITY.translate(EnergyDisplay.of(energyContainer.getMaxEnergy())));
        ret.add(MekanismLang.NEEDED_PER_TICK.translate(EnergyDisplay.of(perTick)));
        if (perTick.greaterThan(energyContainer.getMaxEnergy())) {
            ret.add(MekanismLang.MINER_INSUFFICIENT_BUFFER.translateColored(EnumColor.RED));
        }
        ret.add(MekanismLang.MINER_BUFFER_FREE.translate(EnergyDisplay.of(energyContainer.getNeeded())));
        return ret;
    }));
    int buttonStart = 19;
    startButton = addButton(new TranslationButton(this, 87, buttonStart, 61, 18, MekanismLang.BUTTON_START, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.START_BUTTON, tile))));
    stopButton = addButton(new TranslationButton(this, 87, buttonStart + 17, 61, 18, MekanismLang.BUTTON_STOP, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.STOP_BUTTON, tile))));
    configButton = addButton(new TranslationButton(this, 87, buttonStart + 34, 61, 18, MekanismLang.BUTTON_CONFIG, () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedTileButton.DIGITAL_MINER_CONFIG, tile))));
    addButton(new TranslationButton(this, 87, buttonStart + 51, 61, 18, MekanismLang.MINER_RESET, () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.RESET_BUTTON, tile))));
    updateEnabledButtons();
    trackWarning(WarningType.FILTER_HAS_BLACKLISTED_ELEMENT, () -> tile.getFilters().stream().anyMatch(MinerFilter::hasBlacklistedElement));
}
Also used : PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiDigitalSwitch(mekanism.client.gui.element.GuiDigitalSwitch) ArrayList(java.util.ArrayList) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) GuiVerticalPowerBar(mekanism.client.gui.element.bar.GuiVerticalPowerBar) GuiEnergyTab(mekanism.client.gui.element.tab.GuiEnergyTab) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) FloatingLong(mekanism.api.math.FloatingLong) MinerEnergyContainer(mekanism.common.capabilities.energy.MinerEnergyContainer) ArrayList(java.util.ArrayList) List(java.util.List) GuiVisualsTab(mekanism.client.gui.element.tab.GuiVisualsTab) ILangEntry(mekanism.api.text.ILangEntry)

Example 4 with PacketGuiButtonPress

use of mekanism.common.network.to_server.PacketGuiButtonPress in project Mekanism by mekanism.

the class GuiFusionReactorInfo method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new MekanismImageButton(this, 6, 6, 14, getButtonLocation("back"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedTileButton.BACK_BUTTON, tile))));
}
Also used : PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton)

Example 5 with PacketGuiButtonPress

use of mekanism.common.network.to_server.PacketGuiButtonPress in project Mekanism by mekanism.

the class GuiDigitalMinerConfig method addGuiElements.

@Override
protected void addGuiElements() {
    super.addGuiElements();
    addButton(new TranslationButton(this, 56, 136, 96, 20, MekanismLang.BUTTON_NEW_FILTER, () -> addWindow(new GuiMinerFilerSelect(this, tile))));
    addButton(new MekanismImageButton(this, 5, 5, 11, 14, getButtonLocation("back"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiButtonPress(ClickedTileButton.BACK_BUTTON, tile))));
    addButton(new GuiDigitalSwitch(this, 10, 115, INVERSE, tile::getInverse, MekanismLang.MINER_INVERSE.translate(), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.INVERSE_BUTTON, tile)), SwitchType.LEFT_ICON));
    addButton(new GuiSlot(SlotType.NORMAL, this, 13, 135)).setRenderAboveSlots().setRenderHover(true).stored(() -> new ItemStack(tile.getInverseReplaceTarget())).click((element, mouseX, mouseY) -> {
        if (Screen.hasShiftDown()) {
            updateInverseReplaceTarget(Items.AIR);
        } else {
            ItemStack stack = minecraft.player.inventory.getCarried();
            if (!stack.isEmpty() && stack.getItem() instanceof BlockItem) {
                updateInverseReplaceTarget(stack.getItem());
            }
        }
    }).setGhostHandler((IGhostBlockItemConsumer) ingredient -> updateInverseReplaceTarget(((ItemStack) ingredient).getItem()));
    addButton(new MekanismImageButton(this, 35, 137, 14, 16, getButtonLocation("exclamation"), () -> Mekanism.packetHandler.sendToServer(new PacketGuiInteract(GuiInteraction.INVERSE_REQUIRES_REPLACEMENT_BUTTON, tile)), getOnHover(() -> MekanismLang.MINER_REQUIRE_REPLACE_INVERSE.translate(YesNo.of(tile.getInverseRequiresReplacement())))));
    radiusField = addButton(new GuiTextField(this, 13, 49, 38, 11));
    radiusField.setMaxStringLength(Integer.toString(MekanismConfig.general.minerMaxRadius.get()).length());
    radiusField.setInputValidator(InputValidator.DIGIT);
    radiusField.configureDigitalBorderInput(() -> setText(radiusField, GuiInteraction.SET_RADIUS));
    minField = addButton(new GuiTextField(this, 13, 74, 38, 11));
    minField.setMaxStringLength(3);
    minField.setInputValidator(InputValidator.DIGIT);
    minField.configureDigitalBorderInput(() -> setText(minField, GuiInteraction.SET_MIN_Y));
    maxField = addButton(new GuiTextField(this, 13, 99, 38, 11));
    maxField.setMaxStringLength(3);
    maxField.setInputValidator(InputValidator.DIGIT);
    maxField.configureDigitalBorderInput(() -> setText(maxField, GuiInteraction.SET_MAX_Y));
    // Note: We add this after all the buttons have their warnings added so that it is further down the tracker
    // so the tracker can short circuit on this type of warning and not have to check all the filters if one of
    // the ones that are currently being shown has the warning
    trackWarning(WarningType.FILTER_HAS_BLACKLISTED_ELEMENT, () -> tile.getFilters().stream().anyMatch(MinerFilter::hasBlacklistedElement));
}
Also used : GuiTextField(mekanism.client.gui.element.text.GuiTextField) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) Item(net.minecraft.item.Item) FilterButton(mekanism.client.gui.element.button.FilterButton) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) InputValidator(mekanism.common.util.text.InputValidator) YesNo(mekanism.common.util.text.BooleanStateDisplay.YesNo) GuiMinerTagFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerTagFilter) MinerModIDFilter(mekanism.common.content.miner.MinerModIDFilter) TranslationButton(mekanism.client.gui.element.button.TranslationButton) ClickedTileButton(mekanism.common.network.to_server.PacketGuiButtonPress.ClickedTileButton) SlotType(mekanism.client.gui.element.slot.SlotType) ITagFilter(mekanism.common.content.filter.ITagFilter) GuiMinerModIDFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerModIDFilter) MekanismUtils(mekanism.common.util.MekanismUtils) GuiFilterHolder(mekanism.client.gui.GuiFilterHolder) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) IModIDFilter(mekanism.common.content.filter.IModIDFilter) BlockItem(net.minecraft.item.BlockItem) GuiInteraction(mekanism.common.network.to_server.PacketGuiInteract.GuiInteraction) MekanismLang(mekanism.common.MekanismLang) IFilter(mekanism.common.content.filter.IFilter) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) MinerItemStackFilter(mekanism.common.content.miner.MinerItemStackFilter) SimpleSound(net.minecraft.client.audio.SimpleSound) GuiMinerItemStackFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerItemStackFilter) TileEntityDigitalMiner(mekanism.common.tile.machine.TileEntityDigitalMiner) ITextComponent(net.minecraft.util.text.ITextComponent) WarningType(mekanism.client.gui.warning.WarningTracker.WarningType) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) GuiInteractionItem(mekanism.common.network.to_server.PacketGuiInteract.GuiInteractionItem) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) Nonnull(javax.annotation.Nonnull) GuiMinerMaterialFilter(mekanism.client.gui.element.window.filter.miner.GuiMinerMaterialFilter) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GuiDigitalSwitch(mekanism.client.gui.element.GuiDigitalSwitch) Mekanism(mekanism.common.Mekanism) PlayerInventory(net.minecraft.entity.player.PlayerInventory) GuiMinerFilerSelect(mekanism.client.gui.element.window.filter.miner.GuiMinerFilerSelect) IMaterialFilter(mekanism.common.content.filter.IMaterialFilter) SwitchType(mekanism.client.gui.element.GuiDigitalSwitch.SwitchType) MinerFilter(mekanism.common.content.miner.MinerFilter) Items(net.minecraft.item.Items) SoundEvents(net.minecraft.util.SoundEvents) IItemStackFilter(mekanism.common.content.filter.IItemStackFilter) MekanismTileContainer(mekanism.common.inventory.container.tile.MekanismTileContainer) ResourceLocation(net.minecraft.util.ResourceLocation) MinerMaterialFilter(mekanism.common.content.miner.MinerMaterialFilter) MekanismConfig(mekanism.common.config.MekanismConfig) MinerTagFilter(mekanism.common.content.miner.MinerTagFilter) TagCache(mekanism.common.base.TagCache) PacketGuiButtonPress(mekanism.common.network.to_server.PacketGuiButtonPress) TranslationButton(mekanism.client.gui.element.button.TranslationButton) GuiDigitalSwitch(mekanism.client.gui.element.GuiDigitalSwitch) GuiMinerFilerSelect(mekanism.client.gui.element.window.filter.miner.GuiMinerFilerSelect) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) PacketGuiInteract(mekanism.common.network.to_server.PacketGuiInteract) ItemStack(net.minecraft.item.ItemStack) GuiTextField(mekanism.client.gui.element.text.GuiTextField) BlockItem(net.minecraft.item.BlockItem)

Aggregations

PacketGuiButtonPress (mekanism.common.network.to_server.PacketGuiButtonPress)7 MekanismImageButton (mekanism.client.gui.element.button.MekanismImageButton)6 List (java.util.List)2 GuiDigitalSwitch (mekanism.client.gui.element.GuiDigitalSwitch)2 GuiInnerScreen (mekanism.client.gui.element.GuiInnerScreen)2 TranslationButton (mekanism.client.gui.element.button.TranslationButton)2 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)2 GuiSecurityTab (mekanism.client.gui.element.tab.GuiSecurityTab)2 PacketGuiInteract (mekanism.common.network.to_server.PacketGuiInteract)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 FloatingLong (mekanism.api.math.FloatingLong)1 ILangEntry (mekanism.api.text.ILangEntry)1 GuiFilterHolder (mekanism.client.gui.GuiFilterHolder)1 SwitchType (mekanism.client.gui.element.GuiDigitalSwitch.SwitchType)1 GuiHorizontalPowerBar (mekanism.client.gui.element.bar.GuiHorizontalPowerBar)1 GuiVerticalPowerBar (mekanism.client.gui.element.bar.GuiVerticalPowerBar)1 FilterButton (mekanism.client.gui.element.button.FilterButton)1 SlotType (mekanism.client.gui.element.slot.SlotType)1