Commit Graph

6 Commits

Author SHA1 Message Date
SashegDev cf1ee08bb8 perf: cut per-tick allocation and collapse STARS into one scheduler task
Цель — не средний тик, а разброс: p95 26.9 мс и пики под 170 мс на 60 ботах
бьют по игрокам сильнее, чем медиана 14.8 мс. Почти весь этот разброс шёл
от мусора в горячих путях.

1. Кеш владельца ножа переехал в начало проверки.
   Раньше isOwner() сначала звал BlackKnifeItem.is() на обеих руках и только
   потом смотрел ownerCache, то есть кеш не срабатывал никогда. is() обязан
   взять ItemMeta, а Bukkit возвращает там полную копию метаданных вместе с
   PDC. tickShield() зовёт isOwner каждый тик на каждого игрока: при 60
   игроках это 2400 копий ItemMeta в секунду. Теперь на попадание в кеш —
   ноль аллокаций, пересчёт раз в 2 с. Кеш хранит оба ответа сразу
   (в руках / где-то в инвентаре), потому что hasMagic и превью интересуют
   разные вещи.

2. BlackKnifeItem.inHands() вместо пары is() в горячих путях:
   7 проверок превью прицеливания и SWOON на каждый удар.

3. DustOptions вынесены в константы Particles.
   36 мест создавали new Particle.DustOptions(Color.fromRGB(...)), и почти все
   внутри циклов или задач с периодом в несколько тиков. DustOptions
   иммутабелен, поэтому один объект на цвет. Отдельно вынесен тернарник,
   выбиравший цвет кольца ВНУТРИ цикла в превью SNIPE/TRI: он пересчитывал
   один и тот же цвет на каждой из 12-16 итераций.

4. getGazePoint() больше не зовёт getEyeLocation() три раза и getDirection()
   два. Метод работает каждые 4 тика на каждого игрока с ножом.

5. Визуал STARS вынесен в StarFx под одну задачу.
   Раньше 18 звёзд и до 108 осколков получали по своей задаче с периодом в
   один тик — до 126 задач планировщика на одно нажатие, каждая со своим
   getNearbyEntities и getNearbyPlayers. Теперь один список под одной
   задачей, которая снимает себя сама в простое.

   Попутно исправлен баг: EntityTracker.untrack() вызывался на каждом тике,
   пока сущность жива, поэтому после первого тика она исчезала из множества
   отслеживаемых и EntityTracker.cleanup() её больше не находил. Теперь
   untrack вызывается один раз, при удалении.
2026-10-04 13:11:14 +00:00
SashegDev 81e86fdc9f rework: SWOON rewrite, tension economy, DIVE physics, predictive displays
SWOON: virtual HP deleted. Damage now goes through DamageType.GENERIC_KILL,
which vanilla marks as bypassing armour, enchantments, effects and shields,
and which consumes no armour durability. The old mechanic cancelled the damage
outright and only regenened virtual HP back to 1, so a swoon could never be
escaped by any means.

- cost by mob max HP: clamp(mob-base-cost + mob-cost-per-hp * HP, base, max).
  Player cost is flat. Chicken 14.5 -> Zombie 22.5 -> Enderman 32.5 -> Warden 137.
- cooldown inversely proportional to TP spent: trash mob 40t, player 160t.
  Moved off Material.NETHERITE_SWORD onto a per-ability key: the material
  cooldown is a shared per-material table, so it blocked every netherite sword
  in the inventory and any inventory rebuild wiped it. New AbilityCooldown.
- death message detected statelessly from the damage type plus who holds the
  knife, so no marker state has to survive the death.
- TP is now checked BEFORE the original hit is cancelled. Cancelling first made
  every swing without enough TP a free block: no damage, no gain, no progress.
- 257 -> ~110 lines; the VHP/SWOONED checks in DamageUtil, ParryHandler,
  GrenadeAttack and SkyDiveAttack are gone with the mechanic they guarded.

Tension:
- passive regen 0.25/tick (was 2/tick, i.e. 100 TP/s) with a hard 3s pause
  after the last combat action.
- hit gain 7.5, crit 11.25 (1.5x base instead of 2x).
- onQuit clears TP. It only dropped bossbars and caches, so a quitting player
  left a full bar in memory for the rest of the uptime.
- shield gain and delay moved into config; they were the only remaining
  hardcoded economy numbers.

DIVE:
- setGravity(false) for the whole ability. Gravity fought setVelocity(0) every
  tick and the flag reaches clients, so server and client now agree and hover
  is a real state instead of a fight over movement prediction.
- own gravity constant and an analytic apex; the old code probed velocity three
  different ways.
- one state machine with a single exit, so death, wall, logout, respawn and
  damage can never leave a player with gravity off. The runnables used to
  return without cancel() and leaked a per-tick task per dive.
- ground contact for 3 ticks aborts the dive without damage. Unimplemented
  before, so you could dive into the ground, walk to the target and hit them.
- dash 3.0 blocks/tick over 60 ticks (was 2.8/40).
- hover pins X/Z only, camera stays free, no per-tick actionbar spam.
- quitting mid-dive refunds the unused knife cooldown.
- fall damage cancelled only while diving and for 2.5s after, not for the whole
  cooldown.

Displays: predictive teleport. A visual is spawned N ticks along its own
trajectory and told to interpolate the teleport over those same N ticks, so the
client never lags behind and the packet count is unchanged. Duration 1 is
effectively no smoothing, which is why the visuals snapped on real ping.
Applied to DIAMOND, DIAMOND_TRI, LUNGE (catalyst, sword, overhead, volley) and
GRENADE. lead-ticks is configurable; 0 restores stock behaviour.
2026-09-30 12:41:28 +00:00
SashegDev 3e26bb9ad5 fix DIVE: allow creative, feedback messages, segment hit sampling; tune GRENADE faster flight + 10t cd 2026-09-24 19:07:50 +00:00
SashegDev fa81d144ba smooth display motion via teleport_duration=1 (no desync) 2026-09-17 09:18:53 +00:00
SashegDev 3e00c57fa7 tweak grenade: no flight cap, range 15, preview matches 2026-09-17 08:43:44 +00:00
SashegDev ee4eb7f897 feat: GRENADE parabolic nade (35/5.5, 25TP, 15cd) + DIVE sky strike (25dmg knockback, 87.5TP, 120cd) 2026-09-17 08:41:14 +00:00