Java Code Examples for protocolsupport.protocol.serializer.ArraySerializer#readVarIntTArray()

The following examples show how to use protocolsupport.protocol.serializer.ArraySerializer#readVarIntTArray() . 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: MiddleChunkData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	coord = PositionSerializer.readIntChunkCoord(serverdata);
	full = serverdata.readBoolean();
	useExistingLight = serverdata.readBoolean();

	blockMask = VarNumberSerializer.readVarInt(serverdata);
	heightmaps = ItemStackSerializer.readDirectTag(serverdata);
	if (full) {
		for (int i = 0; i < biomes.length; i++) {
			biomes[i] = serverdata.readInt();
		}
	}

	{
		ByteBuf chunkdata = ArraySerializer.readVarIntByteArraySlice(serverdata);
		for (int sectionNumber = 0; sectionNumber < ChunkConstants.SECTION_COUNT_BLOCKS; sectionNumber++) {
			if (BitUtils.isIBitSet(blockMask, sectionNumber)) {
				sections[sectionNumber] = ChunkSectonBlockData.readFromStream(chunkdata);
			}
		}
	}

	tiles = ArraySerializer.readVarIntTArray(serverdata, TileEntity.class, from -> new TileEntity(ItemStackSerializer.readDirectTag(serverdata)));
}
 
Example 2
Source File: MiddleUpdateMap.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	id = VarNumberSerializer.readVarInt(serverdata);
	scale = serverdata.readUnsignedByte();
	showIcons = serverdata.readBoolean();
	locked = serverdata.readBoolean();
	icons = ArraySerializer.readVarIntTArray(
		serverdata, Icon.class,
		from -> new Icon(
			VarNumberSerializer.readVarInt(from),
			from.readUnsignedByte(),
			from.readUnsignedByte(),
			from.readByte(),
			from.readBoolean() ? StringSerializer.readVarIntUTF8String(serverdata) : null
		)
	);
	columns = serverdata.readUnsignedByte();
	if (columns > 0) {
		rows = serverdata.readUnsignedByte();
		xstart = serverdata.readUnsignedByte();
		zstart = serverdata.readUnsignedByte();
		colors = ArraySerializer.readVarIntByteArray(serverdata);
	}
}
 
Example 3
Source File: MiddleStatistics.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	statistics = ArraySerializer.readVarIntTArray(
		serverdata, Statistic.class,
		from -> new Statistic(VarNumberSerializer.readVarInt(from), VarNumberSerializer.readVarInt(from), VarNumberSerializer.readVarInt(from))
	);
}
 
Example 4
Source File: MiddleAdvancements.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void readServerData(ByteBuf serverdata) {
	reset = serverdata.readBoolean();
	advancementsMapping = ArraySerializer.readVarIntTArray(
		serverdata, Any.class,
		buf -> new Any<>(StringSerializer.readVarIntUTF8String(buf), Advancement.read(buf))
	);
	removeAdvancements = ArraySerializer.readVarIntVarIntUTF8StringArray(serverdata);
	advancementsProgress = ArraySerializer.readVarIntTArray(
		serverdata, Any.class,
		buf -> new Any<>(StringSerializer.readVarIntUTF8String(buf), AdvancementProgress.read(buf))
	);
}
 
Example 5
Source File: MiddleAdvancements.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
protected static Advancement read(ByteBuf from) {
	String parentId = from.readBoolean() ? StringSerializer.readVarIntUTF8String(from) : null;
	AdvancementDisplay display = from.readBoolean() ? AdvancementDisplay.read(from) : null;
	String[] criterias = ArraySerializer.readVarIntVarIntUTF8StringArray(from);
	String[][] requirments = ArraySerializer.readVarIntTArray(from, String[].class, ArraySerializer::readVarIntVarIntUTF8StringArray);
	return new Advancement(parentId, display, criterias, requirments);
}
 
Example 6
Source File: MiddleAdvancements.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected static AdvancementProgress read(ByteBuf from) {
	return new AdvancementProgress(ArraySerializer.readVarIntTArray(
		from, Any.class,
		buf -> new Any<>(StringSerializer.readVarIntUTF8String(from), buf.readBoolean() ? buf.readLong() : null)
	));
}
 
Example 7
Source File: MiddleBlockChangeMulti.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	chunkCoord = PositionSerializer.readIntChunkCoord(serverdata);
	records = ArraySerializer.readVarIntTArray(
		serverdata,
		Record.class,
		from -> new Record(serverdata.readUnsignedShort(), VarNumberSerializer.readVarInt(from))
	);
}
 
Example 8
Source File: MiddleTabComplete.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	id = VarNumberSerializer.readVarInt(serverdata);
	start = VarNumberSerializer.readVarInt(serverdata);
	length = VarNumberSerializer.readVarInt(serverdata);
	matches = ArraySerializer.readVarIntTArray(serverdata, CommandMatch.class, data -> {
		String match = StringSerializer.readVarIntUTF8String(serverdata);
		String tooltip = serverdata.readBoolean() ? StringSerializer.readVarIntUTF8String(serverdata) : null;
		return new CommandMatch(match, tooltip);
	});
}
 
Example 9
Source File: MiddleDeclareTags.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
protected static Tag[] readTags(ByteBuf from) {
	return ArraySerializer.readVarIntTArray(from, Tag.class, lFrom -> {
		return new Tag(StringSerializer.readVarIntUTF8String(lFrom), ArraySerializer.readVarIntVarIntArray(lFrom));
	});
}