Java Code Examples for protocolsupport.protocol.serializer.VarNumberSerializer#readVarInt()

The following examples show how to use protocolsupport.protocol.serializer.VarNumberSerializer#readVarInt() . 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: MiddleEntityAttributes.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	super.readServerData(serverdata);
	int attributesCount = serverdata.readInt();
	for (int i = 0; i < attributesCount; i++) {
		Attribute attribute = new Attribute();
		attribute.key = StringSerializer.readVarIntUTF8String(serverdata);
		attribute.value = serverdata.readDouble();
		if (attribute.value == 0.0D) {
			attribute.value = 0.00000001;
		}
		attribute.modifiers = new Modifier[VarNumberSerializer.readVarInt(serverdata)];
		for (int j = 0; j < attribute.modifiers.length; j++) {
			Modifier modifier = new Modifier();
			modifier.uuid = UUIDSerializer.readUUID2L(serverdata);
			modifier.amount = serverdata.readDouble();
			modifier.operation = serverdata.readByte();
			attribute.modifiers[j] = modifier;
		}
		attributes.put(attribute.key, attribute);
	}
}
 
Example 2
Source File: BlockPlace.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	hand = MiscSerializer.readVarIntEnum(clientdata, UsedHand.CONSTANT_LOOKUP);
	PositionSerializer.readPositionTo(clientdata, position);
	face = VarNumberSerializer.readVarInt(clientdata);
	cX = clientdata.readFloat();
	cY = clientdata.readFloat();
	cZ = clientdata.readFloat();
	insideblock = clientdata.readBoolean();
}
 
Example 3
Source File: PacketDecompressor.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf from, List<Object> list) throws DataFormatException {
	if (!from.isReadable()) {
		return;
	}
	int uncompressedlength = VarNumberSerializer.readVarInt(from);
	if (uncompressedlength == 0) {
		list.add(from.readBytes(from.readableBytes()));
	} else {
		if (uncompressedlength > maxPacketLength) {
			throw new DecoderException(MessageFormat.format("Badly compressed packet - size of {0} is larger than protocol maximum of {1}", uncompressedlength, maxPacketLength));
		}
		list.add(Unpooled.wrappedBuffer(decompressor.decompress(MiscSerializer.readAllBytes(from), uncompressedlength)));
	}
}
 
Example 4
Source File: ProtocolUtils.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
protected static ProtocolVersion readNewHandshake(ByteBuf data) {
	int packetId = VarNumberSerializer.readVarInt(data);
	if (packetId == 0x00) {
		return ProtocolVersionsHelper.getNewProtocolVersion(VarNumberSerializer.readVarInt(data));
	} else {
		throw new DecoderException(packetId + " is not a valid packet id");
	}
}
 
Example 5
Source File: MiddleWorldSound.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);
	category = MiscSerializer.readVarIntEnum(serverdata, SoundCategory.CONSTANT_LOOKUP);
	x = serverdata.readInt();
	y = serverdata.readInt();
	z = serverdata.readInt();
	volume = serverdata.readFloat();
	pitch = serverdata.readFloat();
}
 
Example 6
Source File: ParticleFallingDust.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void readData(ByteBuf buf) {
	blockdata = VarNumberSerializer.readVarInt(buf);
}
 
Example 7
Source File: TabComplete.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	id = VarNumberSerializer.readVarInt(clientdata);
	string = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
}
 
Example 8
Source File: LegacyCustomPayloadData.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void transformAndWritePickItem(PacketDataCodec codec, ByteBuf data) {
	int slot = VarNumberSerializer.readVarInt(data);
	codec.read(MiddlePickItem.create(slot));
}
 
Example 9
Source File: MiddleBlockBreakAnimation.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	entityId = VarNumberSerializer.readVarInt(serverdata);
	super.readServerData(serverdata);
	stage = serverdata.readByte();
}
 
Example 10
Source File: ResourcePackStatus.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	result = VarNumberSerializer.readVarInt(clientdata);
}
 
Example 11
Source File: MiddleUpdateViewDistance.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	distance = VarNumberSerializer.readVarInt(serverdata);
}
 
Example 12
Source File: NetworkEntityMetadataObjectBlockData.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void readFromStream(ByteBuf from) {
	value = VarNumberSerializer.readVarInt(from);
}
 
Example 13
Source File: MiddleSetExperience.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	exp = serverdata.readFloat();
	level = VarNumberSerializer.readVarInt(serverdata);
	totalExp = VarNumberSerializer.readVarInt(serverdata);
}
 
Example 14
Source File: QueryBlockNBT.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	id = VarNumberSerializer.readVarInt(clientdata);
	PositionSerializer.readLegacyPositionLTo(clientdata, position);
}
 
Example 15
Source File: MiddleSetCompression.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	threshold = VarNumberSerializer.readVarInt(serverdata);
}
 
Example 16
Source File: ModernPacketCodec.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public int readPacketId(ByteBuf from) {
	return VarNumberSerializer.readVarInt(from);
}
 
Example 17
Source File: UpdateCommandMinecart.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	entityId = VarNumberSerializer.readVarInt(clientdata);
	command = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	trackOutput = clientdata.readBoolean();
}
 
Example 18
Source File: ModalRequestPacket.java    From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void readFromClientData(ConnectionImpl connection, ByteBuf clientdata) {
	modalId = VarNumberSerializer.readVarInt(clientdata);
	modalJSON = StringSerializer.readString(clientdata, connection.getVersion());
}
 
Example 19
Source File: PickItem.java    From ProtocolSupport with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	slot = VarNumberSerializer.readVarInt(clientdata);
}
 
Example 20
Source File: ModalResponsePacket.java    From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void readFromClientData(ConnectionImpl connection, ByteBuf clientdata) {
	modalId = VarNumberSerializer.readVarInt(clientdata);
	modalJSON = StringSerializer.readString(clientdata, connection.getVersion());
}