net.querz.nbt.tag.DoubleTag Java Examples

The following examples show how to use net.querz.nbt.tag.DoubleTag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NBTOutputStream.java    From NBT with MIT License 4 votes vote down vote up
private static void writeDouble(NBTOutputStream out, Tag<?> tag) throws IOException {
	out.writeDouble(((DoubleTag) tag).asDouble());
}
 
Example #2
Source File: SNBTWriter.java    From NBT with MIT License 4 votes vote down vote up
private void writeAnything(Tag<?> tag, int maxDepth) throws IOException {
	switch (tag.getID()) {
	case EndTag.ID:
		//do nothing
		break;
	case ByteTag.ID:
		writer.append(Byte.toString(((ByteTag) tag).asByte())).write('b');
		break;
	case ShortTag.ID:
		writer.append(Short.toString(((ShortTag) tag).asShort())).write('s');
		break;
	case IntTag.ID:
		writer.write(Integer.toString(((IntTag) tag).asInt()));
		break;
	case LongTag.ID:
		writer.append(Long.toString(((LongTag) tag).asLong())).write('l');
		break;
	case FloatTag.ID:
		writer.append(Float.toString(((FloatTag) tag).asFloat())).write('f');
		break;
	case DoubleTag.ID:
		writer.append(Double.toString(((DoubleTag) tag).asDouble())).write('d');
		break;
	case ByteArrayTag.ID:
		writeArray(((ByteArrayTag) tag).getValue(), ((ByteArrayTag) tag).length(), "B");
		break;
	case StringTag.ID:
		writer.write(escapeString(((StringTag) tag).getValue()));
		break;
	case ListTag.ID:
		writer.write('[');
		for (int i = 0; i < ((ListTag<?>) tag).size(); i++) {
			writer.write(i == 0 ? "" : ",");
			writeAnything(((ListTag<?>) tag).get(i), decrementMaxDepth(maxDepth));
		}
		writer.write(']');
		break;
	case CompoundTag.ID:
		writer.write('{');
		boolean first = true;
		for (Map.Entry<String, Tag<?>> entry : (CompoundTag) tag) {
			writer.write(first ? "" : ",");
			writer.append(escapeString(entry.getKey())).write(':');
			writeAnything(entry.getValue(), decrementMaxDepth(maxDepth));
			first = false;
		}
		writer.write('}');
		break;
	case IntArrayTag.ID:
		writeArray(((IntArrayTag) tag).getValue(), ((IntArrayTag) tag).length(), "I");
		break;
	case LongArrayTag.ID:
		writeArray(((LongArrayTag) tag).getValue(), ((LongArrayTag) tag).length(), "L");
		break;
	default:
		throw new IOException("unknown tag with id \"" + tag.getID() + "\"");
	}
}
 
Example #3
Source File: NBTInputStream.java    From NBT with MIT License 4 votes vote down vote up
private static DoubleTag readDouble(NBTInputStream in) throws IOException {
	return new DoubleTag(in.readDouble());
}