Search in sources :

Example 1 with WidgetFluidStack

use of me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack in project pnc-repressurized by TeamPneumatic.

the class GuiLogisticsBase method initGui.

@Override
public void initGui() {
    super.initGui();
    if (searchGui != null) {
        inventorySlots.getSlot(editingSlot).putStack(searchGui.getSearchStack());
        NetworkHandler.sendToServer(new PacketSetLogisticsFilterStack(logistics, searchGui.getSearchStack(), editingSlot));
        searchGui = null;
    }
    if (fluidSearchGui != null && fluidSearchGui.getFilter() != null) {
        FluidStack filter = new FluidStack(fluidSearchGui.getFilter(), 1000);
        logistics.setFilter(editingSlot, filter);
        NetworkHandler.sendToServer(new PacketSetLogisticsFluidFilterStack(logistics, filter, editingSlot));
        fluidSearchGui = null;
    }
    String invisibleText = I18n.format("gui.logistic_frame.invisible");
    addWidget(invisible = new GuiCheckBox(9, guiLeft + xSize - 15 - fontRenderer.getStringWidth(invisibleText), guiTop + 7, 0xFF404040, invisibleText));
    invisible.setTooltip(Arrays.asList(WordUtils.wrap(I18n.format("gui.logistic_frame.invisible.tooltip"), 40).split(System.getProperty("line.separator"))));
    addWidget(new WidgetLabel(guiLeft + 8, guiTop + 18, I18n.format(String.format("gui.%s.filters", SemiBlockManager.getKeyForSemiBlock(logistics)))));
    addWidget(new WidgetLabel(guiLeft + 8, guiTop + 90, I18n.format("gui.logistic_frame.liquid")));
    for (int i = 0; i < 9; i++) {
        addWidget(new WidgetFluidStack(i, guiLeft + i * 18 + 8, guiTop + 101, logistics.getTankFilter(i)));
    }
    addInfoTab(I18n.format("gui.tab.info." + SemiBlockManager.getKeyForSemiBlock(logistics)));
}
Also used : WidgetLabel(me.desht.pneumaticcraft.client.gui.widget.WidgetLabel) PacketSetLogisticsFilterStack(me.desht.pneumaticcraft.common.network.PacketSetLogisticsFilterStack) PacketSetLogisticsFluidFilterStack(me.desht.pneumaticcraft.common.network.PacketSetLogisticsFluidFilterStack) WidgetFluidStack(me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack) FluidStack(net.minecraftforge.fluids.FluidStack) WidgetFluidStack(me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack) GuiCheckBox(me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox)

Example 2 with WidgetFluidStack

use of me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack in project pnc-repressurized by TeamPneumatic.

the class GuiLogisticsBase method actionPerformed.

@Override
public void actionPerformed(IGuiWidget widget) {
    super.actionPerformed(widget);
    if (widget instanceof WidgetFluidStack) {
        boolean leftClick = Mouse.isButtonDown(0);
        boolean middleClick = Mouse.isButtonDown(2);
        boolean shift = PneumaticCraftRepressurized.proxy.isSneakingInGui();
        IFluidTank tank = logistics.getTankFilter(widget.getID());
        if (tank.getFluidAmount() > 0) {
            if (middleClick) {
                logistics.setFilter(widget.getID(), null);
            } else if (leftClick) {
                tank.drain(shift ? tank.getFluidAmount() / 2 : 1000, true);
                if (tank.getFluidAmount() < 1000) {
                    tank.drain(1000, true);
                }
            } else {
                tank.fill(new FluidStack(tank.getFluid().getFluid(), shift ? tank.getFluidAmount() : 1000), true);
            }
            NetworkHandler.sendToServer(new PacketSetLogisticsFluidFilterStack(logistics, tank.getFluid(), widget.getID()));
        } else {
            fluidSearchGui = new GuiLogisticsLiquidFilter(this);
            editingSlot = widget.getID();
            mc.displayGuiScreen(fluidSearchGui);
        }
    }
}
Also used : PacketSetLogisticsFluidFilterStack(me.desht.pneumaticcraft.common.network.PacketSetLogisticsFluidFilterStack) WidgetFluidStack(me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack) FluidStack(net.minecraftforge.fluids.FluidStack) WidgetFluidStack(me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Aggregations

WidgetFluidStack (me.desht.pneumaticcraft.client.gui.widget.WidgetFluidStack)2 PacketSetLogisticsFluidFilterStack (me.desht.pneumaticcraft.common.network.PacketSetLogisticsFluidFilterStack)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 GuiCheckBox (me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox)1 WidgetLabel (me.desht.pneumaticcraft.client.gui.widget.WidgetLabel)1 PacketSetLogisticsFilterStack (me.desht.pneumaticcraft.common.network.PacketSetLogisticsFilterStack)1 IFluidTank (net.minecraftforge.fluids.IFluidTank)1