本文整理匯總了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);
}
}
}
示例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)});
}
}
}
}
示例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)});
}
}
}
}