Search in sources :

Example 1 with OpenSynthesis

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

the class BlockSynthesisTable method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, ModSounds.kupo, SoundCategory.BLOCKS, 0.5F, 1.0F);
    if (world.isRemote)
        PacketDispatcher.sendToServer(new OpenSynthesis());
    player.openGui(KingdomKeys.instance, GuiIDs.GUI_SYNTHESISTABLE, world, pos.getX(), pos.getY(), pos.getZ());
    if (!world.isRemote) {
        PacketDispatcher.sendTo(new SyncRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
        PacketDispatcher.sendTo(new SyncFreeDevRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
        PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
    }
    return true;
}
Also used : SyncRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncRecipeData) SyncFreeDevRecipeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncFreeDevRecipeData) OpenSynthesis(uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis) SyncMaterialData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)

Example 2 with OpenSynthesis

use of uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis 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

OpenSynthesis (uk.co.wehavecookies56.kk.common.network.packet.server.OpenSynthesis)2 ItemStack (net.minecraft.item.ItemStack)1 SyncFreeDevRecipeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncFreeDevRecipeData)1 SyncMaterialData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData)1 SyncRecipeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncRecipeData)1 GiveBoughtItem (uk.co.wehavecookies56.kk.common.network.packet.server.GiveBoughtItem)1 TakeSoldItem (uk.co.wehavecookies56.kk.common.network.packet.server.TakeSoldItem)1