Disable metadata rewriting for 1.16 (#520)

This commit is contained in:
FivePB (Xer) 2020-06-23 19:39:57 +02:00 committed by GitHub
parent 29b6e01657
commit b3296adf72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 204 deletions

View File

@ -1,4 +1,4 @@
From 9da452ffb41fac35f2eb2731d699d08256f19763 Mon Sep 17 00:00:00 2001
From 00bef612cda98bb7d8c91839c71e7c92c51f9a42 Mon Sep 17 00:00:00 2001
From: "Five (Xer)" <admin@xernium.com>
Date: Wed, 29 Apr 2020 20:52:13 +0200
Subject: [PATCH] Waterfall 1.16
@ -1307,7 +1307,7 @@ index 37ea35e3..98c0c2d7 100644
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
index bc1de55a..ef2a66fa 100644
index bc1de55a..ad80ffc8 100644
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
@@ -67,6 +67,8 @@ public abstract class EntityMap
@ -1315,211 +1315,10 @@ index bc1de55a..ef2a66fa 100644
case ProtocolConstants.MINECRAFT_1_15_2:
return EntityMap_1_15.INSTANCE;
+ case ProtocolConstants.MINECRAFT_1_16:
+ return EntityMap_1_16.INSTANCE;
+ return EntityMap_Dummy.INSTANCE; // Waterfall Skip for 1.16
}
throw new RuntimeException( "Version " + version + " has no entity map" );
}
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java
new file mode 100644
index 00000000..a825c438
--- /dev/null
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16.java
@@ -0,0 +1,194 @@
+// Travertine start
+package net.md_5.bungee.entitymap;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import io.netty.buffer.ByteBuf;
+import net.md_5.bungee.BungeeCord;
+import net.md_5.bungee.UserConnection;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+import net.md_5.bungee.protocol.DefinedPacket;
+import net.md_5.bungee.protocol.ProtocolConstants;
+
+import java.util.UUID;
+
+class EntityMap_1_16 extends EntityMap
+{
+
+ static final EntityMap_1_16 INSTANCE = new EntityMap_1_16();
+
+ EntityMap_1_16()
+ {
+ addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
+ addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
+ /* Waterfall (1.16: 1.16-pre1+ 0x03 -> 0x02) */ addRewrite( 0x02, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
+ /* Waterfall (1.16: 1.16-pre1+ 0x04 -> 0x03) */ addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
+ /* Waterfall (1.16: 1.16-pre1+ 0x05 -> 0x04) */ addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
+ /* Waterfall (1.16: 1.16-pre1+ 0x06 -> 0x05) */ addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
+ /* Waterfall (1.16: 1.16-pre1+ 0x09 -> 0x08) */ addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
+ /* Waterfall (1.16: 1.16-pre1+ 0x01C -> 0x1B) */ addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
+ /* Waterfall (1.16: 1.16-pre1+ 0x029 -> 0x28) */ addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
+ /* Waterfall (1.16: 1.16-pre1+ 0x3A -> 0x29) */ addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
+ /* Waterfall (1.16: 1.16-pre1+ 0x2B -> 0x2A) */ addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
+ /* Waterfall (1.16: 1.16-pre1+ 0x2C -> 0x2B) */ addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
+ /* Waterfall (1.16: 1.16-pre1+ 0x39 -> 0x38) */ addRewrite( 0x38, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
+ /* Waterfall (1.16: 1.16-pre1+ 0x3C -> 0x3B) */ addRewrite( 0x3B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
+ /* Waterfall (1.16: 1.16-pre1+ 0x3F -> 0x3D) */ addRewrite( 0x3D, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
+ addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
+ addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
+ addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
+ addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
+ addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
+ /* Waterfall (1.16: 1.16-pre1+ 0x56 -> 0x55) */ addRewrite( 0x55, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
+ /* Waterfall (1.16: 1.16-pre1+ 0x57 -> 0x56) */ addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
+ /* Waterfall (1.16: 1.16-pre1+ 0x59 -> 0x58) */ addRewrite( 0x58, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
+ /* Waterfall (1.16: 1.16-pre1+ 0x5A -> 0x59) */ addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
+
+ addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
+ /* Waterfall (1.16: 20w16a+ 0x1B -> 0x1C) */ addRewrite( 0x1C, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
+ }
+
+ @Override
+ @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
+ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
+ {
+ super.rewriteClientbound( packet, oldId, newId );
+
+ // Special cases
+ int readerIndex = packet.readerIndex();
+ int packetId = DefinedPacket.readVarInt( packet );
+ int packetIdLength = packet.readerIndex() - readerIndex;
+ int jumpIndex = packet.readerIndex();
+ switch ( packetId )
+ {
+ case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */:
+ rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x56 -> 0x55) */ case 0x55 /* Collect Item : PacketPlayOutCollect */:
+ DefinedPacket.readVarInt( packet );
+ rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x4C -> 0x4B) */ case 0x4B /* Set Passengers : PacketPlayOutMount */:
+ DefinedPacket.readVarInt( packet );
+ jumpIndex = packet.readerIndex();
+ // Fall through on purpose to int array of IDs
+ /* Waterfall (1.16: 1.16-pre1+ 0x38 -> 0x37) */ case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */:
+ int count = DefinedPacket.readVarInt( packet );
+ int[] ids = new int[ count ];
+ for ( int i = 0; i < count; i++ )
+ {
+ ids[i] = DefinedPacket.readVarInt( packet );
+ }
+ packet.readerIndex( jumpIndex );
+ packet.writerIndex( jumpIndex );
+ DefinedPacket.writeVarInt( count, packet );
+ for ( int id : ids )
+ {
+ if ( id == oldId )
+ {
+ id = newId;
+ } else if ( id == newId )
+ {
+ id = oldId;
+ }
+ DefinedPacket.writeVarInt( id, packet );
+ }
+ break;
+ case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
+ DefinedPacket.readVarInt( packet );
+ DefinedPacket.readUUID( packet );
+ int type = DefinedPacket.readVarInt( packet );
+
+ if ( type == 2 || type == 102 || type == 72 ) // arrow, fishing_bobber or spectral_arrow
+ {
+ if ( type == 2 || type == 72 ) // arrow or spectral_arrow
+ {
+ oldId = oldId + 1;
+ newId = newId + 1;
+ }
+
+ packet.skipBytes( 26 ); // double, double, double, byte, byte
+ int position = packet.readerIndex();
+ int readId = packet.readInt();
+ if ( readId == oldId )
+ {
+ packet.setInt( position, newId );
+ } else if ( readId == newId )
+ {
+ packet.setInt( position, oldId );
+ }
+ }
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x05 -> 0x04) */ case 0x04 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
+ DefinedPacket.readVarInt( packet ); // Entity ID
+ int idLength = packet.readerIndex() - readerIndex - packetIdLength;
+ UUID uuid = DefinedPacket.readUUID( packet );
+ ProxiedPlayer player;
+ if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
+ {
+ int previous = packet.writerIndex();
+ packet.readerIndex( readerIndex );
+ packet.writerIndex( readerIndex + packetIdLength + idLength );
+ DefinedPacket.writeUUID( player.getUniqueId(), packet );
+ packet.writerIndex( previous );
+ }
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x33 -> 0x32) */ case 0x32 /* Combat Event : PacketPlayOutCombatEvent */:
+ int event = packet.readUnsignedByte();
+ if ( event == 1 /* End Combat*/ )
+ {
+ DefinedPacket.readVarInt( packet );
+ rewriteInt( packet, oldId, newId, packet.readerIndex() );
+ } else if ( event == 2 /* Entity Dead */ )
+ {
+ int position = packet.readerIndex();
+ rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
+ packet.readerIndex( position );
+ DefinedPacket.readVarInt( packet );
+ rewriteInt( packet, oldId, newId, packet.readerIndex() );
+ }
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x45 -> 0x44) */ case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */:
+ DefinedPacket.readVarInt( packet ); // Entity ID
+ rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook
+ /*
+ * Waterfall (1.16: 20w12a+)
+ * metaVarInt was shifted to 8 from 16 and 16 omitted, previously:
+ * rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al)
+ * */
+ rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // guardian beam
+ break;
+ /* Waterfall (1.16: 1.16-pre1+ 0x51 -> 0x50) */ case 0x50 /* Entity Sound Effect : PacketPlayOutEntitySound */:
+ DefinedPacket.readVarInt( packet );
+ DefinedPacket.readVarInt( packet );
+ rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
+ break;
+ }
+ packet.readerIndex( readerIndex );
+ }
+
+ @Override
+ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
+ {
+ super.rewriteServerbound( packet, oldId, newId );
+ // Special cases
+ int readerIndex = packet.readerIndex();
+ int packetId = DefinedPacket.readVarInt( packet );
+ int packetIdLength = packet.readerIndex() - readerIndex;
+
+ if ( packetId == 0x2C /* Waterfall (1.16: 20w16a+ 0x2B -> 0x2C) Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
+ {
+ UUID uuid = DefinedPacket.readUUID( packet );
+ ProxiedPlayer player;
+ if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
+ {
+ int previous = packet.writerIndex();
+ packet.readerIndex( readerIndex );
+ packet.writerIndex( readerIndex + packetIdLength );
+ DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
+ packet.writerIndex( previous );
+ }
+ }
+ packet.readerIndex( readerIndex );
+ }
+}
+// Travertine end
\ No newline at end of file
--
2.24.0