Skip to content

Commit

Permalink
Remove fall-through from mount to entity destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Janmm14 committed Oct 31, 2023
1 parent ee502b0 commit 9dbb458
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x40 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x40 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x42 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x31 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x43 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x32 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int
break;
case 0x46 /* Set Passengers : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int
break;
case 0x4A /* Set Passengers : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
rewriteSpawnObject( wrapper, oldId, newId, 2, 101, 71 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int
break;
case 0x4B /* Set Passengers : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x38 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_14.rewriteSpawnObject( wrapper, oldId, newId, 2, 102, 72 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId, int
break;
case 0x4B /* Set Passengers : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x37 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_14.rewriteSpawnObject( wrapper, oldId, newId, 2, 102, 72 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
rewriteVarInt( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x13 /* Destroy Entities */:
rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x0E /* Spawn Object */:
DefinedPacket.skipVarInt( packet );
Expand Down Expand Up @@ -171,12 +171,14 @@ public static void rewriteSpawnPlayerUuid(PacketWrapper wrapper, int readerIndex
}
}

public static void rewriteDestroyEntities(PacketWrapper wrapper, int oldId, int newId, int readerIndexAfterPID)
public static void rewriteEntityIdArray(PacketWrapper wrapper, int oldId, int newId, int readerIndexAfterPID)
{
if ( oldId == newId )
{
return;
}
// we don't do it conditionally if we changed something as this packet is not
// hard to compress again if we didn't do changes
wrapper.destroyCompressed();

ByteBuf packet = wrapper.buf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x40 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
rewriteSpawnObject( wrapper, oldId, newId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public void rewriteClientbound(PacketWrapper wrapper, int oldId, int newId)
break;
case 0x40 /* Attach Entity : PacketPlayOutMount */:
DefinedPacket.skipVarInt( packet );
readerIndexAfterPID = packet.readerIndex();
// Fall through on purpose to int array of IDs
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, packet.readerIndex() );
break;
case 0x30 /* Destroy Entities : PacketPlayOutEntityDestroy */:
EntityMap_1_8.rewriteDestroyEntities( wrapper, oldId, newId, readerIndexAfterPID );
EntityMap_1_8.rewriteEntityIdArray( wrapper, oldId, newId, readerIndexAfterPID );
break;
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
EntityMap_1_9.rewriteSpawnObject( wrapper, oldId, newId );
Expand Down

0 comments on commit 9dbb458

Please sign in to comment.