本文整理汇总了Java中net.minecraft.item.ItemStack.getOrCreateSubCompound方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getOrCreateSubCompound方法的具体用法?Java ItemStack.getOrCreateSubCompound怎么用?Java ItemStack.getOrCreateSubCompound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getOrCreateSubCompound方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemBlockWithInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getItemBlockWithInventory(IInventory inventory, ItemStack stack) {
if (!stack.isEmpty() && stack.getItem() instanceof ItemBlock && inventory != null && inventory.getSizeInventory() > 0) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound stackNBT = stack.getOrCreateSubCompound("BlockEntityTag");
NBTTagList stackList = new NBTTagList();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i).isEmpty()) {
continue;
}
NBTTagCompound slotNBT = new NBTTagCompound();
slotNBT.setByte("Slot", (byte) i);
inventory.getStackInSlot(i).writeToNBT(slotNBT);
stackList.appendTag(slotNBT);
}
stackNBT.setTag("Items", stackList);
stack.setTagInfo("BlockEntityTag", stackNBT);
return stack;
}
return null;
}
示例2: getStackWithInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack getStackWithInventory(IInventory inventory, ItemStack stack) {
if (inventory != null && inventory.getSizeInventory() > 0 && stack != null) {
NBTTagCompound stackNBT = stack.getOrCreateSubCompound("BlockEntityTag");
NBTTagList stackList = new NBTTagList();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
NBTTagCompound slotNBT = new NBTTagCompound();
slotNBT.setByte("Slot", (byte) i);
inventory.getStackInSlot(i).writeToNBT(slotNBT);
stackList.appendTag(slotNBT);
}
stackNBT.setTag("Items", stackList);
stack.setTagInfo("BlockEntityTag", stackNBT);
return stack;
}
return null;
}
示例3: getAttributeValue
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public int getAttributeValue(ItemStack stack) {
if(!stack.isEmpty() && stack.hasTagCompound()) {
NBTTagCompound tag = stack.getOrCreateSubCompound("Upgrades");
return tag.getInteger(Integer.toString(this.id));
}
return 0;
}
示例4: RandoresItemData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public RandoresItemData(ItemStack stack) {
this(stack.getOrCreateSubCompound("randores"));
}