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