package com.tiedup.remake.util; import com.tiedup.remake.compat.mca.MCACompat; import com.tiedup.remake.v2.BodyRegionV2; import com.tiedup.remake.state.IRestrainable; import com.tiedup.remake.state.PlayerBindState; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; /** * Phase 14.1: Helper utility for working with IRestrainable entities. * * Provides convenient methods for obtaining IRestrainable instances from various entity types. * *
{@code
* public InteractionResult interactLivingEntity(ItemStack stack, Player user,
* LivingEntity target, InteractionHand hand) {
* IRestrainable state = KidnappedHelper.getKidnappedState(target);
* if (state == null) {
* return InteractionResult.PASS; // Entity cannot be restrained
* }
*
* if (state.isTiedUp()) {
* user.sendSystemMessage(Component.literal("Already tied up!"));
* return InteractionResult.FAIL;
* }
*
* state.equip(BodyRegionV2.ARMS, stack.copy());
* return InteractionResult.SUCCESS;
* }
* }
*/
public class KidnappedHelper {
/**
* Get the IRestrainable instance for any living entity.
*
* This method determines the appropriate IRestrainable implementation based on entity type: *
Convenience method that combines {@link #getKidnappedState(LivingEntity)} * and {@link IRestrainable#isTiedUp()}. * * @param entity The living entity to check * @return true if the entity is tied up, false otherwise */ public static boolean isTiedUp(LivingEntity entity) { IRestrainable state = getKidnappedState(entity); return state != null && state.isTiedUp(); } /** * Check if an entity is currently gagged. * *
Convenience method that combines {@link #getKidnappedState(LivingEntity)} * and {@link IRestrainable#isGagged()}. * * @param entity The living entity to check * @return true if the entity is gagged, false otherwise */ public static boolean isGagged(LivingEntity entity) { IRestrainable state = getKidnappedState(entity); return state != null && state.isGagged(); } /** * Check if an entity is currently blindfolded. * *
Convenience method that combines {@link #getKidnappedState(LivingEntity)} * and {@link IRestrainable#isBlindfolded()}. * * @param entity The living entity to check * @return true if the entity is blindfolded, false otherwise */ public static boolean isBlindfolded(LivingEntity entity) { IRestrainable state = getKidnappedState(entity); return state != null && state.isBlindfolded(); } /** * Check if an entity has a collar. * *
Convenience method that combines {@link #getKidnappedState(LivingEntity)} * and {@link IRestrainable#hasCollar()}. * * @param entity The living entity to check * @return true if the entity has a collar, false otherwise */ public static boolean hasCollar(LivingEntity entity) { IRestrainable state = getKidnappedState(entity); return state != null && state.hasCollar(); } /** * Check if an entity is enslaved. * *
Convenience method that combines {@link #getKidnappedState(LivingEntity)} * and {@link IRestrainable#isSlave()}. * * @param entity The living entity to check * @return true if the entity is enslaved, false otherwise */ /** * Phase 17: Renamed from isSlave to isCaptive */ public static boolean isCaptive(LivingEntity entity) { IRestrainable state = getKidnappedState(entity); return state != null && state.isCaptive(); } }