feat(D-01/B): add can_attach_padlock field to data-driven items (B0)
- DataDrivenItemDefinition: add canAttachPadlock boolean (default true) - DataDrivenItemParser: parse "can_attach_padlock" from JSON - DataDrivenBondageItem: add static canAttachPadlockTo(stack) method - AnvilEventHandler: check V2 definition before allowing padlock attach
This commit is contained in:
@@ -40,7 +40,11 @@ public class AnvilEventHandler {
|
||||
|
||||
// Check if item can have a padlock attached (tape, slime, vine, web cannot)
|
||||
if (!lockable.canAttachPadlock()) {
|
||||
return; // Item type cannot have padlock
|
||||
return; // Item type cannot have padlock (V1)
|
||||
}
|
||||
// V2 data-driven items: check definition's can_attach_padlock field
|
||||
if (!com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem.canAttachPadlockTo(left)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Item must not already have a padlock attached
|
||||
|
||||
@@ -436,6 +436,19 @@ public class DataDrivenBondageItem extends AbstractV2BondageItem {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stack-aware padlock attachment check for data-driven items.
|
||||
* Returns false for organic items (slime, vine, web, tape) that have
|
||||
* {@code can_attach_padlock: false} in their JSON definition.
|
||||
*/
|
||||
public static boolean canAttachPadlockTo(ItemStack stack) {
|
||||
DataDrivenItemDefinition def = DataDrivenItemRegistry.get(stack);
|
||||
if (def != null) {
|
||||
return def.canAttachPadlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===== FACTORY =====
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,6 +58,9 @@ public record DataDrivenItemDefinition(
|
||||
/** Whether this item can be locked with a padlock. */
|
||||
boolean lockable,
|
||||
|
||||
/** Whether a padlock can be attached to this item. False for organic items (slime, vine, web, tape). */
|
||||
boolean canAttachPadlock,
|
||||
|
||||
/** Whether this item supports color variants. */
|
||||
boolean supportsColor,
|
||||
|
||||
|
||||
@@ -200,6 +200,9 @@ public final class DataDrivenItemParser {
|
||||
// Optional: lockable (default true)
|
||||
boolean lockable = getBooleanOrDefault(root, "lockable", true);
|
||||
|
||||
// Optional: can_attach_padlock (default true). False for organic items.
|
||||
boolean canAttachPadlock = getBooleanOrDefault(root, "can_attach_padlock", true);
|
||||
|
||||
// Optional: supports_color (default false)
|
||||
boolean supportsColor = getBooleanOrDefault(
|
||||
root,
|
||||
@@ -335,6 +338,7 @@ public final class DataDrivenItemParser {
|
||||
posePriority,
|
||||
escapeDifficulty,
|
||||
lockable,
|
||||
canAttachPadlock,
|
||||
supportsColor,
|
||||
tintChannels,
|
||||
icon,
|
||||
|
||||
Reference in New Issue
Block a user