Search in sources :

Example 1 with IGhostBlockItemConsumer

use of mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer in project Mekanism by mekanism.

the class GuiMinerFilterHelper method addMinerDefaults.

default void addMinerDefaults(IGuiWrapper gui, MinerFilter<?> filter, int slotOffset, UnaryOperator<GuiElement> childAdder) {
    childAdder.apply(new GuiSlot(SlotType.NORMAL, gui, getRelativeX() + 148, getRelativeY() + slotOffset).setRenderHover(true).stored(() -> new ItemStack(filter.replaceTarget)).setGhostHandler((IGhostBlockItemConsumer) ingredient -> {
        filter.replaceTarget = ((ItemStack) ingredient).getItem();
        Minecraft.getInstance().getSoundManager().play(SimpleSound.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
    }));
    childAdder.apply(new MekanismImageButton(gui, getRelativeX() + 148, getRelativeY() + 45, 14, 16, MekanismUtils.getResource(ResourceType.GUI_BUTTON, "exclamation.png"), () -> filter.requiresReplacement = !filter.requiresReplacement, (onHover, matrix, xAxis, yAxis) -> gui.displayTooltip(matrix, MekanismLang.MINER_REQUIRE_REPLACE.translate(YesNo.of(filter.requiresReplacement)), xAxis, yAxis)));
}
Also used : GuiFilter(mekanism.client.gui.element.window.filter.GuiFilter) SimpleSound(net.minecraft.client.audio.SimpleSound) GuiElement(mekanism.client.gui.element.GuiElement) SlotType(mekanism.client.gui.element.slot.SlotType) ResourceType(mekanism.common.util.MekanismUtils.ResourceType) UnaryOperator(java.util.function.UnaryOperator) MinerFilter(mekanism.common.content.miner.MinerFilter) TileEntityDigitalMiner(mekanism.common.tile.machine.TileEntityDigitalMiner) SoundEvents(net.minecraft.util.SoundEvents) MekanismUtils(mekanism.common.util.MekanismUtils) ItemStack(net.minecraft.item.ItemStack) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) Minecraft(net.minecraft.client.Minecraft) IGuiWrapper(mekanism.client.gui.IGuiWrapper) YesNo(mekanism.common.util.text.BooleanStateDisplay.YesNo) GuiFilterHelper(mekanism.client.gui.element.window.filter.GuiFilterHelper) MekanismLang(mekanism.common.MekanismLang) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) IGhostBlockItemConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer) MekanismImageButton(mekanism.client.gui.element.button.MekanismImageButton) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IGhostBlockItemConsumer

use of mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer 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

MekanismImageButton (mekanism.client.gui.element.button.MekanismImageButton)2 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)2 SlotType (mekanism.client.gui.element.slot.SlotType)2 IGhostBlockItemConsumer (mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostBlockItemConsumer)2 MekanismLang (mekanism.common.MekanismLang)2 MinerFilter (mekanism.common.content.miner.MinerFilter)2 TileEntityDigitalMiner (mekanism.common.tile.machine.TileEntityDigitalMiner)2 MekanismUtils (mekanism.common.util.MekanismUtils)2 ResourceType (mekanism.common.util.MekanismUtils.ResourceType)2 YesNo (mekanism.common.util.text.BooleanStateDisplay.YesNo)2 Minecraft (net.minecraft.client.Minecraft)2 SimpleSound (net.minecraft.client.audio.SimpleSound)2 ItemStack (net.minecraft.item.ItemStack)2 SoundEvents (net.minecraft.util.SoundEvents)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 List (java.util.List)1 UnaryOperator (java.util.function.UnaryOperator)1 Nonnull (javax.annotation.Nonnull)1 GuiFilterHolder (mekanism.client.gui.GuiFilterHolder)1 IGuiWrapper (mekanism.client.gui.IGuiWrapper)1