diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java index 55d2f8dc89..748aea1dda 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_10.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x48 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x40 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -99,11 +98,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java index a37f119f1c..3f3a13c3dc 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_11.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x48 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x40 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -100,11 +99,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java index 70fd573556..f3ea2417f5 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3C /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x4A /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x42 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x31 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -100,11 +99,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java index cbfc713f14..6d18d0c245 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_12_1.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3D /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x4B /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x43 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x32 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2D /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -100,11 +99,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java index 027a64c437..98384d2bbb 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x40 /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x4F /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int break; case 0x46 /* Set Passengers : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2F /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -100,11 +99,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java index abfead86a7..846537205c 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_14.java @@ -53,12 +53,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x44 /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x55 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -66,16 +65,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int break; case 0x4A /* Set Passengers : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: rewriteSpawnObject( wrapper, oldId, newId, 2, 101, 71 ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x32 /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -104,11 +103,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java index 7679119dfd..4c8ab4129f 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java @@ -53,12 +53,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x56 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -66,16 +65,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int break; case 0x4B /* Set Passengers : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x38 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_14.rewriteSpawnObject( wrapper, oldId, newId, 2, 102, 72 ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x33 /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -104,11 +103,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } 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 index e3a42b4183..f39a697f58 100644 --- 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 @@ -53,12 +53,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x55 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -66,16 +65,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int break; case 0x4B /* Set Passengers : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_14.rewriteSpawnObject( wrapper, oldId, newId, 2, 102, 72 ); break; case 0x04 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x32 /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -104,11 +103,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java index b595366469..43d58961b4 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_16_2.java @@ -37,7 +37,7 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int if ( packetId == spawnPlayerId ) { - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); } packet.readerIndex( readerIndex ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java index c8d1cfc92d..1d86445acd 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_8.java @@ -58,19 +58,18 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) //Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x1B /* Attach Entity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x0D /* Collect Item */: DefinedPacket.skipVarInt( packet ); rewriteVarInt( wrapper, oldId, newId, packet.readerIndex() ); break; case 0x13 /* Destroy Entities */: - int jumpIndex = readerIndex + packetIdLength; - rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x0E /* Spawn Object */: DefinedPacket.skipVarInt( packet ); @@ -102,7 +101,7 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) } break; case 0x0C /* Spawn Player */: - rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x42 /* Combat Event */: rewriteCombatEvent( wrapper, oldId, newId ); @@ -120,17 +119,21 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) //Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } public static void rewriteCombatEvent(PacketWrapper wrapper, int oldId, int newId) { + if ( oldId == newId ) + { + return; + } ByteBuf packet = wrapper.buf; int event = packet.readUnsignedByte(); @@ -148,12 +151,12 @@ public static void rewriteCombatEvent(PacketWrapper wrapper, int oldId, int newI } } - public static void rewriteSpawnPlayerUuid(PacketWrapper wrapper, int readerIndex, int packetIdLength) + public static void rewriteSpawnPlayerUuid(PacketWrapper wrapper, int readerIndex) { ByteBuf packet = wrapper.buf; DefinedPacket.skipVarInt( packet ); // Entity ID - int idLength = packet.readerIndex() - readerIndex - packetIdLength; + int readerIndexAfterEID = packet.readerIndex(); UUID uuid = DefinedPacket.readUUID( packet ); ProxiedPlayer player; if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) @@ -162,14 +165,18 @@ public static void rewriteSpawnPlayerUuid(PacketWrapper wrapper, int readerIndex int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); - packet.writerIndex( readerIndex + packetIdLength + idLength ); + packet.writerIndex( readerIndexAfterEID ); DefinedPacket.writeUUID( player.getUniqueId(), packet ); packet.writerIndex( previous ); } } - public static void rewriteDestroyEntities(PacketWrapper wrapper, int oldId, int newId, int jumpIndex) + public static void rewriteDestroyEntities(PacketWrapper wrapper, int oldId, int newId, int readerIndexAfterPID) { + if ( oldId == newId ) + { + return; + } wrapper.destroyCompressed(); ByteBuf packet = wrapper.buf; @@ -179,8 +186,8 @@ public static void rewriteDestroyEntities(PacketWrapper wrapper, int oldId, int { ids[ i ] = DefinedPacket.readVarInt( packet ); } - packet.readerIndex( jumpIndex ); - packet.writerIndex( jumpIndex ); + packet.readerIndex( readerIndexAfterPID ); + packet.writerIndex( readerIndexAfterPID ); DefinedPacket.writeVarInt( count, packet ); for ( int id : ids ) { @@ -195,7 +202,7 @@ public static void rewriteDestroyEntities(PacketWrapper wrapper, int oldId, int } } - public static void rewriteSpectateUuid(PacketWrapper wrapper, int readerIndex, int packetIdLength) + public static void rewriteSpectateUuid(PacketWrapper wrapper, int readerIndex, int readerIndexAfterPID) { ByteBuf packet = wrapper.buf; @@ -207,7 +214,7 @@ public static void rewriteSpectateUuid(PacketWrapper wrapper, int readerIndex, i int previous = packet.writerIndex(); packet.readerIndex( readerIndex ); - packet.writerIndex( readerIndex + packetIdLength ); + packet.writerIndex( readerIndexAfterPID ); DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); packet.writerIndex( previous ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java index 18bd29b8f4..7f5eec535a 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x49 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x40 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -99,17 +98,21 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); } public static void rewriteSpawnObject(PacketWrapper wrapper, int oldId, int newId) { + if ( oldId == newId ) + { + return; + } ByteBuf packet = wrapper.buf; DefinedPacket.skipVarInt( packet ); diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java index fde45d64d9..abf1bc6648 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_9_4.java @@ -54,12 +54,11 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; - int jumpIndex = packet.readerIndex(); + int readerIndexAfterPID = packet.readerIndex(); switch ( packetId ) { case 0x3A /* Attach Entity : PacketPlayOutAttachEntity */: - rewriteInt( wrapper, oldId, newId, readerIndex + packetIdLength + 4 ); + rewriteInt( wrapper, oldId, newId, readerIndexAfterPID + 4 ); break; case 0x48 /* Collect Item : PacketPlayOutCollect */: DefinedPacket.skipVarInt( packet ); @@ -67,16 +66,16 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId) break; case 0x40 /* Attach Entity : PacketPlayOutMount */: DefinedPacket.skipVarInt( packet ); - jumpIndex = packet.readerIndex(); + readerIndexAfterPID = packet.readerIndex(); // Fall through on purpose to int array of IDs case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */: - EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, jumpIndex ); + EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID ); break; case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId ); break; case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: - EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpawnPlayerUuid( wrapper, readerIndex ); break; case 0x2C /* Combat Event : PacketPlayOutCombatEvent */: EntityMap_1_8.rewriteCombatEvent( wrapper, oldId, newId ); @@ -99,11 +98,11 @@ public void rewriteServerbound(PacketWrapper wrapper, int oldId, int newId) // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt( packet ); - int packetIdLength = packet.readerIndex() - readerIndex; + int readerIndexAfterPID = packet.readerIndex(); if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) { - EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, packetIdLength ); + EntityMap_1_8.rewriteSpectateUuid( wrapper, readerIndex, readerIndexAfterPID ); } packet.readerIndex( readerIndex ); }