if(baubles.isItemValidForSlot(i, toEquip, player)) { ItemStack stackInSlot = baubles.getStackInSlot(i); if(stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
@Override public boolean canTakeStack(EntityPlayer player) { ItemStack stack = getStack(); if(stack.isEmpty()) return false; IBauble bauble = stack.getCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null); return bauble.canUnequip(stack, player); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); ItemStack toEquip = stack.splitStack(1); if(Loader.isModLoaded("baubles")) { if (canEquip(toEquip, player)) { IItemHandlerModifiable baubles = BaublesApi.getBaublesHandler(player); for (int i = 0; i < baubles.getSlots(); i++) { ItemStack simulate = baubles.insertItem(i, toEquip, true); if (simulate.isEmpty()) { ItemStack stackInSlot = baubles.getStackInSlot(i); if (stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) { if (!world.isRemote) { baubles.setStackInSlot(i, toEquip); } if (!stackInSlot.isEmpty()) { ((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, player); return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot.copy()); } break; } } } } } return ActionResult.newResult(EnumActionResult.PASS, stack); }