Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6968

Minecarts movement velocity hardcapped on rails due to vanilla behavior


    • CraftBukkit version 3463-Spigot-ffceeae-953d3dd (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT)
    • Yes

      Overview: Tested in 1.18.2 on Spigot, Vanilla, and Paper but should affect all versions from 1.5 forward, as the only notable vanilla change was in a 1.8 snapshot and was reverted in the same series of snapshots.

      In vanilla minecarts have a max speed of 0.4d blocks per tick (b/t for short,) The interface minecart provides the ability to set this max speed to any nonnegative double. However, there is some code under the vanilla protected method moveAlongTrack() AbstarctMinecart that clamps this to a maximum of 2.0b/t when a minecart is on a rail block.

      Line 468: double d13 = Math.min(2.0, vec33.horizontalDistance());

      This effectively caps the setMaxSpeed to 2.0 b/t.  After this a check if the cart has a passenger (regardless of type, and regardless of how it was marked a passenger, however usually done by player interacting with or by the cart colliding with a whitelist of entities) the setMaxSpeed is then multiplied by 0.75 This results in the speed cap for carts with passengers 1.5 b/t.

      Minecarts accelerate when their Y decreases, when they are on-top a powered powered rail, when a player "moves" inside them (however this doesn't respect maxSpeed), and when pushed by another entity. The most commonly used method is powered rails.

      I have tried applying a relative forward vector to the cart to bypass this cap which only causes the cart to accelerate towards the 2.0 b/t (1.5 b/t with passenger) faster.

      Removing the rail under the cart allows the cart to accelerate past 2.0 b/t, while still respecting maxSpeed but has other undesirable behavior.

      Proposed Solution: Removing the Math.min() would solve the hard-cap.

      Potential Issues:  Potentially this could cause the cart to skip blocks, however that is already expected behavior from the setMaxSpeed. And typically plugin authors (RS Rails for example) warn to slow carts down before approaching a turn.

            Unassigned Unassigned
            LadyPotaty Trish Goodman
            1 Vote for this issue
            1 Start watching this issue