WIP: create TiedUpRigConstants, replace EpicFightMod/SharedConstants refs
- Nouveau TiedUpRigConstants.java : centralise MODID/LOGGER/identifier/prefix, constantes runtime (IS_DEV_ENV, A_TICK, GENERAL_ANIMATION_TRANSITION_TIME, MAX_JOINTS), factory ANIMATOR_PROVIDER (client/server split) + helpers stacktraceIfDevSide/logAndStacktraceIfDevSide. - sed global : EpicFightMod.* → TiedUpRigConstants.* - sed global : EpicFightSharedConstants.* → TiedUpRigConstants.* - sed global : EpicFightRenderTypes → TiedUpRenderTypes (class rename upstream) - Fix package declarations : Armature.java + TiedUpRenderTypes.java Résidus yesman.epicfight : 115 → 86 (-29) Reste : gameasset/physics/network/world/config/skill (combat deps à strip) + combat mode refs dans patch/LocalPlayerPatch + ClientPlayerPatch (Phase 2).
This commit is contained in:
114
src/main/java/com/tiedup/remake/rig/TiedUpRigConstants.java
Normal file
114
src/main/java/com/tiedup/remake/rig/TiedUpRigConstants.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.tiedup.remake.rig;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.tiedup.remake.core.TiedUpMod;
|
||||
import com.tiedup.remake.rig.anim.Animator;
|
||||
import com.tiedup.remake.rig.anim.ServerAnimator;
|
||||
import com.tiedup.remake.rig.patch.LivingEntityPatch;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Remplace {@code yesman.epicfight.main.EpicFightMod} + {@code EpicFightSharedConstants}
|
||||
* du fork upstream. Expose les singletons nécessaires au runtime RIG :
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link #MODID} — ID du mod TiedUp (tiedup)</li>
|
||||
* <li>{@link #LOGGER} — logger commun RIG</li>
|
||||
* <li>{@link #identifier(String)} — helper ResourceLocation</li>
|
||||
* <li>{@link #ANIMATOR_PROVIDER} — factory client/server split pour instancier l'Animator</li>
|
||||
* <li>{@link #isPhysicalClient()} — détection side runtime</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Pattern lazy method-ref : {@code ClientAnimator::getAnimator} n'est chargé
|
||||
* que si {@link #isPhysicalClient()} est true. Sur serveur dedié, la classe
|
||||
* client n'est jamais référencée, donc jamais chargée → pas de
|
||||
* {@code NoClassDefFoundError}.</p>
|
||||
*/
|
||||
public final class TiedUpRigConstants {
|
||||
|
||||
public static final String MODID = TiedUpMod.MOD_ID;
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
/** Détection dev env (Gradle runClient) — utilisé pour les logs debug EF. */
|
||||
public static final boolean IS_DEV_ENV = !FMLEnvironment.production;
|
||||
|
||||
/** Durée d'un tick MC en secondes (20 TPS). */
|
||||
public static final float A_TICK = 1.0F / 20.0F;
|
||||
|
||||
/** Durée de transition inter-animation par défaut (en ticks). */
|
||||
public static final int GENERAL_ANIMATION_TRANSITION_TIME = 6;
|
||||
|
||||
/** Nombre max de joints supportés par une armature (limite matrice pool). */
|
||||
public static final int MAX_JOINTS = 128;
|
||||
|
||||
/**
|
||||
* Factory lazy : crée un Animator approprié au side runtime courant.
|
||||
* Client → ClientAnimator (à créer Phase 2)
|
||||
* Server → ServerAnimator (forké verbatim EF)
|
||||
*
|
||||
* <p><b>Note Phase 0</b> : ClientAnimator n'est pas encore forké/créé
|
||||
* (Phase 2). Tant que c'est le cas, on retourne ServerAnimator des deux
|
||||
* côtés. Remplacer par {@code ClientAnimator::getAnimator} quand
|
||||
* disponible.</p>
|
||||
*/
|
||||
public static final Function<LivingEntityPatch<?>, Animator> ANIMATOR_PROVIDER =
|
||||
isPhysicalClient()
|
||||
? ServerAnimator::getAnimator // TODO Phase 2 : ClientAnimator::getAnimator
|
||||
: ServerAnimator::getAnimator;
|
||||
|
||||
private TiedUpRigConstants() {}
|
||||
|
||||
public static ResourceLocation identifier(String path) {
|
||||
return ResourceLocation.fromNamespaceAndPath(MODID, path);
|
||||
}
|
||||
|
||||
/** Alias d'{@link #identifier(String)} — équivalent TiedUpRigConstants.prefix upstream. */
|
||||
public static ResourceLocation prefix(String path) {
|
||||
return identifier(path);
|
||||
}
|
||||
|
||||
public static boolean isPhysicalClient() {
|
||||
return FMLEnvironment.dist == Dist.CLIENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* En dev env : log un message + throw l'exception fournie.
|
||||
* En prod : log WARN seulement. Équivalent EF {@code TiedUpRigConstants.stacktraceIfDevSide}.
|
||||
*/
|
||||
public static <E extends RuntimeException> void stacktraceIfDevSide(
|
||||
String message,
|
||||
java.util.function.Function<String, E> exceptionFactory
|
||||
) {
|
||||
if (IS_DEV_ENV) {
|
||||
throw exceptionFactory.apply(message);
|
||||
} else {
|
||||
LOGGER.warn(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* En dev env : log via le consumer + throw l'exception.
|
||||
* En prod : log seulement. Équivalent EF {@code TiedUpRigConstants.logAndStacktraceIfDevSide}.
|
||||
*/
|
||||
public static <E extends RuntimeException> void logAndStacktraceIfDevSide(
|
||||
java.util.function.BiConsumer<Logger, String> logAction,
|
||||
String message,
|
||||
java.util.function.Function<String, E> exceptionFactory
|
||||
) {
|
||||
logAction.accept(LOGGER, message);
|
||||
if (IS_DEV_ENV) {
|
||||
throw exceptionFactory.apply(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user