feature/d01-component-system #5

Merged
NotEvil merged 20 commits from feature/d01-component-system into develop 2026-04-14 00:54:17 +00:00
2 changed files with 42 additions and 3 deletions
Showing only changes of commit 750be66d80 - Show all commits

View File

@@ -1,6 +1,8 @@
package com.tiedup.remake.v2.bondage.datadriven;
import com.google.gson.JsonObject;
import com.tiedup.remake.v2.BodyRegionV2;
import com.tiedup.remake.v2.bondage.component.ComponentType;
import java.util.Map;
import java.util.Set;
import net.minecraft.resources.ResourceLocation;
@@ -97,5 +99,14 @@ public record DataDrivenItemDefinition(
*
* <p>This field is required in the JSON definition. Never null, never empty.</p>
*/
Map<String, Set<String>> animationBones
) {}
Map<String, Set<String>> animationBones,
/** Raw component configs from JSON, keyed by ComponentType. */
Map<ComponentType, JsonObject> componentConfigs
) {
/** Check whether this definition declares a given component type. */
public boolean hasComponent(ComponentType type) {
return componentConfigs != null && componentConfigs.containsKey(type);
}
}

View File

@@ -5,12 +5,14 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.tiedup.remake.v2.BodyRegionV2;
import com.tiedup.remake.v2.bondage.component.ComponentType;
import com.tiedup.remake.v2.bondage.movement.MovementModifier;
import com.tiedup.remake.v2.bondage.movement.MovementStyle;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -266,6 +268,31 @@ public final class DataDrivenItemParser {
return null;
}
// Optional: components (per-component JSON configs)
Map<ComponentType, JsonObject> componentConfigs =
new EnumMap<>(ComponentType.class);
if (root.has("components")) {
JsonObject componentsObj = root.getAsJsonObject("components");
for (Map.Entry<String, JsonElement> entry :
componentsObj.entrySet()) {
ComponentType compType = ComponentType.fromKey(
entry.getKey()
);
if (compType != null) {
JsonObject config = entry.getValue().isJsonObject()
? entry.getValue().getAsJsonObject()
: new JsonObject();
componentConfigs.put(compType, config);
} else {
LOGGER.warn(
"[DataDrivenItemParser] Unknown component type '{}' in item '{}'",
entry.getKey(),
fileId
);
}
}
}
// Build the item ID from the file path
// fileId is like "tiedup:tiedup_items/leather_armbinder.json"
// We want "tiedup:leather_armbinder"
@@ -302,7 +329,8 @@ public final class DataDrivenItemParser {
movementStyle,
movementModifier,
creator,
animationBones
animationBones,
componentConfigs
);
}