add rig extraction scripts

scripts/rig-rewrite-imports.sh  — package rewrites yesman.epicfight.* → com.tiedup.remake.rig.*
scripts/rig-headers.sh          — GPLv3 + attribution Epic Fight header injection
scripts/rig-extract-phase0.sh   — master script Phase 0 (copy + rewrite + headers)

Cf. docs/plans/rig/EXTRACTION.md §9 (docs restent locales).
This commit is contained in:
NotEvil
2026-04-22 00:26:09 +02:00
parent 088e614a49
commit 8bfa140ad9
3 changed files with 250 additions and 0 deletions

137
scripts/rig-extract-phase0.sh Executable file
View File

@@ -0,0 +1,137 @@
#!/usr/bin/env bash
# rig-extract-phase0.sh
# Extrait le core Epic Fight nécessaire pour le RIG system TiedUp.
# Voir docs/plans/rig/EXTRACTION.md §9 pour détails.
#
# NE PAS utiliser "set -e" — certains cp peuvent échouer (fichiers non
# critiques, 2>/dev/null || true) et on veut continuer.
#
# Lancer depuis la racine du projet.
set -u
SRC="docs/ModSources/epicfight-1.20.1/src/main/java/yesman/epicfight"
DST="src/main/java/com/tiedup/remake/rig"
if [ ! -d "$SRC" ]; then
echo "ERROR: Epic Fight source not found at $SRC"
exit 1
fi
echo "=== rig-extract-phase0.sh ==="
echo "Source : $SRC"
echo "Cible : $DST"
echo ""
echo "=== 0. Structure des packages ==="
mkdir -p "$DST"/{math,armature,armature/types,anim,anim/types,anim/property,anim/client,anim/client/property,mesh,mesh/transformer,cloth,asset,event,patch,render,render/compute,registry,bridge,tick,mixin,util,util/datastruct,exception}
echo "=== 1. Math utils ==="
cp -v "$SRC"/api/utils/math/*.java "$DST/math/"
echo ""
echo "=== 2. Armature (Armature + Joint + JointTransform) ==="
cp -v "$SRC"/api/model/Armature.java "$DST/armature/"
cp -v "$SRC"/api/animation/Joint.java "$DST/armature/"
cp -v "$SRC"/api/animation/JointTransform.java "$DST/armature/"
echo ""
echo "=== 3. Animation core + LivingMotion + ServerAnimator ==="
for f in Animator AnimationPlayer AnimationClip AnimationManager AnimationVariables \
SynchedAnimationVariableKey SynchedAnimationVariableKeys Keyframe Pose TransformSheet \
LivingMotion LivingMotions ServerAnimator; do
cp -v "$SRC/api/animation/$f.java" "$DST/anim/" 2>/dev/null || echo " (skip : $f.java non trouvé)"
done
cp -v "$SRC"/api/animation/property/*.java "$DST/anim/property/" 2>/dev/null
echo ""
echo "=== 4. Animation types (filtrés + stubs combat pour JsonAssetLoader) ==="
for f in DynamicAnimation StaticAnimation MovementAnimation LinkAnimation \
ConcurrentLinkAnimation LayerOffAnimation EntityState \
ActionAnimation AttackAnimation MainFrameAnimation; do
# ActionAnimation/AttackAnimation/MainFrameAnimation seront simplifiés
# manuellement en stubs (retirer le combat, garder signatures).
cp -v "$SRC/api/animation/types/$f.java" "$DST/anim/types/" 2>/dev/null || echo " (skip : $f.java non trouvé)"
done
echo ""
echo "=== 5. Animation client ==="
cp -v "$SRC"/api/client/animation/*.java "$DST/anim/client/" 2>/dev/null
cp -v "$SRC"/api/client/animation/property/*.java "$DST/anim/client/property/" 2>/dev/null
# TrailInfo hors scope
rm -f "$DST/anim/client/property/TrailInfo.java"
echo ""
echo "=== 6. Mesh ==="
cp -v "$SRC"/api/client/model/*.java "$DST/mesh/" 2>/dev/null
# Retirer ItemSkinsReloadListener (cosmetics combat)
rm -f "$DST/mesh/ItemSkinsReloadListener.java"
echo ""
echo "=== 7. Cloth (absorbé Phase 0 — StaticMesh en dépend) ==="
cp -v "$SRC"/api/client/physics/AbstractSimulator.java "$DST/cloth/" 2>/dev/null
cp -v "$SRC"/api/client/physics/cloth/*.java "$DST/cloth/" 2>/dev/null
echo ""
echo "=== 8. Asset loader ==="
cp -v "$SRC"/api/asset/*.java "$DST/asset/" 2>/dev/null
echo ""
echo "=== 9. Forge events ==="
for f in PatchedRenderersEvent PrepareModelEvent RegisterResourceLayersEvent; do
cp -v "$SRC/api/client/forgeevent/$f.java" "$DST/event/" 2>/dev/null || echo " (skip : $f.java non trouvé)"
done
echo ""
echo "=== 10. RenderTypes ==="
cp -v "$SRC"/client/renderer/EpicFightRenderTypes.java "$DST/render/TiedUpRenderTypes.java" 2>/dev/null
echo " NOTE: RenderEngine.Events à extraire manuellement dans render/TiedUpRenderEngine.java"
echo " NOTE: TiedUpRigConstants.java à créer manuellement (factory ANIMATOR_PROVIDER + isPhysicalClient)"
echo ""
echo "=== 11. ComputeShader stubs (à créer manuellement, no-op) ==="
echo " NOTE: créer render/compute/ComputeShaderSetup.java et ComputeShaderProvider.java (stubs vides)"
echo ""
echo "=== 12. Transitives oubliées (découvertes par review) ==="
cp -v "$SRC"/api/utils/ParseUtil.java "$DST/util/" 2>/dev/null
cp -v "$SRC"/api/utils/datastruct/*.java "$DST/util/datastruct/" 2>/dev/null
cp -v "$SRC"/api/exception/*.java "$DST/exception/" 2>/dev/null
cp -v "$SRC"/model/armature/HumanoidArmature.java "$DST/armature/" 2>/dev/null
cp -v "$SRC"/model/armature/types/HumanLikeArmature.java "$DST/armature/types/" 2>/dev/null
cp -v "$SRC"/client/mesh/HumanoidMesh.java "$DST/mesh/" 2>/dev/null
echo ""
echo "=== 13. ClientPlayerPatch + LocalPlayerPatch (typo upstream 'capabilites') ==="
cp -v "$SRC"/client/world/capabilites/entitypatch/player/AbstractClientPlayerPatch.java "$DST/patch/ClientPlayerPatch.java" 2>/dev/null
cp -v "$SRC"/client/world/capabilites/entitypatch/player/LocalPlayerPatch.java "$DST/patch/" 2>/dev/null
echo ""
echo "=== 14. Rewrite imports ==="
bash scripts/rig-rewrite-imports.sh "$DST"
echo ""
echo "=== 15. License headers ==="
bash scripts/rig-headers.sh "$DST"
echo ""
echo "--- Phase 0 extraction done ---"
echo ""
echo "Fichiers copiés :"
find "$DST" -type f -name "*.java" | wc -l
echo "LOC totales :"
find "$DST" -type f -name "*.java" -exec cat {} + | wc -l
echo ""
echo "Next steps (manuel, cf. EXTRACTION.md §9) :"
echo " 1. Fixer compile errors (strip combat from types, stub refs EpicFightMod/ClientConfig/ClientEngine/SkillManager)"
echo " 2. Strip valeurs combat de LivingMotion/LivingMotions enum, ajouter valeurs TiedUp"
echo " 3. Extraire RenderEngine.Events → render/TiedUpRenderEngine.java"
echo " 4. Créer ComputeShader stubs (render/compute/ComputeShaderSetup.java + ComputeShaderProvider.java no-op)"
echo " 5. Adapter TiedUpCapabilities.java depuis EpicFightCapabilities.java (retirer combat caps)"
echo " 6. Écrire TiedUpCapabilityEvents.java from scratch (~50L : RegisterCapabilitiesEvent + AttachCapabilitiesEvent)"
echo " 7. Fork mixins (MixinEntity, MixinLivingEntity, MixinLivingEntityRenderer — @Invoker only pour renderer)"
echo " 8. Simplifier LivingEntityPatch.java (1213L → ~400L, strip combat)"
echo " 9. Créer TiedUpRigConstants.java (factory ANIMATOR_PROVIDER)"
echo ""
echo "Budget total post-script : 2 à 3 semaines pour vert-compile."

38
scripts/rig-headers.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# rig-headers.sh
# Ajoute un header attribution Epic Fight + GPLv3 à chaque fichier .java
# forké dans v3/rig qui n'en a pas déjà un.
set -u
TARGET="${1:-src/main/java/com/tiedup/remake/rig}"
if [ ! -d "$TARGET" ]; then
echo "ERROR: target dir not found: $TARGET"
exit 1
fi
HEADER='/*
* Derived from Epic Fight (https://github.com/Epic-Fight/epicfight)
* by the Epic Fight Team, licensed under GPLv3.
* Modifications © 2026 TiedUp! Remake Contributors, distributed under GPLv3.
*/
'
count=0
skipped=0
find "$TARGET" -type f -name "*.java" | while read f; do
if head -5 "$f" | grep -q "Derived from Epic Fight"; then
skipped=$((skipped + 1))
else
tmp=$(mktemp)
printf '%s' "$HEADER" > "$tmp"
cat "$f" >> "$tmp"
mv "$tmp" "$f"
count=$((count + 1))
fi
done
echo "Headers injected in files (check count via grep)."
echo "Run: grep -l 'Derived from Epic Fight' $TARGET -r | wc -l"

75
scripts/rig-rewrite-imports.sh Executable file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# rig-rewrite-imports.sh
# Renomme les imports yesman.epicfight.* vers com.tiedup.remake.rig.*
# dans tous les fichiers Java fraîchement copiés dans v3/rig.
#
# IMPORTANT : ordre du plus spécifique au plus général.
# Si on fait api.animation avant api.client.animation, la première rule
# mange la seconde. Chaque règle utilise un pattern qui matche exactement
# le chemin complet jusqu'au séparateur suivant.
#
# Portabilité : sed -i non-portable BSD (macOS) — utiliser "sed -i.bak"
# si besoin support Mac.
set -u
TARGET="${1:-src/main/java/com/tiedup/remake/rig}"
if [ ! -d "$TARGET" ]; then
echo "ERROR: target dir not found: $TARGET"
exit 1
fi
echo "Rewriting imports in $TARGET..."
find "$TARGET" -type f -name "*.java" -exec sed -i \
-e 's|yesman\.epicfight\.api\.utils\.math|com.tiedup.remake.rig.math|g' \
-e 's|yesman\.epicfight\.api\.utils\.datastruct|com.tiedup.remake.rig.util.datastruct|g' \
-e 's|yesman\.epicfight\.api\.utils\.ParseUtil|com.tiedup.remake.rig.util.ParseUtil|g' \
-e 's|yesman\.epicfight\.api\.utils|com.tiedup.remake.rig.util|g' \
-e 's|yesman\.epicfight\.api\.exception|com.tiedup.remake.rig.exception|g' \
-e 's|yesman\.epicfight\.api\.forgeevent|com.tiedup.remake.rig.event|g' \
-e 's|yesman\.epicfight\.api\.model\.Armature|com.tiedup.remake.rig.armature.Armature|g' \
-e 's|yesman\.epicfight\.api\.animation\.Joint|com.tiedup.remake.rig.armature.Joint|g' \
-e 's|yesman\.epicfight\.api\.animation\.JointTransform|com.tiedup.remake.rig.armature.JointTransform|g' \
-e 's|yesman\.epicfight\.api\.animation\.types\.datapack|com.tiedup.remake.rig.anim.types.datapack|g' \
-e 's|yesman\.epicfight\.api\.animation\.types\.grappling|com.tiedup.remake.rig.anim.types.grappling|g' \
-e 's|yesman\.epicfight\.api\.animation\.types\.procedural|com.tiedup.remake.rig.anim.types.procedural|g' \
-e 's|yesman\.epicfight\.api\.animation\.types|com.tiedup.remake.rig.anim.types|g' \
-e 's|yesman\.epicfight\.api\.animation\.property|com.tiedup.remake.rig.anim.property|g' \
-e 's|yesman\.epicfight\.api\.animation|com.tiedup.remake.rig.anim|g' \
-e 's|yesman\.epicfight\.api\.client\.animation\.property|com.tiedup.remake.rig.anim.client.property|g' \
-e 's|yesman\.epicfight\.api\.client\.animation|com.tiedup.remake.rig.anim.client|g' \
-e 's|yesman\.epicfight\.api\.client\.model\.transformer|com.tiedup.remake.rig.mesh.transformer|g' \
-e 's|yesman\.epicfight\.api\.client\.model|com.tiedup.remake.rig.mesh|g' \
-e 's|yesman\.epicfight\.api\.client\.physics\.cloth|com.tiedup.remake.rig.cloth|g' \
-e 's|yesman\.epicfight\.api\.client\.physics|com.tiedup.remake.rig.cloth|g' \
-e 's|yesman\.epicfight\.api\.client\.forgeevent|com.tiedup.remake.rig.event|g' \
-e 's|yesman\.epicfight\.api\.asset|com.tiedup.remake.rig.asset|g' \
-e 's|yesman\.epicfight\.model\.armature\.types|com.tiedup.remake.rig.armature.types|g' \
-e 's|yesman\.epicfight\.model\.armature|com.tiedup.remake.rig.armature|g' \
-e 's|yesman\.epicfight\.world\.capabilities\.provider|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.world\.capabilities\.entitypatch\.player|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.world\.capabilities\.entitypatch|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.world\.capabilities\.EpicFightCapabilities|com.tiedup.remake.rig.patch.TiedUpCapabilities|g' \
-e 's|yesman\.epicfight\.world\.capabilities|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.client\.world\.capabilites\.entitypatch\.player|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.client\.world\.capabilites\.entitypatch|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.client\.world\.capabilites|com.tiedup.remake.rig.patch|g' \
-e 's|yesman\.epicfight\.client\.renderer\.patched\.entity|com.tiedup.remake.rig.render|g' \
-e 's|yesman\.epicfight\.client\.renderer\.patched|com.tiedup.remake.rig.render|g' \
-e 's|yesman\.epicfight\.client\.renderer\.EpicFightRenderTypes|com.tiedup.remake.rig.render.TiedUpRenderTypes|g' \
-e 's|yesman\.epicfight\.client\.mesh|com.tiedup.remake.rig.mesh|g' \
{} +
echo ""
echo "Verifying no yesman.epicfight references remain..."
remaining=$(grep -r "yesman\.epicfight" "$TARGET" 2>/dev/null | wc -l)
if [ "$remaining" -eq 0 ]; then
echo "OK - all imports rewritten."
else
echo "WARN - $remaining residual refs found:"
grep -rn "yesman\.epicfight" "$TARGET" | head -20
echo "..."
echo "(affichage limité aux 20 premiers)"
fi