net.querz.nbt.tag.ListTag Java Examples

The following examples show how to use net.querz.nbt.tag.ListTag. 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: Anvil115ChunkDataProcessor.java    From mcaselector with MIT License 6 votes vote down vote up
@Override
protected void fixEntityUUID(CompoundTag entity) {
	if (entity.containsKey("UUID")) {
		int[] uuid = entity.getIntArray("UUID");
		if (uuid.length == 4) {
			for (int i = 0; i < 4; i++) {
				uuid[i] = random.nextInt();
			}
		}
	}
	if (entity.containsKey("Passengers")) {
		ListTag<CompoundTag> passengers = withDefault(() -> entity.getListTag("Passengers").asCompoundTagList(), null);
		if (passengers != null) {
			passengers.forEach(this::fixEntityUUID);
		}
	}
}
 
Example #2
Source File: SNBTParser.java    From NBT with MIT License 6 votes vote down vote up
private ListTag<?> parseListTag(int maxDepth) throws ParseException {
	ptr.expectChar('[');
	ptr.skipWhitespace();
	ListTag<?> list = ListTag.createUnchecked(EndTag.class);
	while (ptr.currentChar() != ']') {
		Tag<?> element = parseAnything(decrementMaxDepth(maxDepth));
		try {
			list.addUnchecked(element);
		} catch (IllegalArgumentException ex) {
			throw ptr.parseException(ex.getMessage());
		}
		if (!ptr.nextArrayElement()) {
			break;
		}
	}
	ptr.expectChar(']');
	return list;
}
 
Example #3
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 6 votes vote down vote up
private void mergeListTagLists(CompoundTag source, CompoundTag destination, List<Range> ranges, String name) {
	ListTag<ListTag<?>> sourceList = withDefault(() -> source.getCompoundTag("Level").getListTag(name).asListTagList(), new ListTag<>(ListTag.class));
	ListTag<ListTag<?>> destinationList = withDefault(() -> destination.getCompoundTag("Level").getListTag(name).asListTagList(), sourceList);

	if (sourceList.size() != destinationList.size()) {
		return;
	}

	for (Range range : ranges) {
		int m = Math.min(range.getTo(), sourceList.size() - 1);
		for (int i = Math.max(range.getFrom(), 0); i <= m; i++) {
			destinationList.set(i, sourceList.get(i));
		}
	}

	initLevel(destination).put(name, destinationList);
}
 
Example #4
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 #5
Source File: DeleteSectionsField.java    From mcaselector with MIT License 6 votes vote down vote up
@Override
public void change(CompoundTag root) {
	Tag<?> rawSections = root.getCompoundTag("Level").get("Sections");
	if (rawSections == null || rawSections.getID() == LongArrayTag.ID) {
		return;
	}
	ListTag<CompoundTag> sections = ((ListTag<?>) rawSections).asCompoundTagList();
	for (int i = 0; i < sections.size(); i++) {
		CompoundTag section = sections.get(i);
		for (Range range : getNewValue()) {
			if (range.contains(section.getByte("Y"))) {
				sections.remove(i);
				i--;
			}
		}
	}
}
 
Example #6
Source File: Anvil113ChunkFilter.java    From mcaselector with MIT License 5 votes vote down vote up
@Override
public boolean matchBlockNames(CompoundTag data, String... names) {
	CompoundTag level = withDefault(() -> data.getCompoundTag("Level"), null);
	if (level == null) {
		return false;
	}
	Tag<?> rawSections = level.get("Sections");
	if (rawSections == null || rawSections.getID() == LongArrayTag.ID) {
		return false;
	}
	ListTag<CompoundTag> sections = catchClassCastException(((ListTag<?>) rawSections)::asCompoundTagList);
	if (sections == null) {
		return false;
	}
	int c = 0;
	nameLoop:
	for (String name : names) {
		for (CompoundTag t : sections) {
			ListTag<?> rawPalette = withDefault(() -> t.getListTag("Palette"), null);
			if (rawPalette == null) {
				continue;
			}
			ListTag<CompoundTag> palette = catchClassCastException(rawPalette::asCompoundTagList);
			if (palette == null) {
				continue;
			}
			for (CompoundTag p : palette) {
				if (("minecraft:" + name).equals(withDefault(() -> p.getString("Name"), null))) {
					c++;
					continue nameLoop;
				}
			}
		}
	}
	return names.length == c;
}
 
Example #7
Source File: Section.java    From NBT with MIT License 5 votes vote down vote up
/**
 * Creates an empty Section with base values.
 * @return An empty Section
 */
public static Section newSection() {
	Section s = new Section();
	s.blockStates = new long[256];
	s.palette = new ListTag<>(CompoundTag.class);
	CompoundTag air = new CompoundTag();
	air.putString("Name", "minecraft:air");
	s.palette.add(air);
	s.data = new CompoundTag();
	return s;
}
 
Example #8
Source File: NBTInputStream.java    From NBT with MIT License 5 votes vote down vote up
private static ListTag<?> readListTag(NBTInputStream in, int maxDepth) throws IOException {
	byte listType = in.readByte();
	ListTag<?> list = ListTag.createUnchecked(idClassMapping.get(listType));
	int length = in.readInt();
	if (length < 0) {
		length = 0;
	}
	for (int i = 0; i < length; i++) {
		list.addUnchecked(in.readTag(listType, in.decrementMaxDepth(maxDepth)));
	}
	return list;
}
 
Example #9
Source File: NBTOutputStream.java    From NBT with MIT License 5 votes vote down vote up
private static void writeList(NBTOutputStream out, Tag<?> tag, int maxDepth) throws IOException {
	out.writeByte(idFromClass(((ListTag<?>) tag).getTypeClass()));
	out.writeInt(((ListTag<?>) tag).size());
	for (Tag<?> t : ((ListTag<?>) tag)) {
		out.writeRawTag(t, out.decrementMaxDepth(maxDepth));
	}
}
 
Example #10
Source File: MCAChunkData.java    From mcaselector with MIT License 5 votes vote down vote up
private void applyOffsetToItem(CompoundTag item, Point2i offset) {
	if (item != null) {
		String id = catchClassCastException(() -> item.getString("id"));
		CompoundTag tag = catchClassCastException(() -> item.getCompoundTag("tag"));

		if (id != null && tag != null) {
			// using a switch-case here for the future
			// noinspection SwitchStatementWithTooFewBranches
			switch (id) {
				case "minecraft:compass":
					CompoundTag lodestonePos = catchClassCastException(() -> tag.getCompoundTag("LodestonePos"));
					applyIntOffsetIfRootPresent(lodestonePos, "X", "Z", offset);
					break;
			}

			// recursively update all items in child containers

			CompoundTag blockEntityTag = catchClassCastException(() -> tag.getCompoundTag("BlockEntityTag"));
			if (blockEntityTag != null) {
				if (blockEntityTag.containsKey("Items")) {
					ListTag<CompoundTag> items = catchClassCastException(() -> blockEntityTag.getListTag("Items").asCompoundTagList());
					if (items != null) {
						items.forEach(i -> applyOffsetToItem(i, offset));
					}
				}
			}
		}
	}
}
 
Example #11
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 #12
Source File: DeleteEntitiesField.java    From mcaselector with MIT License 5 votes vote down vote up
@Override
public void change(CompoundTag root) {
	Tag<?> rawEntities = root.getCompoundTag("Level").get("Entities");
	if (rawEntities == null || rawEntities.getID() == LongArrayTag.ID) {
		return;
	}
	((ListTag<?>) rawEntities).asCompoundTagList().clear();
}
 
Example #13
Source File: TileEntityAmountFilter.java    From mcaselector with MIT License 5 votes vote down vote up
@Override
protected Integer getNumber(FilterData data) {
	Tag<?> rawTileEntities = data.getChunk().getCompoundTag("Level").get("TileEntities");
	if (rawTileEntities == null || rawTileEntities.getID() == LongArrayTag.ID) {
		return 0;
	}
	return ((ListTag<?>) rawTileEntities).asCompoundTagList().size();
}
 
Example #14
Source File: EntityAmountFilter.java    From mcaselector with MIT License 5 votes vote down vote up
@Override
protected Integer getNumber(FilterData data) {
	Tag<?> rawEntities = data.getChunk().getCompoundTag("Level").get("Entities");
	if (rawEntities == null || rawEntities.getID() == LongArrayTag.ID) {
		return 0;
	}
	return ((ListTag<?>) rawEntities).asCompoundTagList().size();
}
 
Example #15
Source File: Anvil112ChunkFilter.java    From mcaselector with MIT License 5 votes vote down vote up
@Override
public boolean matchBlockNames(CompoundTag data, String... names) {
	ListTag<CompoundTag> sections = withDefault(() -> data.getCompoundTag("Level").getListTag("Sections").asCompoundTagList(), null);
	if (sections == null) {
		return false;
	}
	int c = 0;
	nameLoop:
	for (String name : names) {
		BlockData[] bd = mapping.get(name);
		if (bd == null) {
			Debug.dump("No mapping found for " + name);
			continue;
		}
		for (CompoundTag t : sections) {
			byte[] blocks = withDefault(() -> t.getByteArray("Blocks"), null);
			if (blocks == null) {
				continue;
			}
			byte[] blockData = withDefault(() -> t.getByteArray("Data"), null);
			if (blockData == null) {
				continue;
			}

			for (int i = 0; i < blocks.length; i++) {
				short b = (short) (blocks[i] & 0xFF);
				for (BlockData d : bd) {
					if (d.id == b) {
						byte dataByte = (byte) (i % 2 == 0 ? blockData[i / 2] & 0x0F : (blockData[i / 2] >> 4) & 0x0F);
						if (d.data.contains(dataByte)) {
							c++;
							continue nameLoop;
						}
					}
				}
			}
		}
	}
	return names.length == c;
}
 
Example #16
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 5 votes vote down vote up
protected void fixEntityUUID(CompoundTag entity) {
	if (entity.containsKey("UUIDMost")) {
		entity.putLong("UUIDMost", random.nextLong());
	}
	if (entity.containsKey("UUIDLeast")) {
		entity.putLong("UUIDLeast", random.nextLong());
	}
	if (entity.containsKey("Passengers")) {
		ListTag<CompoundTag> passengers = withDefault(() -> entity.getListTag("Passengers").asCompoundTagList(), null);
		if (passengers != null) {
			passengers.forEach(this::fixEntityUUID);
		}
	}
}
 
Example #17
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 5 votes vote down vote up
protected void fixEntityUUIDs(CompoundTag root) {
	ListTag<CompoundTag> entities = withDefault(() -> root.getCompoundTag("Level").getListTag("Entities").asCompoundTagList(), null);
	if (entities == null) {
		return;
	}
	entities.forEach(this::fixEntityUUID);
}
 
Example #18
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return Things that are in post processing in this chunk.
 */
public ListTag<ListTag<?>> getPostProcessing() {
	return postProcessing;
}
 
Example #19
Source File: MCAFileTest.java    From NBT with MIT License 4 votes vote down vote up
public void testGetters() {
	MCAFile f = assertThrowsNoException(() -> MCAUtil.read(copyResourceToTmp("r.2.2.mca")));
	assertNotNull(f);

	assertThrowsRuntimeException(() -> f.getChunk(-1), IndexOutOfBoundsException.class);
	assertThrowsRuntimeException(() -> f.getChunk(1024), IndexOutOfBoundsException.class);
	assertNotNull(assertThrowsNoRuntimeException(() -> f.getChunk(0)));
	assertNotNull(assertThrowsNoRuntimeException(() -> f.getChunk(1023)));
	assertNotNull(assertThrowsNoRuntimeException(() -> f.getChunk(96, 64)));
	assertNotNull(assertThrowsNoRuntimeException(() -> f.getChunk(95, 95)));
	assertNull(assertThrowsNoRuntimeException(() -> f.getChunk(63, 64)));
	assertNull(assertThrowsNoRuntimeException(() -> f.getChunk(95, 64)));
	assertNotNull(assertThrowsNoRuntimeException(() -> f.getChunk(64, 96)));
	assertNull(assertThrowsNoRuntimeException(() -> f.getChunk(64, 63)));
	assertNull(assertThrowsNoRuntimeException(() -> f.getChunk(64, 95)));
	//not loaded

	MCAFile u = new MCAFile(2, 2);
	assertThrowsRuntimeException(() -> u.getChunk(-1), IndexOutOfBoundsException.class);
	assertThrowsRuntimeException(() -> u.getChunk(1024), IndexOutOfBoundsException.class);
	assertNull(assertThrowsNoRuntimeException(() -> u.getChunk(0)));
	assertNull(assertThrowsNoRuntimeException(() -> u.getChunk(1023)));

	assertEquals(1628, f.getChunk(0).getDataVersion());
	assertEquals(1538048269, f.getChunk(0).getLastMCAUpdate());
	assertEquals(1205486986, f.getChunk(0).getLastUpdate());
	assertNotNull(f.getChunk(0).getBiomes());
	assertNull(f.getChunk(0).getHeightMaps());
	assertNull(f.getChunk(0).getCarvingMasks());
	assertEquals(new ListTag<>(CompoundTag.class), f.getChunk(0).getEntities());
	assertNull(f.getChunk(0).getTileEntities());
	assertNull(f.getChunk(0).getTileTicks());
	assertNull(f.getChunk(0).getLiquidTicks());
	assertNull(f.getChunk(0).getLights());
	assertNull(f.getChunk(0).getLiquidsToBeTicked());
	assertNull(f.getChunk(0).getToBeTicked());
	assertNull(f.getChunk(0).getPostProcessing());
	assertNotNull(f.getChunk(0).getStructures());

	assertNotNull(f.getChunk(0).getSection(0).getSkyLight());
	assertEquals(2048, f.getChunk(0).getSection(0).getSkyLight().length);
	assertNotNull(f.getChunk(0).getSection(0).getBlockLight());
	assertEquals(2048, f.getChunk(0).getSection(0).getBlockLight().length);
	assertNotNull(f.getChunk(0).getSection(0).getBlockStates());
	assertEquals(256, f.getChunk(0).getSection(0).getBlockStates().length);
}
 
Example #20
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return Stuff to be ticked in this chunk.
 */
public ListTag<ListTag<?>> getToBeTicked() {
	return toBeTicked;
}
 
Example #21
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return THe liquids to be ticked in this chunk.
 */
public ListTag<ListTag<?>> getLiquidsToBeTicked() {
	return liquidsToBeTicked;
}
 
Example #22
Source File: MCATestCase.java    From NBT with MIT License 4 votes vote down vote up
public ListTag<CompoundTag> getSomeCompoundTagList() {
	ListTag<CompoundTag> l = new ListTag<>(CompoundTag.class);
	l.add(getSomeCompoundTag());
	l.add(getSomeCompoundTag());
	return l;
}
 
Example #23
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return The light sources in this chunk.
 */
public ListTag<ListTag<?>> getLights() {
	return lights;
}
 
Example #24
Source File: MCATestCase.java    From NBT with MIT License 4 votes vote down vote up
public ListTag<ListTag<?>> getSomeListTagList() {
	ListTag<ListTag<?>> l = new ListTag<>(ListTag.class);
	l.add(getSomeCompoundTagList());
	l.add(getSomeCompoundTagList());
	return l;
}
 
Example #25
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return The liquid ticks of this chunk.
 */
public ListTag<CompoundTag> getLiquidTicks() {
	return liquidTicks;
}
 
Example #26
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return The tile ticks of this chunk.
 */
public ListTag<CompoundTag> getTileTicks() {
	return tileTicks;
}
 
Example #27
Source File: Anvil113ChunkDataProcessor.java    From mcaselector with MIT License 4 votes vote down vote up
@Override
public void drawChunk(CompoundTag root, ColorMapping colorMapping, int x, int z, int[] pixelBuffer, int[] waterPixels, byte[] terrainHeights, byte[] waterHeights, boolean water) {
	CompoundTag level = withDefault(() -> root.getCompoundTag("Level"), null);
	if (level == null) {
		return;
	}

	String status = withDefault(() -> level.getString("Status"), null);
	if (status == null || "empty".equals(status)) {
		return;
	}

	Tag<?> rawSections = level.get("Sections");
	if (rawSections == null || rawSections.getID() == LongArrayTag.ID) {
		return;
	}

	ListTag<CompoundTag> sections = catchClassCastException(((ListTag<?>) rawSections)::asCompoundTagList);
	if (sections == null) {
		return;
	}

	sections.sort(this::filterSections);

	int[] biomes = withDefault(() -> level.getIntArray("Biomes"), null);

	for (int cx = 0; cx < Tile.CHUNK_SIZE; cx++) {
		zLoop:
		for (int cz = 0; cz < Tile.CHUNK_SIZE; cz++) {

			int biome = getBiomeAtBlock(biomes, cx, 255, cz);

			//loop over sections
			boolean waterDepth = false;
			for (int i = 0; i < sections.size(); i++) {
				final int si = i;
				CompoundTag section;
				ListTag<?> rawPalette;
				ListTag<CompoundTag> palette;
				if ((section = sections.get(si)) == null
						|| (rawPalette = section.getListTag("Palette")) == null
						|| (palette = rawPalette.asCompoundTagList()) == null) {
					continue;
				}
				long[] blockStates = withDefault(() -> sections.get(si).getLongArray("BlockStates"), null);
				if (blockStates == null) {
					continue;
				}

				Byte height = withDefault(() -> sections.get(si).getByte("Y"), null);
				if (height == null) {
					continue;
				}

				int sectionHeight = height * 16;

				int bits = blockStates.length / 64;
				int clean = ((int) Math.pow(2, bits) - 1);

				for (int cy = Tile.CHUNK_SIZE - 1; cy >= 0; cy--) {
					int paletteIndex = getPaletteIndex(getIndex(cx, cy, cz), blockStates, bits, clean);
					CompoundTag blockData = palette.get(paletteIndex);

					//ignore bedrock and netherrack until 75
					if (isIgnoredInNether(biome, blockData, sectionHeight + cy)) {
						continue;
					}

					if (!isEmpty(paletteIndex, blockData)) {
						int regionIndex = (z + cz) * Tile.SIZE + (x + cx);
						if (water) {
							if (!waterDepth) {
								pixelBuffer[regionIndex] = colorMapping.getRGB(blockData) | 0xFF000000; // water color
								waterHeights[regionIndex] = (byte) (sectionHeight + cy); // height of highest water or terrain block
							}
							if (isWater(blockData)) {
								waterDepth = true;
								continue;
							} else {
								waterPixels[regionIndex] = colorMapping.getRGB(blockData) | 0xFF000000; // color of block at bottom of water
							}
						} else {
							pixelBuffer[regionIndex] = colorMapping.getRGB(blockData) | 0xFF000000;
						}
						terrainHeights[regionIndex] = (byte) (sectionHeight + cy); // height of bottom of water
						continue zLoop;
					}
				}
			}
		}
	}
}
 
Example #28
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 4 votes vote down vote up
@Override
public void drawChunk(CompoundTag root, ColorMapping colorMapping, int x, int z, int[] pixelBuffer, int[] waterPixels, byte[] terrainHeights, byte[] waterHeights, boolean water) {
	ListTag<CompoundTag> sections = withDefault(() -> root.getCompoundTag("Level").getListTag("Sections").asCompoundTagList(), null);
	if (sections == null) {
		return;
	}
	sections.sort(this::filterSections);

	//loop over x / z
	for (int cx = 0; cx < Tile.CHUNK_SIZE; cx++) {
		zLoop:
		for (int cz = 0; cz < Tile.CHUNK_SIZE; cz++) {

			byte[] biomes = withDefault(() -> root.getCompoundTag("Level").getByteArray("Biomes"), null);
			int biome = -1;
			if (biomes != null && biomes.length != 0) {
				biome = biomes[getBlockIndex(cx, 0, cz)];
			}

			boolean waterDepth = false;
			//loop over sections
			for (int i = 0; i < sections.size(); i++) {
				final int si = i;
				byte[] blocks = withDefault(() -> sections.get(si).getByteArray("Blocks"), null);
				if (blocks == null) {
					continue;
				}
				byte[] data = withDefault(() -> sections.get(si).getByteArray("Data"), null);
				if (data == null) {
					continue;
				}

				Byte height = withDefault(() -> sections.get(si).getByte("Y"), null);
				if (height == null) {
					continue;
				}
				int sectionHeight = height * 16;

				//loop over y value in section from top to bottom
				for (int cy = Tile.CHUNK_SIZE - 1; cy >= 0; cy--) {
					int index = getBlockIndex(cx, cy, cz);
					short block = (short) (blocks[index] & 0xFF);

					//ignore bedrock and netherrack until 75
					if (isIgnoredInNether(biome, block, sectionHeight + cy)) {
						continue;
					}

					byte blockData = (byte) (index % 2 == 0 ? data[index / 2] & 0x0F : (data[index / 2] >> 4) & 0x0F);

					if (!isEmpty(block)) {
						int regionIndex = (z + cz) * Tile.SIZE + (x + cx);
						if (water) {
							if (!waterDepth) {
								pixelBuffer[regionIndex] = colorMapping.getRGB(((block << 4) + blockData)) | 0xFF000000;
								waterHeights[regionIndex] = (byte) (sectionHeight + cy);
							}
							if (isWater(block)) {
								waterDepth = true;
								continue;
							} else {
								waterPixels[regionIndex] = colorMapping.getRGB(((block << 4) + blockData)) | 0xFF000000;
							}
						} else {
							pixelBuffer[regionIndex] = colorMapping.getRGB(((block << 4) + blockData)) | 0xFF000000;
						}
						terrainHeights[regionIndex] = (byte) (sectionHeight + cy);
						continue zLoop;
					}
				}
			}
		}
	}
}
 
Example #29
Source File: Anvil112ChunkDataProcessor.java    From mcaselector with MIT License 4 votes vote down vote up
private void mergeCompoundTagLists(CompoundTag source, CompoundTag destination, List<Range> ranges, String name, Function<CompoundTag, Integer> ySupplier) {
	ListTag<CompoundTag> sourceElements = withDefault(() -> source.getCompoundTag("Level").getListTag(name).asCompoundTagList(), new ListTag<>(CompoundTag.class));
	ListTag<CompoundTag> destinationElements = withDefault(() -> destination.getCompoundTag("Level").getListTag(name).asCompoundTagList(), new ListTag<>(CompoundTag.class));

	initLevel(destination).put(name, mergeLists(sourceElements, destinationElements, ranges, ySupplier));
}
 
Example #30
Source File: Chunk.java    From NBT with MIT License 4 votes vote down vote up
/**
 * @return The entities of this chunk.
 */
public ListTag<CompoundTag> getEntities() {
	return entities;
}