1+ package com .manwe .dsl .dedicatedServer .proxy .back .packets ;
2+
3+ import com .manwe .dsl .dedicatedServer .InternalPacketTypes ;
4+ import com .manwe .dsl .dedicatedServer .proxy .back .listeners .ProxyListener ;
5+ import net .minecraft .network .FriendlyByteBuf ;
6+ import net .minecraft .network .codec .StreamCodec ;
7+ import net .minecraft .network .protocol .Packet ;
8+ import net .minecraft .network .protocol .PacketType ;
9+ import org .jetbrains .annotations .NotNull ;
10+
11+ public class ProxyBoundHealthPacket implements Packet <ProxyListener > {
12+
13+ public static final StreamCodec <FriendlyByteBuf , ProxyBoundHealthPacket > STREAM_CODEC = Packet .codec (
14+ ProxyBoundHealthPacket ::write , ProxyBoundHealthPacket ::new
15+ );
16+
17+ private final long [] tickTime ;
18+ private final int workerId ;
19+
20+ public ProxyBoundHealthPacket (long [] tickTime , int workerId ) {
21+ this .tickTime = tickTime ;
22+ this .workerId = workerId ;
23+ }
24+
25+ private ProxyBoundHealthPacket (FriendlyByteBuf buf ) {
26+ this .tickTime = buf .readLongArray ();
27+ this .workerId = buf .readInt ();
28+ }
29+
30+ private void write (FriendlyByteBuf buf ) {
31+ buf .writeLongArray (this .tickTime );
32+ buf .writeInt (this .workerId );
33+ }
34+
35+ public int getWorkerSource () {
36+ return workerId ;
37+ }
38+
39+ public long [] getTickTime () {
40+ return tickTime ;
41+ }
42+
43+ @ Override
44+ public @ NotNull PacketType <? extends Packet <ProxyListener >> type () {
45+ return InternalPacketTypes .WORKER_PROXY_HEALTH ;
46+ }
47+
48+ /**
49+ * Passes this Packet on to the PacketListener for processing.
50+ */
51+ @ Override
52+ public void handle (ProxyListener pHandler ) {
53+ pHandler .handleWorkerHealth (this );
54+ }
55+ }
0 commit comments