Search in sources :

Example 1 with GiveBoughtItem

use of uk.co.wehavecookies56.kk.common.network.packet.server.GiveBoughtItem in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class GuiShop method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) throws IOException {
    switch(button.id) {
        case BUY:
            submenu = BUY;
            break;
        case SELL:
            submenu = SELL;
            break;
        case BACK:
            submenu = HOME;
            buySelected = -1;
            sellSelected = -1;
            break;
        case BUYCONFIRM:
            if (buySelected != -1) {
                if (canAffordSelected()) {
                    ItemStack stack = GuiBuyList.itemsForSale.get(buySelected);
                    if (!quantity.getText().isEmpty())
                        stack.setCount(Integer.parseInt(quantity.getText()));
                    PacketDispatcher.sendToServer(new GiveBoughtItem(getPriceFromSelected(buySelected, false, Integer.parseInt(quantity.getText())), stack.getCount(), stack));
                    buySelected = -1;
                    quantity.setText("0");
                }
            }
            break;
        case SELLCONFIRM:
            if (sellSelected != -1) {
                int amount = 0;
                if (!quantity.getText().isEmpty())
                    amount = Integer.parseInt(quantity.getText());
                PacketDispatcher.sendToServer(new TakeSoldItem(getPriceFromSelected(sellSelected, true, Integer.parseInt(quantity.getText())) / 2, amount, GuiSellList.sellableItems.get(sellSelected)));
                sellSelected = -1;
                quantity.setText("0");
            }
            sellList.occupyList();
            break;
        case SYNTHESIS:
            PacketDispatcher.sendToServer(new OpenSynthesis());
            Minecraft.getMinecraft().displayGuiScreen(new GuiSynthesis(this));
            break;
    }
    updateButtons();
}
Also used : TakeSoldItem(uk.co.wehavecookies56.kk.common.network.packet.server.TakeSoldItem) ItemStack(net.minecraft.item.ItemStack) OpenSynthesis(uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis) GiveBoughtItem(uk.co.wehavecookies56.kk.common.network.packet.server.GiveBoughtItem)

Aggregations

ItemStack (net.minecraft.item.ItemStack)1 GiveBoughtItem (uk.co.wehavecookies56.kk.common.network.packet.server.GiveBoughtItem)1 OpenSynthesis (uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis)1 TakeSoldItem (uk.co.wehavecookies56.kk.common.network.packet.server.TakeSoldItem)1