Search in sources :

Example 1 with GuiLogisticsLiquidFilter

use of pneumaticCraft.client.gui.semiblock.GuiLogisticsLiquidFilter in project PneumaticCraft by MineMaarten.

the class GuiAmadronAddTrade method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    ContainerAmadronAddTrade container = (ContainerAmadronAddTrade) inventorySlots;
    if (button.id < 6 && button.id >= 0) {
        isSettingInput = button.id < 3;
        if (button.id % 3 == 0) {
            searchGui = new GuiSearcher(player);
            searchGui.setSearchStack(container.getStack(isSettingInput ? 0 : 1));
            FMLClientHandler.instance().showGuiScreen(searchGui);
        } else if (button.id % 3 == 1) {
            invSearchGui = new GuiInventorySearcher(player);
            invSearchGui.setSearchStack(container.getStack(isSettingInput ? 0 : 1));
            FMLClientHandler.instance().showGuiScreen(invSearchGui);
        } else if (button.id % 3 == 2) {
            fluidGui = new GuiLogisticsLiquidFilter(this);
            fluidGui.setFilter(isSettingInput ? inputFluid.getFluid() : outputFluid.getFluid());
            FMLClientHandler.instance().showGuiScreen(fluidGui);
        }
    } else if (button.id == 8) {
        Object input;
        if (container.getStack(0) != null) {
            input = container.getStack(0).copy();
            ((ItemStack) input).stackSize = inputNumber.getValue();
        } else {
            input = new FluidStack(inputFluid.getFluid(), inputNumber.getValue());
        }
        Object output;
        if (container.getStack(1) != null) {
            output = container.getStack(1).copy();
            ((ItemStack) output).stackSize = outputNumber.getValue();
        } else {
            output = new FluidStack(outputFluid.getFluid(), outputNumber.getValue());
        }
        AmadronOfferCustom trade = new AmadronOfferCustom(input, output, player);
        ChunkPosition pos = getInputPosition();
        int dimensionId = getInputDimension();
        trade.setProvidingPosition(pos, dimensionId);
        pos = getOutputPosition();
        dimensionId = getOutputDimension();
        trade.setReturningPosition(pos, dimensionId);
        NetworkHandler.sendToServer(new PacketAmadronTradeAdd(trade.invert()));
        player.closeScreen();
    }
    super.actionPerformed(button);
}
Also used : ContainerAmadronAddTrade(pneumaticCraft.common.inventory.ContainerAmadronAddTrade) FluidStack(net.minecraftforge.fluids.FluidStack) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketAmadronTradeAdd(pneumaticCraft.common.network.PacketAmadronTradeAdd) GuiLogisticsLiquidFilter(pneumaticCraft.client.gui.semiblock.GuiLogisticsLiquidFilter) ItemStack(net.minecraft.item.ItemStack) AmadronOfferCustom(pneumaticCraft.common.recipes.AmadronOfferCustom)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 ChunkPosition (net.minecraft.world.ChunkPosition)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 GuiLogisticsLiquidFilter (pneumaticCraft.client.gui.semiblock.GuiLogisticsLiquidFilter)1 ContainerAmadronAddTrade (pneumaticCraft.common.inventory.ContainerAmadronAddTrade)1 PacketAmadronTradeAdd (pneumaticCraft.common.network.PacketAmadronTradeAdd)1 AmadronOfferCustom (pneumaticCraft.common.recipes.AmadronOfferCustom)1