Add BotPrePhysicsTick event for movement-assist plugins#313
Add BotPrePhysicsTick event for movement-assist plugins#313aquariusnetwork9 wants to merge 1 commit into
Conversation
Adds a new plugin-facing event, BotPrePhysicsTick, posted once per bot tick from Bot.tick() at the exact point after the server's latest entity metadata sync for this tick has been applied (fall-flying included, via updateFallFlying()) but before the local physics/ movement step runs. This supports plugins implementing autonomous flight/movement modules (e.g. a long-distance elytra autopilot) that need tick-precise control over physics-affecting state like fall-flying, so client-side prediction doesn't fall out of sync with the server's own movement validation by even one tick. Currently the only way to get this ordering right is to fork Bot.java directly and splice logic into the tick method; this event gives plugins a proper, general extension point through the existing event-bus API instead. Also adds Bot#setFallFlying(boolean), a small public wrapper around the existing package-private startFallFlying()/stopFallFlying(), since there was previously no public way for a plugin to set this state from an event handler.
|
why can't you just submit a jump input to start flying: |
|
Good question — the short answer is a plain jump input isn't enough, for two separate, code-level reasons:
What's actually missing isn't a way to submit a jump — it's a seam to act after Happy to narrow scope if useful (e.g. trim the setter to the minimum surface). But this is solving a real tick-ordering gap, not standing in for input submission. I'm looing to port the ebounce capabilities of my zenith fork to a straight plugin instead of using something totally different |
vanilla (possible with current zenith) and what you want to do:
a server packet to stop flying (metadata or teleport) would be handled either after or before the ClientBotTick. which may be what you're getting confusing about? |
Summary
Adds
BotPrePhysicsTick, a new plugin-facing event posted once per bot tick fromBot.tick(), at the exact point after the server's latest entity metadata sync for that tick has been applied (fall-flying included, viaupdateFallFlying()) but before the local physics/movement step runs.This supports plugins that implement autonomous flight/movement modules — for example, a long-distance elytra autopilot — which need tick-precise control over physics-affecting state like fall-flying. If a plugin sets that state even one tick off from this exact seam, client-side prediction falls out of sync with what the server's own movement validation confirms a moment later, and the server corrects/rubberbands the player. Today the only way to get this ordering right is to fork
Bot.javadirectly and splice private logic into the tick method, which means every plugin author who needs it has to maintain their own fork of the whole proxy. This PR replaces that with a proper, general extension point through the existing event-bus API (EventConsumer.of(...)), following the same pattern as the existingClientBotTickevent.Changes
src/main/java/com/zenith/event/client/BotPrePhysicsTick.java(new): a zero-field record event, mirroringClientBotTick's style/shape.src/main/java/com/zenith/feature/player/Bot.java: postsBotPrePhysicsTick.INSTANCEviaEVENT_BUS.post(...)at the seam described above (immediately after the existing jump/fall-flying handling block, before theif (isFlying)physics block).src/main/java/com/zenith/feature/player/Bot.java: addspublic void setFallFlying(boolean value). There was previously no public way to set this state —startFallFlying()/stopFallFlying()are package-private — so a plugin subscribed to the new event would otherwise have nothing to call. This is a thin wrapper around the two existing package-private methods; no new logic.No existing behavior changes when nothing subscribes to the new event — this is purely an additive extension point.
Test plan
./gradlew compileJava— compiles clean./gradlew shadowJar— builds successfully