当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayerMP.updateHeldItem方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayerMP.updateHeldItem方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayerMP.updateHeldItem方法的具体用法?Java EntityPlayerMP.updateHeldItem怎么用?Java EntityPlayerMP.updateHeldItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayerMP的用法示例。


在下文中一共展示了EntityPlayerMP.updateHeldItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialiseInventory

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
private void initialiseInventory(EntityPlayerMP player, Inventory inventory)
{
    // Clear inventory:
    player.inventory.func_174925_a(null, -1, -1, null);
    player.inventoryContainer.detectAndSendChanges();
    if (!player.capabilities.isCreativeMode)
        player.updateHeldItem();

    // Now add specified items:
    for (JAXBElement<? extends InventoryObjectType> el : inventory.getInventoryObject())
    {
        InventoryObjectType obj = el.getValue();
        DrawItem di = new DrawItem();
        di.setColour(obj.getColour());
        di.setVariant(obj.getVariant());
        di.setType(obj.getType());
        ItemStack item = MinecraftTypeHelper.getItemStackFromDrawItem(di);
        if( item != null )
        {
            item.stackSize = obj.getQuantity();
            player.inventory.setInventorySlotContents(obj.getSlot(), item);
        }
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:25,代码来源:ServerStateMachine.java

示例2: processCommand

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    EntityPlayerMP entityplayermp = args.length == 0 ? getCommandSenderAsPlayer(sender) : getPlayer(sender, args[0]);
    Item item = args.length >= 2 ? getItemByText(sender, args[1]) : null;
    int i = args.length >= 3 ? parseInt(args[2], -1) : -1;
    int j = args.length >= 4 ? parseInt(args[3], -1) : -1;
    NBTTagCompound nbttagcompound = null;

    if (args.length >= 5)
    {
        try
        {
            nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 4));
        }
        catch (NBTException nbtexception)
        {
            throw new CommandException("commands.clear.tagError", new Object[] {nbtexception.getMessage()});
        }
    }

    if (args.length >= 2 && item == null)
    {
        throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getName()});
    }
    else
    {
        int k = entityplayermp.inventory.clearMatchingItems(item, i, j, nbttagcompound);
        entityplayermp.inventoryContainer.detectAndSendChanges();

        if (!entityplayermp.capabilities.isCreativeMode)
        {
            entityplayermp.updateHeldItem();
        }

        sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, k);

        if (k == 0)
        {
            throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getName()});
        }
        else
        {
            if (j == 0)
            {
                sender.addChatMessage(new ChatComponentTranslation("commands.clear.testing", new Object[] {entityplayermp.getName(), Integer.valueOf(k)}));
            }
            else
            {
                notifyOperators(sender, this, "commands.clear.success", new Object[] {entityplayermp.getName(), Integer.valueOf(k)});
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:57,代码来源:CommandClearInventory.java

示例3: execute

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    EntityPlayerMP entityplayermp = args.length == 0 ? getCommandSenderAsPlayer(sender) : getPlayer(server, sender, args[0]);
    Item item = args.length >= 2 ? getItemByText(sender, args[1]) : null;
    int i = args.length >= 3 ? parseInt(args[2], -1) : -1;
    int j = args.length >= 4 ? parseInt(args[3], -1) : -1;
    NBTTagCompound nbttagcompound = null;

    if (args.length >= 5)
    {
        try
        {
            nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 4));
        }
        catch (NBTException nbtexception)
        {
            throw new CommandException("commands.clear.tagError", new Object[] {nbtexception.getMessage()});
        }
    }

    if (args.length >= 2 && item == null)
    {
        throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getName()});
    }
    else
    {
        int k = entityplayermp.inventory.clearMatchingItems(item, i, j, nbttagcompound);
        entityplayermp.inventoryContainer.detectAndSendChanges();

        if (!entityplayermp.capabilities.isCreativeMode)
        {
            entityplayermp.updateHeldItem();
        }

        sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, k);

        if (k == 0)
        {
            throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getName()});
        }
        else
        {
            if (j == 0)
            {
                sender.addChatMessage(new TextComponentTranslation("commands.clear.testing", new Object[] {entityplayermp.getName(), Integer.valueOf(k)}));
            }
            else
            {
                notifyCommandListener(sender, this, "commands.clear.success", new Object[] {entityplayermp.getName(), Integer.valueOf(k)});
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:57,代码来源:CommandClearInventory.java


注:本文中的net.minecraft.entity.player.EntityPlayerMP.updateHeldItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。