Search in sources :

Example 1 with PacketAmadronTradeAdd

use of me.desht.pneumaticcraft.common.network.PacketAmadronTradeAdd in project pnc-repressurized by TeamPneumatic.

the class GuiAmadronAddTrade method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    EntityPlayer player = FMLClientHandler.instance().getClient().player;
    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).isEmpty()) {
            input = container.getStack(0).copy();
            ((ItemStack) input).setCount(inputNumber.getValue());
        } else {
            input = new FluidStack(inputFluid.getFluid(), inputNumber.getValue());
        }
        Object output;
        if (!container.getStack(1).isEmpty()) {
            output = container.getStack(1).copy();
            ((ItemStack) output).setCount(outputNumber.getValue());
        } else {
            output = new FluidStack(outputFluid.getFluid(), outputNumber.getValue());
        }
        AmadronOfferCustom trade = new AmadronOfferCustom(input, output, player);
        BlockPos 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(me.desht.pneumaticcraft.common.inventory.ContainerAmadronAddTrade) FluidStack(net.minecraftforge.fluids.FluidStack) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketAmadronTradeAdd(me.desht.pneumaticcraft.common.network.PacketAmadronTradeAdd) GuiLogisticsLiquidFilter(me.desht.pneumaticcraft.client.gui.semiblock.GuiLogisticsLiquidFilter) BlockPos(net.minecraft.util.math.BlockPos) AmadronOfferCustom(me.desht.pneumaticcraft.common.recipes.AmadronOfferCustom)

Aggregations

GuiLogisticsLiquidFilter (me.desht.pneumaticcraft.client.gui.semiblock.GuiLogisticsLiquidFilter)1 ContainerAmadronAddTrade (me.desht.pneumaticcraft.common.inventory.ContainerAmadronAddTrade)1 PacketAmadronTradeAdd (me.desht.pneumaticcraft.common.network.PacketAmadronTradeAdd)1 AmadronOfferCustom (me.desht.pneumaticcraft.common.recipes.AmadronOfferCustom)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 FluidStack (net.minecraftforge.fluids.FluidStack)1