Phase 0 compile progress (70% reduction). Core data model compile :
Refs yesman.epicfight strippées (hors 4 javadocs) :
- AnimationProperty : combat properties EXTRA_DAMAGE, STUN_TYPE, PARTICLE
- ClientAnimator : playAnimationAt(..., AnimatorControlPacket.Layer, Priority)
- ClothSimulator : OBBCollider -> fork geometry-only dans rig/collider/
- InstantiateInvoker : Collider, ColliderPreset, Armatures, DatapackEditScreen
- MoveCoordFunctions : GrapplingAttackAnimation
- SimulationTypes : InverseKinematicsSimulator (path rewrite)
Stubs patch/ :
- EntityPatch<T> abstract — getOriginal, isLogicalClient, getMatrix, getAngleTo
- LivingEntityPatch<T> abstract — getAnimator, getArmature, getTarget, getYRot*
- MobPatch<T extends Mob> — instanceof check only
- item/CapabilityItem — type marker
Forks utilitaires :
- rig/collider/OBBCollider — geometry only (strip Entity collision, drawInternal)
- anim/types/StateSpectrum — identique EF, imports rewrités
- util/PacketBufferCodec — StreamCodec backport
- util/TimePairList — identique EF
- util/HitEntityList — shell pour Priority enum uniquement
- util/ExtendableEnum + ExtendableEnumManager — register/assign enum
Fix package declarations :
- armature/Joint.java + JointTransform.java : package rig.anim -> rig.armature
- Imports JointTransform ajoutés dans anim/{Pose,Keyframe,TransformSheet}
Residu 135 errors = cluster rendering (Phase 2) :
- render/TiedUpRenderTypes (17) : CompositeState package-private MC
- event/PatchedRenderersEvent (11) : missing PatchedEntityRenderer
- mesh/SkinnedMesh (13) : VanillaMeshPartDefinition, compute shader fields
- asset/JsonAssetLoader (6), anim/LivingMotion (5)
117 lines
3.9 KiB
Java
117 lines
3.9 KiB
Java
/*
|
|
* 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.util;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.NoSuchElementException;
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
import com.tiedup.remake.rig.TiedUpRigConstants;
|
|
|
|
public class ExtendableEnumManager<T extends ExtendableEnum> {
|
|
private final Int2ObjectMap<T> enumMapByOrdinal = new Int2ObjectLinkedOpenHashMap<>();
|
|
private final Map<String, T> enumMapByName = Maps.newLinkedHashMap();
|
|
private final Map<String, Class<?>> enums = Maps.newConcurrentMap();
|
|
private final String enumName;
|
|
private int lastOrdinal = 0;
|
|
|
|
public ExtendableEnumManager(String enumName) {
|
|
this.enumName = enumName;
|
|
}
|
|
|
|
public void registerEnumCls(String modid, Class<? extends ExtendableEnum> cls) {
|
|
if (this.enums.containsKey(modid)) {
|
|
TiedUpRigConstants.LOGGER.error(modid + " is already registered in " + this.enumName);
|
|
}
|
|
TiedUpRigConstants.LOGGER.debug("Registered Extendable Enum " + cls + " in " + this.enumName);
|
|
this.enums.put(modid, cls);
|
|
}
|
|
|
|
public void loadEnum() {
|
|
List<String> orderByModid = new ArrayList<>(this.enums.keySet());
|
|
Collections.sort(orderByModid);
|
|
Class<?> cls = null;
|
|
|
|
try {
|
|
for (String modid : orderByModid) {
|
|
cls = this.enums.get(modid);
|
|
Method m = cls.getMethod("values");
|
|
m.invoke(null);
|
|
TiedUpRigConstants.LOGGER.debug("Loaded enums in " + cls);
|
|
}
|
|
} catch (ClassCastException e) {
|
|
TiedUpRigConstants.LOGGER.error(cls.getCanonicalName() + " is not an ExtendableEnum!");
|
|
e.printStackTrace();
|
|
} catch (NoSuchMethodException e) {
|
|
TiedUpRigConstants.LOGGER.error(cls.getCanonicalName() + " is not an Enum class!");
|
|
e.printStackTrace();
|
|
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
|
TiedUpRigConstants.LOGGER.warn("Error while loading extendable enum " + cls.getCanonicalName());
|
|
e.printStackTrace();
|
|
}
|
|
|
|
TiedUpRigConstants.LOGGER.debug("All enums are loaded: " + this.enumName + " " + this.enumMapByName.values());
|
|
}
|
|
|
|
public int assign(T value) {
|
|
int lastOrdinal = this.lastOrdinal;
|
|
String enumName = ParseUtil.toLowerCase(value.toString());
|
|
|
|
if (this.enumMapByName.containsKey(enumName)) {
|
|
throw new IllegalArgumentException("Enum name " + enumName + " already exists in " + this.enumName);
|
|
}
|
|
|
|
this.enumMapByOrdinal.put(lastOrdinal, value);
|
|
this.enumMapByName.put(enumName, value);
|
|
++this.lastOrdinal;
|
|
|
|
return lastOrdinal;
|
|
}
|
|
|
|
public T getOrThrow(int id) throws NoSuchElementException {
|
|
if (!this.enumMapByOrdinal.containsKey(id)) {
|
|
throw new NoSuchElementException("Enum id " + id + " does not exist in " + this.enumName);
|
|
}
|
|
return this.enumMapByOrdinal.get(id);
|
|
}
|
|
|
|
public T getOrThrow(String name) throws NoSuchElementException {
|
|
String key = ParseUtil.toLowerCase(name);
|
|
if (!this.enumMapByName.containsKey(key)) {
|
|
throw new NoSuchElementException("Enum name " + key + " does not exist in " + this.enumName);
|
|
}
|
|
return this.enumMapByName.get(key);
|
|
}
|
|
|
|
public T get(int id) {
|
|
return this.enumMapByOrdinal.get(id);
|
|
}
|
|
|
|
public T get(String name) {
|
|
return this.enumMapByName.get(ParseUtil.toLowerCase(name));
|
|
}
|
|
|
|
public Collection<T> universalValues() {
|
|
return this.enumMapByOrdinal.values();
|
|
}
|
|
|
|
public String toTranslated(ExtendableEnum e) {
|
|
return Component.translatable(TiedUpRigConstants.MODID + "." + this.enumName + "." + ParseUtil.toLowerCase(e.toString())).getString();
|
|
}
|
|
}
|