Skip to content

Packets: receive/send events, send and fake-receive, connect/disconnect - #4

Merged
MonsterMilo merged 7 commits into
mainfrom
claude/project-thread-99w3r6
Nov 23, 2026
Merged

MonsterMilo merged 7 commits into
mainfrom
claude/project-thread-99w3r6

Conversation

@MonsterMilo

Copy link
Copy Markdown
Owner

Requested by Milo · project thread

Adds packet access for plugins.

  • Core: a Netty handler prism_packets goes in right before Minecraft's packet_handler in every client connection. New connections are caught through a hook on NetworkManager.channelActive, and a connection that's already open when Prism injects is picked up too. Singleplayer's server-side connection is skipped. The handler is removed from every pipeline on unload.
  • API:
    • ctx.network(): connected(), serverAddress(), send(packet) and receive(packet). Neither send nor receive raises an event.
    • New events: PacketReceiveEvent and PacketSendEvent (both can be cancelled or replaced), plus ConnectEvent and DisconnectEvent.
  • Example plugin: says in chat which server you joined.
  • Tests: a stand-in NetworkManager on a Netty EmbeddedChannel. Checks receive/send events, cancel, replace, send and receive, that the server side is left alone, the disconnect event, removal on unload, and attaching to the open connection on re-inject. All pass.

Generated by Claude Code

MonsterMilo and others added 7 commits November 22, 2026 23:46
- native/agent: DLL that attaches to the game's JVM, finds Minecraft's class
  loader (mcp/srg/notch names) and starts the Java core on top of it
- native/inject: finds Java game windows, loads the agent via LoadLibraryW
- native/app: Prism.exe with Inject/Unload, auto-inject for Lunar 1.8.9,
  plugin list and log; agent + core embedded
- java/api + java/core: plugin API, event bus, scheduler on the client
  thread, plugin manager with hot reload
- tests/run.sh: end-to-end test against a stand-in game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1jsNaA8oesLoCYL6zeeF7
- agent: JVMTI retransform with a ClassFileLoadHook that is only on for the
  class being patched; Native.retransform0 replaces redefineClass0
- core: hook system (ASM, relocated to prism.shadow.asm). Injected code uses
  only JDK classes via System properties; all patches undone on unload
- events: TickEvent, RenderOverlayEvent, RenderWorldEvent, KeyEvent,
  MouseButtonEvent (key/mouse cancelable); Draw API for text and rects
- fix: a plugin added while running now says Loaded, not Reloaded
- tests: stand-in game gets the hooked methods; hook test plugin checks
  events, cancel, restore on unload and re-inject

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1jsNaA8oesLoCYL6zeeF7
Lunar with Forge mods (and Forge) draw the HUD with GuiIngameForge, which
overrides renderGameOverlay without calling the vanilla method, so
RenderOverlayEvent never fired there. Optional hooks skip quietly when the
class doesn't exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1jsNaA8oesLoCYL6zeeF7
- core: Netty handler 'prism_packets' before Minecraft's packet_handler in
  every client connection (hook on NetworkManager.channelActive, plus the
  connection already open at inject); singleplayer's server side skipped;
  removed from every pipeline on unload
- api: Network (connected, serverAddress, send, receive), PacketReceiveEvent
  and PacketSendEvent (cancel/replace), ConnectEvent, DisconnectEvent
- example plugin says which server you joined
- tests: stand-in NetworkManager on an EmbeddedChannel; checks events,
  cancel, replace, send/receive, server side ignored, removal on unload

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N1jsNaA8oesLoCYL6zeeF7
@MonsterMilo
MonsterMilo merged commit ea30760 into main Nov 23, 2026
2 checks passed
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.

2 participants