Skip to content

Commit

Permalink
Fix item data handling order
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Jun 16, 2024
1 parent f91a25c commit 5f57041
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import com.viaversion.viaversion.rewriter.IdRewriteFunction;
import java.util.ArrayList;
import java.util.Arrays;
import org.checkerframework.checker.nullness.qual.Nullable;

import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.downgradeItemData;
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.updateItemData;
Expand Down Expand Up @@ -148,9 +147,10 @@ public Item handleItemToClient(final UserConnection connection, final Item item)
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.ENCHANTMENTS, idRewriteFunction, descriptionSupplier, false);
enchantmentRewriter.rewriteEnchantmentsToClient(data, StructuredDataKey.STORED_ENCHANTMENTS, idRewriteFunction, descriptionSupplier, true);

// Order is important
super.handleItemToClient(connection, item);
downgradeItemData(item);

return super.handleItemToClient(connection, item);
return item;
}

@Override
Expand All @@ -170,9 +170,10 @@ public Item handleItemToServer(final UserConnection connection, final Item item)
// Restore originals if present
enchantmentRewriter.handleToServer(item);

// Order is important
super.handleItemToServer(connection, item);
updateItemData(item);

return super.handleItemToServer(connection, item);
return item;
}

private void rewriteEnchantmentToServer(final EnchantmentsPaintingsStorage storage, final Item item, final StructuredDataKey<Enchantments> key) {
Expand Down

0 comments on commit 5f57041

Please sign in to comment.