use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class UpstreamSession method sendAllPackets.
public void sendAllPackets(PEPacket[] packets, boolean high_priority) {
if (// <- this disable batched packets
packets.length < 5 || true)
for (PEPacket packet : packets) sendPacket(packet, high_priority);
else {
BatchPacket batchPacket = new BatchPacket();
// System.out.println("BatchPacket :");
for (PEPacket packet : packets) // System.out.println(" - " + packet.getClass().getSimpleName());
if (high_priority) {
batchPacket.packets.add(packet);
break;
}
sendPacket(batchPacket, high_priority);
}
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class PEPacketProcessor method onTick.
public void onTick() {
int cnt = 0;
Timings.playerNetworkReceiveTimer.startTiming();
while (cnt < MAX_PACKETS_PER_CYCLE && !packets.isEmpty()) {
cnt++;
byte[] p = packets.pop();
PEPacket[] packets;
try {
packets = Protocol.decode(p);
if (packets == null || packets.length <= 0)
continue;
} catch (Exception e) {
e.printStackTrace();
return;
}
for (PEPacket decoded : packets) try (Timing timing = Timings.getReceiveDataPacketTiming(decoded)) {
handlePacket(decoded);
}
}
Timings.playerNetworkReceiveTimer.stopTiming();
}
use of org.dragonet.protocol.PEPacket in project DragonProxy by DragonetMC.
the class InventoryTranslatorRegister method sendPlayerInventory.
public static PEPacket[] sendPlayerInventory(UpstreamSession session) {
CachedWindow win = session.getWindowCache().getPlayerInventory();
// Translate and send
InventoryContentPacket ret = new InventoryContentPacket();
ret.windowId = ContainerId.INVENTORY.getId();
ret.items = new Slot[40];
// hotbar
for (int i = 36; i < 45; i++) ret.items[i - 36] = ItemBlockTranslator.translateSlotToPE(win.slots[i]);
// inventory
for (int i = 9; i < 36; i++) // TODO: Add NBT support
ret.items[i] = ItemBlockTranslator.translateSlotToPE(win.slots[i]);
// armors
for (int i = 5; i < 9; i++) ret.items[i + 31] = ItemBlockTranslator.translateSlotToPE(win.slots[i]);
// TODO: Add armor support
return new PEPacket[] { ret };
}
Aggregations