fix(D-01/A): 3 review bugs + null guards (BUG-001, BUG-002, BUG-003, RISK-003)
BUG-001: TyingInteractionHelper swap now checks V2EquipResult — on failure, rolls back by re-equipping the old bind instead of leaving target untied BUG-002: OwnershipComponent.onUnequipped no longer double-calls unregisterWearer — onCollarRemoved already handles it. Suppressed-alert path calls unregister directly since onCollarRemoved is skipped. BUG-003: PacketSelfBondage handleV2SelfBind now clears completed tying task from PlayerBindState to prevent blocking future tying interactions RISK-003: StruggleCollar get/setResistanceState null-guard on player
This commit is contained in:
@@ -9,6 +9,7 @@ import com.tiedup.remake.tasks.V2TyingPlayerTask;
|
||||
import com.tiedup.remake.util.KidnappedHelper;
|
||||
import com.tiedup.remake.v2.BodyRegionV2;
|
||||
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
||||
import com.tiedup.remake.v2.bondage.V2EquipResult;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
@@ -50,11 +51,18 @@ public final class TyingInteractionHelper {
|
||||
if (stack.isEmpty()) return InteractionResult.PASS;
|
||||
ItemStack oldBind = V2EquipmentHelper.unequipFromRegion(target, BodyRegionV2.ARMS);
|
||||
if (!oldBind.isEmpty()) {
|
||||
V2EquipmentHelper.equipItem(target, stack.copy());
|
||||
stack.shrink(1);
|
||||
target.spawnAtLocation(oldBind);
|
||||
TiedUpMod.LOGGER.debug("[TyingInteraction] Swapped bind on {}", target.getName().getString());
|
||||
return InteractionResult.SUCCESS;
|
||||
V2EquipResult result = V2EquipmentHelper.equipItem(target, stack.copy());
|
||||
if (result.isSuccess()) {
|
||||
stack.shrink(1);
|
||||
target.spawnAtLocation(oldBind);
|
||||
TiedUpMod.LOGGER.debug("[TyingInteraction] Swapped bind on {}", target.getName().getString());
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
// Equip failed — rollback: re-equip old bind
|
||||
V2EquipmentHelper.equipItem(target, oldBind);
|
||||
TiedUpMod.LOGGER.debug("[TyingInteraction] Swap failed, rolled back old bind on {}", target.getName().getString());
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user