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

The following examples show how to use net.querz.nbt.tag.CompoundTag#getString() . 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: EntityFilter.java    From mcaselector with MIT License 6 votes vote down vote up
@Override
public boolean contains(List<String> value, FilterData data) {
	Tag<?> rawEntities = data.getChunk().getCompoundTag("Level").get("Entities");
	if (rawEntities == null || rawEntities.getID() == LongArrayTag.ID) {
		return false;
	}
	ListTag<CompoundTag> entities = ((ListTag<?>) rawEntities).asCompoundTagList();
	nameLoop: for (String name : getFilterValue()) {
		for (CompoundTag entity : entities) {
			String id = entity.getString("id");
			if (name.equals(id)) {
				continue nameLoop;
			}
		}
		return false;
	}
	return true;
}
 
Example 2
Source File: Section.java    From NBT with MIT License 6 votes vote down vote up
void putValueIndexedPalette(CompoundTag data, int index) {
	PaletteIndex leaf = new PaletteIndex(data, index);
	String name = data.getString("Name");
	List<PaletteIndex> leaves = valueIndexedPalette.get(name);
	if (leaves == null) {
		leaves = new ArrayList<>(1);
		leaves.add(leaf);
		valueIndexedPalette.put(name, leaves);
	} else {
		for (PaletteIndex pal : leaves) {
			if (pal.data.equals(data)) {
				return;
			}
		}
		leaves.add(leaf);
	}
}
 
Example 3
Source File: Anvil113ChunkDataProcessor.java    From mcaselector with MIT License 5 votes vote down vote up
private boolean isWater(CompoundTag blockData) {
	switch (blockData.getString("Name")) {
		case "minecraft:water":
		case "minecraft:bubble_column":
			return true;
	}
	return false;
}
 
Example 4
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
private void initReferences(long loadFlags) {
	if (data == null) {
		throw new NullPointerException("data cannot be null");
	}
	CompoundTag level;
	if ((level = data.getCompoundTag("Level")) == null) {
		throw new IllegalArgumentException("data does not contain \"Level\" tag");
	}
	dataVersion = data.getInt("DataVersion");
	inhabitedTime = level.getLong("InhabitedTime");
	lastUpdate = level.getLong("LastUpdate");
	if ((loadFlags & BIOMES) != 0) {
		biomes = level.getIntArray("Biomes");
	}
	if ((loadFlags & HEIGHTMAPS) != 0) {
		heightMaps = level.getCompoundTag("Heightmaps");
	}
	if ((loadFlags & CARVING_MASKS) != 0) {
		carvingMasks = level.getCompoundTag("CarvingMasks");
	}
	if ((loadFlags & ENTITIES) != 0) {
		entities = level.containsKey("Entities") ? level.getListTag("Entities").asCompoundTagList() : null;
	}
	if ((loadFlags & TILE_ENTITIES) != 0) {
		tileEntities = level.containsKey("TileEntities") ? level.getListTag("TileEntities").asCompoundTagList() : null;
	}
	if ((loadFlags & TILE_TICKS) != 0) {
		tileTicks = level.containsKey("TileTicks") ? level.getListTag("TileTicks").asCompoundTagList() : null;
	}
	if ((loadFlags & LIQUID_TICKS) != 0) {
		liquidTicks = level.containsKey("LiquidTicks") ? level.getListTag("LiquidTicks").asCompoundTagList() : null;
	}
	if ((loadFlags & LIGHTS) != 0) {
		lights = level.containsKey("Lights") ? level.getListTag("Lights").asListTagList() : null;
	}
	if ((loadFlags & LIQUIDS_TO_BE_TICKED) != 0) {
		liquidsToBeTicked = level.containsKey("LiquidsToBeTicked") ? level.getListTag("LiquidsToBeTicked").asListTagList() : null;
	}
	if ((loadFlags & TO_BE_TICKED) != 0) {
		toBeTicked = level.containsKey("ToBeTicked") ? level.getListTag("ToBeTicked").asListTagList() : null;
	}
	if ((loadFlags & POST_PROCESSING) != 0) {
		postProcessing = level.containsKey("PostProcessing") ? level.getListTag("PostProcessing").asListTagList() : null;
	}
	status = level.getString("Status");
	if ((loadFlags & STRUCTURES) != 0) {
		structures = level.getCompoundTag("Structures");
	}
	if ((loadFlags & (BLOCK_LIGHTS|BLOCK_STATES|SKY_LIGHT)) != 0 && level.containsKey("Sections")) {
		for (CompoundTag section : level.getListTag("Sections").asCompoundTagList()) {
			int sectionIndex = section.getByte("Y");
			if (sectionIndex > 15 || sectionIndex < 0) {
				continue;
			}
			Section newSection = new Section(section, dataVersion, loadFlags);
			if (newSection.isEmpty()) {
				continue;
			}
			sections[sectionIndex] = newSection;
		}
	}

	// If we haven't requested the full set of data we can drop the underlying raw data to let the GC handle it.
	if (loadFlags != ALL_DATA) {
		data = null;
		partial = true;
	} else {
		partial = false;
	}
}