Skip to content

About

NeoForge 1.21.1 mixin mod that drops non-finite or absurd entity movement, so one broken velocity cannot freeze the server thread.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Entity Motion Guard icon

Entity Motion Guard

NeoForge 1.21.1 mixin mod that drops non-finite or absurd entity movement, so one broken velocity cannot freeze the server thread.

Build Release License: proprietary

English | Русский

English

Overview

Every tick a moving entity calls Entity.move(MoverType, Vec3) with the distance it wants to travel. Vanilla never checks that vector. If a mod, a mount or a bad calculation leaves Infinity in an entity's velocity, the collision code that follows walks the path block by block:

  • BlockGetter.traverseBlocks steps by 1 / distance. With an infinite distance the step is 0, the loop condition stays true, and the server thread spins forever.
  • With physics mods such as Sable, collide also gathers colliders over a box that is billions of blocks wide.

The watchdog then dumps the same stack every 10 seconds and the server stops answering until the process is killed. The case that led to this mod was an Aether Swet that had swallowed a player: its velocity became infinite, and the server froze inside Swet.travel -> Entity.move -> BlockGetter.clip -> traverseBlocks for 45 minutes.

The mod checks the movement vector at the head of Entity.move:

  1. If every axis is finite and at most the limit (512 blocks per tick by default), vanilla runs unchanged.
  2. Otherwise the move becomes zero and the entity's velocity is reset, so the next tick does not try again.
  3. The drop is logged as a warning with the entity type, UUID, dimension, position, the rejected vector, its rider and its vehicle. Repeats are folded into one line per minute.

Real gameplay never comes close to the limit: elytra with rockets, ender pearls and minecart boosters stay under 10 blocks per tick. Teleports do not go through move at all.

Requirements

  • Minecraft 1.21.1
  • NeoForge 21.1 or newer, or a NeoForge-based hybrid core (Youer, Mohist)
  • Java 21

Installation

Download entity-motion-guard-<version>.jar from Releases and put it into the server's mods/ folder. Clients do not need it, but it does no harm there and protects singleplayer worlds the same way.

Configuration

One optional JVM flag: -Dentitymotionguard.limit=<blocks> changes the per-axis limit. Non-finite values are always dropped.

Testing

Checked on an isolated Youer 1.21.1 server with The Aether and Sable, using a helper command that sets an entity's velocity at runtime:

  • Without the mod an infinite velocity on a pig freezes the server inside Entity.move and the watchdog starts dumping threads.
  • With the mod, pigs, blue Swets and golden Swets flung with Infinity, -Infinity, 1e300, NaN and 600 all stay in place, the server keeps answering, and the drop is logged once.
  • A Swet with a rider, flung with Infinity, is handled the same way.
  • A normal fling of 2 blocks per tick still moves the entity.

Releases

Every tag v* is built by GitHub Actions from this source and published in Releases. The build log of each release is public, so every jar can be traced to its commit.

Known limitations

  • It treats the symptom. Whatever produced the broken velocity still does so; the log line names the entity and its rider so the cause can be found.
  • A vector that is large but under the limit still runs through vanilla collision. Lower the limit if a mod on your server produces such values.
  • Built and tested for 1.21.1 only.

License

Proprietary, all rights reserved. Official release binaries may be run unmodified on servers you operate. Copying, modifying or redistributing the code or the binaries requires written permission. Full terms: LICENSE.

Русский

Обзор

Каждый тик движущаяся сущность вызывает Entity.move(MoverType, Vec3) с расстоянием, на которое хочет сдвинуться. Ваниль этот вектор не проверяет. Если мод, ездовое существо или ошибка в расчёте оставит в скорости сущности Infinity, следующий за этим код столкновений проходит путь по блокам:

  • BlockGetter.traverseBlocks шагает на 1 / расстояние. При бесконечном расстоянии шаг равен 0, условие цикла не меняется, и серверный поток крутится вечно.
  • С физическими модами вроде Sable collide ещё и собирает коллайдеры в коробке шириной в миллиарды блоков.

Сторож сервера каждые 10 секунд печатает один и тот же стек, и сервер не отвечает, пока процесс не убьют. Случай, из-за которого появился мод: свет из Aether проглотил игрока, его скорость стала бесконечной, и сервер завис в Swet.travel -> Entity.move -> BlockGetter.clip -> traverseBlocks на 45 минут.

Мод проверяет вектор движения в начале Entity.move:

  1. Если каждая ось конечна и не больше предела (по умолчанию 512 блоков за тик), работает ванильный код.
  2. Иначе движение становится нулевым, а скорость сущности сбрасывается, чтобы следующий тик не повторил попытку.
  3. В лог пишется предупреждение с типом сущности, UUID, измерением, позицией, отброшенным вектором, всадником и транспортом. Повторы сводятся в одну строку в минуту.

Обычная игра к пределу даже не приближается: элитры с ракетами, жемчуг Края и ускорители вагонеток укладываются в 10 блоков за тик. Телепорты через move не идут вообще.

Требования

  • Minecraft 1.21.1
  • NeoForge 21.1 и новее или гибридное ядро на NeoForge (Youer, Mohist)
  • Java 21

Установка

Скачать entity-motion-guard-<версия>.jar из Releases и положить в папку mods/ сервера. Клиентам он не нужен, но и не мешает, а одиночные миры защищает так же.

Настройка

Один необязательный флаг JVM: -Dentitymotionguard.limit=<блоки> меняет предел по каждой оси. Нечисловые и бесконечные значения отбрасываются всегда.

Проверка

Проверено на отдельном сервере Youer 1.21.1 с The Aether и Sable, с вспомогательной командой, которая задаёт скорость сущности во время игры:

  • Без мода бесконечная скорость у свиньи вешает сервер внутри Entity.move, и сторож начинает печатать дампы потоков.
  • С модом свиньи, синие и золотые светы с Infinity, -Infinity, 1e300, NaN и 600 остаются на месте, сервер отвечает, отброс записан в лог один раз.
  • Свет со всадником и скоростью Infinity обрабатывается так же.
  • Обычный толчок на 2 блока за тик по-прежнему двигает сущность.

Релизы

Каждый тег v* собирается из этих исходников в GitHub Actions и публикуется в Releases. Лог сборки каждого релиза открыт, так что любой jar можно сверить с его коммитом.

Ограничения

  • Мод лечит симптом. То, что выдало сломанную скорость, продолжает это делать; строка в логе называет сущность и всадника, чтобы найти причину.
  • Большой, но не превышающий предел вектор всё ещё идёт через ванильные столкновения. Если какой-то мод на сервере даёт такие значения, предел стоит уменьшить.
  • Собрано и проверено только для 1.21.1.

Лицензия

Проприетарная, все права защищены. Официальные сборки из релизов можно запускать без изменений на своих серверах. Копировать, изменять и распространять код или сборки можно только с письменного разрешения. Полный текст: LICENSE.

About

NeoForge 1.21.1 mixin mod that drops non-finite or absurd entity movement, so one broken velocity cannot freeze the server thread.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages