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

The following examples show how to use protocolsupport.protocol.serializer.VarNumberSerializer#readVarLong() . 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: UpdateStructureBlock.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	PositionSerializer.readLegacyPositionLTo(clientdata, position);
	action = MiscSerializer.readVarIntEnum(clientdata, Action.CONSTANT_LOOKUP);
	mode = MiscSerializer.readVarIntEnum(clientdata, Mode.CONSTANT_LOOKUP);
	name = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	offsetX = clientdata.readByte();
	offsetY = clientdata.readByte();
	offsetZ = clientdata.readByte();
	sizeX = clientdata.readByte();
	sizeY = clientdata.readByte();
	sizeZ = clientdata.readByte();
	mirror = MiscSerializer.readVarIntEnum(clientdata, Mirror.CONSTANT_LOOKUP);
	rotation = MiscSerializer.readVarIntEnum(clientdata, Rotation.CONSTANT_LOOKUP);
	metadata = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	integrity = clientdata.readFloat();
	seed = VarNumberSerializer.readVarLong(clientdata);
	flags = clientdata.readByte();
}
 
Example 2
Source File: UpdateStructureBlock.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	PositionSerializer.readPositionTo(clientdata, position);
	action = MiscSerializer.readVarIntEnum(clientdata, Action.CONSTANT_LOOKUP);
	mode = MiscSerializer.readVarIntEnum(clientdata, Mode.CONSTANT_LOOKUP);
	name = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	offsetX = clientdata.readByte();
	offsetY = clientdata.readByte();
	offsetZ = clientdata.readByte();
	sizeX = clientdata.readByte();
	sizeY = clientdata.readByte();
	sizeZ = clientdata.readByte();
	mirror = MiscSerializer.readVarIntEnum(clientdata, Mirror.CONSTANT_LOOKUP);
	rotation = MiscSerializer.readVarIntEnum(clientdata, Rotation.CONSTANT_LOOKUP);
	metadata = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	integrity = clientdata.readFloat();
	seed = VarNumberSerializer.readVarLong(clientdata);
	flags = clientdata.readByte();
}
 
Example 3
Source File: LegacyCustomPayloadData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void transformAndWriteStructureBlock(PacketDataCodec codec, ByteBuf data) {
	Position position = PositionSerializer.readLegacyPositionI(data);
	MiddleUpdateStructureBlock.Action action = MiddleUpdateStructureBlock.Action.CONSTANT_LOOKUP.getByOrdinal(data.readByte() - 1);
	MiddleUpdateStructureBlock.Mode mode = MiddleUpdateStructureBlock.Mode.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	String name = StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE);
	byte offsetX = (byte) data.readInt();
	byte offsetY = (byte) data.readInt();
	byte offsetZ = (byte) data.readInt();
	byte sizeX = (byte) data.readInt();
	byte sizeY = (byte) data.readInt();
	byte sizeZ = (byte) data.readInt();
	MiddleUpdateStructureBlock.Mirror mirror = MiddleUpdateStructureBlock.Mirror.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	MiddleUpdateStructureBlock.Rotation rotation = MiddleUpdateStructureBlock.Rotation.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	String metadata = StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE);
	int ignoreEntities = data.readBoolean() ? 0x01 : 0;
	int showAir = data.readBoolean() ? 0x02 : 0;
	int showBoundingBox = data.readBoolean() ? 0x04 : 0;
	float integrity = data.readFloat();
	long seed = VarNumberSerializer.readVarLong(data);
	byte flags = (byte) (ignoreEntities | showAir | showBoundingBox);
	codec.read(MiddleUpdateStructureBlock.create(
		position, action, mode, name,
		offsetX, offsetY, offsetZ, sizeX, sizeY, sizeZ,
		mirror, rotation, metadata, integrity, seed, flags
	));
}
 
Example 4
Source File: MiddleWorldBorder.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	action = MiscSerializer.readVarIntEnum(serverdata, Action.CONSTANT_LOOKUP);
	switch (action) {
		case SET_SIZE: {
			radius = serverdata.readDouble();
			break;
		}
		case LERP_SIZE: {
			oldRadius = serverdata.readDouble();
			newRadius = serverdata.readDouble();
			speed = VarNumberSerializer.readVarLong(serverdata);
			break;
		}
		case SET_CENTER: {
			x = serverdata.readDouble();
			z = serverdata.readDouble();
			break;
		}
		case INIT: {
			x = serverdata.readDouble();
			z = serverdata.readDouble();
			oldRadius = serverdata.readDouble();
			newRadius = serverdata.readDouble();
			speed = VarNumberSerializer.readVarLong(serverdata);
			teleportBound = VarNumberSerializer.readVarInt(serverdata);
			warnTime = VarNumberSerializer.readVarInt(serverdata);
			warnBlocks = VarNumberSerializer.readVarInt(serverdata);
			break;
		}
		case SET_WARN_TIME: {
			warnTime = VarNumberSerializer.readVarInt(serverdata);
			break;
		}
		case SET_WARN_BLOCKS: {
			warnBlocks = VarNumberSerializer.readVarInt(serverdata);
			break;
		}
	}
}
 
Example 5
Source File: EntityPickRequestPacket.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) {
	entityId = VarNumberSerializer.readVarLong(clientdata);
	slot = clientdata.readByte();
}
 
Example 6
Source File: EntityDataPacket.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) {
	this.entityId = VarNumberSerializer.readVarLong(clientdata);
	clientdata.skipBytes(clientdata.readableBytes());
}