feature/d01-branch-a-bridge #6
@@ -291,6 +291,12 @@ public class PacketSelfBondage {
|
|||||||
if (playerState.getCurrentTyingTask() == newTask) {
|
if (playerState.getCurrentTyingTask() == newTask) {
|
||||||
newTask.update();
|
newTask.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear completed task to prevent blocking future tying interactions
|
||||||
|
TyingTask activeTask = playerState.getCurrentTyingTask();
|
||||||
|
if (activeTask != null && activeTask.isStopped()) {
|
||||||
|
playerState.setCurrentTyingTask(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleV2SelfAccessory(
|
private static void handleV2SelfAccessory(
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class StruggleCollar extends StruggleState {
|
|||||||
@Override
|
@Override
|
||||||
protected int getResistanceState(PlayerBindState state) {
|
protected int getResistanceState(PlayerBindState state) {
|
||||||
Player player = state.getPlayer();
|
Player player = state.getPlayer();
|
||||||
|
if (player == null) return 0;
|
||||||
ItemStack collar = V2EquipmentHelper.getInRegion(player, BodyRegionV2.NECK);
|
ItemStack collar = V2EquipmentHelper.getInRegion(player, BodyRegionV2.NECK);
|
||||||
|
|
||||||
if (collar.isEmpty() || !CollarHelper.isCollar(collar)) return 0;
|
if (collar.isEmpty() || !CollarHelper.isCollar(collar)) return 0;
|
||||||
@@ -66,6 +67,7 @@ public class StruggleCollar extends StruggleState {
|
|||||||
@Override
|
@Override
|
||||||
protected void setResistanceState(PlayerBindState state, int resistance) {
|
protected void setResistanceState(PlayerBindState state, int resistance) {
|
||||||
Player player = state.getPlayer();
|
Player player = state.getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
ItemStack collar = V2EquipmentHelper.getInRegion(player, BodyRegionV2.NECK);
|
ItemStack collar = V2EquipmentHelper.getInRegion(player, BodyRegionV2.NECK);
|
||||||
|
|
||||||
if (collar.isEmpty() || !CollarHelper.isCollar(collar)) return;
|
if (collar.isEmpty() || !CollarHelper.isCollar(collar)) return;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.tiedup.remake.tasks.V2TyingPlayerTask;
|
|||||||
import com.tiedup.remake.util.KidnappedHelper;
|
import com.tiedup.remake.util.KidnappedHelper;
|
||||||
import com.tiedup.remake.v2.BodyRegionV2;
|
import com.tiedup.remake.v2.BodyRegionV2;
|
||||||
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
import com.tiedup.remake.v2.bondage.capability.V2EquipmentHelper;
|
||||||
|
import com.tiedup.remake.v2.bondage.V2EquipResult;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
@@ -50,11 +51,18 @@ public final class TyingInteractionHelper {
|
|||||||
if (stack.isEmpty()) return InteractionResult.PASS;
|
if (stack.isEmpty()) return InteractionResult.PASS;
|
||||||
ItemStack oldBind = V2EquipmentHelper.unequipFromRegion(target, BodyRegionV2.ARMS);
|
ItemStack oldBind = V2EquipmentHelper.unequipFromRegion(target, BodyRegionV2.ARMS);
|
||||||
if (!oldBind.isEmpty()) {
|
if (!oldBind.isEmpty()) {
|
||||||
V2EquipmentHelper.equipItem(target, stack.copy());
|
V2EquipResult result = V2EquipmentHelper.equipItem(target, stack.copy());
|
||||||
stack.shrink(1);
|
if (result.isSuccess()) {
|
||||||
target.spawnAtLocation(oldBind);
|
stack.shrink(1);
|
||||||
TiedUpMod.LOGGER.debug("[TyingInteraction] Swapped bind on {}", target.getName().getString());
|
target.spawnAtLocation(oldBind);
|
||||||
return InteractionResult.SUCCESS;
|
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;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,23 +67,26 @@ public class OwnershipComponent implements IItemComponent {
|
|||||||
if (entity.level().isClientSide()) return;
|
if (entity.level().isClientSide()) return;
|
||||||
if (!(entity.level() instanceof ServerLevel serverLevel)) return;
|
if (!(entity.level() instanceof ServerLevel serverLevel)) return;
|
||||||
|
|
||||||
// Alert kidnappers if removal wasn't suppressed
|
// Alert kidnappers + unregister from CollarRegistry
|
||||||
|
// onCollarRemoved handles both the alert AND the unregister call internally,
|
||||||
|
// so we do NOT call registry.unregisterWearer() separately to avoid double unregister.
|
||||||
if (!CollarHelper.isRemovalAlertSuppressed()) {
|
if (!CollarHelper.isRemovalAlertSuppressed()) {
|
||||||
ItemCollar.onCollarRemoved(entity, true);
|
ItemCollar.onCollarRemoved(entity, true);
|
||||||
}
|
} else {
|
||||||
|
// Suppressed alert path: still need to unregister, just skip the alert
|
||||||
try {
|
try {
|
||||||
CollarRegistry registry = CollarRegistry.get(serverLevel);
|
CollarRegistry registry = CollarRegistry.get(serverLevel);
|
||||||
registry.unregisterWearer(entity.getUUID());
|
registry.unregisterWearer(entity.getUUID());
|
||||||
TiedUpMod.LOGGER.debug(
|
TiedUpMod.LOGGER.debug(
|
||||||
"[OwnershipComponent] Unregistered collar for {}",
|
"[OwnershipComponent] Unregistered collar for {} (alert suppressed)",
|
||||||
entity.getName().getString()
|
entity.getName().getString()
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TiedUpMod.LOGGER.warn(
|
TiedUpMod.LOGGER.warn(
|
||||||
"[OwnershipComponent] Failed to unregister collar for {}: {}",
|
"[OwnershipComponent] Failed to unregister collar for {}: {}",
|
||||||
entity.getName().getString(), e.getMessage()
|
entity.getName().getString(), e.getMessage()
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user