fix(D-01): wire LockableComponent.lockResistance via getItemLockResistance() (BUG-003)

- Remove redundant blocksUnequip() from LockableComponent since
  AbstractV2BondageItem.canUnequip() already checks ILockable.isLocked()
- Add DataDrivenBondageItem.getItemLockResistance(ItemStack) that reads
  the per-item lock resistance from the LockableComponent, falling back
  to the global config value when absent
This commit is contained in:
NotEvil
2026-04-14 02:27:37 +02:00
parent bb209bcd8e
commit 456335e0dd
2 changed files with 39 additions and 13 deletions

View File

@@ -1,16 +1,20 @@
package com.tiedup.remake.v2.bondage.component;
import com.google.gson.JsonObject;
import com.tiedup.remake.items.base.ILockable;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
/**
* Component: lockable behavior for data-driven items.
* Delegates lock checks to ILockable on the item.
*
* <p>Stores the per-item lock resistance parsed from JSON. The lock check
* itself is NOT done here because {@code AbstractV2BondageItem.canUnequip()}
* already delegates to {@code ILockable.isLocked()} -- duplicating it in
* {@code blocksUnequip()} would be redundant.</p>
*
* <p>Consumers retrieve the per-item lock resistance via
* {@link com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem#getItemLockResistance(net.minecraft.world.item.ItemStack)}.</p>
*
* JSON config:
* {@code "lockable": true} or {@code "lockable": {"lock_resistance": 300}}
* {@code "lockable": {}} or {@code "lockable": {"lock_resistance": 300}}
*/
public class LockableComponent implements IItemComponent {
@@ -28,15 +32,12 @@ public class LockableComponent implements IItemComponent {
return new LockableComponent(resistance);
}
/**
* Get the per-item lock resistance value parsed from JSON.
*
* @return lock resistance (always >= 0 after RISK-003 clamping)
*/
public int getLockResistance() {
return lockResistance;
}
@Override
public boolean blocksUnequip(ItemStack stack, LivingEntity entity) {
if (stack.getItem() instanceof ILockable lockable) {
return lockable.isLocked(stack);
}
return false;
}
}