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


Java NBT.TAG_COMPOUND属性代码示例

本文整理汇总了Java中net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND属性的典型用法代码示例。如果您正苦于以下问题:Java NBT.TAG_COMPOUND属性的具体用法?Java NBT.TAG_COMPOUND怎么用?Java NBT.TAG_COMPOUND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.minecraftforge.common.util.Constants.NBT的用法示例。


在下文中一共展示了NBT.TAG_COMPOUND属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: iterate

private static final void iterate(NBTTagCompound parent, NBTTreeConsumer consumer, int depth) {
	if(parent == null) return;
	consumer.consume(depth+1, "<compound>", parent, null);

	for(Object keyObject : parent.getKeySet()) {
		String key = (String)keyObject;
		NBTBase value = parent.getTag(key);

		consumer.consume(depth+1, key, value, parent);

		if(value instanceof NBTTagCompound) {
			iterate((NBTTagCompound)value, consumer, depth+1);
		}

		if(value instanceof NBTTagList) {
			NBTTagList list = (NBTTagList) value;
			if(list.getTagType() == NBT.TAG_COMPOUND) {
				for(int i = 0; i < list.tagCount(); i++) {
					NBTTagCompound compound = list.getCompoundTagAt(i);
					iterate(compound, consumer, depth+1);
				}
			}
		}
	}
	consumer.consume(depth+1, "", null, parent);
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:26,代码来源:RecursiveNBTIterator.java

示例2: asJson

private static void asJson(NBTBase tag, StringBuilder builder) {
	switch(tag.getId()) {
	case NBT.TAG_BYTE: builder.append(((NBTTagByte)tag).getByte()).append('b'); break;
	case NBT.TAG_SHORT: builder.append(((NBTTagShort)tag).getByte()).append('b'); break;
	case NBT.TAG_INT: builder.append(((NBTTagInt)tag).getInt()); break;
	case NBT.TAG_LONG: builder.append(((NBTTagLong)tag).getByte()).append('l'); break;
	case NBT.TAG_FLOAT: builder.append(((NBTTagFloat)tag).getFloat()).append('f'); break;
	case NBT.TAG_DOUBLE: builder.append(((NBTTagDouble)tag).getDouble()).append('d'); break;
	case NBT.TAG_STRING: builder.append('"').append(((NBTTagString)tag).getString()).append('"'); break;
	case NBT.TAG_BYTE_ARRAY: builder.append(Arrays.toString(((NBTTagByteArray)tag).getByteArray())); break;
	case NBT.TAG_INT_ARRAY: builder.append(Arrays.toString(((NBTTagIntArray)tag).getIntArray())); break;
	case NBT.TAG_COMPOUND: asJson((NBTTagCompound) tag, builder); break;
	case NBT.TAG_LIST: asJson((NBTTagList) tag, builder); break;
	}

}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:16,代码来源:NBTHelper.java

示例3: addNBTToTooltip

public static void addNBTToTooltip(NBTTagCompound nbt, List<String> tooltip, int depth) {
	if (nbt == null)
		return;
	String blank = Tool.makeString(' ', (depth - 1) * 3);
	for (String key : nbt.getKeySet()) {
		NBTBase base = nbt.getTag(key);
		if (base.getId() == NBT.TAG_COMPOUND) {
			tooltip.add(blank + "|-> " + key + " : (" + base.getClass().getSimpleName().replace("NBTTag", "") + ")");
			addNBTToTooltip((NBTTagCompound) base, tooltip, depth + 1);
		} else
			tooltip.add(blank + "|-> " + key + " = (" + base.getClass().getSimpleName().replace("NBTTag", "") + ") " +  base.toString());
	}
}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:13,代码来源:RTooltip.java

示例4: nbtMerge

/**
 * Merges two nbt tag compounds
 * 
 * @param tag the tag to merge the "other" tag into
 * @param other the tag which shall be merged into "tag"
 * @param mergeLists whether lists shall be replaced or merged
 */
public static void nbtMerge(NBTTagCompound tag, NBTTagCompound other, boolean mergeLists) {
	if (tag == null || other == null) return;
       Iterator iterator = other.getKeySet().iterator();

       while (iterator.hasNext())
       {
           String s = (String)iterator.next();
           NBTBase nbtbase = other.getTag(s);

           if (nbtbase.getId() == NBT.TAG_COMPOUND && tag.hasKey(s, NBT.TAG_COMPOUND))
           {
                  nbtMerge(tag.getCompoundTag(s), (NBTTagCompound) nbtbase, mergeLists);
           }
           else if (nbtbase.getId() == NBT.TAG_LIST && tag.hasKey(s, NBT.TAG_LIST) && mergeLists) {
           	if (((NBTTagList) nbtbase).getTagType() == ((NBTTagList) tag.getTag(s)).getTagType()) {
           		NBTTagList l1 = (NBTTagList) nbtbase, l2 = (NBTTagList) tag.getTag(s);
           		
           		for (int i = 0; i < l1.tagCount(); i++)
           			l2.appendTag(l1.get(i).copy());
           	}
           	else tag.setTag(s, nbtbase.copy());
           }
           else
           {
           	tag.setTag(s, nbtbase.copy());
           }
       }
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:35,代码来源:TargetSelector.java


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