本文整理汇总了Java中net.minecraft.item.ItemStack.getEnchantmentTagList方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getEnchantmentTagList方法的具体用法?Java ItemStack.getEnchantmentTagList怎么用?Java ItemStack.getEnchantmentTagList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getEnchantmentTagList方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyEnchantmentModifier
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Executes the enchantment modifier on the ItemStack passed.
*/
private static void applyEnchantmentModifier(EnchantmentHelper.IModifier modifier, ItemStack stack)
{
if (stack != null)
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(j) != null)
{
modifier.calculateModifier(Enchantment.getEnchantmentByID(j), k);
}
}
}
}
}
示例2: applyEnchantmentModifier
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Executes the enchantment modifier on the ItemStack passed.
*/
private static void applyEnchantmentModifier(EnchantmentHelper.IModifier modifier, ItemStack stack)
{
if (stack != null)
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentById(j) != null)
{
modifier.calculateModifier(Enchantment.getEnchantmentById(j), k);
}
}
}
}
}
示例3: getEnchantments
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static Map<Integer, Integer> getEnchantments(ItemStack stack)
{
Map<Integer, Integer> map = Maps.<Integer, Integer>newLinkedHashMap();
NBTTagList nbttaglist = stack.getItem() == Items.enchanted_book ? Items.enchanted_book.getEnchantments(stack) : stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
map.put(Integer.valueOf(j), Integer.valueOf(k));
}
}
return map;
}
示例4: getEnchantmentIdLevels
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static int[][] getEnchantmentIdLevels(ItemStack p_getEnchantmentIdLevels_0_)
{
Item item = p_getEnchantmentIdLevels_0_.getItem();
NBTTagList nbttaglist = item == Items.enchanted_book ? Items.enchanted_book.getEnchantments(p_getEnchantmentIdLevels_0_) : p_getEnchantmentIdLevels_0_.getEnchantmentTagList();
if (nbttaglist != null && nbttaglist.tagCount() > 0)
{
int[][] aint = new int[nbttaglist.tagCount()][2];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getShort("id");
int k = nbttagcompound.getShort("lvl");
aint[i][0] = j;
aint[i][1] = k;
}
return aint;
}
else
{
return EMPTY_INT2_ARRAY;
}
}
示例5: getEnchantments
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static Map<Enchantment, Integer> getEnchantments(ItemStack stack)
{
Map<Enchantment, Integer> map = Maps.<Enchantment, Integer>newLinkedHashMap();
NBTTagList nbttaglist = stack.getItem() == Items.ENCHANTED_BOOK ? Items.ENCHANTED_BOOK.getEnchantments(stack) : stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
Enchantment enchantment = Enchantment.getEnchantmentByID(nbttaglist.getCompoundTagAt(i).getShort("id"));
int j = nbttaglist.getCompoundTagAt(i).getShort("lvl");
map.put(enchantment, Integer.valueOf(j));
}
}
return map;
}
示例6: applyEnchantmentModifier
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Executes the enchantment modifier on the ItemStack passed.
*/
private static void applyEnchantmentModifier(EnchantmentHelper.IModifier modifier, ItemStack stack)
{
if (!stack.func_190926_b())
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(j) != null)
{
modifier.calculateModifier(Enchantment.getEnchantmentByID(j), k);
}
}
}
}
}
示例7: getEnchantmentIdLevels
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static int[][] getEnchantmentIdLevels(ItemStack p_getEnchantmentIdLevels_0_)
{
Item item = p_getEnchantmentIdLevels_0_.getItem();
NBTTagList nbttaglist = item == Items.ENCHANTED_BOOK ? Items.ENCHANTED_BOOK.getEnchantments(p_getEnchantmentIdLevels_0_) : p_getEnchantmentIdLevels_0_.getEnchantmentTagList();
if (nbttaglist != null && nbttaglist.tagCount() > 0)
{
int[][] aint = new int[nbttaglist.tagCount()][2];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getShort("id");
int k = nbttagcompound.getShort("lvl");
aint[i][0] = j;
aint[i][1] = k;
}
return aint;
}
else
{
return EMPTY_INT2_ARRAY;
}
}
示例8: getEnchantmentLevel
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns the level of enchantment on the ItemStack passed.
*/
public static int getEnchantmentLevel(int enchID, ItemStack stack)
{
if (stack == null)
{
return 0;
}
else
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null)
{
return 0;
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (j == enchID)
{
return k;
}
}
return 0;
}
}
}
示例9: getEnchantmentLevel
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns the level of enchantment on the ItemStack passed.
*/
public static int getEnchantmentLevel(Enchantment enchID, ItemStack stack)
{
if (stack.func_190926_b())
{
return 0;
}
else
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null)
{
return 0;
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
Enchantment enchantment = Enchantment.getEnchantmentByID(nbttaglist.getCompoundTagAt(i).getShort("id"));
int j = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (enchantment == enchID)
{
return j;
}
}
return 0;
}
}
}
示例10: getEnchantmentLevel
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns the level of enchantment on the ItemStack passed.
*/
public static int getEnchantmentLevel(Enchantment enchID, @Nullable ItemStack stack)
{
if (stack == null)
{
return 0;
}
else
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null)
{
return 0;
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
Enchantment enchantment = Enchantment.getEnchantmentByID(nbttaglist.getCompoundTagAt(i).getShort("id"));
int j = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (enchantment == enchID)
{
return j;
}
}
return 0;
}
}
}
示例11: execute
import net.minecraft.item.ItemStack; //导入方法依赖的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.enchant.usage", new Object[0]);
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)getEntity(server, sender, args[0], EntityLivingBase.class);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
Enchantment enchantment;
try
{
enchantment = Enchantment.getEnchantmentByID(parseInt(args[1], 0));
}
catch (NumberInvalidException var12)
{
enchantment = Enchantment.getEnchantmentByLocation(args[1]);
}
if (enchantment == null)
{
throw new NumberInvalidException("commands.enchant.notFound", new Object[] {Integer.valueOf(Enchantment.getEnchantmentID(enchantment))});
}
else
{
int i = 1;
ItemStack itemstack = entitylivingbase.getHeldItemMainhand();
if (itemstack == null)
{
throw new CommandException("commands.enchant.noItem", new Object[0]);
}
else if (!enchantment.canApply(itemstack))
{
throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
}
else
{
if (args.length >= 3)
{
i = parseInt(args[2], enchantment.getMinLevel(), enchantment.getMaxLevel());
}
if (itemstack.hasTagCompound())
{
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int j = 0; j < nbttaglist.tagCount(); ++j)
{
int k = nbttaglist.getCompoundTagAt(j).getShort("id");
if (Enchantment.getEnchantmentByID(k) != null)
{
Enchantment enchantment1 = Enchantment.getEnchantmentByID(k);
if (!enchantment.canApplyTogether(enchantment1) || !enchantment1.canApplyTogether(enchantment)) //Forge BugFix: Let Both enchantments veto being together
{
throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.getTranslatedName(i), enchantment1.getTranslatedName(nbttaglist.getCompoundTagAt(j).getShort("lvl"))});
}
}
}
}
}
itemstack.addEnchantment(enchantment, i);
notifyCommandListener(sender, this, "commands.enchant.success", new Object[0]);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 1);
}
}
}
}
示例12: execute
import net.minecraft.item.ItemStack; //导入方法依赖的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.enchant.usage", new Object[0]);
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)getEntity(server, sender, args[0], EntityLivingBase.class);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
Enchantment enchantment;
try
{
enchantment = Enchantment.getEnchantmentByID(parseInt(args[1], 0));
}
catch (NumberInvalidException var12)
{
enchantment = Enchantment.getEnchantmentByLocation(args[1]);
}
if (enchantment == null)
{
throw new NumberInvalidException("commands.enchant.notFound", new Object[] {args[1]});
}
else
{
int i = 1;
ItemStack itemstack = entitylivingbase.getHeldItemMainhand();
if (itemstack.func_190926_b())
{
throw new CommandException("commands.enchant.noItem", new Object[0]);
}
else if (!enchantment.canApply(itemstack))
{
throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
}
else
{
if (args.length >= 3)
{
i = parseInt(args[2], enchantment.getMinLevel(), enchantment.getMaxLevel());
}
if (itemstack.hasTagCompound())
{
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int j = 0; j < nbttaglist.tagCount(); ++j)
{
int k = nbttaglist.getCompoundTagAt(j).getShort("id");
if (Enchantment.getEnchantmentByID(k) != null)
{
Enchantment enchantment1 = Enchantment.getEnchantmentByID(k);
if (!enchantment.func_191560_c(enchantment1))
{
throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.getTranslatedName(i), enchantment1.getTranslatedName(nbttaglist.getCompoundTagAt(j).getShort("lvl"))});
}
}
}
}
}
itemstack.addEnchantment(enchantment, i);
notifyCommandListener(sender, this, "commands.enchant.success", new Object[0]);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 1);
}
}
}
}