本文整理汇总了Java中net.minecraft.entity.item.EntityItem.setNoPickupDelay方法的典型用法代码示例。如果您正苦于以下问题:Java EntityItem.setNoPickupDelay方法的具体用法?Java EntityItem.setNoPickupDelay怎么用?Java EntityItem.setNoPickupDelay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.item.EntityItem
的用法示例。
在下文中一共展示了EntityItem.setNoPickupDelay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(sender, args[0]);
Item item = getItemByText(sender, args[1]);
int i = args.length >= 3 ? parseInt(args[2], 1, 64) : 1;
int j = args.length >= 4 ? parseInt(args[3]) : 0;
ItemStack itemstack = new ItemStack(item, i, j);
if (args.length >= 5)
{
String s = getChatComponentFromNthArg(sender, args, 4).getUnformattedText();
try
{
itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.give.tagError", new Object[] {nbtexception.getMessage()});
}
}
boolean flag = entityplayer.inventory.addItemStackToInventory(itemstack);
if (flag)
{
entityplayer.worldObj.playSoundAtEntity(entityplayer, "random.pop", 0.2F, ((entityplayer.getRNG().nextFloat() - entityplayer.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.inventoryContainer.detectAndSendChanges();
}
if (flag && itemstack.stackSize <= 0)
{
itemstack.stackSize = 1;
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i);
EntityItem entityitem1 = entityplayer.dropPlayerItemWithRandomChoice(itemstack, false);
if (entityitem1 != null)
{
entityitem1.func_174870_v();
}
}
else
{
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i - itemstack.stackSize);
EntityItem entityitem = entityplayer.dropPlayerItemWithRandomChoice(itemstack, false);
if (entityitem != null)
{
entityitem.setNoPickupDelay();
entityitem.setOwner(entityplayer.getName());
}
}
notifyOperators(sender, this, "commands.give.success", new Object[] {itemstack.getChatComponent(), Integer.valueOf(i), entityplayer.getName()});
}
}
示例2: execute
import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
Item item = getItemByText(sender, args[1]);
int i = args.length >= 3 ? parseInt(args[2], 1, 64) : 1;
int j = args.length >= 4 ? parseInt(args[3]) : 0;
ItemStack itemstack = new ItemStack(item, i, j);
if (args.length >= 5)
{
String s = getChatComponentFromNthArg(sender, args, 4).getUnformattedText();
try
{
itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.give.tagError", new Object[] {nbtexception.getMessage()});
}
}
boolean flag = entityplayer.inventory.addItemStackToInventory(itemstack);
if (flag)
{
entityplayer.world.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((entityplayer.getRNG().nextFloat() - entityplayer.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.inventoryContainer.detectAndSendChanges();
}
if (flag && itemstack.func_190926_b())
{
itemstack.func_190920_e(1);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i);
EntityItem entityitem1 = entityplayer.dropItem(itemstack, false);
if (entityitem1 != null)
{
entityitem1.makeFakeItem();
}
}
else
{
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i - itemstack.func_190916_E());
EntityItem entityitem = entityplayer.dropItem(itemstack, false);
if (entityitem != null)
{
entityitem.setNoPickupDelay();
entityitem.setOwner(entityplayer.getName());
}
}
notifyCommandListener(sender, this, "commands.give.success", new Object[] {itemstack.getTextComponent(), Integer.valueOf(i), entityplayer.getName()});
}
}
示例3: execute
import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.give.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
Item item = getItemByText(sender, args[1]);
int i = args.length >= 3 ? parseInt(args[2], 1, 64) : 1;
int j = args.length >= 4 ? parseInt(args[3]) : 0;
ItemStack itemstack = new ItemStack(item, i, j);
if (args.length >= 5)
{
String s = getChatComponentFromNthArg(sender, args, 4).getUnformattedText();
try
{
itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.give.tagError", new Object[] {nbtexception.getMessage()});
}
}
boolean flag = entityplayer.inventory.addItemStackToInventory(itemstack);
if (flag)
{
entityplayer.worldObj.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((entityplayer.getRNG().nextFloat() - entityplayer.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.inventoryContainer.detectAndSendChanges();
}
if (flag && itemstack.stackSize <= 0)
{
itemstack.stackSize = 1;
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i);
EntityItem entityitem1 = entityplayer.dropItem(itemstack, false);
if (entityitem1 != null)
{
entityitem1.makeFakeItem();
}
}
else
{
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i - itemstack.stackSize);
EntityItem entityitem = entityplayer.dropItem(itemstack, false);
if (entityitem != null)
{
entityitem.setNoPickupDelay();
entityitem.setOwner(entityplayer.getName());
}
}
notifyCommandListener(sender, this, "commands.give.success", new Object[] {itemstack.getTextComponent(), Integer.valueOf(i), entityplayer.getName()});
}
}