fix(D-01/E): padlock resistance double-count + knife progress persist (review)
BUG-001: PacketV2StruggleStart only adds padlock resistance bonus on first session (when resistance >= base). Interrupted sessions that persisted combined resistance no longer re-add the bonus, preventing infinite resistance inflation. BUG-002: PacketV2LockToggle UNLOCK clears knifeCutProgress and accessoryStruggleResistance NBT keys, preventing partial knife-cut progress from persisting across lock/unlock cycles.
This commit is contained in:
@@ -149,6 +149,10 @@ public class PacketV2LockToggle {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear partial knife-cut progress and stale struggle resistance on unlock
|
||||
com.tiedup.remake.util.ItemNBTHelper.remove(stack, "knifeCutProgress");
|
||||
com.tiedup.remake.util.ItemNBTHelper.remove(stack, "accessoryStruggleResistance");
|
||||
|
||||
TiedUpMod.LOGGER.debug(
|
||||
"[V2LockToggle] Unlocked region {} on entity {}",
|
||||
region.name(),
|
||||
|
||||
@@ -84,9 +84,23 @@ public class PacketV2StruggleStart {
|
||||
if (stack.getItem() instanceof ILockable lockable) {
|
||||
isLocked = lockable.isLocked(stack);
|
||||
if (isLocked) {
|
||||
// Only add padlock bonus on FIRST session (fresh resistance = base).
|
||||
// If resistance was already decremented and persisted from a prior
|
||||
// interrupted session, the padlock bonus is already baked in.
|
||||
int baseResistance = resistance; // getCurrentResistance returns base if no NBT
|
||||
com.tiedup.remake.v2.bondage.component.ResistanceComponent comp =
|
||||
com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem.getComponent(
|
||||
stack, com.tiedup.remake.v2.bondage.component.ComponentType.RESISTANCE,
|
||||
com.tiedup.remake.v2.bondage.component.ResistanceComponent.class);
|
||||
if (comp != null) {
|
||||
baseResistance = comp.getBaseResistance();
|
||||
}
|
||||
if (resistance >= baseResistance) {
|
||||
// Fresh or fully restored — add padlock bonus
|
||||
resistance += com.tiedup.remake.core.SettingsAccessor.getPadlockResistance(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RISK-003 fix: no point starting a session with 0 resistance
|
||||
if (resistance <= 0) return;
|
||||
|
||||
Reference in New Issue
Block a user