Search in sources :

Example 1 with PotionConsume

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

the class ItemKKPotion method getItem.

public static void getItem(EntityPlayer player, World world, String item, int slot) {
    while (ItemStack.areItemStacksEqual(player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().getStackInSlot(slot), ItemStack.EMPTY)) {
        slot++;
    }
    switch(item) {
        case Strings.Potion:
            ((ItemKKPotion) ModItems.Potion).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.Potion));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.HiPotion:
            ((ItemKKPotion) ModItems.HiPotion).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.HiPotion));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.MegaPotion:
            ((ItemKKPotion) ModItems.MegaPotion).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.MegaPotion));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.Ether:
            ((ItemKKPotion) ModItems.Ether).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.Ether));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.MegaEther:
            ((ItemKKPotion) ModItems.MegaEther).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.MegaEther));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.Elixir:
            ((ItemKKPotion) ModItems.Elixir).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.Elixir));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.Megalixir:
            ((ItemKKPotion) ModItems.Megalixir).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.Megalixir));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.DriveRecovery:
            ((ItemKKPotion) ModItems.DriveRecovery).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.DriveRecovery));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.HighDriveRecovery:
            ((ItemKKPotion) ModItems.HighDriveRecovery).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.HighDriveRecovery));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        case Strings.Panacea:
            ((ItemKKPotion) ModItems.Panacaea).getPotionEffect(player);
            player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 1.0f, 1.0f);
            player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu().setStackInSlot(slot, ItemStack.EMPTY);
            PacketDispatcher.sendToServer(new PotionConsume(Strings.Panacea));
            PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.Potion, slot, true));
            break;
        default:
            break;
    }
}
Also used : RemoveItemInSlot(uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot) PotionConsume(uk.co.wehavecookies56.kk.common.network.packet.server.PotionConsume)

Aggregations

PotionConsume (uk.co.wehavecookies56.kk.common.network.packet.server.PotionConsume)1 RemoveItemInSlot (uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot)1