本文整理汇总了Java中net.minecraft.item.ItemStack.func_150996_a方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.func_150996_a方法的具体用法?Java ItemStack.func_150996_a怎么用?Java ItemStack.func_150996_a使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.func_150996_a方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enchantItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* enchants the item on the table using the specified slot; also deducts XP from player
*/
@Override
public boolean enchantItem(EntityPlayer player, int id) {
ItemStack var3 = tableInventory.getStackInSlot(0);
ItemStack var4 = tableInventory.getStackInSlot(1);
int var5 = id + 1;
if ((var4 == null || var4.stackSize < var5) && !player.capabilities.isCreativeMode)
return false;
else if (enchantLevels[id] > 0 && var3 != null && (player.experienceLevel >= var5 && player.experienceLevel >= enchantLevels[id] || player.capabilities.isCreativeMode)) {
if (!world.isRemote) {
List<EnchantmentData> var6 = func_178148_a(var3, id, enchantLevels[id]);
boolean var7 = var3.getItem() == Items.book;
if (var6 != null) {
chargeForEnchant(player, rand, var5);
if (var7)
var3.func_150996_a(Items.enchanted_book);
for (int var8 = 0; var8 < var6.size(); ++var8) {
EnchantmentData var9 = var6.get(var8);
if (var7)
Items.enchanted_book.addEnchantment(var3, var9);
else
var3.addEnchantment(var9.enchantmentobj, var9.enchantmentLevel);
}
if (!player.capabilities.isCreativeMode) {
var4.stackSize -= var5;
if (var4.stackSize <= 0)
tableInventory.setInventorySlotContents(1, (ItemStack) null);
}
tableInventory.markDirty();
enchantmentSeed = rand.nextInt();
onCraftMatrixChanged(tableInventory);
}
}
return true;
} else
return false;
}