diff --git a/src/main/java/com/tiedup/remake/rig/patch/LivingEntityPatch.java b/src/main/java/com/tiedup/remake/rig/patch/LivingEntityPatch.java index 56b049d..6f7a8f3 100644 --- a/src/main/java/com/tiedup/remake/rig/patch/LivingEntityPatch.java +++ b/src/main/java/com/tiedup/remake/rig/patch/LivingEntityPatch.java @@ -13,6 +13,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.phys.Vec3; +import com.tiedup.remake.rig.TiedUpRigConstants; import com.tiedup.remake.rig.anim.Animator; import com.tiedup.remake.rig.anim.LivingMotion; import com.tiedup.remake.rig.anim.LivingMotions; @@ -22,26 +23,64 @@ import com.tiedup.remake.rig.anim.types.DynamicAnimation; import com.tiedup.remake.rig.armature.Armature; /** - * Stub RIG Phase 0 — patch de capability attaché à un {@link LivingEntity}. - * Expose l'animator, l'armature, la motion courante + quelques helpers. - * La version finale sera étoffée en Phase 2 (NPCs + player) avec les données - * d'entraînement/bondage spécifiques. + * RIG Phase 2 — patch de capability attaché à un {@link LivingEntity}. Porte + * l'{@link Animator} (initialisé eager via {@link TiedUpRigConstants#ANIMATOR_PROVIDER} + * dans {@link #onConstructed(LivingEntity)}) et expose {@link #getArmature()} + * (abstract — subclass fournit son biped armature via {@code TiedUpRigRegistry}). + * + *

Pattern init EF-style (voir EF LivingEntityPatch:146-156) : + *

    + *
  1. {@code onConstructed} fait super.onConstructed puis construit l'animator + * via le factory client/server split
  2. + *
  3. {@link #initAnimator(Animator)} permet aux subclasses de registrer leurs + * {@code LivingMotion → StaticAnimation} avant que l'animator commence à + * tourner
  4. + *
  5. {@link Animator#postInit()} poste l'event {@code InitAnimatorEvent} + * pour les extensions tierces
  6. + *
+ *

*/ public abstract class LivingEntityPatch extends EntityPatch { public LivingMotion currentLivingMotion = LivingMotions.IDLE; public LivingMotion currentCompositeMotion = LivingMotions.IDLE; + /** Animator initialisé dans {@link #onConstructed(LivingEntity)}, non-null après. */ + protected Animator animator; + public abstract void updateMotion(boolean considerInaction); public abstract Armature getArmature(); + @Override + public void onConstructed(T entity) { + super.onConstructed(entity); + this.animator = TiedUpRigConstants.ANIMATOR_PROVIDER.apply(this); + this.initAnimator(this.animator); + this.animator.postInit(); + } + + /** + * Hook pour subclasses : bind des {@code LivingMotion → StaticAnimation} + * sur l'animator avant qu'il ne commence à tourner. Default no-op. + * + *

Exemple subclass :

+ *
+	 * protected void initAnimator(Animator a) {
+	 *     a.addLivingAnimation(LivingMotions.IDLE, TiedUpAnimationRegistry.CONTEXT_STAND_IDLE);
+	 * }
+	 * 
+ */ + protected void initAnimator(Animator animator) { + // no-op par défaut + } + public Animator getAnimator() { - return null; + return this.animator; } @Nullable public ClientAnimator getClientAnimator() { - return null; + return this.animator instanceof ClientAnimator ca ? ca : null; } public LivingMotion getCurrentLivingMotion() {