Commit Graph

22 Commits

Author SHA1 Message Date
kayjaydee 5b2484be3b feat: add showcase region on first run to enhance user experience
- Implemented a mechanism to bootstrap a demo gravity flip region when regions.json is absent or empty.
- The showcase region features a 10×20×10 box with upward force and Torch_Fire particles, allowing immediate demonstration of functionality.
- Users can customize or remove this region via regions.json.
2026-04-23 16:52:23 +02:00
kayjaydee f5e6cc24f5 refactor: remove all debug code (DumpParticles, RegionEnterNotifier, dead ctors) 2026-04-23 16:45:37 +02:00
kayjaydee 1e47f4e846 refactor(03-06): remove debug logs + efficiency pass
Log cleanup:
- Drop redundant INFO "Gravity Flip enabled" in setup() (substantive version at
  start() remains as the single startup line).
- Drop INFO "debug enter/exit notifier ENABLED" (the notifier itself emits per
  region transition; extra startup noise not needed).
- Remove dead back-compat GravityApplier ctors that accepted an infoHandler
  Consumer (no callers post-03-06; debug logs already stripped).
- Clean stale javadoc referencing removed [DBG npc.woken]/[DBG npc.ctrlNull]
  one-shot logs.
- Also ship the pre-staged cleanup work: RegionEnterNotifier gated behind
  GRAVITYFLIP_DEBUG_NOTIFY env var, GravityApplier infoHandler field removed,
  tick logs stripped.

Efficiency:
- RegionVisualizer.resolveParticleId now memoises the requested->resolved
  mapping in a ConcurrentHashMap, eliminating the ParticleSystem.getAssetMap()
  lookup on every tick emission per region. Warn-once semantics preserved via
  warnedInvalidIds. Fail-open path (AssetMap unavailable in tests) intentionally
  does not populate the cache.
- Document in GravityApplier javadoc why Pass 1 + Pass 2 cannot be fused:
  restore requires the complete currentlyInRegion set before diffing against
  previouslyInverted.

Considered but not applied:
- ParticleEdgeEmitter.edgePoints caching per (box, density): throttled to
  >=100ms refresh and typical <20 regions => alloc pressure negligible;
  premature without measurement.
- Reusing RegionRegistry snapshot in RegionEnterNotifier: notifier is
  opt-in/off-by-default, so its independent ECS scan has zero prod cost.

Tests: ./gradlew clean build green, no test changes required.
2026-04-23 16:43:07 +02:00
kayjaydee beba729115 feat(03-06): add Particles visual mode with per-region id/density (Task 3) 2026-04-23 15:44:42 +02:00
kayjaydee ee1d1b9bdb feat(03-06): add ParticleEdgeEmitter + tests (Task 2) 2026-04-23 15:42:26 +02:00
kayjaydee 7bbd65dad2 feat(03-06): add particle-system dump for discovery (Task 1)
- New DumpParticlesCommand utility: enumerates loaded ParticleSystem
  asset-ids via ParticleSystem.getAssetMap().getAssetMap().keySet().
- Wired in GravityFlipPlugin.start() behind GRAVITYFLIP_DUMP_PARTICLES
  env var (or -Dgravityflip.dumpParticles sysprop). No-op when unset.
- Boot-time fallback approach (plan-allowed) -- proper CommandBase
  registration deferred to avoid i18n translation-key plumbing for a
  one-shot discovery dump.
- See .planning/phases/03-gravity-physics/03-06-DUMP-NOTES.md for
  trigger instructions and the user checkpoint before Task 3.
2026-04-23 15:32:55 +02:00
kayjaydee 3511493687 feat(03-05): cable RegionVisualizer dans RegionTickLoop + shutdown clearAll (Task 3)
- RegionTickLoop: nouveau ctor 4-arg (registry, gravityApplier, regionVisualizer,
  errorHandler). Les ctors 2-arg et 3-arg existants delegent (back-compat tests).
  Tick appelle regionVisualizer.visualize(w, snapshot) apres gravityApplier.apply()
  avec null-safe gate (meme pattern que gravityApplier).
- GravityFlipPlugin.start(): construit RegionVisualizer avec errorHandler log WARN,
  le passe au tickLoop.
- GravityFlipPlugin.shutdown(): appelle regionVisualizer.clearAll(world) AVANT
  tickLoop.stop() (si Universe encore vivante), emet ClearDebugShapes a tous
  les PlayerRefs. Si universe null, fallback TTL expiration.
- Aucun nouveau scheduler/thread cree.
2026-04-23 14:55:24 +02:00
kayjaydee 99b9072b78 feat(03-05): ajoute RegionVisualizer (parsing hex/mode, throttling, low-level DebugUtils.add) (Task 2)
- RegionVisualizer emet DisplayDebug cube par region via
  DebugUtils.add(World, DebugShape.Cube, Matrix4d, color, opacity, time, flags)
  (low-level => opacity custom respectee, vs addCube qui hardcode 0.8).
- Mapping modes: Outline=FLAG_NO_SOLID, Faces=FLAG_NO_WIREFRAME, Both=FLAG_NONE,
  None=skip, unknown=fallback Outline.
- parseColor(#RRGGBB) avec fallback COLOR_CYAN sur input invalide.
- Throttling par region via ConcurrentHashMap<name, lastEmitMs> + clock injecte.
- Clamp defensive: VisualRefreshMs plancher 100ms (anti-DoS T-03-05-03),
  VisualOpacity clamp [0,1] (T-03-05-04).
- TTL = refreshMs * 1.2 / 1000 (overlap 20% anti-flicker).
- Toute emission wrappee dans world.execute(...) via WorldExecutor injectable.
- Tests: parseColor valid/invalid, normalizeMode, flagsForMode, matrixFromBox
  non-cubique, throttling deterministe, skip None/disabled, clamp opacity/refresh.
2026-04-23 14:54:31 +02:00
kayjaydee 0069d4c47e feat(03-05): ajoute 4 champs Visual* optionnels + round-trip tests (Task 1)
- GravityFlipRegion: VisualColor/VisualMode/VisualRefreshMs/VisualOpacity
  avec defaults (#00FFFF, Outline, 1000, 0.5), getters/setters, javadoc.
- CODEC: 4 KeyedCodec optionnels (pas de validator nonNull) => back-compat
  legacy regions.json.
- 2 tests round-trip (custom + defaults quand champs absents).
2026-04-23 14:52:42 +02:00
kayjaydee d43aa4a98c feat(03-04): FallDamageSuppressorSystem + wiring + cleanup [DBG throttle] (Task 3)
- FallDamageSuppressorSystem: subclass DamageEventSystem, cancel Damage
  cause=Fall quand guard.shouldSuppressFallDamage; FALL_INDEX lazy via
  DamageCause.getAssetMap().getIndex; groupe inspectDamageGroup
- GravityApplier: 3-arg constructor avec FallDamageGuard; first-match
  region, filtres AffectPlayers/Npcs/Items avant wake, seed addForce
  paramétré par VerticalForce (remplace hardcode 0.1); notifie
  guard.markInRegion / markExit (via lastKnownRegion map pour Pass 2)
- Cleanup: retire les AtomicInteger counters + log [DBG tick=...]
  throttle 1s; conserve logs one-shot [DBG npc.woken]/[DBG npc.ctrlNull]
- GravityFlipPlugin.setup(): instancie FallDamageGuard, registerSystem
  sur entityStoreRegistry; start() passe guard au GravityApplier
- Imports Query + CommandBuffer alignés sur FlockMembershipSystems
2026-04-23 14:03:58 +02:00
kayjaydee f9d5595837 feat(03-04): ajoute FallDamageGuard tracker thread-safe (Task 2)
- ConcurrentHashMap<UUID, region> current + exit + regionAtExit
- shouldSuppressFallDamage: in-region FallDamage=false OU grace window
- Pas de static mutable, injecté via constructeur
- 7 tests pure-data couvrant entry/in-region/exit/grace/re-entry/override
2026-04-23 14:00:56 +02:00
kayjaydee a834c59b66 feat(03-04): ajoute 6 champs optionnels sur GravityFlipRegion (Task 1)
- POJO: FallDamage (false), GracePeriodMs (2500), VerticalForce (0.1),
  AffectPlayers/Npcs/Items (true) avec getters/setters
- CODEC: 6 .append sans nonNull validator (sémantique optionnelle)
- Tests: 6 round-trip + back-compat defaults (9 tests total)
2026-04-23 14:00:12 +02:00
kayjaydee 210c93aee7 feat(03-02): wake-up MovementManager + MotionController on region flip
- GravityApplier: branches player (setDefaultSettings + applyDefaultSettings + update) et NPC (Role.getActiveMotionController().updatePhysicsValues) dans les 2 pass
- wakePlayerOrNpc() helper appelé depuis forEachEntityParallel (sous world.execute — WorldThread assert OK)
- PhysicsValues construit localement via buildPhysicsValuesWithFlag (évite relookup ECS pre-commit cmdBuf)
- Seam pure FlaggedDecision extraite pour tests unitaires hors runtime Hytale (Rule 3 — static init PhysicsValues nécessite PluginBase)
- 8 tests verts (6 existants + 2 nouveaux sur buildFlaggedDecision)
2026-04-23 12:29:00 +02:00
kayjaydee 4a02ceaa82 fix(region): wrap refreshFor(World) dans world.execute (WorldThread assert)
- RegionRegistry.refreshFor dispatche scan ECS + publishSnapshot via world.execute
- Publication devient asynchrone (1-tick staleness max, borne par tick loop @100ms)
- Null-path enabled.isEmpty publie directement (pas de travail ECS requis)
- Amendement D-04 du plan 03-01 : world.execute requis côté initiation de forEachEntityParallel
2026-04-23 11:49:00 +02:00
kayjaydee af02e19685 fix(gravity): wrap forEachEntityParallel dans world.execute (WorldThread assert)
- GravityApplier.apply dispatche via world.execute(Runnable) pour satisfaire assertThread de Store.forEachEntityParallel
- PASS 1, PASS 2 et update tracker exécutés dans le même Runnable (cohérence intra-tick)
- Null-guards conservés avant le dispatch
- Amendement D-04 du plan 03-01 : world.execute requis côté initiation
2026-04-23 11:48:29 +02:00
kayjaydee f7dcc7d59a feat(03-01): wire GravityApplier into RegionTickLoop + plugin (Task 2)
- RegionTickLoop gagne un constructeur 3-args (registry, gravityApplier, errorHandler)
- Ancien constructeur 2-args conservé pour rétrocompat des tests Phase 02
- Tick body appelle gravityApplier.apply(w, registry.currentSnapshot(w)) après refreshFor
- GravityFlipPlugin.start() construit l'applier et l'injecte dans le tickLoop
- Log de démarrage mis à jour: 'gravity inversion active'
2026-04-23 10:32:28 +02:00
kayjaydee ef3f398c55 feat(03-01): add GravityApplier with native PhysicsValues.invertedGravity toggle (Task 1)
- Service GravityApplier qui toggle PhysicsValues.invertedGravity via CommandBuffer.replaceComponent
- Thread-safe tracker ConcurrentHashMap.newKeySet<UUID> pour dedup entre ticks
- Second pass O(N) pour restaurer la gravité à la sortie de région (trade-off v1 documenté)
- Pure diff static helper + hooks package-private pour tests unitaires sans runtime Hytale
- 6 tests verts (diff + tracker semantics)
2026-04-23 10:31:43 +02:00
kayjaydee 53b43d83c7 feat(02-02): add RegionTickLoop + plugin wiring (Task 3)
- RegionTickLoop: single-thread daemon scheduler @100ms, 2s initial delay,
  shutdown -> awaitTermination(5s) -> shutdownNow lifecycle.
  Three start overloads: (World), (Supplier<World>), (Runnable). Errors are
  routed to a Consumer<Throwable> so an exception in one tick never kills
  the scheduler.
- GravityFlipPlugin.start():
  * builds RegionRegistry from configHolder.get() + holder for save()
  * starts the tick loop with a Supplier<World> that lazily resolves
    Universe.get().getDefaultWorld() (deviation: PrepareUniverseEvent in the
    pinned API only carries WorldConfigProvider — no Universe/World access,
    so we use the lazy-supplier pattern from MythWorld instead)
  * registers the ScheduledFuture with TaskRegistry (raw cast, try/catch fallback)
- GravityFlipPlugin.shutdown(): tickLoop.stop() BEFORE super.shutdown()
- RegionTickLoopTest: 3 timing tests pass (>=8 ticks/sec, stop within 5s,
  exception resilience).
- gradle build green; fat jar contains both region/ and tick/ class dirs.
2026-04-23 00:56:12 +02:00
kayjaydee 6574c05128 feat(02-02): add RegionRegistry + RegionSnapshot with ECS refreshFor (Tasks 1+2)
- RegionSnapshot: immutable per-world occupancy view (byRegion/tickId/world)
- RegionRegistry:
  * AtomicReference<List<GravityFlipRegion>> for tick-loop-safe region reads
  * CRUD (add/remove/setEnabled) under mutationLock + atomic snapshot republish
  * refreshFromConfig(cfg) hook for Phase 4 command handlers
  * refreshFor(World) iterates ECS via forEachEntityParallel +
    TransformComponent.getComponentType() (ComponentType IS-A Query, no builder) +
    Box.containsPosition(x,y,z); publishes per-world snapshot via AtomicReference.
  * Lazy ComponentType init (avoids Hytale PluginBase static init in tests)
  * Snapshots map keyed by Object (not World) so JDK 25 tests don't need Mockito
- 7/7 RegionRegistryTest pass: CRUD, snapshot read/publish, cross-thread visibility,
  refreshFromConfig atomic swap.

Probe results (recorded for SUMMARY):
- ArchetypeChunk.getRef(int) NOT present; actual method is getReferenceTo(int)
- TransformComponent.getPosition() returns com.hypixel.hytale.math.vector.Vector3d
  in pinned 2026.03.26 (Phase 02-01 deviation pattern recurs)
2026-04-23 00:54:32 +02:00
kayjaydee 216f544d9b feat(02-01): wire GravityFlipConfig to regions.json via named withConfig
- GravityFlipConfig wraps List<GravityFlipRegion> via ArrayCodec under the
  KeyedCodec("Regions", ...) entry. Decoded list is a mutable ArrayList
  (NOT List.of(arr)) so Phase 4 commands can mutate at runtime.
- GravityFlipPlugin.configHolder uses the named overload
  withConfig("regions", GravityFlipConfig.CODEC) — produces
  <dataDirectory>/regions.json. The 1-arg overload would hardcode config.json.
- configHolder() javadoc documents the save contract (no auto-save on
  shutdown; mutators must call configHolder.save() explicitly) and the shared
  mutable reference caveat that 02-02's RegionRegistry will resolve.
- 4 round-trip tests cover: empty default, two-region order preservation,
  empty list, and list mutability (regression guard against List.of).
2026-04-23 00:43:26 +02:00
kayjaydee b046f44ab5 feat(02-01): add GravityFlipRegion POJO + BuilderCodec with round-trip tests
- GravityFlipRegion holds Name (String) + Box (Hytale AABB) + Enabled (boolean),
  serialised through a BuilderCodec keyed on "Name"/"Box"/"Enabled".
- Validators.nonNull() applied to Name and Box (correct package is
  com.hypixel.hytale.codec.validation.Validators, not codec.builder).
- Server jar 2026.03.26 uses com.hypixel.hytale.math.vector.Vector3d for Box.min/max
  (NOT org.joml.Vector3d, which only appeared in newer builds).
- 3 JUnit 5 round-trip tests cover name/box/enabled, enabled=false, and empty name.
- testImplementation added for the Server artifact so codec encode/decode is
  reachable from unit tests.
2026-04-23 00:41:36 +02:00
kayjaydee 2e26f8a10f feat(01): plugin manifest and entry class 2026-04-22 23:28:13 +02:00