Java Code Examples for net.querz.nbt.tag.StringTag

The following examples show how to use net.querz.nbt.tag.StringTag. These examples are extracted from open source projects. 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 Project: mcaselector   Source File: Anvil113ColorMapping.java    License: MIT License 6 votes vote down vote up
public int getColor(CompoundTag properties) {
	if (properties != null) {
		for (Map.Entry<String, Tag<?>> property : properties.entrySet()) {
			Map<Set<String>, Integer> clone = new HashMap<>(blockStateMapping);
			for (Map.Entry<Set<String>, Integer> blockState : blockStateMapping.entrySet()) {
				String value = property.getKey() + "=" + ((StringTag) property.getValue()).getValue();
				if (!blockState.getKey().contains(value)) {
					clone.remove(blockState.getKey());
				}
			}
			Iterator<Map.Entry<Set<String>, Integer>> it = clone.entrySet().iterator();
			if (it.hasNext()) {
				return it.next().getValue();
			}
		}
	}
	return 0x000000;
}
 
Example 2
Source Project: mcaselector   Source File: StatusField.java    License: MIT License 5 votes vote down vote up
@Override
public void change(CompoundTag root) {
	StringTag tag = root.getCompoundTag("Level").getStringTag("Status");
	if (tag != null) {
		tag.setValue(getNewValue());
	}
}
 
Example 3
Source Project: mcaselector   Source File: StatusFilter.java    License: MIT License 4 votes vote down vote up
@Override
public boolean contains(String value, FilterData data) {
	StringTag tag = data.getChunk().getCompoundTag("Level").getStringTag("Status");
	return tag != null && validStatus.contains(tag.getValue());
}
 
Example 4
Source Project: mcaselector   Source File: StatusFilter.java    License: MIT License 4 votes vote down vote up
@Override
public boolean containsNot(String value, FilterData data) {
	StringTag tag = data.getChunk().getCompoundTag("Level").getStringTag("Status");
	return tag == null || !validStatus.contains(tag.getValue());
}
 
Example 5
Source Project: NBT   Source File: NBTOutputStream.java    License: MIT License 4 votes vote down vote up
private static void writeString(NBTOutputStream out, Tag<?> tag) throws IOException {
	out.writeUTF(((StringTag) tag).getValue());
}
 
Example 6
Source Project: NBT   Source File: SNBTWriter.java    License: 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 7
Source Project: NBT   Source File: NBTInputStream.java    License: MIT License 4 votes vote down vote up
private static StringTag readString(NBTInputStream in) throws IOException {
	return new StringTag(in.readUTF());
}
 
Example 8
Source Project: amidst   Source File: LevelDatNbt.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static String readGeneratorName(CompoundTag dataTag) {
	return dataTag.get(NBTTagKeys.TAG_KEY_GENERATOR_NAME, StringTag.class).getValue();
}
 
Example 9
Source Project: amidst   Source File: LevelDatNbt.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static String readGeneratorOptions(CompoundTag dataTag) {
	return dataTag.get(NBTTagKeys.TAG_KEY_GENERATOR_OPTIONS, StringTag.class).getValue();
}
 
Example 10
Source Project: amidst   Source File: LevelDatNbt.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static String readGeneratorName(CompoundTag dataTag) {
	return dataTag.get(NBTTagKeys.TAG_KEY_GENERATOR_NAME, StringTag.class).getValue();
}
 
Example 11
Source Project: amidst   Source File: LevelDatNbt.java    License: GNU General Public License v3.0 4 votes vote down vote up
private static String readGeneratorOptions(CompoundTag dataTag) {
	return dataTag.get(NBTTagKeys.TAG_KEY_GENERATOR_OPTIONS, StringTag.class).getValue();
}