Remove internal phase comments and format code

Strip all Phase references, TODO/FUTURE roadmap notes, and internal
planning comments from the codebase. Run Prettier for consistent
formatting across all Java files.
This commit is contained in:
NotEvil
2026-04-12 01:24:49 +02:00
parent 73d70e212d
commit a71093ba9c
482 changed files with 8500 additions and 5155 deletions

View File

@@ -17,7 +17,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
*/
@OnlyIn(Dist.CLIENT)
public enum AnimationContext {
STAND_IDLE("stand_idle", false),
STAND_WALK("stand_walk", false),
STAND_SNEAK("stand_sneak", false),

View File

@@ -50,15 +50,21 @@ public final class AnimationContextResolver {
* @param activeStyle the active movement style from client state, or null
* @return the resolved animation context, never null
*/
public static AnimationContext resolve(Player player, @Nullable PlayerBindState state,
@Nullable MovementStyle activeStyle) {
public static AnimationContext resolve(
Player player,
@Nullable PlayerBindState state,
@Nullable MovementStyle activeStyle
) {
boolean sitting = PetBedClientState.get(player.getUUID()) != 0;
boolean struggling = state != null && state.isStruggling();
boolean sneaking = player.isCrouching();
boolean moving = player.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6;
boolean moving =
player.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6;
if (sitting) {
return struggling ? AnimationContext.SIT_STRUGGLE : AnimationContext.SIT_IDLE;
return struggling
? AnimationContext.SIT_STRUGGLE
: AnimationContext.SIT_IDLE;
}
if (struggling) {
return AnimationContext.STAND_STRUGGLE;
@@ -78,12 +84,23 @@ public final class AnimationContextResolver {
/**
* Map a movement style + moving flag to the appropriate AnimationContext.
*/
private static AnimationContext resolveStyleContext(MovementStyle style, boolean moving) {
private static AnimationContext resolveStyleContext(
MovementStyle style,
boolean moving
) {
return switch (style) {
case SHUFFLE -> moving ? AnimationContext.SHUFFLE_WALK : AnimationContext.SHUFFLE_IDLE;
case HOP -> moving ? AnimationContext.HOP_WALK : AnimationContext.HOP_IDLE;
case WADDLE -> moving ? AnimationContext.WADDLE_WALK : AnimationContext.WADDLE_IDLE;
case CRAWL -> moving ? AnimationContext.CRAWL_MOVE : AnimationContext.CRAWL_IDLE;
case SHUFFLE -> moving
? AnimationContext.SHUFFLE_WALK
: AnimationContext.SHUFFLE_IDLE;
case HOP -> moving
? AnimationContext.HOP_WALK
: AnimationContext.HOP_IDLE;
case WADDLE -> moving
? AnimationContext.WADDLE_WALK
: AnimationContext.WADDLE_IDLE;
case CRAWL -> moving
? AnimationContext.CRAWL_MOVE
: AnimationContext.CRAWL_IDLE;
};
}
@@ -99,13 +116,18 @@ public final class AnimationContextResolver {
boolean sitting = entity.isSitting();
boolean kneeling = entity.isKneeling();
boolean struggling = entity.isStruggling();
boolean moving = entity.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6;
boolean moving =
entity.getDeltaMovement().horizontalDistanceSqr() > 1.0E-6;
if (sitting) {
return struggling ? AnimationContext.SIT_STRUGGLE : AnimationContext.SIT_IDLE;
return struggling
? AnimationContext.SIT_STRUGGLE
: AnimationContext.SIT_IDLE;
}
if (kneeling) {
return struggling ? AnimationContext.KNEEL_STRUGGLE : AnimationContext.KNEEL_IDLE;
return struggling
? AnimationContext.KNEEL_STRUGGLE
: AnimationContext.KNEEL_IDLE;
}
if (struggling) {
return AnimationContext.STAND_STRUGGLE;

View File

@@ -6,10 +6,10 @@ import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
/**
@@ -42,13 +42,15 @@ public final class ContextAnimationFactory {
* Cache keyed by "contextSuffix|ownedPartsHashCode".
* Null values are stored as sentinels for missing animations to avoid repeated lookups.
*/
private static final Map<String, KeyframeAnimation> CACHE = new ConcurrentHashMap<>();
private static final Map<String, KeyframeAnimation> CACHE =
new ConcurrentHashMap<>();
/**
* Sentinel set used to track cache keys where the base animation was not found,
* so we don't log the same warning repeatedly.
*/
private static final Set<String> MISSING_WARNED = ConcurrentHashMap.newKeySet();
private static final Set<String> MISSING_WARNED =
ConcurrentHashMap.newKeySet();
private ContextAnimationFactory() {}
@@ -65,8 +67,14 @@ public final class ContextAnimationFactory {
* @return the context animation with disabled parts suppressed, or null if not found
*/
@Nullable
public static KeyframeAnimation create(AnimationContext context, Set<String> disabledParts) {
String cacheKey = context.getAnimationSuffix() + "|" + String.join(",", new java.util.TreeSet<>(disabledParts));
public static KeyframeAnimation create(
AnimationContext context,
Set<String> disabledParts
) {
String cacheKey =
context.getAnimationSuffix() +
"|" +
String.join(",", new java.util.TreeSet<>(disabledParts));
// computeIfAbsent cannot store null values, so we handle the missing case
// by checking the MISSING_WARNED set to avoid redundant work.
KeyframeAnimation cached = CACHE.get(cacheKey);
@@ -77,7 +85,10 @@ public final class ContextAnimationFactory {
return null;
}
KeyframeAnimation result = buildContextAnimation(context, disabledParts);
KeyframeAnimation result = buildContextAnimation(
context,
disabledParts
);
if (result != null) {
CACHE.put(cacheKey, result);
} else {
@@ -100,8 +111,10 @@ public final class ContextAnimationFactory {
* </ol>
*/
@Nullable
private static KeyframeAnimation buildContextAnimation(AnimationContext context,
Set<String> disabledParts) {
private static KeyframeAnimation buildContextAnimation(
AnimationContext context,
Set<String> disabledParts
) {
String suffix = context.getAnimationSuffix();
// Priority 1: GLB-based context animation from ContextGlbRegistry
@@ -110,13 +123,17 @@ public final class ContextAnimationFactory {
// Priority 2: JSON-based context animation from PlayerAnimationRegistry
if (baseAnim == null) {
ResourceLocation animId = ResourceLocation.fromNamespaceAndPath(
NAMESPACE, "context_" + suffix
NAMESPACE,
"context_" + suffix
);
baseAnim = PlayerAnimationRegistry.getAnimation(animId);
}
if (baseAnim == null) {
LOGGER.warn("[V2Animation] Context animation not found for suffix: {}", suffix);
LOGGER.warn(
"[V2Animation] Context animation not found for suffix: {}",
suffix
);
return null;
}
@@ -140,8 +157,10 @@ public final class ContextAnimationFactory {
* <p>Unknown part names are silently ignored -- this can happen if the disabled parts set
* includes future bone names not present in the current context animation.</p>
*/
private static void disableParts(KeyframeAnimation.AnimationBuilder builder,
Set<String> disabledParts) {
private static void disableParts(
KeyframeAnimation.AnimationBuilder builder,
Set<String> disabledParts
) {
for (String partName : disabledParts) {
KeyframeAnimation.StateCollection part = builder.getPart(partName);
if (part != null) {

View File

@@ -8,7 +8,6 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
@@ -16,6 +15,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
/**
* Registry for context animations loaded from GLB files.
@@ -70,10 +70,15 @@ public final class ContextGlbRegistry {
public static void reload(ResourceManager resourceManager) {
Map<String, KeyframeAnimation> newRegistry = new HashMap<>();
Map<ResourceLocation, Resource> resources = resourceManager.listResources(
DIRECTORY, loc -> loc.getPath().endsWith(".glb"));
Map<ResourceLocation, Resource> resources =
resourceManager.listResources(DIRECTORY, loc ->
loc.getPath().endsWith(".glb")
);
for (Map.Entry<ResourceLocation, Resource> entry : resources.entrySet()) {
for (Map.Entry<
ResourceLocation,
Resource
> entry : resources.entrySet()) {
ResourceLocation loc = entry.getKey();
Resource resource = entry.getValue();
@@ -89,15 +94,26 @@ public final class ContextGlbRegistry {
KeyframeAnimation anim = GltfPoseConverter.convert(data);
newRegistry.put(suffix, anim);
LOGGER.info("[GltfPipeline] Loaded context GLB: '{}' -> suffix '{}'", loc, suffix);
LOGGER.info(
"[GltfPipeline] Loaded context GLB: '{}' -> suffix '{}'",
loc,
suffix
);
} catch (Exception e) {
LOGGER.error("[GltfPipeline] Failed to load context GLB: {}", loc, e);
LOGGER.error(
"[GltfPipeline] Failed to load context GLB: {}",
loc,
e
);
}
}
// Atomic swap: render thread never sees a partially populated registry
REGISTRY = Collections.unmodifiableMap(newRegistry);
LOGGER.info("[ContextGlb] Loaded {} context GLB animations", newRegistry.size());
LOGGER.info(
"[ContextGlb] Loaded {} context GLB animations",
newRegistry.size()
);
}
/**

View File

@@ -6,10 +6,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import org.jetbrains.annotations.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;
/**
* Resolves which named animation to play from a GLB file based on the current
@@ -42,9 +42,12 @@ public final class GlbAnimationResolver {
* @return parsed GLB data, or null if loading failed
*/
@Nullable
public static GltfData resolveAnimationData(ResourceLocation itemModelLoc,
@Nullable ResourceLocation animationSource) {
ResourceLocation source = animationSource != null ? animationSource : itemModelLoc;
public static GltfData resolveAnimationData(
ResourceLocation itemModelLoc,
@Nullable ResourceLocation animationSource
) {
ResourceLocation source =
animationSource != null ? animationSource : itemModelLoc;
return GltfCache.get(source);
}
@@ -66,8 +69,8 @@ public final class GlbAnimationResolver {
*/
@Nullable
public static String resolve(GltfData data, AnimationContext context) {
String prefix = context.getGlbContextPrefix(); // "Sit", "Kneel", "Sneak", "Walk", ""
String variant = context.getGlbVariant(); // "Idle" or "Struggle"
String prefix = context.getGlbContextPrefix(); // "Sit", "Kneel", "Sneak", "Walk", ""
String variant = context.getGlbVariant(); // "Idle" or "Struggle"
// 1. Exact match: "FullSitIdle" then "SitIdle" (with variants)
String exact = prefix + variant;
@@ -146,6 +149,8 @@ public final class GlbAnimationResolver {
if (candidates.isEmpty()) return null;
if (candidates.size() == 1) return candidates.get(0);
return candidates.get(ThreadLocalRandom.current().nextInt(candidates.size()));
return candidates.get(
ThreadLocalRandom.current().nextInt(candidates.size())
);
}
}

View File

@@ -6,11 +6,11 @@ import com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem;
import com.tiedup.remake.v2.bondage.datadriven.DataDrivenItemDefinition;
import com.tiedup.remake.v2.bondage.datadriven.DataDrivenItemRegistry;
import java.util.*;
import org.jetbrains.annotations.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;
/**
* Maps V2 body regions to PlayerAnimator part names.
@@ -29,7 +29,12 @@ public final class RegionBoneMapper {
/** All PlayerAnimator part names for the player model. */
public static final Set<String> ALL_PARTS = Set.of(
"head", "body", "rightArm", "leftArm", "rightLeg", "leftLeg"
"head",
"body",
"rightArm",
"leftArm",
"rightLeg",
"leftLeg"
);
/**
@@ -46,7 +51,6 @@ public final class RegionBoneMapper {
* the other item takes precedence (the bone goes to {@code otherParts}).</p>
*/
public record BoneOwnership(Set<String> thisParts, Set<String> otherParts) {
/**
* Parts not owned by any item. These are "free" and can be animated
* by the winning item IF the GLB contains keyframes for them.
@@ -84,20 +88,20 @@ public final class RegionBoneMapper {
static {
Map<BodyRegionV2, Set<String>> map = new EnumMap<>(BodyRegionV2.class);
map.put(BodyRegionV2.HEAD, Set.of("head"));
map.put(BodyRegionV2.EYES, Set.of("head"));
map.put(BodyRegionV2.EARS, Set.of("head"));
map.put(BodyRegionV2.MOUTH, Set.of("head"));
map.put(BodyRegionV2.NECK, Set.of());
map.put(BodyRegionV2.TORSO, Set.of("body"));
map.put(BodyRegionV2.ARMS, Set.of("rightArm", "leftArm"));
map.put(BodyRegionV2.HANDS, Set.of("rightArm", "leftArm"));
map.put(BodyRegionV2.HEAD, Set.of("head"));
map.put(BodyRegionV2.EYES, Set.of("head"));
map.put(BodyRegionV2.EARS, Set.of("head"));
map.put(BodyRegionV2.MOUTH, Set.of("head"));
map.put(BodyRegionV2.NECK, Set.of());
map.put(BodyRegionV2.TORSO, Set.of("body"));
map.put(BodyRegionV2.ARMS, Set.of("rightArm", "leftArm"));
map.put(BodyRegionV2.HANDS, Set.of("rightArm", "leftArm"));
map.put(BodyRegionV2.FINGERS, Set.of());
map.put(BodyRegionV2.WAIST, Set.of("body"));
map.put(BodyRegionV2.LEGS, Set.of("rightLeg", "leftLeg"));
map.put(BodyRegionV2.FEET, Set.of("rightLeg", "leftLeg"));
map.put(BodyRegionV2.TAIL, Set.of());
map.put(BodyRegionV2.WINGS, Set.of());
map.put(BodyRegionV2.WAIST, Set.of("body"));
map.put(BodyRegionV2.LEGS, Set.of("rightLeg", "leftLeg"));
map.put(BodyRegionV2.FEET, Set.of("rightLeg", "leftLeg"));
map.put(BodyRegionV2.TAIL, Set.of());
map.put(BodyRegionV2.WINGS, Set.of());
REGION_TO_PARTS = Collections.unmodifiableMap(map);
}
@@ -123,7 +127,9 @@ public final class RegionBoneMapper {
* @param equipped map from representative region to equipped ItemStack
* @return unmodifiable set of owned part name strings
*/
public static Set<String> computeOwnedParts(Map<BodyRegionV2, ItemStack> equipped) {
public static Set<String> computeOwnedParts(
Map<BodyRegionV2, ItemStack> equipped
) {
Set<String> owned = new HashSet<>();
for (Map.Entry<BodyRegionV2, ItemStack> entry : equipped.entrySet()) {
ItemStack stack = entry.getValue();
@@ -151,14 +157,18 @@ public final class RegionBoneMapper {
* @param winningItemStack the ItemStack of the highest-priority V2 item with a GLB model
* @return BoneOwnership describing this item's parts vs other items' parts
*/
public static BoneOwnership computePerItemParts(Map<BodyRegionV2, ItemStack> equipped,
ItemStack winningItemStack) {
public static BoneOwnership computePerItemParts(
Map<BodyRegionV2, ItemStack> equipped,
ItemStack winningItemStack
) {
Set<String> thisParts = new HashSet<>();
Set<String> otherParts = new HashSet<>();
// Track which ItemStacks we've already processed to avoid duplicate work
// (multiple regions can map to the same ItemStack)
Set<ItemStack> processed = Collections.newSetFromMap(new IdentityHashMap<>());
Set<ItemStack> processed = Collections.newSetFromMap(
new IdentityHashMap<>()
);
for (Map.Entry<BodyRegionV2, ItemStack> entry : equipped.entrySet()) {
ItemStack stack = entry.getValue();
@@ -199,8 +209,11 @@ public final class RegionBoneMapper {
* @param winningItem the actual ItemStack reference (for identity comparison in
* {@link #computePerItemParts})
*/
public record GlbModelResult(ResourceLocation modelLoc, @Nullable ResourceLocation animSource,
ItemStack winningItem) {}
public record GlbModelResult(
ResourceLocation modelLoc,
@Nullable ResourceLocation animSource,
ItemStack winningItem
) {}
/**
* Animation info for a single equipped V2 item.
@@ -213,9 +226,13 @@ public final class RegionBoneMapper {
* @param animationBones per-animation bone whitelist from the data-driven definition.
* Empty map for hardcoded items (no filtering applied).
*/
public record V2ItemAnimInfo(ResourceLocation modelLoc, @Nullable ResourceLocation animSource,
Set<String> ownedParts, int posePriority,
Map<String, Set<String>> animationBones) {}
public record V2ItemAnimInfo(
ResourceLocation modelLoc,
@Nullable ResourceLocation animSource,
Set<String> ownedParts,
int posePriority,
Map<String, Set<String>> animationBones
) {}
/**
* Find the highest-priority V2 item with a GLB model in the equipped map.
@@ -230,7 +247,9 @@ public final class RegionBoneMapper {
* @return the winning item's model info, or null if no V2 item has a GLB model (V1 fallback)
*/
@Nullable
public static GlbModelResult resolveWinningItem(Map<BodyRegionV2, ItemStack> equipped) {
public static GlbModelResult resolveWinningItem(
Map<BodyRegionV2, ItemStack> equipped
) {
ItemStack bestStack = null;
ResourceLocation bestModel = null;
int bestPriority = Integer.MIN_VALUE;
@@ -238,7 +257,10 @@ public final class RegionBoneMapper {
ItemStack stack = entry.getValue();
if (stack.getItem() instanceof IV2BondageItem v2Item) {
ResourceLocation model = v2Item.getModelLocation(stack);
if (model != null && v2Item.getPosePriority(stack) > bestPriority) {
if (
model != null &&
v2Item.getPosePriority(stack) > bestPriority
) {
bestPriority = v2Item.getPosePriority(stack);
bestModel = model;
bestStack = stack;
@@ -252,7 +274,9 @@ public final class RegionBoneMapper {
// (the model's own animations are used).
ResourceLocation animSource = null;
if (bestStack.getItem() instanceof DataDrivenBondageItem) {
DataDrivenItemDefinition def = DataDrivenItemRegistry.get(bestStack);
DataDrivenItemDefinition def = DataDrivenItemRegistry.get(
bestStack
);
if (def != null) {
animSource = def.animationSource();
}
@@ -273,13 +297,23 @@ public final class RegionBoneMapper {
* @return list of V2ItemAnimInfo, sorted by priority descending. Empty if no V2 items.
* The first element (if any) is the free-bone donor.
*/
public static List<V2ItemAnimInfo> resolveAllV2Items(Map<BodyRegionV2, ItemStack> equipped) {
record ItemEntry(ItemStack stack, IV2BondageItem v2Item, ResourceLocation model,
@Nullable ResourceLocation animSource, Set<String> rawParts, int priority,
Map<String, Set<String>> animationBones) {}
public static List<V2ItemAnimInfo> resolveAllV2Items(
Map<BodyRegionV2, ItemStack> equipped
) {
record ItemEntry(
ItemStack stack,
IV2BondageItem v2Item,
ResourceLocation model,
@Nullable ResourceLocation animSource,
Set<String> rawParts,
int priority,
Map<String, Set<String>> animationBones
) {}
List<ItemEntry> entries = new ArrayList<>();
Set<ItemStack> seen = Collections.newSetFromMap(new IdentityHashMap<>());
Set<ItemStack> seen = Collections.newSetFromMap(
new IdentityHashMap<>()
);
for (Map.Entry<BodyRegionV2, ItemStack> entry : equipped.entrySet()) {
ItemStack stack = entry.getValue();
@@ -299,15 +333,26 @@ public final class RegionBoneMapper {
ResourceLocation animSource = null;
Map<String, Set<String>> animBones = Map.of();
if (stack.getItem() instanceof DataDrivenBondageItem) {
DataDrivenItemDefinition def = DataDrivenItemRegistry.get(stack);
DataDrivenItemDefinition def = DataDrivenItemRegistry.get(
stack
);
if (def != null) {
animSource = def.animationSource();
animBones = def.animationBones();
}
}
entries.add(new ItemEntry(stack, v2Item, model, animSource, rawParts,
v2Item.getPosePriority(stack), animBones));
entries.add(
new ItemEntry(
stack,
v2Item,
model,
animSource,
rawParts,
v2Item.getPosePriority(stack),
animBones
)
);
}
}
@@ -323,8 +368,15 @@ public final class RegionBoneMapper {
ownedParts.removeAll(claimed);
if (ownedParts.isEmpty()) continue;
claimed.addAll(ownedParts);
result.add(new V2ItemAnimInfo(e.model(), e.animSource(),
Collections.unmodifiableSet(ownedParts), e.priority(), e.animationBones()));
result.add(
new V2ItemAnimInfo(
e.model(),
e.animSource(),
Collections.unmodifiableSet(ownedParts),
e.priority(),
e.animationBones()
)
);
}
return Collections.unmodifiableList(result);