Search in sources :

Example 1 with RemoveItemInSlot

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

Example 2 with RemoveItemInSlot

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

the class ItemMagicBoost method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    player.getActiveItemStack().setCount(player.getActiveItemStack().getCount() - 1);
    if (world.isRemote) {
        PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.MagicBoost, player.inventory.currentItem));
    }
    player.world.playSound(player, player.getPosition(), ModSounds.itemget, SoundCategory.MASTER, 1.0f, 1.0f);
    return super.onItemRightClick(world, player, hand);
}
Also used : RemoveItemInSlot(uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot)

Example 3 with RemoveItemInSlot

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

the class ItemPowerBoost method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    player.getActiveItemStack().setCount(player.getActiveItemStack().getCount() - 1);
    if (world.isRemote) {
        PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.PowerBoost, player.inventory.currentItem));
    }
    player.world.playSound(player, player.getPosition(), ModSounds.itemget, SoundCategory.MASTER, 1.0f, 1.0f);
    return super.onItemRightClick(world, player, hand);
}
Also used : RemoveItemInSlot(uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot)

Example 4 with RemoveItemInSlot

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

the class ItemDefenseBoost method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    player.getActiveItemStack().setCount(player.getActiveItemStack().getCount() - 1);
    if (world.isRemote) {
        PacketDispatcher.sendToServer(new RemoveItemInSlot(Strings.DefenseBoost, player.inventory.currentItem));
    }
    player.world.playSound(player, player.getPosition(), ModSounds.itemget, SoundCategory.MASTER, 1.0f, 1.0f);
    return super.onItemRightClick(world, player, hand);
}
Also used : RemoveItemInSlot(uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot)

Example 5 with RemoveItemInSlot

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

the class CommandOpenKeyInv method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
        if (args.length > 1) {
            TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
        } else {
            EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
            if (args.length == 1) {
                if (getPlayerFromUsername(args[0]) != null) {
                    player = getPlayerFromUsername(args[0]);
                }
            }
            ISummonKeyblade KEYBLADE = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
            GuiHelper.openInv(GuiIDs.GUI_KEYCHAIN_INV);
        /*  if (!ItemStack.areItemStacksEqual(KEYBLADE.getInventoryKeychain().getStackInSlot(slot), ItemStack.EMPTY)) {
                    PacketDispatcher.sendToServer(new RemoveItemInSlot("keychain", slot));
                    PacketDispatcher.sendToAllAround(new RemoveItemInSlot("keychain", slot), (EntityPlayer) sender.getCommandSenderEntity(), 1);

                    if (sender.getCommandSenderEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getIsKeybladeSummoned(EnumHand.MAIN_HAND))
                        if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY) && player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemKeyblade)
                            //player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, true);
                        PacketDispatcher.sendToServer(new DeSummonKeyblade());
                    	if(args.length == 2)
                    		TextHelper.sendFormattedChatMessage(args[1] + "'s keychain has been removed!", TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
                    	else
                    		TextHelper.sendFormattedChatMessage("Your keychain has been removed!", TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
                } else
                    TextHelper.sendFormattedChatMessage("The chain slot has no chain!", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
                */
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISummonKeyblade(uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability.ISummonKeyblade)

Aggregations

RemoveItemInSlot (uk.co.wehavecookies56.kk.common.network.packet.server.RemoveItemInSlot)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ISummonKeyblade (uk.co.wehavecookies56.kk.common.capability.SummonKeybladeCapability.ISummonKeyblade)1 PotionConsume (uk.co.wehavecookies56.kk.common.network.packet.server.PotionConsume)1