当前位置: 首页>>代码示例>>Java>>正文


Java ItemStack.getOrCreateSubCompound方法代码示例

本文整理汇总了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;
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:23,代码来源:EntityFrienderman.java

示例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;
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:17,代码来源:ChestUtils.java

示例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;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:8,代码来源:RIGUpgrade.java

示例4: RandoresItemData

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public RandoresItemData(ItemStack stack) {
    this(stack.getOrCreateSubCompound("randores"));
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:4,代码来源:RandoresItemData.java


注:本文中的net.minecraft.item.ItemStack.getOrCreateSubCompound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。