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