@@ -175,18 +175,15 @@ public void clearConfigFrom(int startingIndex) {
175175
176176 @ SideOnly (Side .CLIENT )
177177 public void setConfig (int index , @ Nullable T newConfig ) {
178- if ( newConfig == null ) {
179- syncToServer ( setConfigID , buf -> {
180- buf . writeVarInt ( index );
178+ syncToServer ( setConfigID , buf -> {
179+ buf . writeVarInt ( index );
180+ if ( newConfig == null ) {
181181 buf .writeBoolean (false );
182- });
183- } else {
184- syncToServer (setConfigID , buf -> {
185- buf .writeVarInt (index );
182+ } else {
186183 buf .writeBoolean (true );
187- newConfig . writeToPacket (buf );
188- });
189- }
184+ byteBufAdapter . serialize (buf , newConfig );
185+ }
186+ });
190187 }
191188
192189 @ Nullable
@@ -222,7 +219,7 @@ public T getStock(int index) {
222219 * @param function a function that takes the slot index and the original stack size, and returns a new stack size
223220 */
224221 @ SideOnly (Side .CLIENT )
225- public void modifyConfigAmounts (IntBinaryOperator function ) {
222+ public void modifyConfigAmounts (@ NotNull IntBinaryOperator function ) {
226223 Int2IntMap changeMap = new Int2IntArrayMap (slots .length );
227224
228225 for (int index = 0 ; index < slots .length ; index ++) {
@@ -236,14 +233,16 @@ public void modifyConfigAmounts(IntBinaryOperator function) {
236233 }
237234 }
238235
239- syncToServer (bulkConfigAmountChangeID , buf -> {
240- buf .writeVarInt (changeMap .size ());
236+ if (!changeMap .isEmpty ()) {
237+ syncToServer (bulkConfigAmountChangeID , buf -> {
238+ buf .writeVarInt (changeMap .size ());
241239
242- for (int index : changeMap .keySet ()) {
243- buf .writeVarInt (index );
244- buf .writeInt (changeMap .get (index ));
245- }
246- });
240+ for (int index : changeMap .keySet ()) {
241+ buf .writeVarInt (index );
242+ buf .writeInt (changeMap .get (index ));
243+ }
244+ });
245+ }
247246 }
248247
249248 @ SuppressWarnings ("BooleanMethodIsAlwaysInverted" )
0 commit comments