Superb Input Precision

chizz

Superb Input Precision

What does it do?

Superb Input Precision lets your inputs register at a higher precision than vanilla's discrete ticks, while staying as close to vanilla physics as possible. Vanilla normally processes queued inputs for the tick all at once. This mod tracks where in the tick they should be, so your clicks land when you actually want them to.

Why did I make this mod?

Click Between Steps and Click Between Frames both use a method called tick splitting to achieve subtick inputs. When an input lands between two ticks, the tick gets split into two or more smaller subticks that run independently. (Click Between Steps is slightly different as it allows no more than one split right in the middle. When referring to "vanilla" in the example below, it is assumed that Click Between Steps is disabled.)

The problem is that tick splitting doesn't reproduce vanilla physics exactly for gravity based modes. For example, a cube at 1x speed falling under gravity at 240 TPS:

  • Gravity per tick: 0.958199 * (54/240) = 0.215594775 yvels/tick
  • Starting velocity: 0 yvels

Vanilla (one full tick): v = 0 - 0.215594775 = -0.215594775 dy = 0.225 * (-0.215594775) = -0.048508824375 units

Tick split at 30% (two subticks of 0.3 and 0.7): Subtick 1 (30%): v = 0 - (0.215594775 * 0.3) = -0.0646784325 dy = 0.225 * 0.3 * (-0.0646784325) = -0.00436579419375 Subtick 2 (70%): v = -0.0646784325 - (0.215594775 * 0.7) = -0.215594775 dy = 0.225 * 0.7 * (-0.215594775) = -0.0339561770625 Total dy = -0.03832197125625 units

The velocity ends up the same, but the position doesn't. This comes from gravity being applied to velocity before displacement in each subtick. Splitting one tick into two smaller ones changes the intermediate velocity, which changes the total displacement. The error varies with split position and can accumulate. (Note: in actuality, velocity is rounded to 3 decimal places. For the sake of "simplicity" I used the full non-rounded values here. In game the disparity may be even worse, since every subtick gets rounded separately.)

Tick splitting also runs collision checks and other per-tick logic in the middle of a tick, which vanilla never does.

How it works

Superb Input Precision takes a different approach. Vanilla still owns the physics and runs exactly one normal tick at a time. Inputs are still processed at the start of the tick like vanilla, and then the mod corrects the result.

  • Y position correction: vanilla runs the input at the start of the tick, so the player moves as if the input had already happened for the whole tick. For the part of the tick before the input, you should still have been moving with the pre-input state, so your Y position is adjusted by the difference between how far you'd move with the pre-input and post-input state. For inputs that set your velocity (like a cube jump), that means moving with your old velocity instead of the new jump velocity up until the input time. For inputs that change acceleration (like holding or releasing in ship), the velocity carries through, so the difference comes from using the pre-input gravity up until the input time. Inputs that change how you move entirely, like dash orbs, use that movement instead. If an input teleports you (spider, spider orbs, teleport orbs), the movement before it is dropped, since the teleport overwrites your position anyway. With several inputs in one tick, each one adds its own piece of the correction.

  • Y velocity correction: gravity should only act on each velocity for the part of the tick it actually existed. For inputs that set and override your velocity (like a cube jump), the gravity before the input is thrown away and only the remaining part of the tick counts. For inputs that change acceleration (like holding or releasing in ship), the tick gets a mix of the old and new gravity. The velocity is adjusted once to automatically account for either scenario depending on the input. Like the Y position correction, several inputs in a tick are each handled, in order.

Note: that corrected velocity is a value vanilla could never produce, since it only ever applies gravity in whole ticks. Any method that allows subtick input precision (tick splitting included) has to end up at that same velocity, because that's what an input partway through a tick means. The difference is that this mod gets there without running extra physics ticks. When Velocity Unrounding is off, the corrected velocity is still rounded to 3 decimal places like any vanilla velocity.

Inputs fire at the most recent input sample (rate is customizable in mod settings) or immediately (if Instantaneous Inputs is enabled), and the corrections handle where the player should be.

Wave is the one exception: because wave velocity is constant between inputs (no acceleration), tick splitting doesn't cause the displacement error above. So for wave, the tick is split at the input point, which is the most accurate (and simplest) option. Every other gamemode uses the corrections instead. This does mean that unlike vanilla, wave gets collision checks in between ticks.

Note: if at least one player is wave, every input for that tick uses tick split method, even if the other player may not be wave.

The result is subtick input precision that aims to stay as faithful to vanilla physics as possible.

Future plans

  • Platformer keys support
  • Botting support
  • 2.1 mode (someday, maybe, i hope)

Credits

  • Thanks to syzzi for the original CBF idea, this was obviously heavily inspired by it. CBF GitHub

  • Thanks to alex/sinc0s for logo inspo and permission

Bugs

I'm not an expert modder or coder, so don't be surprised if you find any bugs. Please leave a bug report if you have any issues.

Changelog

v1.0.0-prerelease.3

  • fixed the position correction using normal gravity instead of the dash when clicking a dash orb
  • fixed the position correction counting movement from before a teleport (spider, spider orbs, teleport orbs)
  • the position correction now accounts for force blocks
  • sip now gets the tick count and timings from what vanilla actually used instead of assuming 240 tps, so it should work with tps bypasses
  • fixed clicks right after a timewarp trigger sometimes being registered too late

v1.0.0-prerelease.2

  • writing pr instead of prerelease apparently doesn't work 🫩

v1.0.0-prerelease.1

  • port to 2.2091, luckily nothing important changed
  • fixed some more slight issues with PlayerObject::update rewrite
  • fixed velocity unrounding not enabling patches on startup when the setting was already enabled
  • fixed velocity corrections from a previous attempt carrying over after respawning
  • fixed gd's "phantom" inputs at the start of any attempt breaking stuff for wave
  • fixed wave inputs going to the wrong player (or only one player) with p2 bound keys, flipped 2-player controls, and dual mode
  • input ratios and velocity corrections now stay accurate with speedhack and timewarp triggers
  • velocity corrections are now skipped when the player's velocity isn't what was predicted
  • if any player is a wave, all players now use tick splitting for that tick
  • input hz is now a double instead of a float, and its minimum has been raised from 60 to 240 (it never did anything below tps anyways)
  • getInputQueueWithRatios and setInputQueueWithRatios have been moved from subtickinputs to subtickinputs::api
  • getInputQueueWithRatios no longer clamps all inputs to one tick
  • pls lmk if you're experiencing any bugs that didn't exist before

v1.0.0-beta.6

  • added a yvel adjustment
  • fixed a force block issue and some other oversights with PlayerObject::update rewrite

v1.0.0-beta.5

  • removed wave trail drag/draw fix incompatibility marks since i didn't see any major issues (just don't click multiple times in the same frame or whatever)
  • made postDv a double

v1.0.0-beta.4

  • forgot header

v1.0.0-beta.3

  • (experimental) added functions for botting compatibility

v1.0.0-beta.2

  • force enabled click on steps such that inputs are not always processed on the first tick of the frame (caused issues when there is more than one tick in a frame, e.g. <240fps)

v1.0.0-beta.1

  • merged Subtick Inputs API with this mod, nothing functionally changed

API v0.6.1

  • rewrote getGravPerTick (this has been unreleased for like a week or two i forgot ✌️)
  • fixed debug logs
  • bump geode version

SIP v0.1.4

  • bump api ver
  • let api handle cbs/cos disabling

API v0.6.0

  • reworked processInputs again, should hopefully fix the mod doing effectively nothing below 240fps (which kinda defeated the purpose)
  • added a setting to force disable CBS+COS from within the API, so dependent mods don't need to handle it
  • added isApiEnabled(), deprecated isApiDisabled()
  • changed gravity precision to better match vanilla (i'll thoroughly check this someday to find other issues)
  • lots of refactoring

SIP v0.1.3

  • changed processQueuedButtons hook priority
  • bump geode version
  • mark wave trail drag/draw fix as incompatiblities

API v0.5.0

  • restructured the input processing model
  • added debug logging
  • bump geode version

SIP v0.1.2

  • made Instantaneous Inputs on by default
  • used config listeners

API v0.4.1

  • fixed listeners' respective events

API v0.4.0

  • added listeners for the configs similar to geode's listenForSettingChanges
  • added updateRotation for tick splits, might fix some wave stuff, might not

API v0.3.1

  • added non-windows support, no velocity unrounding for those platforms for now

SIP v0.1.1

  • added non-windows support

API v0.3.0

  • replaced the y-displacement midhook with a full reimplementation of PlayerObject::update, potential for non-windows support 😮 (backup incase it goes wrong)
  • fixed some wave stuff, added subtick collisions for them
  • removed the SafetyHook dependency
  • general refactoring

API v0.2.0

  • removed processInputs PlayerObject* param
  • fixed p2 input doing nothing in non-dual mode

API v0.1.3

  • rounded getGravPerTick to 3dp if velocity unrounding is not enabled

SIP v0.1.0

  • public beta (or alpha? idrk), expect bugs

API v0.1.2

  • updated mod.json and README, and slightly simplified the midhook

API v0.1.1

  • added cheat tag

API v0.1.0

  • public beta (i've barely tested this at all lol)

Original Site made by HJfod. Geode 2 parody-ish by MeFinity.

Geode-SDK is the property of the Geode Team.


This website (Geode 2, Codename Malachite) is not affiliated with the Geode Team in any way shape or form.