diff --git a/.gitignore b/.gitignore index d34d2a2..11d83bd 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,7 @@ logs/ .env .env.local *.local + +# Phase 4 — temporary asset sources (not committed) +*.zip +note diff --git a/src/main/java/com/mythlane/chainlightning/chain/ParticleTrail.java b/src/main/java/com/mythlane/chainlightning/chain/ParticleTrail.java index 99944a0..70815fa 100644 --- a/src/main/java/com/mythlane/chainlightning/chain/ParticleTrail.java +++ b/src/main/java/com/mythlane/chainlightning/chain/ParticleTrail.java @@ -18,8 +18,10 @@ import java.util.List; */ public final class ParticleTrail { - /** Default trail density in particles per block. */ - public static final double TRAIL_DENSITY = 4.0; + /** Default trail density in particles per block. Reduced from 4.0 (post 14:37 UAT) to keep + * total per-click emit count low enough that the client doesn't throttle at the particle + * budget. With 5-hop chain at 5 blocks each: 1.0 = ~25 arcs total instead of ~100. */ + public static final double TRAIL_DENSITY = 1.0; private ParticleTrail() { // utility class — no instances diff --git a/src/main/java/com/mythlane/chainlightning/sceptre/ChainLightningSceptreInteraction.java b/src/main/java/com/mythlane/chainlightning/sceptre/ChainLightningSceptreInteraction.java index e621c4c..f491b6c 100644 --- a/src/main/java/com/mythlane/chainlightning/sceptre/ChainLightningSceptreInteraction.java +++ b/src/main/java/com/mythlane/chainlightning/sceptre/ChainLightningSceptreInteraction.java @@ -136,6 +136,17 @@ public final class ChainLightningSceptreInteraction extends SimpleInstantInterac ChainDamageApplier.apply(hits, playerRef, commandBuffer, commandBuffer); LOGGER.info("[ChainLightning][7/9] damage application returned"); + // --- Étape 7.5 : émettre VFX/SFX (best-effort) --- + // CONTEXT failure-mode decision : damage déjà appliqué — si l'emit échoue, log + continue + // vers le cooldown. Pas de propagation : le tick serveur ne doit pas crash sur un bug VFX. + try { + LOGGER.info(String.format("[ChainLightning][7.5/9] vfx emit START hits=%d", hits.size())); + HytaleVfxEmitter.playChainEffects(hits, playerRef, commandBuffer); + LOGGER.info("[ChainLightning][7.5/9] vfx emit DONE"); + } catch (Throwable t) { + LOGGER.log(Level.WARNING, "[ChainLightning][7.5/9] vfx emit failed (damage already applied)", t); + } + // --- Étape 8 : démarrer le cooldown APRÈS succès --- cooldown.deductCharge(); LOGGER.info(String.format("[ChainLightning][8/9] cooldown deducted (next available in %.1fs)", COOLDOWN_TIME)); diff --git a/src/main/java/com/mythlane/chainlightning/sceptre/HytaleVfxEmitter.java b/src/main/java/com/mythlane/chainlightning/sceptre/HytaleVfxEmitter.java new file mode 100644 index 0000000..70cef6b --- /dev/null +++ b/src/main/java/com/mythlane/chainlightning/sceptre/HytaleVfxEmitter.java @@ -0,0 +1,93 @@ +package com.mythlane.chainlightning.sceptre; + +import com.hypixel.hytale.component.CommandBuffer; +import com.hypixel.hytale.component.ComponentAccessor; +import com.hypixel.hytale.component.Ref; +import com.hypixel.hytale.server.core.asset.type.entityeffect.config.EntityEffect; +import com.hypixel.hytale.server.core.entity.effect.EffectControllerComponent; +import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; +import com.mythlane.chainlightning.chain.ChainHit; + +import javax.annotation.Nonnull; +import java.util.List; +import java.util.logging.Logger; + +/** + * Phase 4 — Adapter VFX/SFX qui applique un EntityEffect custom à chaque cible touchée. + * + *
Pivot 14:52 (POC EntityEffect bridge) : les tentatives précédentes via + * {@code ParticleUtil.spawnParticleEffect("Splash", ...)} ne rendaient pas les particles côté + * client (asset sync plugin custom + budget client → 0/5 visible). On utilise maintenant le + * pattern canonique Cleric-Rod : on déclare un {@code EntityEffect} JSON (Server/Entity/Effects/ + * Chain_Hit_Effect.json) qui contient des particles vanilla inline + EntityTopTint/BottomTint, + * et on applique cet effect à chaque target via {@link EffectControllerComponent#addEffect}. + * + *
Le rendu passe par la réplication ECS (le ECS state du target propage l'effet aux clients + * automatiquement), pas par un packet SpawnParticleSystem standalone. C'est le path éprouvé. + * + *
Fallback : si le lookup de l'EntityEffect échoue (asset pas chargé), on log et skip. + * Pas de propagation : damage déjà appliqué côté caller, l'emit failure ne doit pas crash. + * + *
Hop-index ignoré pour POC : l'EntityEffect est uniforme sur les 5 cibles. La courbe
+ * de volume (VFX-02) reste implémentée dans {@code VolumeCurve} mais n'est pas utilisée ici --
+ * une variante future pourrait définir 5 EntityEffects {@code Chain_Hit_Effect_0..4} avec des
+ * intensités décroissantes, ou patcher l'EntityEffect existant runtime (non supporté par l'API).
+ */
+public final class HytaleVfxEmitter {
+
+ private static final Logger LOGGER = Logger.getLogger(HytaleVfxEmitter.class.getName());
+
+ /** Asset id du EntityEffect appliqué à chaque target touchée par la chaîne. */
+ private static final String EFFECT_ID = "Chain_Hit_Effect";
+
+ private HytaleVfxEmitter() {}
+
+ /**
+ * Applique l'EntityEffect {@code Chain_Hit_Effect} à chaque hit de la chaîne.
+ *
+ * @param hits liste résolue par ChainResolver, ordre BFS
+ * @param playerRef ref du caster (présent pour symétrie d'API future, non utilisé ici --
+ * l'EntityEffect rend automatiquement à tous les viewers en range)
+ * @param commandBuffer le CommandBuffer du tick courant (sert pour {@code getComponent} et
+ * pour propager les changes d'état ECS au tick end)
+ */
+ public static void playChainEffects(@Nonnull List