feature/d01-branch-b-definitions #7

Merged
NotEvil merged 3 commits from feature/d01-branch-b-definitions into develop 2026-04-14 20:23:54 +00:00
4 changed files with 25 additions and 1 deletions
Showing only changes of commit b193c77021 - Show all commits

View File

@@ -40,7 +40,11 @@ public class AnvilEventHandler {
// Check if item can have a padlock attached (tape, slime, vine, web cannot) // Check if item can have a padlock attached (tape, slime, vine, web cannot)
if (!lockable.canAttachPadlock()) { 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 // Item must not already have a padlock attached

View File

@@ -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 ===== // ===== FACTORY =====
/** /**

View File

@@ -58,6 +58,9 @@ public record DataDrivenItemDefinition(
/** Whether this item can be locked with a padlock. */ /** Whether this item can be locked with a padlock. */
boolean lockable, 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. */ /** Whether this item supports color variants. */
boolean supportsColor, boolean supportsColor,

View File

@@ -200,6 +200,9 @@ public final class DataDrivenItemParser {
// Optional: lockable (default true) // Optional: lockable (default true)
boolean lockable = getBooleanOrDefault(root, "lockable", 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) // Optional: supports_color (default false)
boolean supportsColor = getBooleanOrDefault( boolean supportsColor = getBooleanOrDefault(
root, root,
@@ -335,6 +338,7 @@ public final class DataDrivenItemParser {
posePriority, posePriority,
escapeDifficulty, escapeDifficulty,
lockable, lockable,
canAttachPadlock,
supportsColor, supportsColor,
tintChannels, tintChannels,
icon, icon,