Skip to content

Feat: Add recipe sharing#1088

Draft
DanielKnourek wants to merge 24 commits intoemilyploszaj:1.21from
DanielKnourek:1.21
Draft

Feat: Add recipe sharing#1088
DanielKnourek wants to merge 24 commits intoemilyploszaj:1.21from
DanielKnourek:1.21

Conversation

@DanielKnourek
Copy link

@DanielKnourek DanielKnourek commented Nov 30, 2025

Summary

This PR introduces a multiplayer-centric feature allowing players to broadcast specific recipes to the server chat. This addresses the common issue in complex modpacks where verbally describing a recipe or item name is difficult.

Feature-Description v2

Features

  • Share Button: Added a new button in the recipe GUI (next to the recipe).
  • Chat Integration: Clicking the share button (or keybind) sends a packet to the server, which broadcasts the recipe data packet to all players. The receiving clients then construct the interactive chat message locally using their own EMI index.
  • Interactive Chat: Clicking the generated chat message opens the specific recipe directly in EMI (no need to search).
  • History Panel: Added a new "Shared Recipes" sidebar panel that logs received recipes, allowing players to review shared items without scrolling back through chat.

Demo

Demo_v1.webm

Technical Implementation

  • Architecture: Recipe lookup and chat component construction are handled client-side to ensure the correct local EMI index is used.
  • Networking: Uses a modified packet structure to transmit the Recipe ID and Sender Name.
  • Permissions: Access level for the share command was lowered to allow standard players to use the feature.

Areas for Review / Feedback Needed

I would appreciate specific feedback on the following implementation details:

  • Packet Structure: I modified CommandS2CPacket.java to include the player's displayName. Please verify if this modification approach is acceptable regarding backward compatibility or protocol standards.
  • Permission Levels: I removed the Level 2 requirement in EmiCommands.java so standard players (Level 0) can use the feature, as recipe sharing should not require admin privileges.
  • Asset Style: Please review buttons.png and widgets.png. I attempted to match the existing EMI aesthetic but would like confirmation that these fit the design standards. Also files have different size, I hope I did save it correctly.
  • Duplicate Packet Issue (1.20.1):
    • Issue: In testing (specifically the Reclamation modpack, 1.20.1), CommandS2CPacket.apply was triggering multiple times for a single event.
    • Current Workaround: I implemented a "recent check" in EmiShareRecipe.java comparing the share history with the latest item to prevent the UI from updating multiple times and displaying duplicite chat messages to player.
    • Note: I have not observed this behavior on 1.21, so it may be specific to the 1.20.1 environment or modpack.

Related Files

  • xplat/src/main/resources/assets/emi/textures/gui/buttons.png
  • xplat/src/main/resources/assets/emi/textures/gui/widgets.png
  • xplat/src/main/java/dev/emi/emi/network/CommandS2CPacket.java
  • xplat/src/main/java/dev/emi/emi/registry/EmiCommands.java
  • xplat/src/main/java/dev/emi/emi/runtime/EmiShareRecipe.java

Copy link
Owner

@emilyploszaj emilyploszaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I enjoy this feature implementation route, but at the very least you need to adhere to codebase style, this codebase uses tabs and not spaces, it's making diffs hard to read, please fix this.

@DanielKnourek
Copy link
Author

Sorry for the spaces @emilyploszaj. As you might have guesed I am kinda new to this.
I do value your time and don't want to waste it. If you are willing to give me guidance, I am willing to make other changes. If not I do understand.
I hacked it together for me and friend. It is being used for its purpose, but I wanted to share it for others.

@Kewz4
Copy link

Kewz4 commented Dec 10, 2025

This is really good! Hope it can be merged!

@Kewz4
Copy link

Kewz4 commented Feb 27, 2026

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants