Search in sources :

Example 1 with GuiMekanismTile

use of mekanism.client.gui.GuiMekanismTile in project Mekanism by mekanism.

the class GuiTankGauge method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    if (isMouseOver(mouseX, mouseY) && tankType != null) {
        ItemStack stack = minecraft.player.inventory.getCarried();
        if (gui() instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) {
            int index = infoHandler.getTankIndex();
            if (index != -1) {
                DropperAction action;
                if (button == 0) {
                    action = Screen.hasShiftDown() ? DropperAction.DUMP_TANK : DropperAction.FILL_DROPPER;
                } else {
                    action = DropperAction.DRAIN_DROPPER;
                }
                Mekanism.packetHandler.sendToServer(new PacketDropperUse(((GuiMekanismTile<?, ?>) gui()).getTileEntity().getBlockPos(), action, tankType, index));
            }
            return true;
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : DropperAction(mekanism.common.network.to_server.PacketDropperUse.DropperAction) PacketDropperUse(mekanism.common.network.to_server.PacketDropperUse) ItemGaugeDropper(mekanism.common.item.ItemGaugeDropper) ItemStack(net.minecraft.item.ItemStack) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile)

Example 2 with GuiMekanismTile

use of mekanism.client.gui.GuiMekanismTile in project Mekanism by mekanism.

the class GuiGauge method renderToolTip.

@Override
public void renderToolTip(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
    super.renderToolTip(matrix, mouseX, mouseY);
    ItemStack stack = minecraft.player.inventory.getCarried();
    EnumColor color = getGaugeColor().getColor();
    if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurator && color != null) {
        if (gui() instanceof GuiMekanismTile) {
            TileEntityMekanism tile = ((GuiMekanismTile<?, ?>) gui()).getTileEntity();
            if (tile instanceof ISideConfiguration && getTransmission() != null) {
                DataType dataType = null;
                ConfigInfo config = ((ISideConfiguration) tile).getConfig().getConfig(getTransmission());
                if (config != null) {
                    Set<DataType> supportedDataTypes = config.getSupportedDataTypes();
                    for (DataType type : supportedDataTypes) {
                        if (type.getColor() == color) {
                            dataType = type;
                            break;
                        }
                    }
                }
                if (dataType == null) {
                    displayTooltip(matrix, MekanismLang.GENERIC_PARENTHESIS.translateColored(color, color.getName()), mouseX, mouseY);
                } else {
                    displayTooltip(matrix, MekanismLang.GENERIC_WITH_PARENTHESIS.translateColored(color, dataType, color.getName()), mouseX, mouseY);
                }
            }
        }
    } else {
        List<ITextComponent> list = new ArrayList<>();
        if (getLabel() != null) {
            list.add(getLabel());
        }
        list.addAll(getTooltipText());
        displayTooltips(matrix, list, mouseX, mouseY);
    }
}
Also used : TileEntityMekanism(mekanism.common.tile.base.TileEntityMekanism) EnumColor(mekanism.api.text.EnumColor) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) ItemConfigurator(mekanism.common.item.ItemConfigurator) DataType(mekanism.common.tile.component.config.DataType) ItemStack(net.minecraft.item.ItemStack) ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile) ISideConfiguration(mekanism.common.tile.interfaces.ISideConfiguration)

Example 3 with GuiMekanismTile

use of mekanism.client.gui.GuiMekanismTile in project Mekanism by mekanism.

the class GuiTankBar method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    if (isMouseOver(mouseX, mouseY)) {
        ItemStack stack = Minecraft.getInstance().player.inventory.getCarried();
        if (gui() instanceof GuiMekanismTile && !stack.isEmpty() && stack.getItem() instanceof ItemGaugeDropper) {
            TankType tankType = getType(getHandler().getStack());
            if (tankType != null) {
                int index = getHandler().getTankIndex();
                if (index != -1) {
                    DropperAction action;
                    if (button == 0) {
                        action = Screen.hasShiftDown() ? DropperAction.DUMP_TANK : DropperAction.FILL_DROPPER;
                    } else {
                        action = DropperAction.DRAIN_DROPPER;
                    }
                    Mekanism.packetHandler.sendToServer(new PacketDropperUse(((GuiMekanismTile<?, ?>) gui()).getTileEntity().getBlockPos(), action, tankType, index));
                }
                return true;
            }
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : DropperAction(mekanism.common.network.to_server.PacketDropperUse.DropperAction) PacketDropperUse(mekanism.common.network.to_server.PacketDropperUse) ItemGaugeDropper(mekanism.common.item.ItemGaugeDropper) TankType(mekanism.common.network.to_server.PacketDropperUse.TankType) ItemStack(net.minecraft.item.ItemStack) GuiMekanismTile(mekanism.client.gui.GuiMekanismTile)

Aggregations

GuiMekanismTile (mekanism.client.gui.GuiMekanismTile)3 ItemStack (net.minecraft.item.ItemStack)3 ItemGaugeDropper (mekanism.common.item.ItemGaugeDropper)2 PacketDropperUse (mekanism.common.network.to_server.PacketDropperUse)2 DropperAction (mekanism.common.network.to_server.PacketDropperUse.DropperAction)2 ArrayList (java.util.ArrayList)1 EnumColor (mekanism.api.text.EnumColor)1 ItemConfigurator (mekanism.common.item.ItemConfigurator)1 TankType (mekanism.common.network.to_server.PacketDropperUse.TankType)1 TileEntityMekanism (mekanism.common.tile.base.TileEntityMekanism)1 ConfigInfo (mekanism.common.tile.component.config.ConfigInfo)1 DataType (mekanism.common.tile.component.config.DataType)1 ISideConfiguration (mekanism.common.tile.interfaces.ISideConfiguration)1 ITextComponent (net.minecraft.util.text.ITextComponent)1