Fast TNT and other fast-moving entities can freeze a server for a noticeable moment, even with performance mods installed. Collision Lag Fix makes the collision check for anything moving many blocks per tick cost almost nothing, and the entity still ends up exactly where vanilla would put it.
Fixes MC-260743. Please report bugs here.
What it fixes
When an entity moves, vanilla first gathers the collision shape of every block in the box between where it is and where it's going. Then it moves the entity along one axis at a time. For a TNT shot from a cannon at 80 blocks per tick diagonally into the ground, that box holds hundreds of thousands of blocks, and almost none of them are anywhere near its path.
This mod gathers only the blocks along each axis the entity actually moves through. The entity hits the same blocks, in the same order, and stops in the same place.
Measured in our tests, for one TNT moving 80 blocks per tick into solid stone:
- vanilla: 45–110 ms, about a whole tick (50 ms) or more for a single TNT;
- with this mod: 0.05–0.25 ms.
Lithium already speeds this up when the path goes through air, but not through terrain. With Lithium installed, the same TNT takes 45–62 ms on its own and about 1.1–1.2 ms with this mod added. The two work together.
On 1.21.1, falling TNT also traced a ray along its whole fall every tick (MC-263882), up to 100+ blocks for cannon TNT, to update a fall distance TNT never uses. Newer versions cap that ray at 8 blocks; on 1.21.1 this mod skips it for TNT.
Config
config/collision_lag_fix.properties:
enabled: turn the fix off without removing the mod.minSpeed: how fast, in blocks per tick, an entity must move on at least two axes before the fix is used. The default is 2. Slower movement keeps the vanilla code.
FAQ
Client or server? The server needs it (or your game, in singleplayer). Players don't need it to join.
Does it change how entities move? No. Our tests move thousands of random entities (TNT, items, falling blocks, zombies sneaking or wearing leather boots) through stone, slabs, fences, scaffolding and powder snow, past boats, minecarts and shulkers, and across the world border. Every end position is checked against vanilla's. They run on every version and loader, and once more with Lithium installed. Close to the world border, and when a mob would step up onto a block, the mod leaves the move to vanilla.
Does it need anything else? No.
Can I use it in my modpack? Yes, go ahead, no need to ask.
MIT. Developed with AI assistance. Source: https://github.com/traelmyx/collision-lag-fix