Java Code Examples for protocolsupport.protocol.utils.ProtocolVersionsHelper

The following examples show how to use protocolsupport.protocol.utils.ProtocolVersionsHelper. These examples are extracted from open source projects. 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
protected ParticleDataSerializer() {
	register(Particle.class, (to, particle) -> {}, ProtocolVersionsHelper.UP_1_13);
	register(ParticleDust.class, (to, particle) -> {
		to.writeFloat(particle.getRed());
		to.writeFloat(particle.getGreen());
		to.writeFloat(particle.getBlue());
		to.writeFloat(particle.getScale());
	}, ProtocolVersionsHelper.UP_1_13);
	Arrays.stream(ProtocolVersionsHelper.UP_1_13)
	.forEach(version -> {
		FlatteningBlockDataTable flatteningBlockDataTable = FlatteningBlockData.REGISTRY.getTable(version);
		register(ParticleBlock.class, (to, particle) -> VarNumberSerializer.writeVarInt(to, flatteningBlockDataTable.getBlockDataRemap(particle.getBlockData())), version);
		register(ParticleFallingDust.class, (to, particle) -> VarNumberSerializer.writeFixedSizeVarInt(to, flatteningBlockDataTable.getBlockDataRemap(particle.getBlockData())), version);
		register(ParticleItem.class, (to, particle) -> ItemStackSerializer.writeItemStack(to, version, particle.getItemStack()), version);
	});
}
 
Example 2
protected AreaEffectCloudEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.RADIUS, 7), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.RADIUS, 6), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.RADIUS, 5), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.COLOR, 8), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.COLOR, 7), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.COLOR, 6), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.SINGLE_POINT, 9), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.SINGLE_POINT, 8), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.AreaEffectCloud.SINGLE_POINT, 7), ProtocolVersionsHelper.ALL_1_9);

	addRemapPerVersion(version -> new AreaEffectCloudModernParticleObjectMetadataRemapper(10, ParticleRemapper.REGISTRY.getTable(version)), ProtocolVersionsHelper.UP_1_14);
	addRemapPerVersion(version -> new AreaEffectCloudModernParticleObjectMetadataRemapper(9, ParticleRemapper.REGISTRY.getTable(version)), ProtocolVersionsHelper.ALL_1_13);
	addRemapPerVersion(version -> new AreaEffectCloudLegacyParticleObjectMetadataRemapper(9, ParticleRemapper.REGISTRY.getTable(version)), ProtocolVersionsHelper.RANGE__1_10__1_12_2);
	addRemapPerVersion(version -> new AreaEffectCloudLegacyParticleObjectMetadataRemapper(8, ParticleRemapper.REGISTRY.getTable(version)), ProtocolVersionsHelper.ALL_1_9);
}
 
Example 3
protected WitherEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET1, 15), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET1, 14), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET1, 12), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET1, 11), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.Wither.TARGET1, 17), ProtocolVersionsHelper.DOWN_1_8);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET2, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET2, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET2, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET2, 12), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.Wither.TARGET2, 18), ProtocolVersionsHelper.DOWN_1_8);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET3, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET3, 16), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET3, 14), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.TARGET3, 13), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.Wither.TARGET3, 19), ProtocolVersionsHelper.DOWN_1_8);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.INVULNERABLE_TIME, 18), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.INVULNERABLE_TIME, 17), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.INVULNERABLE_TIME, 15), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wither.INVULNERABLE_TIME, 14), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.Wither.INVULNERABLE_TIME, 20), ProtocolVersionsHelper.DOWN_1_8);
}
 
Example 4
protected PandaEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.BREED_TIMER, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.BREED_TIMER, 15), ProtocolVersionsHelper.ALL_1_14);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.SNEEZE_TIMER, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.SNEEZE_TIMER, 16), ProtocolVersionsHelper.ALL_1_14);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.EAT_TIMER, 18), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.EAT_TIMER, 17), ProtocolVersionsHelper.ALL_1_14);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.GENE_MAIN, 19), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.GENE_MAIN, 18), ProtocolVersionsHelper.ALL_1_14);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.GENE_HIDDEN, 20), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.GENE_HIDDEN, 19), ProtocolVersionsHelper.ALL_1_14);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.PANDA_FLAGS, 21), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Panda.PANDA_FLAGS, 20), ProtocolVersionsHelper.ALL_1_14);
}
 
Example 5
protected TurtleEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HOME_POS, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HOME_POS, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HOME_POS, 13), ProtocolVersionsHelper.ALL_1_13);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HAS_EGG, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HAS_EGG, 16), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.HAS_EGG, 14), ProtocolVersionsHelper.ALL_1_13);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.LAYING_EGG, 18), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.LAYING_EGG, 17), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.LAYING_EGG, 15), ProtocolVersionsHelper.ALL_1_13);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVEL_POS, 19), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVEL_POS, 18), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVEL_POS, 16), ProtocolVersionsHelper.ALL_1_13);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.GOING_HOME, 20), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.GOING_HOME, 19), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.GOING_HOME, 17), ProtocolVersionsHelper.ALL_1_13);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVELING, 21), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVELING, 20), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Turtle.TRAVELING, 18), ProtocolVersionsHelper.ALL_1_13);
}
 
Example 6
protected ShulkerEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.DIRECTION, 15), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.DIRECTION, 14), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.DIRECTION, 12), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.DIRECTION, 11), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.ATTACHMENT_POS, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.ATTACHMENT_POS, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.ATTACHMENT_POS, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.ATTACHMENT_POS, 12), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.SHIELD_HEIGHT, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.SHIELD_HEIGHT, 16), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.SHIELD_HEIGHT, 14), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.SHIELD_HEIGHT, 13), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.COLOR, 18), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.COLOR, 17), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Shulker.COLOR, 15), ProtocolVersionsHelper.RANGE__1_11__1_13_2);
}
 
Example 7
protected CreeperEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.STATE, 15), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.STATE, 14), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.STATE, 12), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.STATE, 11), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.Creeper.STATE, 16), ProtocolVersionsHelper.DOWN_1_8);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.POWERED, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.POWERED, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.POWERED, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.POWERED, 12), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Creeper.POWERED, 17), ProtocolVersionsHelper.DOWN_1_8);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.IGNITED, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.IGNITED, 16), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.IGNITED, 14), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Creeper.IGNITED, 13), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Creeper.IGNITED, 18), ProtocolVersionsHelper.DOWN_1_8);
}
 
Example 8
public static void writePackInfo(ByteBuf serializer, ResourcePack pack) {
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, pack.getPackId());
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, pack.getPackVersion());
	serializer.writeLongLE(pack.getPackSize());
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, ""); // ???
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, ""); // ???
}
 
Example 9
@Override
public void toData(ConnectionImpl connection, ByteBuf serializer) {
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, packId);
	serializer.writeIntLE(chunkIdx);
	serializer.writeLongLE(CHUNK_SIZE * chunkIdx);
	serializer.writeIntLE(packChunk.length);
	serializer.writeBytes(packChunk);
}
 
Example 10
@Override
public void toData(ConnectionImpl connection, ByteBuf serializer) {
	StringSerializer.writeString(serializer, ProtocolVersionsHelper.LATEST_PE, pack.getPackId());
	serializer.writeIntLE(ResourcePackChunkDataPacket.CHUNK_SIZE); //max chunk size 1MB
	serializer.writeIntLE((int) Math.ceil(pack.getPackSize() / ResourcePackChunkDataPacket.CHUNK_SIZE)); //chunk count
	serializer.writeLongLE(pack.getPackSize()); //res pack size
	byte[] hash = pack.getSha256();
	ArraySerializer.writeVarIntByteArray(serializer, hash);
}
 
Example 11
public AbstractPacketEncoder(Connection connection, NetworkDataCache cache) {
	super(Protocol.HANDSHAKE, true, ProtocolVersionsHelper.LATEST_PC.getId());
	this.connection = connection;
	this.cache = cache;
	registry.setCallBack(transformer -> {
		transformer.setConnection(this.connection);
		transformer.setSharedStorage(this.cache);
	});
}
 
Example 12
public LegacyAbstractFromServerPacketDecoder(Connection connection, NetworkDataCache cache) {
	super(Protocol.GAME, false, ProtocolVersionsHelper.LATEST_PC.getId());
	this.connection = connection;
	this.cache = cache;
	registry.setCallBack(transformer -> {
		transformer.setConnection(this.connection);
		transformer.setSharedStorage(this.cache);
	});
}
 
Example 13
public LegacyAbstractFromClientPacketDecoder(Connection connection, NetworkDataCache cache) {
	super(Protocol.HANDSHAKE, true, ProtocolVersionsHelper.LATEST_PC.getId());
	this.connection = connection;
	this.cache = cache;
	registry.setCallBack(transformer -> {
		transformer.setConnection(this.connection);
		transformer.setSharedStorage(this.cache);
	});
}
 
Example 14
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 15
@Override
public Collection<PacketWrapper> toNative() {
	return Arrays.asList(
			new PacketWrapper(new Handshake(ProtocolVersionsHelper.LATEST_PC.getId(), "127.0.0.1", 25565, 1), Unpooled.EMPTY_BUFFER),
			new PacketWrapper(new StatusRequest(), Unpooled.wrappedBuffer(readbytes))
	);
}
 
Example 16
@Override
public Collection<PacketWrapper> toNative() {
	return Arrays.asList(
		new PacketWrapper(new Handshake(ProtocolVersionsHelper.LATEST_PC.getId(), host, port, 1), Unpooled.EMPTY_BUFFER),
		new PacketWrapper(new StatusRequest(), Unpooled.wrappedBuffer(readbytes))
	);
}
 
Example 17
@Override
public Collection<PacketWrapper> toNative() {
	return Arrays.asList(
		new PacketWrapper(new Handshake(ProtocolVersionsHelper.LATEST_PC.getId(), host, port, 2), Unpooled.wrappedBuffer(readbytes)),
		new PacketWrapper(new LoginRequest(username), Unpooled.EMPTY_BUFFER)
	);
}
 
Example 18
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 19
/**
 * Writes itemstack using latest protocol version format
 * @param to buffer to write to
 * @param itemstack itemstack
 */
public static void writeItemStack(ByteBuf to, NetworkItemStack itemstack) {
	if (itemstack.isNull()) {
		to.writeBoolean(false);
	} else {
		to.writeBoolean(true);
		VarNumberSerializer.writeVarInt(to, itemstack.getTypeId());
		to.writeByte(itemstack.getAmount());
		writeTag(to, ProtocolVersionsHelper.LATEST_PC, itemstack.getNBT());
	}
}
 
Example 20
Source Project: ProtocolSupport   Source File: Ping.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, hostname);
	setprotocol.writeShort(port);
	VarNumberSerializer.writeVarInt(setprotocol, 1);
	codec.read(setprotocol);

	codec.read(ServerBoundPacketData.create(PacketType.SERVERBOUND_STATUS_REQUEST));
}
 
Example 21
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, hostname);
	setprotocol.writeShort(port);
	VarNumberSerializer.writeVarInt(setprotocol, 2);
	codec.read(setprotocol);

	ServerBoundPacketData loginstart = ServerBoundPacketData.create(PacketType.SERVERBOUND_LOGIN_START);
	StringSerializer.writeVarIntUTF8String(loginstart, username);
	codec.read(loginstart);
}
 
Example 22
Source Project: ProtocolSupport   Source File: Ping.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, "");
	setprotocol.writeShort(Bukkit.getPort());
	VarNumberSerializer.writeVarInt(setprotocol, 1);
	codec.read(setprotocol);

	codec.read(ServerBoundPacketData.create(PacketType.SERVERBOUND_STATUS_REQUEST));
}
 
Example 23
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, hostname);
	setprotocol.writeShort(port);
	VarNumberSerializer.writeVarInt(setprotocol, 2);
	codec.read(setprotocol);

	ServerBoundPacketData loginstart = ServerBoundPacketData.create(PacketType.SERVERBOUND_LOGIN_START);
	StringSerializer.writeVarIntUTF8String(loginstart, username);
	codec.read(loginstart);
}
 
Example 24
Source Project: ProtocolSupport   Source File: Ping.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, "");
	setprotocol.writeShort(Bukkit.getPort());
	VarNumberSerializer.writeVarInt(setprotocol, 1);
	codec.read(setprotocol);

	codec.read(ServerBoundPacketData.create(PacketType.SERVERBOUND_STATUS_REQUEST));
}
 
Example 25
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, hostname);
	setprotocol.writeShort(port);
	VarNumberSerializer.writeVarInt(setprotocol, nextState);
	codec.read(setprotocol);
}
 
Example 26
protected LivingEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 10), ProtocolVersionsHelper.ALL_1_7);
	addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 10, 64), ProtocolVersionsHelper.ALL_1_6);
	addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 5, 64), ProtocolVersionsHelper.DOWN_1_5_2);

	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Entity.NAMETAG_VISIBLE, 11), ProtocolVersionsHelper.RANGE__1_6__1_7);
	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Entity.NAMETAG_VISIBLE, 6), ProtocolVersionsHelper.DOWN_1_5_2);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 7), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 6), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 5), ProtocolVersionsHelper.ALL_1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 8), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 7), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 6), ProtocolVersion.getAllBetween(ProtocolVersion.MINECRAFT_1_9_4, ProtocolVersion.MINECRAFT_1_6_1));

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 9), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 8), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 7), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 7), ProtocolVersionsHelper.RANGE__1_6__1_8);
	addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 8), ProtocolVersionsHelper.DOWN_1_5_2);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 10), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 9), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 8), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 8), ProtocolVersionsHelper.RANGE__1_6__1_8);
	addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 9), ProtocolVersionsHelper.DOWN_1_5_2);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 11), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 10), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 9), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 9), ProtocolVersionsHelper.RANGE__1_6__1_8);
	addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 10), ProtocolVersionsHelper.DOWN_1_5_2);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ABSORBTION_HEALTH, 12), ProtocolVersionsHelper.UP_1_15);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.BED_LOCATION, 13), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.BED_LOCATION, 12), ProtocolVersionsHelper.ALL_1_14);
}
 
Example 27
protected TameableEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Tameable.TAME_FLAGS, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Tameable.TAME_FLAGS, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Tameable.TAME_FLAGS, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Tameable.TAME_FLAGS, 12), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Tameable.TAME_FLAGS, 16), ProtocolVersionsHelper.DOWN_1_8);
}
 
Example 28
protected InsentientEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Insentient.INS_FLAGS, 14), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Insentient.INS_FLAGS, 13), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Insentient.INS_FLAGS, 11), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Insentient.INS_FLAGS, 10), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Insentient.INS_FLAGS, 15), ProtocolVersion.MINECRAFT_1_8);
}
 
Example 29
protected ArmorStandEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.ARMORSTAND_FLAGS, 14), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.ARMORSTAND_FLAGS, 13), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.ARMORSTAND_FLAGS, 11), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.ARMORSTAND_FLAGS, 10), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.HEAD_ROT, 15), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.HEAD_ROT, 14), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.HEAD_ROT, 12), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.HEAD_ROT, 11), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.BODY_ROT, 16), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.BODY_ROT, 15), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.BODY_ROT, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.BODY_ROT, 12), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_ARM_ROT, 17), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_ARM_ROT, 16), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_ARM_ROT, 14), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_ARM_ROT, 13), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_ARM_ROT, 18), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_ARM_ROT, 17), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_ARM_ROT, 15), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_ARM_ROT, 14), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_LEG_ROT, 19), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_LEG_ROT, 18), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_LEG_ROT, 16), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.LEFT_LEG_ROT, 15), ProtocolVersionsHelper.RANGE__1_8__1_9);

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_LEG_ROT, 20), ProtocolVersionsHelper.UP_1_15);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_LEG_ROT, 19), ProtocolVersionsHelper.ALL_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_LEG_ROT, 17), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.ArmorStand.RIGHT_LEG_ROT, 16), ProtocolVersionsHelper.RANGE__1_8__1_9);
}
 
Example 30
protected MinecartCommandEntityMetadataRemapper() {
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.COMMAND, 13), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.COMMAND, 12), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.COMMAND, 11), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.COMMAND, 23), ProtocolVersion.getAllBetween(ProtocolVersion.MINECRAFT_1_7_5, ProtocolVersion.MINECRAFT_1_8));

	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.LAST_OUTPUT, 14), ProtocolVersionsHelper.UP_1_14);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.LAST_OUTPUT, 13), ProtocolVersionsHelper.RANGE__1_10__1_13_2);
	addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.MinecartCommand.LAST_OUTPUT, 12), ProtocolVersionsHelper.ALL_1_9);
	addRemap(new IndexValueRemapperChatToString(NetworkEntityMetadataObjectIndex.MinecartCommand.LAST_OUTPUT, 24, 64), ProtocolVersion.getAllBetween(ProtocolVersion.MINECRAFT_1_7_5, ProtocolVersion.MINECRAFT_1_8));
}