Java Code Examples for net.querz.nbt.tag.CompoundTag#put()

The following examples show how to use net.querz.nbt.tag.CompoundTag#put() . 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: SNBTParser.java    From NBT with MIT License 6 votes vote down vote up
private CompoundTag parseCompoundTag(int maxDepth) throws ParseException {
	ptr.expectChar('{');

	CompoundTag compoundTag = new CompoundTag();

	ptr.skipWhitespace();
	while (ptr.hasNext() && ptr.currentChar() != '}') {
		ptr.skipWhitespace();
		String key = ptr.currentChar() == '"' ? ptr.parseQuotedString() : ptr.parseSimpleString();
		if (key.isEmpty()) {
			throw new ParseException("empty keys are not allowed");
		}
		ptr.expectChar(':');

		compoundTag.put(key, parseAnything(decrementMaxDepth(maxDepth)));

		if (!ptr.nextArrayElement()) {
			break;
		}
	}
	ptr.expectChar('}');
	return compoundTag;
}
 
Example 2
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 5 votes vote down vote up
private CompoundTag initLevel(CompoundTag c) {
	CompoundTag level = c.getCompoundTag("Level");
	if (level == null) {
		c.put("Level", level = new CompoundTag());
	}
	return level;
}
 
Example 3
Source File: MCAChunkData.java    From mcaselector with MIT License 5 votes vote down vote up
static MCAChunkData newEmptyLevelMCAChunkData(Point2i absoluteLocation, int dataVersion) {
	MCAChunkData mcaChunkData = new MCAChunkData(absoluteLocation, 0, 0, (byte) 1);
	CompoundTag root = new CompoundTag();
	CompoundTag level = new CompoundTag();
	level.putInt("xPos", absoluteLocation.getX());
	level.putInt("zPos", absoluteLocation.getY());
	level.putString("Status", "full");
	root.put("Level", level);
	root.putInt("DataVersion", dataVersion);
	mcaChunkData.data = root;
	mcaChunkData.compressionType = CompressionType.ZLIB;
	return mcaChunkData;
}
 
Example 4
Source File: NBTInputStream.java    From NBT with MIT License 5 votes vote down vote up
private static CompoundTag readCompound(NBTInputStream in, int maxDepth) throws IOException {
	CompoundTag comp = new CompoundTag();
	for (int id = in.readByte() & 0xFF; id != 0; id = in.readByte() & 0xFF) {
		String key = in.readUTF();
		Tag<?> element = in.readTag((byte) id, in.decrementMaxDepth(maxDepth));
		comp.put(key, element);
	}
	return comp;
}
 
Example 5
Source File: Chunk.java    From NBT with MIT License 5 votes vote down vote up
public CompoundTag updateHandle(int xPos, int zPos) {
	data.putInt("DataVersion", dataVersion);
	CompoundTag level = data.getCompoundTag("Level");
	level.putInt("xPos", xPos);
	level.putInt("zPos", zPos);
	level.putLong("LastUpdate", lastUpdate);
	level.putLong("InhabitedTime", inhabitedTime);
	if (dataVersion < 2202) {
		if (biomes != null && biomes.length == 256) level.putIntArray("Biomes", biomes);
	} else {
		if (biomes != null && biomes.length == 1024) level.putIntArray("Biomes", biomes);
	}
	if (heightMaps != null) level.put("Heightmaps", heightMaps);
	if (carvingMasks != null) level.put("CarvingMasks", carvingMasks);
	if (entities != null) level.put("Entities", entities);
	if (tileEntities != null) level.put("TileEntities", tileEntities);
	if (tileTicks != null) level.put("TileTicks", tileTicks);
	if (liquidTicks != null) level.put("LiquidTicks", liquidTicks);
	if (lights != null) level.put("Lights", lights);
	if (liquidsToBeTicked != null) level.put("LiquidsToBeTicked", liquidsToBeTicked);
	if (toBeTicked != null) level.put("ToBeTicked", toBeTicked);
	if (postProcessing != null) level.put("PostProcessing", postProcessing);
	level.putString("Status", status);
	if (structures != null) level.put("Structures", structures);
	ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class);
	for (int i = 0; i < this.sections.length; i++) {
		if (this.sections[i] != null) {
			sections.add(this.sections[i].updateHandle(i));
		}
	}
	level.put("Sections", sections);
	return data;
}
 
Example 6
Source File: MCAFileTest.java    From NBT with MIT License 4 votes vote down vote up
private Chunk createChunkWithPos() {
	CompoundTag data = new CompoundTag();
	CompoundTag level = new CompoundTag();
	data.put("Level", level);
	return new Chunk(data);
}