Add interpretPacketQueue for testing purpose

This commit is contained in:
themode 2022-01-28 05:32:35 +01:00
parent bcc652ede8
commit bd23cd6568
2 changed files with 9 additions and 2 deletions

View File

@ -316,7 +316,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
this.playerConnection.update(); this.playerConnection.update();
// Process received packets // Process received packets
this.packets.drain(packet -> MinecraftServer.getPacketListenerManager().processClientPacket(packet, this)); interpretPacketQueue();
super.update(time); // Super update (item pickup/fire management) super.update(time); // Super update (item pickup/fire management)
@ -1673,6 +1673,13 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
this.packets.offer(packet); this.packets.offer(packet);
} }
@ApiStatus.Internal
@ApiStatus.Experimental
public void interpretPacketQueue() {
// This method is NOT thread-safe
this.packets.drain(packet -> MinecraftServer.getPacketListenerManager().processClientPacket(packet, this));
}
/** /**
* Changes the storage player latency and update its tab value. * Changes the storage player latency and update its tab value.
* *

View File

@ -26,7 +26,7 @@ public class PlayerHeldIntegrationTest {
assertEquals(0, player.getHeldSlot()); assertEquals(0, player.getHeldSlot());
player.addPacketToQueue(new ClientHeldItemChangePacket((short) 1)); player.addPacketToQueue(new ClientHeldItemChangePacket((short) 1));
env.tick(); player.interpretPacketQueue();
assertEquals(ItemStack.of(Material.STONE), player.getItemInMainHand()); assertEquals(ItemStack.of(Material.STONE), player.getItemInMainHand());
assertEquals(1, player.getHeldSlot()); assertEquals(1, player.getHeldSlot());