本文整理汇总了Java中org.jnbt.ListTag类的典型用法代码示例。如果您正苦于以下问题:Java ListTag类的具体用法?Java ListTag怎么用?Java ListTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListTag类属于org.jnbt包,在下文中一共展示了ListTag类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChild
import org.jnbt.ListTag; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends Tag> T getChild(ListTag list, final int index, Class<T> clazz)
{
List<Tag> tags = list.getValue();
if (index >= 0 && index < tags.size())
{
Tag t = tags.get(index);
if (clazz.isInstance(t))
{
return (T)t;
}
}
return null;
}
示例2: convertNBT
import org.jnbt.ListTag; //导入依赖的package包/类
private Object convertNBT(Tag tag) throws InstantiationException, IllegalAccessException, InvocationTargetException {
if (tag instanceof CompoundTag) {
return convertNBT((CompoundTag) tag);
} else if (tag instanceof ListTag) {
return convertNBT(((ListTag) tag));
} else if (tag instanceof StringTag) {
return convertNBT((StringTag) tag);
} else {
throw new UnsupportedOperationException("Unsupported tag type " + tag.getClass().getSimpleName() + " encountered");
}
}
示例3: setDoubleList
import org.jnbt.ListTag; //导入依赖的package包/类
protected final void setDoubleList(String name, double[] values) {
List<Tag> list = new ArrayList<>(values.length);
for (double value : values) {
list.add(new DoubleTag(null, value));
}
tag.setTag(name, new ListTag(name, DoubleTag.class, list));
}
示例4: setFloatList
import org.jnbt.ListTag; //导入依赖的package包/类
protected final void setFloatList(String name, float[] values) {
List<Tag> list = new ArrayList<>(values.length);
for (float value : values) {
list.add(new FloatTag(null, value));
}
tag.setTag(name, new ListTag(name, FloatTag.class, list));
}
示例5: getTag
import org.jnbt.ListTag; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Tag getTag() {
return new ListTag(name, type, values);
}
示例6: addPlayer
import org.jnbt.ListTag; //导入依赖的package包/类
private void addPlayer(String name, CompoundTag ps) {
List<Tag> pos = ((ListTag)(ps.getValue().get("Pos"))).getValue();
double x = (Double)pos.get(0).getValue();
double z = (Double)pos.get(2).getValue();
players.add(new MapObjectPlayer(name, (int) x, (int) z));
}
示例7: getList
import org.jnbt.ListTag; //导入依赖的package包/类
protected final <T extends Tag> List<T> getList(String name) {
ListTag listTag = (ListTag) tag.getTag(name);
return (listTag != null) ? (List<T>) listTag.getValue() : null;
}
示例8: setList
import org.jnbt.ListTag; //导入依赖的package包/类
protected final <T extends Tag> void setList(String name, Class<T> type, List<Tag> list) {
tag.setTag(name, new ListTag(name, type, list));
}
示例9: getTagListFromTag
import org.jnbt.ListTag; //导入依赖的package包/类
/**
* Extracts a list of tags from an NBT compound tag, where the child
* element is assumed to be a {@link org.jnbt.ListTag}.
*
* @param tag the tag instance
* @param key the key for the byte array attribute
* @return the byte array
*/
static List<Tag> getTagListFromTag(CompoundTag tag, String key) {
return ((ListTag) tag.getValue().get(key)).getValue();
}