package com.tiedup.remake.util; import com.tiedup.remake.blocks.entity.IBondageItemHolder; import com.tiedup.remake.items.base.*; import java.util.List; import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; /** * Utility class for loading bondage items into block entity holders. * *
This centralizes the logic for: *
Used by BlockKidnapBomb, BlockRopeTrap, and BlockTrappedChest. */ public final class BondageItemLoaderUtility { private BondageItemLoaderUtility() {} /** * Load a bondage item into the holder. * *
Checks the item type and loads it into the appropriate slot * if that slot is empty. Consumes one item from the stack (unless creative). * * @param holder The bondage item holder (block entity) * @param stack The item stack to load * @param player The player loading the item * @return true if item was loaded, false if slot was occupied or wrong item type */ public static boolean loadItemIntoHolder( IBondageItemHolder holder, ItemStack stack, Player player ) { if (stack.getItem() instanceof ItemBind && holder.getBind().isEmpty()) { holder.setBind(stack.copyWithCount(1)); if (!player.isCreative()) stack.shrink(1); return true; } if (stack.getItem() instanceof ItemGag && holder.getGag().isEmpty()) { holder.setGag(stack.copyWithCount(1)); if (!player.isCreative()) stack.shrink(1); return true; } if ( stack.getItem() instanceof ItemBlindfold && holder.getBlindfold().isEmpty() ) { holder.setBlindfold(stack.copyWithCount(1)); if (!player.isCreative()) stack.shrink(1); return true; } if ( stack.getItem() instanceof ItemEarplugs && holder.getEarplugs().isEmpty() ) { holder.setEarplugs(stack.copyWithCount(1)); if (!player.isCreative()) stack.shrink(1); return true; } if ( stack.getItem() instanceof ItemCollar && holder.getCollar().isEmpty() ) { holder.setCollar(stack.copyWithCount(1)); if (!player.isCreative()) stack.shrink(1); return true; } return false; } /** * Check if an item is a loadable bondage item. * *
Returns true for: Bind, Gag, Blindfold, Earplugs, Collar. * * @param stack The item stack to check * @return true if the item can be loaded into a bondage item holder */ public static boolean isLoadableBondageItem(ItemStack stack) { return ( (stack.getItem() instanceof ItemBind) || (stack.getItem() instanceof ItemGag) || (stack.getItem() instanceof ItemBlindfold) || (stack.getItem() instanceof ItemEarplugs) || (stack.getItem() instanceof ItemCollar) ); } /** * Add item to tooltip if present in NBT. * *
Reads an item from the given NBT key and adds it to the tooltip
* with a "- ItemName" format in gold color.
*
* @param tooltip The tooltip list to add to
* @param beTag The BlockEntity NBT tag
* @param key The NBT key to read (e.g., "bind", "gag")
*/
public static void addItemToTooltip(
List