feature/d01-branch-b-definitions #7
@@ -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
|
||||||
|
|||||||
@@ -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 =====
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user