ProtocolLib

3M Downloads

Deprecated/Modified Packet types in API (1.19 dev builds)

FlailoftheLord opened this issue · 5 comments

commented

Make sure you're doing the following

  • [ y] You're using the latest build for your server version
  • [ y] This isn't an issue caused by another plugin
  • [ y] You've checked for duplicate issues
  • [ y] You didn't use /reload

Describe the question
Two Packets are deprecated and don't register with protocollib anymore.
I have a plugin that uses them to hide players on a server, but it no longer works and spits out a warning on startup.

[21:03:38 WARN]: [ProtocolLib] [PacketFilterManager] Plugin Invisy tried to register listener for unknown packet SPAWN_ENTITY_PAINTING[PLAY, SERVER, 243, classNames: [net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityPainting, net.minecraft.network.protocol.game.ClientboundSpawnEntityPaintingPacket, net.minecraft.network.play.server.SPacketSpawnPainting] (unregistered)] [direction: from SERVER]
[21:03:38 WARN]: [ProtocolLib] [PacketFilterManager] Plugin Invisy tried to register listener for unknown packet SPAWN_ENTITY_LIVING[PLAY, SERVER, 244, classNames: [net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving, net.minecraft.network.protocol.game.ClientboundSpawnEntityLivingPacket, net.minecraft.network.play.server.SPacketSpawnMob] (unregistered)] [direction: from SERVER]

The two packets in question are PacketType.Play.Server.[ SPAWN_ENTITY_LIVING, SPAWN_ENTITY_PAINTING]
Are there new alternatives for these?

API method(s) used

//Refferencing the packet event
PacketEvent#getPacket()

Code is from dmulloys' EntityHider.java project on github
https://gist.github.com/dmulloy2/5526f5bf906c064c255e

Expected behavior
in 1.18 protocollib it worked well.
something's changed with the update to 1.19

Code

          
private static final PacketType[] ENTITY_PACKETS = {
			ENTITY_EQUIPMENT, ANIMATION, NAMED_ENTITY_SPAWN,
			COLLECT, SPAWN_ENTITY, SPAWN_ENTITY_LIVING, SPAWN_ENTITY_PAINTING, SPAWN_ENTITY_EXPERIENCE_ORB,
			ENTITY_VELOCITY, REL_ENTITY_MOVE, ENTITY_LOOK,
			ENTITY_TELEPORT, ENTITY_HEAD_ROTATION, ENTITY_STATUS, ATTACH_ENTITY, ENTITY_METADATA,
			ENTITY_EFFECT, REMOVE_ENTITY_EFFECT, BLOCK_BREAK_ANIMATION};
           
       / * Construct the packet listener that will be used to intercept every entity-related packet.
	 * 
	 * @param plugin
	 *                   - the parent plugin.
	 * @return The packet listener.
	 */
	private PacketAdapter constructProtocol(Plugin plugin) {
		return new PacketAdapter(plugin, ENTITY_PACKETS) {
			@Override
			public void onPacketSending(PacketEvent event) {
				int entityID = event.getPacket().getIntegers().read(0);

				// See if this packet should be cancelled
				if (!isVisible(event.getPlayer(), entityID)) {
					event.setCancelled(true);
				}
			}
		};
	}

Additional context
Running on Papermc 1.19 build 58

commented

In 1.19 mojang removed the EntityLiving/EntityPainting packets, therefore ProtocolLib is printing a warning that you're registering a listener for a packet which no longer exists.

commented
commented

Just cancel SPAWN_ENTITY, it now covers all entity types (aside experience orbs and players)

commented

Yes

commented

what packet handles players then?
Is that NAMED_ENTITY_SPAWN ?