5353import com .kneelawk .graphlib .syncing .knet .api .graph .user .LinkEntitySyncing ;
5454import com .kneelawk .graphlib .syncing .knet .api .graph .user .LinkKeySyncing ;
5555import com .kneelawk .graphlib .syncing .knet .api .graph .user .NodeEntitySyncing ;
56+ import com .kneelawk .graphlib .syncing .knet .api .util .IdPaletteUtils ;
5657import com .kneelawk .graphlib .syncing .knet .api .util .InSyncedUniverse ;
5758import com .kneelawk .graphlib .syncing .knet .impl .StreamCodecHelper ;
5859import com .kneelawk .knet .api .channel .context .PlayChannelContext ;
@@ -74,69 +75,79 @@ private SyncingKNet() {}
7475
7576 /**
7677 * Attachment key for a palette of {@link ResourceLocation}s.
78+ *
79+ * @deprecated use {@link IdPaletteUtils#ID_PALETTE} instead.
7780 */
78- public static final AttachmentKey <Palette <ResourceLocation >> ID_PALETTE = AttachmentKey .ofStaticFieldName ();
81+ @ Deprecated
82+ public static final AttachmentKey <Palette <ResourceLocation >> ID_PALETTE = IdPaletteUtils .ID_PALETTE ;
7983
8084 /**
81- * {@link ResourceLocation} codec that can use an {@link #ID_PALETTE} attachment if present.
85+ * {@link ResourceLocation} codec that can use an {@link IdPaletteUtils#ID_PALETTE} attachment if present.
86+ *
87+ * @deprecated use {@link IdPaletteUtils#PALETTED_ID_CODEC} instead.
8288 */
89+ @ Deprecated
8390 public static final StreamCodec <FriendlyByteBuf , ResourceLocation > PALETTED_ID_CODEC =
84- ID_PALETTE .dispatchIfPresentStreamCodec (palette -> palette .asCodec ("id palette" ),
85- ResourceLocation .STREAM_CODEC );
91+ IdPaletteUtils .PALETTED_ID_CODEC ;
8692
8793 /**
8894 * Wraps the given {@link StreamCodec} codec in a palette that will be used in both encoding and decoding.
8995 * <p>
90- * This provides the {@link #ID_PALETTE} attachment.
96+ * This provides the {@link IdPaletteUtils #ID_PALETTE} attachment.
9197 *
9298 * @param wrappedCodec the codec to wrap.
9399 * @param childBufferCtor the constructor for the buffer type the wrapped codec uses.
94100 * @param <B1> the type of the parent buffer.
95101 * @param <B2> the type of the child buffer.
96102 * @param <V> the result type.
97103 * @return the wrapper stream codec.
104+ * @deprecated use {@link IdPaletteUtils#attachPalette(StreamCodec, ChildBufferFactory)} instead.
98105 */
106+ @ Deprecated
99107 public static <B1 extends FriendlyByteBuf & NetBuf <B1 >, B2 extends FriendlyByteBuf , V > StreamCodec <B1 , V > attachPalette (
100108 StreamCodec <? super B2 , V > wrappedCodec , ChildBufferFactory <? super B1 , B2 > childBufferCtor ) {
101- return ID_PALETTE .mutReadAttachingStreamCodec (Palette .codec (ResourceLocation .STREAM_CODEC ), childBufferCtor ,
102- wrappedCodec , obj -> new Palette <>());
109+ return IdPaletteUtils .<B1 , B2 , V >attachPalette (wrappedCodec , childBufferCtor );
103110 }
104111
105112 /**
106113 * Wraps the given {@link StreamCodec} codec in a palette that will be used in both encoding and decoding, using a
107114 * buffer capable of being used as a {@link net.minecraft.network.RegistryFriendlyByteBuf}.
108115 * <p>
109- * This provides the {@link #ID_PALETTE} attachment.
116+ * This provides the {@link IdPaletteUtils #ID_PALETTE} attachment.
110117 *
111118 * @param wrappedCodec the codec to wrap.
112119 * @param <V> the result type.
113120 * @return the wrapper stream codec.
121+ * @deprecated use {@link IdPaletteUtils#registryAttachPalette(StreamCodec)} instead.
114122 */
123+ @ Deprecated
115124 public static <V > StreamCodec <NetRegistryByteBuf , V > registryAttachPalette (
116125 StreamCodec <? super NetRegistryByteBuf , V > wrappedCodec ) {
117- return attachPalette ( wrappedCodec , ( cap , old ) -> NetBufs . netRegistryBuf ( cap , old . registryAccess ()) );
126+ return IdPaletteUtils . registryAttachPalette ( wrappedCodec );
118127 }
119128
120129 /**
121130 * Wraps the given {@link StreamCodec} codec in a palette that will be used in both encoding and decoding, using a
122131 * buffer capable of being used as a {@link NetByteBuf}.
123132 * <p>
124- * This provides the {@link #ID_PALETTE} attachment.
133+ * This provides the {@link IdPaletteUtils #ID_PALETTE} attachment.
125134 *
126135 * @param wrappedCodec the codec to wrap.
127136 * @param <V> the result type.
128137 * @return the wrapper stream codec.
138+ * @deprecated use {@link IdPaletteUtils#netAttachPalette(StreamCodec)} instead.
129139 */
140+ @ Deprecated
130141 public static <V > StreamCodec <NetRegistryByteBuf , V > netAttachPalette (
131142 StreamCodec <? super RegistryNetByteBuf , V > wrappedCodec ) {
132- return attachPalette ( wrappedCodec , ( cap , old ) -> NetBufs . registryNetBuf ( cap , old . registryAccess ()) );
143+ return IdPaletteUtils . netAttachPalette ( wrappedCodec );
133144 }
134145
135146 /**
136147 * Stream codec that encodes/decodes an entire {@link BlockNode}.
137148 * <p>
138149 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
139- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
150+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
140151 */
141152 public static final StreamCodec <NetRegistryByteBuf , BlockNode > BLOCK_NODE_CODEC =
142153 StreamCodecHelper .createObjStreamCodec (BlockNodeSyncing .REF_CODEC , BlockNode ::getType ,
@@ -146,7 +157,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
146157 * Stream codec that encodes/decodes an entire {@link LinkKey}.
147158 * <p>
148159 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
149- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
160+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
150161 */
151162 public static final StreamCodec <NetRegistryByteBuf , LinkKey > LINK_KEY_CODEC =
152163 StreamCodecHelper .createObjStreamCodec (LinkKeySyncing .REF_CODEC , LinkKey ::getType ,
@@ -156,7 +167,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
156167 * Stream codec that encodes/decodes an entire {@link NodeEntity}.
157168 * <p>
158169 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
159- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
170+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
160171 */
161172 public static final StreamCodec <NetRegistryByteBuf , NodeEntity > NODE_ENTITY_CODEC =
162173 StreamCodecHelper .createObjStreamCodec (NodeEntitySyncing .REF_CODEC , NodeEntity ::getType ,
@@ -166,7 +177,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
166177 * Stream codec that encodes/decodes an entire {@link LinkEntity}.
167178 * <p>
168179 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
169- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
180+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
170181 */
171182 public static final StreamCodec <NetRegistryByteBuf , LinkEntity > LINK_ENTITY_CODEC =
172183 StreamCodecHelper .createObjStreamCodec (LinkEntitySyncing .REF_CODEC , LinkEntity ::getType ,
@@ -176,7 +187,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
176187 * Stream codec that encodes/decodes an entire {@link GraphEntity}.
177188 * <p>
178189 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
179- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
190+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
180191 */
181192 public static final StreamCodec <NetRegistryByteBuf , GraphEntity <?>> GRAPH_ENTITY_CODEC =
182193 StreamCodecHelper .createObjStreamCodec (GraphEntitySyncing .REF_CODEC , GraphEntity ::getType ,
@@ -186,7 +197,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
186197 * Stream codec for a {@link NodePos}.
187198 * <p>
188199 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
189- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
200+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
190201 */
191202 public static final StreamCodec <NetRegistryByteBuf , NodePos > NODE_POS_CODEC =
192203 StreamCodec .composite (NetCodecs .BLOCK_POS .mapStream (NetBufs ::netOf ), NodePos ::pos , BLOCK_NODE_CODEC ,
@@ -196,7 +207,7 @@ public static <V> StreamCodec<NetRegistryByteBuf, V> netAttachPalette(
196207 * Stream codec for a {@link LinkPos}.
197208 * <p>
198209 * <b>This requires the {@link KNetSyncedUniverse#ATTACHMENT_KEY} attachment.</b>
199- * This can optionally make use of the {@link SyncingKNet #ID_PALETTE} attachment.
210+ * This can optionally make use of the {@link IdPaletteUtils #ID_PALETTE} attachment.
200211 */
201212 public static final StreamCodec <NetRegistryByteBuf , LinkPos > LINK_POS_CODEC =
202213 StreamCodec .composite (NODE_POS_CODEC , LinkPos ::first , NODE_POS_CODEC , LinkPos ::second , LINK_KEY_CODEC ,
0 commit comments